protected void Page_Load(object sender, EventArgs e) { if (!(null == Session["totleAuthority"])) { AuthAttributes usrAuthAttr = (AuthAttributes)Session["totleAuthority"]; bool flag = usrAuthAttr.HasOneFlag(AuthAttributes.pay_receiptApply); if (!flag) { Response.Redirect("~/Main/NoAuthority.aspx"); } } else { string url = Request.FilePath; Session["backUrl"] = url; Response.Redirect("~/Account/Login.aspx"); } if (null == Session["seldSubContract"]) { Response.Redirect("~/Main/paymentReceiptManager/subContractPaymentView.aspx"); } if (!IsPostBack) { //DataRow sessionDr = Session["seldSubContract"] as DataRow; //System.Nullable<int> mainContractId = int.Parse(sessionDr["mainContractId"] as string); //string subContractId = sessionDr["subContractId"].ToString(); //string selfReceiving = sessionDr["receivingPercent"].ToString(); int paymentId = int.Parse(Session["seldPaymentId"] as string); Xm_db xmDataCont = Xm_db.GetInstance(); //var paymentApplyEdit = // (from paymentApply in xmDataCont.Tbl_paymentApply // where paymentApply.PaymentId == paymentId // select paymentApply).First(); //string selfReceiving = paymentApplyEdit.Tbl_subContract.Tbl_mainContract.SelfReceivingPercent.ToString(); //System.Nullable<int> mainContractId = paymentApplyEdit.Tbl_subContract.MainContractId; //System.Nullable<int> maxRtn = 0; //string maxPay = xmDataCont.MainContract_MaxPay(mainContractId, ref maxRtn).ToString(); //lblMainContractPay.Text = maxPay + "%"; //lblSubContractPay.Text = selfReceiving + "%"; //#region ddlSelfReceipt //ListItemCollection licNomal = new ListItemCollection(); //int num = 0; //int max = int.Parse(maxPay) - int.Parse(selfReceiving) + 5; //string strValue = string.Empty; //string strPercent = "%"; //string strText = string.Empty; //for (int i = num; i < max; i = i + 5) //{ // strValue = i.ToString(); // strText = strValue + strPercent; // licNomal.Add(strText); //} //ListItemCollection licSpecial = new ListItemCollection(); //num = max; //max = 110 - max; //strValue = string.Empty; //strText = string.Empty; //for (int i = max; i < max; i = i + 5) //{ // strValue = i.ToString(); // strText = strValue + strPercent; // licSpecial.Add(strText); //} //Session["licNomal"] = licNomal; //Session["licSpecial"] = licSpecial; //#endregion var paymentApplyEdit = (from paymentApply in xmDataCont.Tbl_paymentApply where paymentApply.PaymentId == paymentId select paymentApply).First(); float selfReceiving = paymentApplyEdit.HasPayPercent; System.Nullable <int> mainContractId = paymentApplyEdit.Tbl_subContract.MainContractId; System.Nullable <float> maxRtn = 0; string maxPay = xmDataCont.MainContract_MaxPay(mainContractId, ref maxRtn).ToString(); lblMainContractPay.Text = maxRtn.Value.ToString("p"); lblSubContractPay.Text = selfReceiving.ToString("p"); Session["maxPay"] = maxRtn.Value; #region ddlSelfReceipt DataTable dtNomal = new DataTable(); dtNomal.Columns.Add("DataTextField", Type.GetType("System.String")); dtNomal.Columns.Add("DataValueField", Type.GetType("System.Single")); float num = 0; float max = maxRtn.Value - selfReceiving + 0.05f; max = max <= 0.05f ? 0.05f : max; DataRow dr = null; for (float i = num; i < max; i = i + 0.05f) { dr = dtNomal.NewRow(); dr["DataTextField"] = i.ToString("p"); dr["DataValueField"] = i; dtNomal.Rows.Add(dr); } DataTable dtSpecial = new DataTable(); dtSpecial.Columns.Add("DataTextField", Type.GetType("System.String")); dtSpecial.Columns.Add("DataValueField", Type.GetType("System.Single")); num = 0; max = 1.05f - selfReceiving; dr = null; for (float i = num; i < max; i = i + 0.05f) { dr = dtSpecial.NewRow(); dr["DataTextField"] = i.ToString("p"); dr["DataValueField"] = i; dtSpecial.Rows.Add(dr); //licNomal.Add(new ListItem(i.ToString("p"), i.ToString())); } Session["dtNomal"] = dtNomal; Session["dtSpecial"] = dtSpecial; #endregion ddlSelfPay.DataSource = Session["dtNomal"]; ddlSelfPay.DataValueField = "DataValueField"; ddlSelfPay.DataTextField = "DataTextField"; ddlSelfPay.DataBind(); ddlSelfPay.SelectedIndex = 0; txtPayExplication.Text = paymentApplyEdit.PaymentExplication; } }