private void LoadHolidayList() { int holidayProfileId = 0; Business.HR.HolidayProfile objEmployeeHolidayProfileMapping = new Business.HR.HolidayProfile(); DataTable dtEmployeeHolidayProfileMapping = objEmployeeHolidayProfileMapping.EmployeeHolidayProfileMapping_GetAll(new Entity.HR.EmployeeHolidayProfileMapping()); if (dtEmployeeHolidayProfileMapping != null && dtEmployeeHolidayProfileMapping.AsEnumerable().Any() && dtEmployeeHolidayProfileMapping.Select("EmployeeMasterId = " + HttpContext.Current.User.Identity.Name).Any()) { holidayProfileId = Convert.ToInt32(dtEmployeeHolidayProfileMapping .Select("EmployeeMasterId = " + HttpContext.Current.User.Identity.Name).CopyToDataTable() .Rows[0]["HolidayProfileId"].ToString()); } Business.HR.Holiday objHoliday = new Business.HR.Holiday(); DataTable dt = objHoliday.Holiday_GetAll(new Entity.HR.Holiday() { HolidayYear = DateTime.Now.Year, HolidayProfileId = holidayProfileId }); if (dt != null) { gvHoliday.DataSource = dt.Select("Show = 1").CopyToDataTable(); gvHoliday.DataBind(); } }
private void LoadHolidayList() { Business.HR.Holiday objHoliday = new Business.HR.Holiday(); DataTable dt = objHoliday.Holiday_GetAll(new Entity.HR.Holiday()); if (dt != null) { gvHoliday.DataSource = dt; gvHoliday.DataBind(); } }
private void Holiday_GetById() { Business.HR.Holiday objHoliday = new Business.HR.Holiday(); DataTable dt = objHoliday.Holiday_GetById(HolidayId); if (dt != null && dt.AsEnumerable().Any()) { ddlHolidayProfile.SelectedValue = dt.Rows[0]["HolidayProfileId"].ToString(); txtHolidayName.Text = dt.Rows[0]["HolidayName"].ToString(); txtDescription.Text = dt.Rows[0]["HolidayDescription"].ToString(); txtHolidayDate.Text = Convert.ToDateTime(dt.Rows[0]["HolidayDate"].ToString()).ToString("dd MMM yyyy"); chkShowNow.Checked = Convert.ToBoolean(dt.Rows[0]["Show"].ToString()); } }
protected void gvHoliday_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Ed") { HolidayId = Convert.ToInt32(e.CommandArgument.ToString()); Holiday_GetById(); Message.Show = false; btnSave.Text = "Update"; } else if (e.CommandName == "Del") { Business.HR.Holiday objHoliday = new Business.HR.Holiday(); int rowsAffected = objHoliday.Holiday_Delete(Convert.ToInt32(e.CommandArgument.ToString())); if (rowsAffected > 0) { ClearControls(); LoadHolidayList(); Message.IsSuccess = true; Message.Text = "Deleted Successfully"; } else { Message.IsSuccess = false; Message.Text = "Data Dependency Exists"; } Message.Show = true; } } catch (Exception ex) { ex.WriteException(); Message.IsSuccess = false; Message.Text = ex.Message; Message.Show = true; } }
protected void btnSave_Click(object sender, EventArgs e) { try { Business.HR.Holiday objHoliday = new Business.HR.Holiday(); Entity.HR.Holiday holiday = new Entity.HR.Holiday(); holiday.HolidayId = HolidayId; holiday.HolidayProfileId = int.Parse(ddlHolidayProfile.SelectedValue); holiday.HolidayName = txtHolidayName.Text.Trim(); holiday.HolidayDescription = txtDescription.Text.Trim(); holiday.HolidayDate = Convert.ToDateTime(txtHolidayDate.Text.Trim()); holiday.Show = chkShowNow.Checked; int RowsAffected = objHoliday.Holiday_Save(holiday); if (RowsAffected > 0) { ClearControls(); LoadHolidayList(); Message.IsSuccess = true; Message.Text = "Saved Successfully"; } else { Message.IsSuccess = false; Message.Text = "Holiday Profile Name Exists"; } Message.Show = true; } catch (Exception ex) { ex.WriteException(); Message.IsSuccess = false; Message.Text = ex.Message; Message.Show = true; } }
private List <Models.HolidayModel> LoadHolidayList(int employeeId) { List <Models.HolidayModel> model = new List <Models.HolidayModel>(); int holidayProfileId = 0; DataTable dtEmployeeHolidayProfileMapping = new Business.HR.HolidayProfile().EmployeeHolidayProfileMapping_GetByEmployeeId(employeeId); if (dtEmployeeHolidayProfileMapping != null && dtEmployeeHolidayProfileMapping.AsEnumerable().Any()) { holidayProfileId = Convert.ToInt32(dtEmployeeHolidayProfileMapping.Rows[0]["HolidayProfileId"].ToString()); } Business.HR.Holiday objHoliday = new Business.HR.Holiday(); DataTable dt = objHoliday.Holiday_GetAll(new Entity.HR.Holiday() { HolidayYear = DateTime.Now.Year, HolidayProfileId = holidayProfileId }); if (dt != null) { dt = dt.Select("Show = 1").CopyToDataTable(); dt.AcceptChanges(); foreach (DataRow dr in dt.Rows) { model.Add(new Models.HolidayModel { HolidayName = dr["HolidayName"].ToString(), HolidayDate = dr["HolidayDate"].ToString() }); } } return(model); }