Lbl_Username.Text = FirstName + " " + LastName;
#region Get current year
if (!IsPostBack)
{
int getCurrentYear = DateTime.Now.Year;
int co2 = DropDownList2.Items.Count;
for (int jj = 0; jj < co2; jj++)
{
DropDownList2.Items[jj].Selected = false;
string selectyrs = DropDownList2.Items[jj].Value.ToString();
if ((getCurrentYear.ToString()).Equals(selectyrs))
{
DropDownList2.Items[jj].Selected = true;
}
}
}
#endregion
#region Empty Columns
dt.Columns.Add("employeename");
dt.Columns.Add("Workingdays");
dt.Columns.Add("Leavetaken");
GridView_attendancereports.DataSource = dt;
GridView_attendancereports.DataBind();
if (dt.Rows.Count == 0)
{
for (int i = 0; i < 5; i++)
{
DataRow dr = dt.NewRow();
dt.Rows.Add(dr);
}
GridView_attendancereports.DataSource = dt;
GridView_attendancereports.DataBind();
}
#endregion
}
protected void DropDownList2_SelectedIndexChanged1(object sender, EventArgs e)
{
try
{
calculation();
}
catch
{
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
calculation();
}
catch
{
}
}
public void calculation()
{
try
{
#region No.Of working days calculation
dt = objsun.fetchemployeename_reports();
GridView_attendancereports.DataSource = dt;
GridView_attendancereports.DataBind();
for (int i = 0; i < GridView_attendancereports.Rows.Count; i++)
{
GridView_attendancereports.Rows[i].Cells[0].Text = dt.Rows[i]["FirstName"].ToString() + " " + dt.Rows[i]["LastName"].ToString();
}
string dates1 = DropDownList1.SelectedItem.Value + "/1/" + DropDownList2.SelectedItem.Value;
if (GridView_attendancereports.Rows.Count != 0)
{
days = objsun.fetch_noofdaysin_month(dates1);
month = objsun.getmonth(dates1);
year = objsun.getyear(dates1);
data = objsun.fetch_firstdate_lastdate(month, year);
firstdate = data[0].ToString();
lastdate = data[1].ToString();
data_sunday = objsun.fetch_noofsundays(firstdate, lastdate);
count_sunday = data_sunday.Count;
data_holiday = objsun.fetch_holiday_month(firstdate, lastdate, "India");
count_holiday = data_holiday.Count;
for (int j = 0; j < count_sunday; j++)
{
for (int k = 0; k < count_holiday; k++)
{
if (data_holiday[k].ToString() == data_sunday[j].ToString())
{
count = count + 1;
}
}
}
bal_count = count_sunday - count;
cal = bal_count + count_holiday;
calculate_noofworking_days = days - cal;
for (int i = 0; i < GridView_attendancereports.Rows.Count; i++)
{
GridView_attendancereports.Rows[i].Cells[1].Text = calculate_noofworking_days.ToString();
GridView_attendancereports.Rows[i].Cells[2].Text = "0";
GridView_attendancereports.Rows[i].Cells[3].Text = "0";
}
}
#endregion
#region Leave Taken calculation
ds1 = objsun.fetch_user_leavecal(firstdate, lastdate);
user = ds1.Tables[0].Rows.Count;
for (int ii = 0; ii < GridView_attendancereports.Rows.Count; ii++)
{
useridCount.Add(dt.Rows[ii]["UserId"].ToString());
for (int j = 0; j < user; j++)
{
useraccount_userId = useridCount[ii].ToString();
applyleave_userId = ds1.Tables[0].Rows[j]["ApplyLeave_UserID"].ToString();
if (useraccount_userId == applyleave_userId)
{
applyLeave_fromDate = ds1.Tables[0].Rows[j]["ApplyLeave_FromDate"].ToString();
applyLeave_toDate = ds1.Tables[0].Rows[j]["ApplyLeave_ToDate"].ToString();
if ((Convert.ToDateTime(applyLeave_toDate)) > (Convert.ToDateTime(lastdate)))
{
validUserlate = lastdate;
leaveCount = objsun.calculateEmployeeLeave(applyLeave_fromDate, validUserlate);
data_sunday = objsun.fetch_noofsundays(applyLeave_fromDate, validUserlate);
count_sunday = data_sunday.Count;
data_holiday = objsun.fetch_holiday_month(applyLeave_fromDate, validUserlate, "India");
count_holiday = data_holiday.Count;
for (int n = 0; n < count_sunday; n++)
{
for (int k = 0; k < count_holiday; k++)
{
if (data_holiday[k].ToString() == data_sunday[n].ToString())
{
count = count + 1;
}
}
}
bal_count = count_sunday - count;
cal = bal_count + count_holiday;
calculate_noofworking_days = (leaveCount + 1) - cal;
if ((incr != 0) && (captureuserid == Convert.ToInt16(applyleave_userId)))
{
calculate_noofworking_days = previousvalue + calculate_noofworking_days;
}
previousvalue = calculate_noofworking_days;
incr = incr + 1;
}
else
{
leaveCount = objsun.calculateEmployeeLeave(applyLeave_fromDate, applyLeave_toDate);
data_sunday = objsun.fetch_noofsundays(applyLeave_fromDate, applyLeave_toDate);
count_sunday = data_sunday.Count;
data_holiday = objsun.fetch_holiday_month(applyLeave_fromDate, applyLeave_toDate, "India");
count_holiday = data_holiday.Count;
for (int m = 0; m < count_sunday; m++)
{
for (int p = 0; p < count_holiday; p++)
{
if (data_holiday[p].ToString() == data_sunday[m].ToString())
{
count = count + 1;
}
}
}
bal_count = count_sunday - count;
cal = bal_count + count_holiday;
calculate_noofworking_days = (leaveCount + 1) - cal;
//captureuserid = applyleave_userId;
if ((incr != 0) && (captureuserid == Convert.ToInt16(applyleave_userId)))
{
calculate_noofworking_days = previousvalue + calculate_noofworking_days;
}
previousvalue = calculate_noofworking_days;
incr = incr + 1;
}
GridView_attendancereports.Rows[ii].Cells[2].Text = calculate_noofworking_days.ToString();
}
captureuserid = Convert.ToInt16(applyleave_userId);
}
}
#endregion
#region Calculate No.Of days Present
ds2 = objsun.fetch_user_presentdays(firstdate, lastdate);
userPresent = ds2.Tables[0].Rows.Count;
for (int iii = 0; iii < GridView_attendancereports.Rows.Count; iii++)
{
useridCount.Add(dt.Rows[iii]["UserId"].ToString());
for (int jjj = 0; jjj < userPresent; jjj++)
{
user_DaysPresent = useridCount[iii].ToString();
user_PresentUserid = ds2.Tables[0].Rows[jjj]["Attendence_UserID"].ToString();
if (user_DaysPresent == user_PresentUserid)
{
GridView_attendancereports.Rows[iii].Cells[3].Text = ds2.Tables[0].Rows[jjj]["presentdays"].ToString();
}
}
}
#endregion
#region Calculate Oofdays
string s;
int f = 0;
ds3 = objsun.fetch_user_offdays(firstdate, lastdate);
userOof = ds3.Tables[0].Rows.Count;
for (int i_off = 0; i_off < GridView_attendancereports.Rows.Count; i_off++)
{
useridCount.Add(dt.Rows[i_off]["UserId"].ToString());
for (int j_off = 0; j_off < userOof; j_off++)
{
user_DaysOof = useridCount[i_off].ToString();
user_OofUserid = ds3.Tables[0].Rows[j_off]["oof_UserID"].ToString();
if (user_DaysOof == user_OofUserid)
{
s=ds3.Tables[0].Rows[j_off]["off_noofdays"].ToString();
f =Convert.ToInt32(s) + f;
}
}
GridView_attendancereports.Rows[i_off].Cells[4].Text = f.ToString();
f = 0;
}
#endregion
}
catch
{
}
}
protected void logout_Click(object sender, EventArgs e)
{
Session.Clear();
Session.Abandon();
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
}
protected void GridView_attendancereports_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView_attendancereports.PageIndex = e.NewPageIndex;
GridView_attendancereports.DataSource = dt;
GridView_attendancereports.DataBind();
}
hi guys. im anand again .the above code gives empty page when the gridview (page indexing) next page is clicked.somebody help.it'll be really appriciated