protected void Add_Click(object sender, EventArgs e) { Repeater.EditItemIndex = -1; EEmpPermit c = new EEmpPermit(); Hashtable values = new Hashtable(); newBinding.toValues(values); PageErrors errors = PageErrors.getErrors(sdb, Page.Master); errors.clear(); sdb.validate(errors, values); if (!errors.isEmpty()) { return; } sdb.parse(values, c); WebUtils.StartFunction(Session, FUNCTION_CODE, c.EmpID); sdb.insert(dbConn, c); WebUtils.EndFunction(dbConn); view = loadData(info, sdb, Repeater); }
protected void Repeater_ItemDataBound(object sender, DataListItemEventArgs e) { EEmpPermit obj = new EEmpPermit(); sdb.toObject(((DataRowView)e.Item.DataItem).Row, obj); Hashtable values = new Hashtable(); sdb.populate(obj, values); if (e.Item.ItemIndex == Repeater.EditItemIndex) { Binding eBinding; eBinding = new Binding(dbConn, sdb); eBinding.add((HtmlInputHidden)e.Item.FindControl("EmpPermitID")); eBinding.add(new DropDownVLBinder(sdb, (DropDownList)e.Item.FindControl("PermitTypeID"), EPermitType.VLPermitType)); eBinding.add((TextBox)e.Item.FindControl("EmpPermitNo")); eBinding.add(new TextBoxBinder(sdb, ((WebDatePicker)e.Item.FindControl("EmpPermitIssueDate")).TextBox, "EmpPermitIssueDate")); eBinding.add(new TextBoxBinder(sdb, ((WebDatePicker)e.Item.FindControl("EmpPermitExpiryDate")).TextBox, "EmpPermitExpiryDate")); eBinding.add((TextBox)e.Item.FindControl("EmpPermitRemark")); eBinding.init(Request, Session); eBinding.toControl(values); } else { //e.Item.FindControl("Edit").Visible = true & IsAllowEdit; //e.Item.FindControl("DeleteItem").Visible = true & IsAllowEdit; HtmlInputHidden h = (HtmlInputHidden)e.Item.FindControl("EmpPermitID"); h.Value = ((DataRowView)e.Item.DataItem)["EmpPermitID"].ToString(); } HROne.Common.WebUtility.WebControlsLocalization(Session, e.Item.Controls); }
protected void Delete_Click(object sender, EventArgs e) { ArrayList list = new ArrayList(); foreach (DataListItem item in Repeater.Items) { CheckBox c = (CheckBox)item.FindControl("DeleteItem"); HtmlInputHidden h = (HtmlInputHidden)item.FindControl("EmpPermitID"); if (c.Checked) { EEmpPermit obj = new EEmpPermit(); obj.EmpPermitID = Int32.Parse(h.Value); list.Add(obj); } } if (list.Count > 0) { WebUtils.StartFunction(Session, FUNCTION_CODE, CurID); foreach (BaseObject o in list) { if (sdb.select(dbConn, o)) { sdb.delete(dbConn, o); } } WebUtils.EndFunction(dbConn); } loadData(info, sdb, Repeater); }
public void ImportToDatabase(int UploadEmpID) { DBFilter sessionFilter = new DBFilter(); sessionFilter.add(new Match("SessionID", m_SessionID)); if (UploadEmpID > 0) { sessionFilter.add(new Match("UploadEmpID", UploadEmpID)); } ArrayList uploadEmpPermitList = tempDB.select(dbConn, sessionFilter); foreach (EUploadEmpPermit obj in uploadEmpPermitList) { EEmpPermit EmpPermit = new EEmpPermit(); if (obj.ImportActionStatus != ImportDBObject.ImportActionEnum.INSERT) { EmpPermit.EmpPermitID = obj.EmpPermitID; uploadDB.select(dbConn, EmpPermit); } obj.ExportToObject(EmpPermit); if (obj.ImportActionStatus == ImportDBObject.ImportActionEnum.INSERT) { EmpPermit.EmpID = ParseTemp.GetEmpIDFromUploadEmpID(dbConn, obj.UploadEmpID); uploadDB.insert(dbConn, EmpPermit); } else if (obj.ImportActionStatus == ImportDBObject.ImportActionEnum.UPDATE) { uploadDB.update(dbConn, EmpPermit); } tempDB.delete(dbConn, obj); } }
protected void Repeater_ItemCommand(object source, DataListCommandEventArgs e) { Button b = (Button)e.CommandSource; if (b.ID.Equals("Edit")) { Repeater.EditItemIndex = e.Item.ItemIndex; AddPanel.Visible = false; view = loadData(info, sdb, Repeater); } else if (b.ID.Equals("Cancel")) { Repeater.EditItemIndex = -1; AddPanel.Visible = IsAllowEdit; view = loadData(info, sdb, Repeater); } else if (b.ID.Equals("Save")) { Binding eBinding; eBinding = new Binding(dbConn, sdb); eBinding.add((HtmlInputHidden)e.Item.FindControl("EmpPermitID")); eBinding.add(new DropDownVLBinder(sdb, (DropDownList)e.Item.FindControl("PermitTypeID"), EPermitType.VLPermitType)); eBinding.add((TextBox)e.Item.FindControl("EmpPermitNo")); eBinding.add(new TextBoxBinder(sdb, ((WebDatePicker)e.Item.FindControl("EmpPermitIssueDate")).TextBox, "EmpPermitIssueDate")); eBinding.add(new TextBoxBinder(sdb, ((WebDatePicker)e.Item.FindControl("EmpPermitExpiryDate")).TextBox, "EmpPermitExpiryDate")); eBinding.add((TextBox)e.Item.FindControl("EmpPermitRemark")); eBinding.init(Request, Session); EEmpPermit obj = new EEmpPermit(); Hashtable values = new Hashtable(); PageErrors errors = PageErrors.getErrors(sdb, Page.Master); errors.clear(); eBinding.toValues(values); sdb.validate(errors, values); if (!errors.isEmpty()) { return; } sdb.parse(values, obj); WebUtils.StartFunction(Session, FUNCTION_CODE, obj.EmpID); sdb.update(dbConn, obj); WebUtils.EndFunction(dbConn); Repeater.EditItemIndex = -1; AddPanel.Visible = IsAllowEdit; view = loadData(info, sdb, Repeater); } }
protected void Delete_Click(object sender, EventArgs e) { EEmpPermit c = new EEmpPermit(); c.EmpPermitID = CurID; db.select(dbConn, c); WebUtils.StartFunction(Session, FUNCTION_CODE, c.EmpID); db.delete(dbConn, c); WebUtils.EndFunction(dbConn); HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "EmpTab_Permit_View.aspx?EmpID=" + EmpID.Value); }
protected bool loadObject() { obj = new EEmpPermit(); bool isNew = WebFormWorkers.loadKeys(db, obj, DecryptedRequest); DBFilter filter = new DBFilter(); filter.add(new Match("EmpID", CurEmpID)); filter.add(WebUtils.AddRankFilter(Session, "EmpID", true)); if (EEmpPersonalInfo.db.count(dbConn, filter) == 0) { if (CurEmpID <= 0) { return(false); } else { HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx"); } } if (!db.select(dbConn, obj)) { if (CurID <= 0) { return(false); } else { HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx"); } } if (obj.EmpID != CurEmpID) { if (CurID <= 0) { return(false); } else { HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx"); } } Hashtable values = new Hashtable(); db.populate(obj, values); binding.toControl(values); return(true); }
protected void Save_Click(object sender, EventArgs e) { EEmpPermit c = new EEmpPermit(); Hashtable values = new Hashtable(); binding.toValues(values); PageErrors errors = PageErrors.getErrors(db, Page.Master); errors.clear(); db.validate(errors, values); if (!errors.isEmpty()) { return; } db.parse(values, c); //if (!AppUtils.checkDuplicate(dbConn, CurEmpID, db, c, errors, "PermitTypeID")) // return; WebUtils.StartFunction(Session, FUNCTION_CODE, c.EmpID); if (CurID < 0) { // Utils.MarkCreate(Session, c); db.insert(dbConn, c); CurID = c.EmpPermitID; // url = Utils.BuildURL(-1, CurID); } else { // Utils.Mark(Session, c); db.update(dbConn, c); } WebUtils.EndFunction(dbConn); HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "Emp_Permit_View.aspx?EmpPermitID=" + CurID + "&EmpID=" + c.EmpID); }