Exemple #1
0
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        string           arg_05_0         = string.Empty;
        MonthDetailLogic monthDetailLogic = new MonthDetailLogic();
        int num = 0;

        using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString))
        {
            sqlConnection.Open();
            SqlTransaction sqlTransaction = sqlConnection.BeginTransaction();
            for (int i = 0; i < this.gvwWebLineList.Rows.Count; i++)
            {
                MonthDetailModel    monthDetailModel = new MonthDetailModel();
                ClientScriptManager arg_40_0         = this.Page.ClientScript;
                monthDetailModel.UID         = new Guid(this.gvwWebLineList.DataKeys[i].Value.ToString());
                monthDetailModel.MonthPlanID = new Guid(this.hdfMonthPalnID.Value);
                HtmlInputText htmlInputText = this.gvwWebLineList.Rows[i].FindControl("txtOrderID") as HtmlInputText;
                if (htmlInputText.Value != "" && htmlInputText.Value != "0")
                {
                    monthDetailModel.OrderID = new int?(Convert.ToInt32(htmlInputText.Value.ToString()));
                }
                else
                {
                    monthDetailModel.OrderID = new int?(i + 1);
                }
                HiddenField hiddenField = this.gvwWebLineList.Rows[i].FindControl("hidenContractID") as HiddenField;
                if (!(hiddenField.Value.ToString() != ""))
                {
                    num = 0;
                    break;
                }
                monthDetailModel.ContractID  = hiddenField.Value.ToString();
                monthDetailModel.Plansubject = "";
                HtmlInputText htmlInputText2 = this.gvwWebLineList.Rows[i].FindControl("txtOldBalance") as HtmlInputText;
                if (htmlInputText2.Value.ToString() != "")
                {
                    monthDetailModel.OldBalance = new decimal?(decimal.Parse(htmlInputText2.Value.ToString()));
                }
                else
                {
                    monthDetailModel.OldBalance = new decimal?(0m);
                }
                HtmlInputText htmlInputText3 = this.gvwWebLineList.Rows[i].FindControl("txtPlanMoney") as HtmlInputText;
                if (htmlInputText3.Value.ToString() != "")
                {
                    monthDetailModel.PlanMoney = new decimal?(decimal.Parse(htmlInputText3.Value.ToString()));
                }
                else
                {
                    monthDetailModel.PlanMoney = new decimal?(0m);
                }
                HtmlInputText htmlInputText4 = this.gvwWebLineList.Rows[i].FindControl("txtRemark") as HtmlInputText;
                if (htmlInputText4.Value.ToString() != "")
                {
                    monthDetailModel.ReMark = htmlInputText4.Value.ToString();
                }
                else
                {
                    monthDetailModel.ReMark = "";
                }
                if (monthDetailLogic.Update(monthDetailModel, sqlTransaction))
                {
                    num = 1;
                }
            }
            if (num == 1)
            {
                sqlTransaction.Commit();
                Fund_Plan_MonthMainInfo fund_Plan_MonthMainInfo = new Fund_Plan_MonthMainInfo();
                fund_Plan_MonthMainInfo.MonthPlanID  = new Guid(this.hdfMonthPalnID.Value);
                fund_Plan_MonthMainInfo.OperatorCode = base.UserCode;
                fund_Plan_MonthMainInfo.Remark       = this.txtRemark.Text.ToString().Trim();
                this.FA.updateMainInfo(fund_Plan_MonthMainInfo);
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append("btnEdit_onclick();");
                base.RegisterScript(stringBuilder.ToString());
            }
            else
            {
                sqlTransaction.Rollback();
                StringBuilder stringBuilder2 = new StringBuilder();
                stringBuilder2.Append("btnEdit_onclick();");
                base.RegisterScript(stringBuilder2.ToString());
            }
        }
    }
