public static CustomList <LeaveRuleMaster> GetSelectedLeaveRule(int LeaveRuleKey) { ConnectionManager conManager = new ConnectionManager(ConnectionName.HR); CustomList <LeaveRuleMaster> LeaveRuleCollection = new CustomList <LeaveRuleMaster>(); IDataReader reader = null; String sql = "select * from LeaveRuleMaster where LeaveRuleKey= " + LeaveRuleKey + ""; try { conManager.OpenDataReader(sql, out reader); while (reader.Read()) { LeaveRuleMaster newLeaveRule = new LeaveRuleMaster(); newLeaveRule.SetData(reader); LeaveRuleCollection.Add(newLeaveRule); } LeaveRuleCollection.InsertSpName = "spInsertLeaveRule"; LeaveRuleCollection.UpdateSpName = "spUpdateLeaveRule"; LeaveRuleCollection.DeleteSpName = "spDeleteLeaveRule"; return(LeaveRuleCollection); } catch (Exception ex) { throw (ex); } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } }
protected void btnSave_Click(object sender, EventArgs e) { try { CustomList <ASL.Hr.DAO.LeaveRuleMaster> lstLeaveRule = (CustomList <ASL.Hr.DAO.LeaveRuleMaster>)_LeaveRuleMasterForSave; if (lstLeaveRule.IsNull() || lstLeaveRule.Count == 0) { ASL.Hr.DAO.LeaveRuleMaster newLeaveRule = new ASL.Hr.DAO.LeaveRuleMaster(); lstLeaveRule.Add(newLeaveRule); } SetDataFromControlToObj(ref lstLeaveRule); CustomList <ASL.Hr.DAO.LeavePolicyMaster> lstLeaveRuleDetails = (CustomList <ASL.Hr.DAO.LeavePolicyMaster>)_LeavePolicyMasterToDisplayOrSave; int SID = 0; // if (!CheckUserAuthentication(lstLeavePlan, lstLeaveBreakInfo)) return; ManagerLeaveRule.SaveLeaveRule(ref lstLeaveRule, ref lstLeaveRuleDetails, ref SID); txtLeaveRule.Visible = false; ddlLeaveRuleKey.Visible = true; _LeaveRule = ManagerLeaveRule.GetAllLeaveRuleMaster(); ddlLeaveRuleKey.DataSource = _LeaveRule; ddlLeaveRuleKey.DataTextField = "LeaveRuleCode"; ddlLeaveRuleKey.DataValueField = "LeaveRuleKey"; ddlLeaveRuleKey.DataBind(); ddlLeaveRuleKey.Items.Insert(0, new ListItem(String.Empty, String.Empty)); ddlLeaveRuleKey.SelectedIndex = 0; if (SID != 0) { ((PageBase)this.Page).SuccessMessage = (StaticInfo.SavedSuccessfullyMsg); ddlLeaveRuleKey.SelectedValue = SID.ToString(); } else { this.SuccessMessage = "Record Updated Successfully"; ddlLeaveRuleKey.SelectedValue = lstLeaveRule[0].LeaveRuleKey.ToString(); } //LeaveRuleDetailList = ManagerLeaveRuleDetail.GetSelectedLeaveRuleDetail(SID); _LeaveRuleMasterForSave[0] = _LeaveRule.Find(f => f.LeaveRuleKey == SID); ((PageBase)this.Page).SuccessMessage = (StaticInfo.SavedSuccessfullyMsg); } catch (SqlException ex) { ((PageBase)this.Page).ErrorMessage = (ExceptionHelper.getSqlExceptionMessage(ex)); } catch (Exception ex) { ((PageBase)this.Page).ErrorMessage = (ExceptionHelper.getExceptionMessage(ex)); } }
private void SetDataFromControlToObj(ref CustomList <ASL.Hr.DAO.LeaveRuleMaster> PassedLeaveRule) { ASL.Hr.DAO.LeaveRuleMaster obj = PassedLeaveRule[0]; if (txtLeaveRule.Visible.IsTrue()) { obj.LeaveRuleCode = txtLeaveRule.Text; } else { obj.LeaveRuleCode = ddlLeaveRuleKey.SelectedItem.Text; } obj.Description = txtDescription.Text; if (obj.LeaveRuleKey == 0) { obj.SetAdded(); } else { obj.SetModified(); } }