public static CustomList <ShiftRule> GetAllShiftRule() { ConnectionManager conManager = new ConnectionManager(ConnectionName.HR); CustomList <ShiftRule> ShiftRuleCollection = new CustomList <ShiftRule>(); IDataReader reader = null; const String sql = "Select * from ShiftRule"; try { conManager.OpenDataReader(sql, out reader); while (reader.Read()) { ShiftRule newShiftRule = new ShiftRule(); newShiftRule.SetData(reader); ShiftRuleCollection.Add(newShiftRule); } ShiftRuleCollection.InsertSpName = "spInsertShiftRule"; ShiftRuleCollection.UpdateSpName = "spUpdateShiftRule"; ShiftRuleCollection.DeleteSpName = "spDeleteShiftRule"; return(ShiftRuleCollection); } catch (Exception ex) { throw (ex); } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } }
public static CustomList <ShiftRule> doSearch(string whereClause) { ConnectionManager conManager = new ConnectionManager(ConnectionName.HR); CustomList <ShiftRule> ShiftRuleCollection = new CustomList <ShiftRule>(); IDataReader reader = null; String sql = string.Format("Select * From [ShiftRule] Where 1=1 {0}", whereClause); try { conManager.OpenDataReader(sql, out reader); while (reader.Read()) { ShiftRule newShiftRule = new ShiftRule(); newShiftRule.SetData(reader); ShiftRuleCollection.Add(newShiftRule); } return(ShiftRuleCollection); } catch (Exception ex) { throw (ex); } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } }
protected void Page_Load(object sender, EventArgs e) { try { if (IsPostBack.IsFalse()) { InitializeSession(); } else { Page.ClientScript.GetPostBackEventReference(this, String.Empty); String eventTarget = Request["__EVENTTARGET"].IsNullOrEmpty() ? String.Empty : Request["__EVENTTARGET"]; if (eventTarget == "SearchShiftRule") { ASL.Hr.DAO.ShiftRule searchShiftRule = Session[ASL.STATIC.StaticInfo.SearchSessionVarName] as ASL.Hr.DAO.ShiftRule; ShiftRuleMasterList = new CustomList <ASL.Hr.DAO.ShiftRule>(); ShiftRuleMasterList.Add(searchShiftRule); if (searchShiftRule.IsNotNull()) { PopulateShiftRuleInfo(searchShiftRule); } } } } catch (Exception ex) { throw ex; } }
protected void btnSave_Click(object sender, EventArgs e) { try { CustomList <ASL.Hr.DAO.ShiftRule> lstShiftRule = (CustomList <ASL.Hr.DAO.ShiftRule>)ShiftRuleMasterList; if (lstShiftRule.Count == 0) { ASL.Hr.DAO.ShiftRule newShiftRule = new ASL.Hr.DAO.ShiftRule(); lstShiftRule.Add(newShiftRule); } SetDataFromControlToObj(ref lstShiftRule); CustomList <ASL.Hr.DAO.ShiftRuleDetail> lstShiftRuleDetail = (CustomList <ASL.Hr.DAO.ShiftRuleDetail>)ShiftRuleDetailList; if (!CheckUserAuthentication(lstShiftRule, lstShiftRuleDetail)) { return; } manager.SaveShiftRule(lstShiftRule, lstShiftRuleDetail); ((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.ShiftRule> lstShiftRule) { try { ASL.Hr.DAO.ShiftRule obj = lstShiftRule[0]; obj.ShiftRuleCode = txtShiftRuleCode.Text; obj.Description = txtDescription.Text;; obj.IsDefaultRule = chkDefaultShiftRule.Checked; } catch (Exception ex) { throw (ex); } }
private void PopulateShiftRuleInfo(ASL.Hr.DAO.ShiftRule shiftRule) { try { txtShiftRuleCode.Text = shiftRule.ShiftRuleCode; txtDescription.Text = shiftRule.Description; chkDefaultShiftRule.Checked = shiftRule.IsDefaultRule; ShiftRuleDetailList = manager.GetAllShiftRuleDetail(shiftRule.ShiftRuleKey); } catch (Exception ex) { throw (ex); } }