Exemple #1
0
    /// <summary>
    /// 保存
    /// <param name="url">保存后,跳转的页面,为空,则为当前页</param>
    /// </summary>
    private void SaveContact(string url)
    {
        string playType    = sltPlay.Value.Trim();        //付款方式
        string temple      = sltTemple.Value.Trim();      //合同模板
        string priceClause = sltPriceClause.Value.Trim(); //价格条款
        string currency    = sltCurrency.Value.Trim();    //币种
        string remark      = txtRemark.Text.Trim();       //摘要

        string beginDate = txtBeginDate.Value.Trim();     //协议有效开始日期
        string endDate   = txtEndDate.Value.Trim();       //协议有效结束日期


        f_SRM_Result model = new f_SRM_Result();

        model.id = hdfid.Value;
        model.SRM_Contract_NO = hdfSRMNo.Value;
        model.WorkFlowStatus  = "1";
        model.TemplateId      = temple;
        model.Remark          = remark;
        model.PriceClause     = priceClause;
        model.Currency        = currency;
        model.AgreementBDate  = beginDate;
        model.AgreementEDate  = endDate;
        model.CreateTime      = DateTime.Now;
        model.PlayType        = playType;

        decimal totalAmount = 0;
        string  amount      = lbTotal.Text.Trim();//合同金额

        if (string.IsNullOrEmpty(amount))
        {
            amount = "0";
        }
        try
        {
            totalAmount = decimal.Parse(amount);
        }
        catch
        {
            ShareCode.AlertMsg(this, "play", "合计金额出错,请检查后再保存。", url, false);
            return;
        }
        model.Amount = totalAmount;

        int relt = bll.UpdateContactInfo(model);

        if (relt > 0)
        {
            //添加产品表
            ContactProduct         modelp    = new ContactProduct();
            IList <ContactProduct> modelList = new List <ContactProduct>();

            for (int i = 0; i < this.Repeater1.Items.Count; i++)
            {
                modelp = new ContactProduct();

                modelp.CID = hdfid.Value;                                                  //合同主表ID

                modelp.CType = "";                                                         //类型
                Label lb = (Label)this.Repeater1.Items[i].FindControl("lbCode");           //物料编码
                modelp.ItemCode = lb.Text.Trim();
                modelp.CVersion = "";                                                      //版本
                lb = (Label)this.Repeater1.Items[i].FindControl("lbClassificatiion");      //类别
                modelp.Classificatiion = lb.Text.Trim();
                lb = (Label)this.Repeater1.Items[i].FindControl("lbItemName");             //物料名称
                modelp.ItemName = lb.Text.Trim();
                lb          = (Label)this.Repeater1.Items[i].FindControl("lbUnit");        //单位
                modelp.Unit = lb.Text.Trim();
                TextBox txt = (TextBox)this.Repeater1.Items[i].FindControl("txtQuantity"); //数量
                modelp.Quantity = txt.Text.Trim();
                lb = (Label)this.Repeater1.Items[i].FindControl("lbPrice");                //价格
                modelp.UnitPrice = lb.Text.Trim();
                txt = (TextBox)this.Repeater1.Items[i].FindControl("txtPromiseDate");      //已承诺日期
                if (!string.IsNullOrEmpty(txt.Text))
                {
                    modelp.PromiseDate = Convert.ToDateTime(txt.Text.Trim());
                }
                lb = (Label)this.Repeater1.Items[i].FindControl("lbRequireDate2");//需求日期
                if (!string.IsNullOrEmpty(lb.Text))
                {
                    modelp.RequireDate = Convert.ToDateTime(lb.Text.Trim());
                }
                txt            = (TextBox)this.Repeater1.Items[i].FindControl("txtRemark");//备注
                modelp.CRemark = txt.Text.Trim();

                modelList.Add(modelp);
            }
            bll.AddContactProduct(modelList);

            ShareCode.AlertMsg(this, "play", "保存成功", url, false);

            LoadData(hdfid.Value);
        }
        else
        {
            ShareCode.AlertMsg(this, "play", "保存失败", "", false);
        }
    }