Ejemplo n.º 1
0
        private void BindCust()
        {
            StringBuilder where = new StringBuilder();

            where.Append(" 1=1");
            if (!string.IsNullOrEmpty(txtCustCode.Value))
            {
                where.AppendFormat(" AND  C_NO='{0}'", txtCustCode.Value);
            }
            if (!string.IsNullOrEmpty(txtCustCode.Value))
            {
                where.AppendFormat(" AND  C_NAME LIKE '%{0}%'", txtCustName.Value);
            }

            DataTable dt = ts_custfile.GetList(where.ToString()).Tables[0];

            if (dt.Rows.Count > 0)
            {
                rptCust.DataSource = dt;
                rptCust.DataBind();
            }
            else
            {
                rptCust.DataSource = null;
                rptCust.DataBind();
            }
        }
Ejemplo n.º 2
0
        //保存订单
        protected void btnsave_Click(object sender, EventArgs e)
        {
            try
            {
                bool result = true;

                List <string[]> list_log = new List <string[]>();

                List <Mod_TMO_ORDER> orderList = new List <Mod_TMO_ORDER>();

                for (int i = 0; i < rptList_Add.Items.Count; i++)
                {
                    HtmlInputCheckBox chkMat_Code    = (HtmlInputCheckBox)rptList_Add.Items[i].FindControl("chkMat_Code"); //物料ID
                    Literal           ltlStdCode     = (Literal)rptList_Add.Items[i].FindControl("ltlStdCode");            //执行标准
                    Literal           ltlC_IS_BXG    = (Literal)rptList_Add.Items[i].FindControl("ltlC_IS_BXG");           //是否不锈钢
                    Literal           ltlZYX1        = (Literal)rptList_Add.Items[i].FindControl("ltlZYX1");               //自由项1
                    Literal           ltlZYX2        = (Literal)rptList_Add.Items[i].FindControl("ltlZYX2");               //自由项2
                    DropDownList      dropArea       = (DropDownList)rptList_Add.Items[i].FindControl("dropArea");         //区域
                    TextBox           txtPack_Code   = (TextBox)rptList_Add.Items[i].FindControl("txtPack_Code");          //包装
                    TextBox           txtCustName    = (TextBox)rptList_Add.Items[i].FindControl("txtCustName");           //客户
                    TextBox           txtBXGCustName = (TextBox)rptList_Add.Items[i].FindControl("txtBXGCustName");        //不锈钢客户
                    TextBox           txtWgt         = (TextBox)rptList_Add.Items[i].FindControl("txtWgt");                //排产量
                    TextBox           txtRemark      = (TextBox)rptList_Add.Items[i].FindControl("txtRemark");             //备注


                    if (string.IsNullOrEmpty(txtPack_Code.Text) || tqb_pack.Exists(txtPack_Code.Text) == false)
                    {
                        result = false;
                        ScriptManager.RegisterStartupScript(UpdatePanel1, this.Page.GetType(), "", "_closemsg('包装不能为空或与实际包装不符');", true);
                        break;
                    }

                    if (dropArea.SelectedItem.Text != "不锈钢公司")
                    {
                        if (string.IsNullOrEmpty(txtCustName.Text))
                        {
                            result = false;
                            ScriptManager.RegisterStartupScript(UpdatePanel1, this.Page.GetType(), "", "_closemsg('请补全客户信息');", true);
                            break;
                        }
                    }
                    if (result)
                    {
                        #region //插入预测订单
                        Bll_RandomNumber  randomnumber = new Bll_RandomNumber();
                        Mod_TB_MATRL_MAIN modMat       = tb_matrl_main.GetModel(chkMat_Code.Value);

                        Mod_TMO_ORDER modOrder = new Mod_TMO_ORDER();                     //订单表
                        string        orderNo  = "YC" + DateTime.Now.ToString("yyyMMdd");
                        modOrder.C_ORDER_NO    = randomnumber.CreateNeedOrderNo(orderNo); //订单号
                        modOrder.C_CON_NO      = "YC";                                    //合同号
                        modOrder.C_AREA        = dropArea.SelectedItem.Text;              //区域
                        modOrder.C_INVBASDOCID = modMat.C_PK_INVBASDOC;                   //存货档案主键
                        modOrder.C_INVENTORYID = modMat.C_PK_INVMANDOC;                   //存货管理档案主键
                        modOrder.C_MAT_CODE    = modMat.C_MAT_CODE;                       //物料编码
                        modOrder.C_MAT_NAME    = modMat.C_MAT_NAME;                       //物料名称
                        modOrder.C_SPEC        = modMat.C_SPEC;                           //规格
                        modOrder.C_STL_GRD     = modMat.C_STL_GRD;                        //钢种
                        modOrder.C_FUNITID     = modMat.C_FJLDW;                          //辅单位
                        modOrder.C_UNITID      = modMat.C_PK_MEASDOC;                     //主计量单位
                        modOrder.C_YWY         = ltlempname.Text;                         //业务员
                        modOrder.C_SFPJ        = "N";
                        modOrder.N_FLAG        = 1;                                       //预测订单
                        modOrder.N_EXEC_STATUS = -1;                                      //提报订单
                        modOrder.N_TYPE        = Convert.ToDecimal(modMat.C_MAT_TYPE);    //订单类型

                        modOrder.C_FREE1     = ltlZYX1.Text;                              //自由项1
                        modOrder.C_FREE2     = ltlZYX2.Text;                              //自由项2
                        modOrder.C_STD_CODE  = ltlStdCode.Text;                           //执行标准
                        modOrder.C_BY4       = ltlC_IS_BXG.Text;                          //是否不锈钢
                        modOrder.N_WGT       = Convert.ToDecimal(txtWgt.Text);
                        modOrder.C_LEV       = "普通";                                      //钢种等级
                        modOrder.C_ORDER_LEV = "三级";                                      //订单等级
                        modOrder.N_STATUS    = 2;                                         //生效
                        modOrder.C_EMP_ID    = ltlempid.Text;
                        modOrder.C_EMP_NAME  = ltlempname.Text;
                        modOrder.C_PACK      = txtPack_Code.Text;

                        if (modOrder.C_AREA == "不锈钢公司")
                        {
                            modOrder.C_CUST_NAME = txtBXGCustName.Text;//客户信息
                        }
                        else
                        {
                            modOrder.C_CUST_NAME = txtCustName.Text;//客户信息

                            Bll_TS_CUSTFILE ts_custfile = new Bll_TS_CUSTFILE();
                            string where = $@" C_NAME='{txtCustName.Text}'";
                            DataTable dt = ts_custfile.GetList(where).Tables[0];
                            if (dt.Rows.Count > 0)
                            {
                                modOrder.C_CUST_NO = dt.Rows[0]["C_NO"].ToString();//客户编码
                            }
                        }
                        modOrder.C_REMARK4 = txtRemark.Text;  //备注
                        modOrder.C_PCTBEMP = ltlempname.Text; //提报人


                        orderList.Add(modOrder);

                        string[] arr_log = { "提报订单", "预测订单页面", ltlempid.Text, GetClientIP(), "", orderNo };
                        list_log.Add(arr_log);
                        #endregion
                    }
                }
                if (result)
                {
                    if (tmo_con.InsertNeedOrder(orderList))
                    {
                        //日志
                        tmo_order.InsertOrderPlanLog(list_log);

                        ScriptManager.RegisterStartupScript(UpdatePanel1, this.Page.GetType(), "", "_closemsg('保存成功');", true);

                        rptList_Add.DataSource = null;
                        rptList_Add.DataBind();

                        SetData();
                    }
                }
            }
            catch (Exception ex)
            {
                WebMsg.MessageBox(ex.Message);
            }
        }