protected void Save_Click(object sender, EventArgs e) { ETaxPayment c = new ETaxPayment(); Hashtable values = new Hashtable(); binding.toValues(values); PageErrors errors = PageErrors.getErrors(db, Page.Master); errors.clear(); db.validate(errors, values); if (!errors.isEmpty()) { if (CurID > 0) { loadObject(); view = loadData(info, db, Repeater); } return; } db.parse(values, c); if (!errors.isEmpty()) { if (CurID > 0) { loadObject(); view = loadData(info, db, Repeater); } return; } WebUtils.StartFunction(Session, FUNCTION_CODE); db.update(dbConn, c); ArrayList selectedList = new ArrayList(); ArrayList unselectedList = new ArrayList(); foreach (RepeaterItem i in Repeater.Items) { CheckBox cb = (CheckBox)i.FindControl("ItemSelect"); BaseObject o = new EPaymentCode(); WebFormUtils.GetKeys(EPaymentCode.db, o, cb); if (cb.Checked) { selectedList.Add(o); } else { unselectedList.Add(o); } } foreach (EPaymentCode o in selectedList) { DBFilter taxPaymentMapFilter = new DBFilter(); taxPaymentMapFilter.add(new Match("TaxPayID", c.TaxPayID)); taxPaymentMapFilter.add(new Match("PaymentCodeID", o.PaymentCodeID)); ArrayList taxPaymentMaps = ETaxPaymentMap.db.select(dbConn, taxPaymentMapFilter); if (taxPaymentMaps.Count == 0) { ETaxPaymentMap taxPaymentMap = new ETaxPaymentMap(); taxPaymentMap.TaxPayID = c.TaxPayID; taxPaymentMap.PaymentCodeID = o.PaymentCodeID; ETaxPaymentMap.db.insert(dbConn, taxPaymentMap); } } foreach (EPaymentCode o in unselectedList) { DBFilter taxPaymentMapFilter = new DBFilter(); taxPaymentMapFilter.add(new Match("TaxPayID", c.TaxPayID)); taxPaymentMapFilter.add(new Match("PaymentCodeID", o.PaymentCodeID)); ArrayList taxPaymentMaps = ETaxPaymentMap.db.select(dbConn, taxPaymentMapFilter); if (taxPaymentMaps.Count != 0) { foreach (ETaxPaymentMap taxPaymentMap in taxPaymentMaps) { ETaxPaymentMap.db.delete(dbConn, taxPaymentMap); } } } WebUtils.EndFunction(dbConn); HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "Taxation_PaymentMapping_View.aspx?TaxFormType=" + TaxFormType.Text + "&TaxPayID=" + c.TaxPayID); }
protected void Save_Click(object sender, EventArgs e) { EPaymentCode c = new EPaymentCode(); 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, db, c, errors, "PaymentCode")) { return; } WebUtils.StartFunction(Session, FUNCTION_CODE); if (CurID < 0) { // Utils.MarkCreate(Session, c); db.insert(dbConn, c); CurID = c.PaymentCodeID; // url = Utils.BuildURL(-1, CurID); } else { // Utils.Mark(Session, c); db.update(dbConn, c); } ArrayList list = new ArrayList(); foreach (RepeaterItem item in TaxPaymentRepeater.Items) { DropDownList d = (DropDownList)item.FindControl("TaxPayID"); string TaxFormCode = d.Attributes["TaxFormCode"]; DBFilter TaxPaymentFilter = new DBFilter(); TaxPaymentFilter.add(new Match("tp.TaxFormType", TaxFormCode)); DBFilter TaxPaymentMapFilter = new DBFilter(); TaxPaymentMapFilter.add(new Match("PaymentCodeID", c.PaymentCodeID)); TaxPaymentMapFilter.add(new IN("TaxPayID", "Select tp.TaxPayID from " + ETaxPayment.db.dbclass.tableName + " tp", TaxPaymentFilter)); ArrayList taxPaymentMapList = ETaxPaymentMap.db.select(dbConn, TaxPaymentMapFilter); if (taxPaymentMapList.Count > 0) { for (int i = 0; i < taxPaymentMapList.Count; i++) { ETaxPaymentMap taxPayMap = (ETaxPaymentMap)taxPaymentMapList[i]; if (i == 0) { int TaxPayID = 0; if (!int.TryParse(d.SelectedValue, out TaxPayID)) { ETaxPaymentMap.db.delete(dbConn, taxPayMap); } else if (!TaxPayID.Equals(taxPayMap.TaxPayID)) { taxPayMap.TaxPayID = TaxPayID; ETaxPaymentMap.db.update(dbConn, taxPayMap); } } else { ETaxPaymentMap.db.delete(dbConn, taxPayMap); } } } else { int TaxPayID = 0; if (int.TryParse(d.SelectedValue, out TaxPayID)) { ETaxPaymentMap taxPayMap = new ETaxPaymentMap(); taxPayMap.TaxPayID = TaxPayID; taxPayMap.PaymentCodeID = c.PaymentCodeID; ETaxPaymentMap.db.insert(dbConn, taxPayMap); } } } WebUtils.EndFunction(dbConn); HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "PaymentCode_View.aspx?PaymentCodeID=" + CurID); }