Example #1
0
        private void GetArea()
        {
            #region //需求区域

            Mod_TS_DIC mod = new Mod_TS_DIC();
            mod.C_TYPECODE = "ConArea";
            DataTable dt = ts_dic.GetList(mod).Tables[0];
            if (dt.Rows.Count > 0)
            {
                dropneedarea.DataSource     = dt;
                dropneedarea.DataTextField  = "C_DETAILNAME";
                dropneedarea.DataValueField = "C_DETAILNAME";
                dropneedarea.DataBind();
            }
            else
            {
                dropneedarea.DataSource = null;
                dropneedarea.DataBind();
            }
            #endregion

            var vUser = (NF.Framework.CurrentUser)HttpContext.Current.Session["CurrentUser"];

            string dept = ts_user.GetDept(vUser.Account);

            dropneedarea.SelectedIndex = dropneedarea.Items.IndexOf(dropneedarea.Items.FindByText(dept));


            #region //线材库区域

            DataTable dtxcarea = tmo_order.GetXCAREA().Tables[0];
            if (dtxcarea.Rows.Count > 0)
            {
                dropsalearea.DataSource     = dtxcarea;
                dropsalearea.DataTextField  = "C_SALE_AREA";
                dropsalearea.DataValueField = "C_SALE_AREA";
                dropsalearea.DataBind();
                dropsalearea.Items.Insert(0, new ListItem("全部区域", "-1"));//
            }
            else
            {
                dropsalearea.DataSource = null;
                dropsalearea.DataBind();
            }
            #endregion

            #region //质量
            DataTable dtzl = tmo_order.GetXC_JUDGE_LEV_ZH("").Tables[0];
            if (dtzl.Rows.Count > 0)
            {
                dropzldj.DataSource     = dtzl;
                dropzldj.DataTextField  = "C_JUDGE_LEV_ZH";
                dropzldj.DataValueField = "C_JUDGE_LEV_ZH";
                dropzldj.DataBind();
                dropzldj.Items.Insert(0, new ListItem("全部质量", ""));
            }
            #endregion
        }
        //客户调配
        protected void btneditCust_Click(object sender, EventArgs e)
        {
            var vUser = (NF.Framework.CurrentUser)HttpContext.Current.Session["CurrentUser"];

            string dept = ts_user.GetDept(vUser.Account);



            bool result = true;  //判断当前发运数量已超出可发运量

            bool result2 = true; //调配区域是否一致

            string stlgrd = string.Empty;

            #region                                     //初始化DataTable
            DataTable dt = new DataTable();
            dt.Columns.Add("matCode", typeof(string));  //物料编码
            dt.Columns.Add("stdCode", typeof(string));  //执行标准
            dt.Columns.Add("area", typeof(string));     //区域
            dt.Columns.Add("pack", typeof(string));     //包装
            dt.Columns.Add("lev", typeof(string));      //等级
            dt.Columns.Add("custname", typeof(string)); //客户
            dt.Columns.Add("conno", typeof(string));    //合同号
            dt.Columns.Add("stlgrd", typeof(string));   //钢种
            dt.Columns.Add("wgt", typeof(string));      //重量
            #endregion

            decimal ztwgt = 0; //在途量
            decimal kcwgt = 0; //库存量
            decimal tpwgt = 0; //调配量
            decimal kfwgt = 0; //可发量

            List <Mod_TMC_ROLL_DEPLOY_LOG> list = new List <Mod_TMC_ROLL_DEPLOY_LOG>();
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                HtmlInputCheckBox cbxselect      = (HtmlInputCheckBox)rptList.Items[i].FindControl("cbxselect");
                Literal           ltlbatch       = (Literal)rptList.Items[i].FindControl("ltlbatch");       //批次号
                Literal           ltlmatcode     = (Literal)rptList.Items[i].FindControl("ltlmatcode");     //物料编码
                Literal           ltlstlgrd      = (Literal)rptList.Items[i].FindControl("ltlstlgrd");      //钢种
                Literal           ltlspec        = (Literal)rptList.Items[i].FindControl("ltlspec");        //规格
                Literal           ltlsalearea    = (Literal)rptList.Items[i].FindControl("ltlsalearea");    //销售区域
                Literal           ltlstdcode     = (Literal)rptList.Items[i].FindControl("ltlstdcode");     //执行标准
                Literal           ltlpack        = (Literal)rptList.Items[i].FindControl("ltlpack");        //包装要求
                Literal           ltllev         = (Literal)rptList.Items[i].FindControl("ltllev");         //质量等级
                Literal           ltlN_WGT       = (Literal)rptList.Items[i].FindControl("ltlN_WGT");       //重量
                Literal           ltlC_CUST_NAME = (Literal)rptList.Items[i].FindControl("ltlC_CUST_NAME"); //客户信息
                Literal           ltlC_CON_NO    = (Literal)rptList.Items[i].FindControl("ltlC_CON_NO");    //合同号
                if (cbxselect.Checked)
                {
                    //if (ltlsalearea.Text != dept)
                    //{
                    //    result = false;
                    //    break;
                    //}

                    DataRow[] dr = dt.Select("matCode='" + ltlmatcode.Text + "' and stdCode='" + ltlstdcode.Text + "' and area='" + ltlsalearea.Text + "' and pack='" + ltlpack.Text + "' and lev='" + ltllev.Text + "' and custname='" + ltlC_CUST_NAME.Text + "' and conno='" + ltlC_CON_NO.Text + "'");
                    if (dr.Length <= 0)
                    {
                        dt.Rows.Add(new object[] { ltlmatcode.Text, ltlstdcode.Text, ltlsalearea.Text, ltlpack.Text, ltllev.Text, ltlC_CUST_NAME.Text, ltlC_CON_NO.Text, ltlstlgrd.Text, ltlN_WGT.Text });
                    }
                    else
                    {
                        foreach (var item in dr)
                        {
                            item["wgt"] = Convert.ToString(Convert.ToDecimal(item["wgt"]) + Convert.ToDecimal(ltlN_WGT.Text));
                        }
                    }

                    #region //参数
                    Mod_TMC_ROLL_DEPLOY_LOG mod = new Mod_TMC_ROLL_DEPLOY_LOG();
                    mod.C_ROLL_PROCID = cbxselect.Value;
                    mod.C_BATCH_NO    = ltlbatch.Text;
                    mod.C_MAT_CODE    = ltlmatcode.Text;
                    mod.C_STL_GRD     = ltlstlgrd.Text;
                    mod.C_SPEC        = ltlspec.Text;
                    mod.C_OLDAREA     = ltlsalearea.Text;
                    mod.C_NEWAREA     = dropneedarea.SelectedValue;
                    mod.C_OLDCUST     = ltlC_CUST_NAME.Text;
                    mod.C_NEWCUST     = txtC_CGC.Value.Trim();

                    mod.C_OLDCON = ltlC_CON_NO.Text;                                                         //原资源合同
                    mod.C_NEWCON = txtNeedCon.Text.Trim() == "" ? ltlC_CON_NO.Text : txtNeedCon.Text.Trim(); //需求合同

                    mod.C_EMPID     = ltlempid.Text;
                    mod.C_EMPNAME   = ltlempname.Text;
                    mod.C_STD_CODE  = ltlstdcode.Text;
                    mod.C_JUDGE_LEV = ltllev.Text;
                    mod.C_PACK      = ltlpack.Text;
                    list.Add(mod);
                    #endregion
                }
            }

            if (result2)
            {
                #region //在途量/库存量
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        tpwgt = Convert.ToDecimal(dt.Rows[i]["wgt"]);

                        DataTable dtfyzt = tmo_order.ZTWGT(dt.Rows[i]["matCode"].ToString(), dt.Rows[i]["stdCode"].ToString(), dt.Rows[i]["area"].ToString(), dt.Rows[i]["pack"].ToString(), dt.Rows[i]["lev"].ToString(), dt.Rows[i]["custname"].ToString(), dt.Rows[i]["conno"].ToString()).Tables[0];
                        if (dtfyzt.Rows.Count > 0)                                             //在途量
                        {
                            ztwgt = Convert.ToDecimal(dtfyzt.Compute("sum(N_FYWGT)", "true")); //合计在途量
                        }
                        DataTable dtkc = tmo_order.KCWGT(dt.Rows[i]["matCode"].ToString(), dt.Rows[i]["stdCode"].ToString(), dt.Rows[i]["area"].ToString(), dt.Rows[i]["pack"].ToString(), dt.Rows[i]["lev"].ToString(), dt.Rows[i]["custname"].ToString(), dt.Rows[i]["conno"].ToString()).Tables[0];
                        if (dtkc.Rows.Count > 0)//库存量
                        {
                            if (!string.IsNullOrEmpty(dtkc.Rows[0]["N_WGT"].ToString()))
                            {
                                kcwgt = Convert.ToDecimal(dtkc.Rows[0]["N_WGT"]);//合计在途量
                            }
                        }
                        kfwgt = kcwgt - ztwgt;
                        if (tpwgt > kfwgt)
                        {
                            result = false;
                            break;
                        }
                    }
                }
                #endregion

                #region                            //执行调配资源

                if (dropflag.SelectedValue == "Y") //已判执行
                {
                    if (result)                    //判断当前发运数量已超出可发运量
                    {
                        if (list.Count > 0)
                        {
                            if (tmc_roll_deploy_log.InsertRoll_Proc3(list))
                            {
                                this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", "<script language='javascript'> _closemsg('调配成功');</script>", false);
                                BindList();
                            }
                        }
                        else
                        {
                            this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", "<script language='javascript'> close();</script>", false);
                        }
                    }
                    else
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", "<script language='javascript'> _closemsg('调配资源,存在发运单占用其中客户资源');</script>", false);
                    }
                }
                else
                {
                    #region//待判执行
                    if (list.Count > 0)
                    {
                        if (tmc_roll_deploy_log.InsertRoll_Proc3(list))
                        {
                            this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", "<script language='javascript'> _closemsg('调配成功');</script>", false);
                            BindList();
                        }
                    }
                    else
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", "<script language='javascript'> close();</script>", false);
                    }
                    #endregion
                }
                #endregion
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", "<script language='javascript'> _closemsg('其中资源涉及跨区调配,请重新选择!');</script>", false);
            }
        }