Exemple #2
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        this.gvwWebLineList.Style.Add("min-width", "1024px");
        string           text             = string.Empty;
        MonthDetailLogic monthDetailLogic = new MonthDetailLogic();
        int num = 0;

        using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString))
        {
            sqlConnection.Open();
            SqlTransaction sqlTransaction = sqlConnection.BeginTransaction();
            for (int i = 0; i < this.gvwWebLineList.Rows.Count; i++)
            {
                MonthDetailModel    monthDetailModel = new MonthDetailModel();
                ClientScriptManager arg_5B_0         = this.Page.ClientScript;
                monthDetailModel.UID         = new Guid(this.gvwWebLineList.DataKeys[i].Value.ToString());
                monthDetailModel.MonthPlanID = new Guid(this.hdfMonthPalnID.Value);
                monthDetailModel.ThisBalance = new decimal?(0m);
                HtmlInputText htmlInputText = this.gvwWebLineList.Rows[i].FindControl("txtOrderID") as HtmlInputText;
                monthDetailModel.OrderID = new int?(string.IsNullOrEmpty(htmlInputText.Value.Trim()) ? 0 : Convert.ToInt32(htmlInputText.Value.ToString()));
                HiddenField hiddenField = this.gvwWebLineList.Rows[i].FindControl("hidenContractID") as HiddenField;
                if (hiddenField.Value.ToString() != "")
                {
                    if (this.findInfoByContractID(hiddenField.Value.ToString(), monthDetailModel.UID.ToString()))
                    {
                        text += "依据合同已存在!";
                        num   = 2;
                        break;
                    }
                    monthDetailModel.ContractID = hiddenField.Value.ToString();
                }
                monthDetailModel.Plansubject = "";
                HtmlInputText htmlInputText2 = this.gvwWebLineList.Rows[i].FindControl("txtOldBalance") as HtmlInputText;
                monthDetailModel.OldBalance = new decimal?(string.IsNullOrEmpty(htmlInputText2.Value.Trim()) ? 0m : decimal.Parse(htmlInputText2.Value.ToString()));
                HtmlInputText htmlInputText3 = this.gvwWebLineList.Rows[i].FindControl("txtPlanMoney") as HtmlInputText;
                monthDetailModel.PlanMoney = new decimal?(string.IsNullOrEmpty(htmlInputText3.Value.Trim()) ? 0m : decimal.Parse(htmlInputText3.Value.ToString()));
                HtmlInputText htmlInputText4 = this.gvwWebLineList.Rows[i].FindControl("txtConRemark") as HtmlInputText;
                monthDetailModel.ReMark = (string.IsNullOrEmpty(htmlInputText4.Value.Trim()) ? string.Empty : htmlInputText4.Value.ToString());
                if (!string.IsNullOrEmpty(monthDetailModel.ContractID))
                {
                    if (monthDetailModel.PlanMoney < 1m)
                    {
                        num  = 2;
                        text = "计划金额应大于0";
                        break;
                    }
                    if (this.findInfoByUID(monthDetailModel.UID.ToString()))
                    {
                        if (monthDetailLogic.Add(monthDetailModel))
                        {
                            num = 1;
                        }
                    }
                    else
                    {
                        if (monthDetailLogic.Update(monthDetailModel, sqlTransaction))
                        {
                            num = 1;
                        }
                    }
                }
            }
            if (num == 1)
            {
                sqlTransaction.Commit();
                this.BindPlanDetail();
                DataTable dataTable = this.ViewState["temDT"] as DataTable;
                DataRow   dataRow   = dataTable.NewRow();
                dataRow["UID"]         = Guid.NewGuid();
                dataRow["MonthPlanID"] = this.hdfMonthPalnID.Value;
                dataRow["ContractID"]  = "";
                dataRow["Plansubject"] = "";
                dataRow["PlanMoney"]   = "0.00";
                dataRow["OldBalance"]  = "0.00";
                dataRow["OrderID"]     = "-1";
                dataRow["ReMark"]      = "";
                dataRow["ThisBalance"] = "0.00";
                dataTable.Rows.Add(dataRow);
                this.gvwWebLineList.DataSource = dataTable;
                this.gvwWebLineList.DataBind();
            }
            else
            {
                if (num == 2)
                {
                    sqlTransaction.Rollback();
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.Append(" top.ui.alert('" + text + "');");
                    base.RegisterScript(stringBuilder.ToString());
                }
            }
        }
    }