예제 #1
0
    private void LoadData(string id)
    {
        bool      isD = false;//查询哪个表的产品,false没有生成合同时,根据询价单ID查询,true已生成合同,根据合同ID查询
        DataTable dt  = bll.GetContactDataByID(id.Trim());

        if (dt != null && dt.Rows.Count > 0)
        {
            if (string.IsNullOrEmpty(dt.Rows[0]["CreateTime"].ToString()))
            {
                lbTime.Text = DateTime.Now.ToString();
            }
            else
            {
                lbTime.Text = dt.Rows[0]["CreateTime"].ToString();
            }

            lbBuyOrg.Text = dt.Rows[0]["BuyOrg"].ToString();

            string srmNo = dt.Rows[0]["SRM_Contract_NO"].ToString();
            if (string.IsNullOrEmpty(srmNo))
            {
                //srmNo = "90000001";
                srmNo = bll.GetSRMNo();//取得合同号

                hdfSRMNo.Value = "";
                isD            = false;
            }
            else
            {
                hdfSRMNo.Value = srmNo;
                isD            = true;
            }
            lbSrmNo.Text = srmNo;
            hdfid.Value  = dt.Rows[0]["id"].ToString();

            lbERPNo.Text           = dt.Rows[0]["ERP_Contract_NO"].ToString();
            lbGrantNo.Text         = dt.Rows[0]["GrantNo"].ToString();
            lbDistributorName.Text = dt.Rows[0]["DistributorName"].ToString();
            lbDistributorAddr.Text = dt.Rows[0]["DistributorAddr"].ToString();
            lbContactName.Text     = dt.Rows[0]["ContactName"].ToString();
            lbReceivingParty.Text  = dt.Rows[0]["ReceivingParty"].ToString();
            lbAcquiringParty.Text  = dt.Rows[0]["AcquiringParty"].ToString();

            string currency = dt.Rows[0]["Currency"].ToString();
            if (string.IsNullOrEmpty(currency))
            {
                currency = dt.Rows[0]["AbCurrency"].ToString();
            }
            if (string.IsNullOrEmpty(currency))
            {
                currency = "CNY";
            }
            lbCurrency.Text   = currency;
            sltCurrency.Value = currency;

            lbBuyerAccount.Text = dt.Rows[0]["BuyerAccount"].ToString();

            string workFlowStatus = dt.Rows[0]["WorkFlowStatus"].ToString().Trim();
            lbWorkFlowStatus.Text = CommonCode.GetWorkFlowStatusText(workFlowStatus);

            //判断显示功能按钮
            switch (workFlowStatus)
            {
            case "1":    //明细维护
                btnSave.Visible     = true;
                btnCom.Visible      = true;
                btnAud.Visible      = false;
                hdfStatus.Value     = "1";
                hdfBackStatus.Value = "1";
                break;

            case "2":    //供应商确认中
                btnSave.Visible     = true;
                btnCom.Visible      = false;
                btnAud.Visible      = false;
                hdfStatus.Value     = "2";
                hdfBackStatus.Value = "0";
                break;

            case "3":    //供应商回退
                btnSave.Visible     = true;
                btnCom.Visible      = true;
                btnAud.Visible      = false;
                hdfStatus.Value     = "1";
                hdfBackStatus.Value = "1";
                aStatus.Title       = dt.Rows[0]["DistributorRemark"].ToString();
                break;

            case "4":    //供应商确认
                btnSave.Visible     = true;
                btnCom.Visible      = false;
                btnAud.Visible      = true;
                hdfStatus.Value     = "4";
                hdfBackStatus.Value = "0";
                break;

            case "5":    //经理审批中
                btnSave.Visible     = true;
                btnCom.Visible      = false;
                btnAud.Visible      = false;
                hdfStatus.Value     = "5";
                hdfBackStatus.Value = "0";
                break;

            case "6":    //经理回退
                btnSave.Visible     = true;
                btnCom.Visible      = false;
                btnAud.Visible      = true;
                hdfStatus.Value     = "6";
                hdfBackStatus.Value = "0";
                aStatus.Title       = dt.Rows[0]["AuditRemark"].ToString();
                break;

            case "7":    //合同生效
                btnSave.Visible     = true;
                btnCom.Visible      = false;
                btnAud.Visible      = false;
                hdfStatus.Value     = "7";
                hdfBackStatus.Value = "0";
                hdfUrl.Value        = "ContractEffectiveList.aspx";
                break;

            default:    //未创建
                btnSave.Visible     = true;
                btnCom.Visible      = false;
                btnAud.Visible      = false;
                hdfStatus.Value     = "1";
                hdfBackStatus.Value = "1";
                break;
            }


            sltPlay.Value  = dt.Rows[0]["PlayType"].ToString();          //付款方式
            sltPlay2.Value = dt.Rows[0]["PlayType"].ToString();          //付款方式

            sltTemple.Value      = dt.Rows[0]["TemplateId"].ToString();  //合同模板
            sltPriceClause.Value = dt.Rows[0]["PriceClause"].ToString(); //价格条款
            txtRemark.Text       = dt.Rows[0]["Remark"].ToString();      //摘要

            string bDate = dt.Rows[0]["AgreementBDate"].ToString();
            if (string.IsNullOrEmpty(bDate))
            {
                bDate = DateTime.Now.ToString("yyyy-MM-dd");
            }
            else
            {
                bDate = Convert.ToDateTime(bDate).ToString("yyyy-MM-dd");
            }
            txtBeginDate.Value = bDate;

            bDate = dt.Rows[0]["AgreementEDate"].ToString();
            if (string.IsNullOrEmpty(bDate))
            {
                bDate = DateTime.Now.AddDays(7).ToString("yyyy-MM-dd");
            }
            else
            {
                bDate = Convert.ToDateTime(bDate).ToString("yyyy-MM-dd");
            }
            txtEndDate.Value = bDate;

            DataTable dtp = null;
            //isD = false;//查询哪个表的产品,false没有生成合同时,根据询价单ID查询,true已生成合同,根据合同ID查询
            if (isD)
            {
                dtp = bll.GetContactProductByCID(dt.Rows[0]["id"].ToString());
            }
            else
            {
                string xjNo = dt.Rows[0]["XunJiaWorkflowID"].ToString();
                dtp = bll.GetContactProduct(xjNo);//Amount
            }

            Repeater1.DataSource = dtp;
            Repeater1.DataBind();

            //金额合计
            double amount = 0;
            if (dtp != null && dtp.Rows.Count > 0)
            {
                foreach (DataRow r in dtp.Rows)
                {
                    amount += string.IsNullOrEmpty(r["Amount"].ToString()) ? 0 : double.Parse(r["Amount"].ToString());
                }
            }
            lbTotal.Text = amount.ToString();
        }
    }