protected void FetchLeaveConfigById(int LeaveConfigId) { Business.LeaveManagement.LeaveConfiguration objLeaveConfiguration = new Business.LeaveManagement.LeaveConfiguration(); Entity.LeaveManagement.LeaveConfiguration leaveConfiguration = new Entity.LeaveManagement.LeaveConfiguration(); leaveConfiguration.LeaveConfigId = LeaveConfigId; DataTable dt = objLeaveConfiguration.FetchLeaveConfigById(leaveConfiguration); if (dt.Rows.Count > 0) { ddlLeaveType.SelectedValue = dt.Rows[0]["LeaveTypeId"].ToString(); ddlLeaveFrequency.SelectedValue = dt.Rows[0]["LeaveFrequency"].ToString(); txtLeaveAccrueDate.Text = Convert.ToDateTime(dt.Rows[0]["LeaveAccrueDate"]).ToString("dd MMM yyyy"); ckEncashable.Checked = Convert.ToBoolean(dt.Rows[0]["Encashable"].ToString()); } }
protected void gvLeaveConfig_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "E") { LeaveConfigurationId = Convert.ToInt32(e.CommandArgument.ToString()); FetchLeaveConfigById(LeaveConfigurationId); } else { if (e.CommandName == "D") { Business.LeaveManagement.LeaveConfiguration objLeaveConfiguration = new Business.LeaveManagement.LeaveConfiguration(); LeaveConfigurationId = Convert.ToInt32(e.CommandArgument.ToString()); int RowsAffected = objLeaveConfiguration.LeaveConfigurations_Delete(LeaveConfigurationId); if (RowsAffected > 0) { GlobalCache.RemoveAll(); LoadLeaveType(); LeaveConfig_GetAll(); Message.Show = true; Message.Text = "Deleted Successfully"; } else { Message.Show = 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 { if (LeaveConfigValidate()) { Business.LeaveManagement.LeaveConfiguration objLeaveConfiguration = new Business.LeaveManagement.LeaveConfiguration(); Entity.LeaveManagement.LeaveConfiguration leaveConfiguration = new Entity.LeaveManagement.LeaveConfiguration(); leaveConfiguration.LeaveConfigId = LeaveConfigurationId; leaveConfiguration.LeaveTypeId = Convert.ToInt32(ddlLeaveType.SelectedValue); leaveConfiguration.LeaveFrequency = ddlLeaveFrequency.SelectedValue; leaveConfiguration.LeaveAccrueDate = Convert.ToDateTime(txtLeaveAccrueDate.Text.Trim()); leaveConfiguration.Encashable = ckEncashable.Checked; int response = objLeaveConfiguration.LeaveConfigurations_Save(leaveConfiguration); if (response > 0) { Clear(); LeaveConfig_GetAll(); GlobalCache.RemoveAll(); Message.IsSuccess = true; Message.Text = "Saved Successfully"; } else { Message.IsSuccess = false; Message.Text = "Exists"; } Message.Show = true; } } catch (Exception ex) { ex.WriteException(); Message.IsSuccess = false; Message.Text = ex.Message; Message.Show = true; } }