protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string dt = Convert.ToString(DateTime.Now.Year); txtyear.Text = Convert.ToString(dt); DataTable table = new DataTable(); table = GetMainTable(dt); RG_leavecalender.DataSource = table; SetUnAvailableDays(table, 1); SetSundays(table, Convert.ToInt32(dt), 2); SetWeekoffs(table, Convert.ToInt32(dt), 4); SetHolidys(table, Convert.ToInt32(dt), 8); SetLeaves(table, Convert.ToInt32(dt), 10); RG_leavecalender.DataBind(); int month_no = 1; foreach (GridDataItem dataItem in RG_leavecalender.MasterTableView.Items) { for (int i = 2; i <= 32; i++) { if (dataItem.Cells[i + 3].Text != " " && dataItem.Cells[i + 3].Text != "null") { int cellValue = Convert.ToInt32(dataItem.Cells[i + 3].Text); dataItem.Cells[i + 3].BackColor = GetColorForValue(cellValue); dataItem.Cells[i + 3].ForeColor = Color.White; dataItem.Cells[i + 3].Text = GetText(cellValue, i - 1, month_no, dt); } } month_no++; } txt1.BackColor = System.Drawing.Color.YellowGreen; txt2.BackColor = System.Drawing.Color.Blue; txt3.BackColor = System.Drawing.Color.Coral; string curr_year = Convert.ToString(DateTime.Now.Year); if (txtyear.Text == curr_year) { btnNext.Enabled = false; } else { btnNext.Enabled = true; } _obj_smhr_employee = new SMHR_EMPLOYEE(); _obj_smhr_employee.OPERATION = operation.Select; _obj_smhr_employee.EMP_ID = Convert.ToInt32(Session["EMP_ID"]); //dt_Details = new DataTable(); _obj_smhr_employee.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]); DataTable dt_Details = BLL.get_Employee(_obj_smhr_employee); DateTime doj = Convert.ToDateTime(dt_Details.Rows[0]["EMP_DOJ"]); prev_year = Convert.ToString(doj.Year); if (txtyear.Text == prev_year) { btnprevious.Enabled = false; } else { btnprevious.Enabled = true; } } }
protected void btnprevious_Click(object sender, EventArgs e) { try { string dt_year = Convert.ToString(DateTime.Now.Year); int I_year = Convert.ToInt32(txtyear.Text); string yr = Convert.ToString(I_year - 1); txtyear.Text = yr; DataTable table = GetMainTable(yr); RG_leavecalender.DataSource = table; SetUnAvailableDays(table, 1); SetSundays(table, Convert.ToInt32(yr), 2); SetWeekoffs(table, Convert.ToInt32(yr), 4); SetHolidys(table, Convert.ToInt32(yr), 8); SetLeaves(table, Convert.ToInt32(yr), 10); RG_leavecalender.DataBind(); int month_no = 1; foreach (GridDataItem dataItem in RG_leavecalender.MasterTableView.Items) { for (int i = 2; i <= 32; i++) { if (dataItem.Cells[i + 3].Text != " " && dataItem.Cells[i + 3].Text != "null") { int cellValue = Convert.ToInt32(dataItem.Cells[i + 3].Text); dataItem.Cells[i + 3].BackColor = GetColorForValue(cellValue); dataItem.Cells[i + 3].ForeColor = Color.White; dataItem.Cells[i + 3].Text = GetText(cellValue, i - 1, month_no, yr); } } month_no++; } txt1.BackColor = System.Drawing.Color.YellowGreen; txt2.BackColor = System.Drawing.Color.Blue; txt3.BackColor = System.Drawing.Color.Coral; string curr_year = Convert.ToString(DateTime.Now.Year); if (txtyear.Text == curr_year) { btnNext.Enabled = false; } else { btnNext.Enabled = true; } if (txtyear.Text == prev_year) { btnprevious.Enabled = false; } else { btnprevious.Enabled = true; } } catch (Exception ex) { SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "AllEmpGridCalendar", ex.StackTrace, DateTime.Now); Response.Redirect("~/Frm_ErrorPage.aspx"); } }
protected void btnprevious_Click(object sender, EventArgs e) { string dt_year = Convert.ToString(DateTime.Now.Year); int I_year = Convert.ToInt32(txtyear.Text); string yr = Convert.ToString(I_year - 1); txtyear.Text = yr; DataTable table = GetMainTable(yr); RG_leavecalender.DataSource = table; SetUnAvailableDays(table, 1); SetSundays(table, Convert.ToInt32(yr), 2); SetWeekoffs(table, Convert.ToInt32(yr), 4); SetHolidys(table, Convert.ToInt32(yr), 8); SetLeaves(table, Convert.ToInt32(yr), 10); RG_leavecalender.DataBind(); int month_no = 1; foreach (GridDataItem dataItem in RG_leavecalender.MasterTableView.Items) { for (int i = 2; i <= 32; i++) { if (dataItem.Cells[i + 3].Text != " " && dataItem.Cells[i + 3].Text != "null") { int cellValue = Convert.ToInt32(dataItem.Cells[i + 3].Text); dataItem.Cells[i + 3].BackColor = GetColorForValue(cellValue); dataItem.Cells[i + 3].ForeColor = Color.White; dataItem.Cells[i + 3].Text = GetText(cellValue, i - 1, month_no, yr); } } month_no++; } txt1.BackColor = System.Drawing.Color.YellowGreen; txt2.BackColor = System.Drawing.Color.Blue; txt3.BackColor = System.Drawing.Color.Coral; string curr_year = Convert.ToString(DateTime.Now.Year); if (txtyear.Text == curr_year) { btnNext.Enabled = false; } else { btnNext.Enabled = true; } if (txtyear.Text == prev_year) { btnprevious.Enabled = false; } else { btnprevious.Enabled = true; } }