protected void btnSaveToDB_Click(object sender, EventArgs e) { AgentBiz biz = new AgentBiz(); // check change list foreach (GridViewRow row in lstCompany.Rows) { Label lbID = row.FindControl("lbAgentID") as Label; TextBox txtDiscount = row.FindControl("txtDiscount") as TextBox; HiddenField hdDiscount = row.FindControl("hdDiscount") as HiddenField; TextBox txtCredit = row.FindControl("txtCredit") as TextBox; HiddenField hdCredit = row.FindControl("hdCredit") as HiddenField; decimal newDiscount = PageTools.ParseDecimal(txtDiscount.Text); decimal oldDiscount = PageTools.ParseDecimal(hdDiscount.Value); int agentID = PageTools.ParseInt(lbID.Text); if (newDiscount != oldDiscount) { biz.SaveAgentDiscount(agentID, newDiscount); } decimal newCredit = PageTools.ParseDecimal(txtCredit.Text); decimal oldCredit = PageTools.ParseDecimal(hdCredit.Value); if (newCredit != oldCredit) { biz.SaveAgentCredit(agentID, newCredit); } } lstCompany.DataBind(); btnSave.Visible = true; pnResult.Visible = false; lstCompany.Visible = true; }
protected void btnDoPayment_Click(object sender, EventArgs e) { int agentID = PageTools.GetSavedId("AgentID", null); AgentBiz biz = new AgentBiz(); int apid = biz.UpdatePayment(agentID, PageTools.ParseDecimal(txtPay.Text), PageTools.ParseInt(selePayMethod.SelectedValue), txtRemark.Text); if (apid > 0) { // input array foreach (GridViewRow row in lstOrders.Rows) { TextBox tb = row.FindControl("inpPay") as TextBox; Label lb = row.FindControl("lbOrderID") as Label; if (tb != null) { decimal payItem = PageTools.ParseDecimal(tb.Text); int orderID = PageTools.ParseInt(lb.Text); biz.UpdatePaymentItem(apid, orderID, agentID, payItem); } } lbMsg.Text = "Payment successed."; } lstOrders.DataBind(); }