Beispiel #1
0
        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;

                string mainContractId = sessionDr["mainContractId"].ToString();
                string subContractId  = sessionDr["subContractId"].ToString();

                DataTable paymentApplyTable = null;
                if (null == Session["payApplyTable"])
                {
                    DataRow receiptApplyRow = null;

                    DataColumn colSubContractId  = new DataColumn("subContractId", System.Type.GetType("System.String"));
                    DataColumn colCustMaxPay     = new DataColumn("custMaxPay", System.Type.GetType("System.String"));
                    DataColumn colPayPercent     = new DataColumn("payPercent", System.Type.GetType("System.String"));
                    DataColumn colHasPayPercent  = new DataColumn("selfHasPay", System.Type.GetType("System.String"));
                    DataColumn colPayExplication = new DataColumn("paymentExplication", System.Type.GetType("System.String"));

                    paymentApplyTable = new DataTable("tbl_paymentApply");

                    paymentApplyTable.Columns.Add(colSubContractId);
                    paymentApplyTable.Columns.Add(colCustMaxPay);
                    paymentApplyTable.Columns.Add(colPayPercent);
                    paymentApplyTable.Columns.Add(colHasPayPercent);
                    paymentApplyTable.Columns.Add(colPayExplication);

                    receiptApplyRow = paymentApplyTable.NewRow();
                    receiptApplyRow["subContractId"]      = subContractId;
                    receiptApplyRow["payPercent"]         = string.Empty;
                    receiptApplyRow["paymentExplication"] = string.Empty;
                    paymentApplyTable.Rows.Add(receiptApplyRow);

                    Session["payApplyTable"] = paymentApplyTable;
                }
                else
                {
                    paymentApplyTable = Session["payApplyTable"] as DataTable;
                }

                string selfReceiving = sessionDr["receivingPercent"].ToString();

                DataSet MyDst = new DataSet();

                #region lblContractPay
                PaymentApplyProcess payApplyView = new PaymentApplyProcess(MyDst);

                payApplyView.MainContractPayMax(mainContractId);

                string maxPay = payApplyView.StrRtn;
                //float m = float.Parse(maxPay);
                //paymentApplyTable.Rows[0]["custMaxPay"] = maxPay;
                //lblMainContractPay.Text = maxPay + "%";
                //lblSubContractPay.Text = selfReceiving + "%";
                //#endregion

                //#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

                //ddlSelfPay.DataSource = Session["licNomal"];
                //ddlSelfPay.DataBind();
                //ddlSelfPay.SelectedIndex = 0;

                //Session["PaymentApplyProcess"] = payApplyView;

                float m = float.Parse(maxPay);
                float s = float.Parse(selfReceiving);
                paymentApplyTable.Rows[0]["custMaxPay"] = maxPay;
                lblMainContractPay.Text = m.ToString("p");
                lblSubContractPay.Text  = s.ToString("p");
                #endregion

                #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 = m - s + 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 - s;
                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;

                Session["PaymentApplyProcess"] = payApplyView;
            }
        }