public void print(string label, string goodsName, int Qty, string userId)
        {
            InsertData(label, goodsName, Qty, 3, userId);
            SelectCommandBuilder s = new SelectCommandBuilder();
            int    count           = Convert.ToInt32(s.ExecuteScalar("select count(*) from Material_control_process where label = '" + label + "' and process_id = 3"));
            string sql             = string.Empty;

            if (count != 0)
            {
                sql = "update Material_control_process set OutQty = InQty + " + Qty + " ,CurrQty = CurrQty + " + Qty + " where label = '" + label + "' and process_id = 3 ";
            }
            else
            {
                InsertCommandBuilder ins = new InsertCommandBuilder("Material_control_process");
                ins.InsertColumn("label", label);
                ins.InsertColumn("goods_name", goodsName);
                ins.InsertColumn("process_id", 3);
                ins.InsertColumn("InQty", Qty);
                ins.InsertColumn("OutQty", 0);
                ins.InsertColumn("CurrQty", Qty);
                ins.InsertColumn("in_date", "getDate()");
                sql = ins.getInsertCommand();
            }
            string        sql1 = "update Material_control_process set OutQty = OutQty + " + Qty + " ,CurrQty = CurrQty - " + Qty + " where label = '" + label + "' and process_id = 1 ";
            List <string> list = new List <string>();

            list.Add(sql);
            list.Add(sql1);
            new InsertCommandBuilder().ExcutTransaction(list);
        }
        public void waitStorge(string label, string goodsName, int Qty, string userId)
        {
            InsertData(label, goodsName, Qty, 1, userId);
            SelectCommandBuilder s = new SelectCommandBuilder();
            int    count           = Convert.ToInt32(s.ExecuteScalar("select count(*) from Material_control_process where label = '" + label + "' and process_id = 1"));
            string sql             = string.Empty;

            if (count != 0)
            {
                UpdateCommandBuilder up = new UpdateCommandBuilder();
                sql = "update Material_control_process set InQty = InQty + " + Qty + " ,CurrQty = CurrQty + " + Qty + " where label = '" + label + "' and process_id = 1";
            }
            else
            {
                InsertCommandBuilder ins = new InsertCommandBuilder("Material_control_process");
                ins.InsertColumn("label", label);
                ins.InsertColumn("goods_name", goodsName);
                ins.InsertColumn("process_id", 1);
                ins.InsertColumn("InQty", Qty);
                ins.InsertColumn("OutQty", 0);
                ins.InsertColumn("CurrQty", Qty);
                ins.InsertColumn("in_date", "getDate()");
                sql = ins.getInsertCommand();
            }
            new InsertCommandBuilder().ExecuteNonQuery(sql);
        }
Esempio n. 3
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string msg = inputValidate();

            if (msg != "")
            {
                Response.Write("<script>alert('" + msg + "')</script>");
                return;
            }
            SelectCommandBuilder select = new SelectCommandBuilder(constr, "goods_tmp");

            select.SelectColumn("Count(*)");
            select.ConditionsColumn("goods_name", goods_name.Value.Trim().ToUpper());
            select.getSelectCommand();
            int count = Convert.ToInt32(select.ExecuteScalar());

            if (count == 0)
            {
                Response.Write("<script>alert('部番不存在')</script>");
                return;
            }
            inputData indata = new inputData()
            {
                goods_name = goods_name.Value.Trim().ToUpper(),
                Qty        = int.Parse(qty.Value.Trim()),
                unit       = "pcs",
                goodsPost  = hwh.Value.Trim().ToUpper(),
                batch      = pch.Value.Trim().ToUpper()
            };

            insList.Add(indata);
            gvData.DataSource = insList;
            gvData.DataBind();
            clearText();
        }
Esempio n. 4
0
        protected List <string> getSQLList(GridView dgv)
        {
            int           index = 0;
            List <string> sList = new List <string>();

            try
            {
                InsertCommandBuilder insert = new InsertCommandBuilder(constr, "Goods_Up");
                for (int i = 0; i < dgv.Rows.Count; i++)
                {
                    string goods_name = dgv.Rows[i].Cells[0].Text.ToString().ToUpper();
                    index = i;
                    SelectCommandBuilder s = new SelectCommandBuilder(constr, "goods_tmp");
                    s.SelectColumn("Count(goods_id)");
                    s.ConditionsColumn("goods_name", goods_name.Trim());
                    s.getSelectCommand();
                    int count = Convert.ToInt32(s.ExecuteScalar());
                    if (count == 0)
                    {
                        sList.Add(InsertData(
                                      dgv.Rows[i].Cells[0].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[1].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[2].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[3].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[4].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[5].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[6].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[7].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[8].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[9].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[10].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[11].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[12].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[13].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[14].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[15].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[16].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[17].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[18].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[19].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[20].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[21].Text.ToString().ToUpper().IndexOf('%') != -1 ? (Convert.ToDecimal(dgv.Rows[i].Cells[21].Text.ToString().ToUpper().Split('%')[0]) / 100).ToString() : (Convert.ToDecimal(dgv.Rows[i].Cells[21].Text.ToString().ToUpper()) / 100).ToString(),
                                      dgv.Rows[i].Cells[22].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[23].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[24].Text.ToString().ToUpper(),
                                      dgv.Rows[i].Cells[25].Text.ToString().ToUpper(),
                                      ddlCustomer.SelectedItem.Value
                                      ));
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('系统出现以下错误:" + ex.Message + "!')</script>");
                gvExcel.Rows[index].BackColor = System.Drawing.Color.Red;
            }
            return(sList);
        }
        public bool getUser(string UserId)
        {
            SelectCommandBuilder select = new SelectCommandBuilder(ConnectionFactory.ConnectionString_hudsonwwwroot, "HUDSON_User");

            select.SelectColumn("Count(*)");
            select.ConditionsColumn("UserId", UserId);
            select.getSelectCommand();
            bool flag = Convert.ToInt32(select.ExecuteScalar()) != 0 ? true : false;

            return(flag);
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string produceArea = Request.QueryString["Area"];
            string tableSign   = Request.QueryString["tableSign"];

            if (produceArea == null || tableSign == null)
            {
                Response.Redirect("query.aspx");
            }
            string inputArea1 = "inputArea = 2";
            string inputArea2 = " inputArea = 1";
            string Area       = produceArea == "品检不良品" ? inputArea1 : inputArea2;
            string sqlMoney   = string.Format(@"select sum(moneySum)  from shatter_Parts
                                where tableSign= " + tableSign
                                              + " and ({0}) and (topManagerConfirm is not null or managerConfirm is not null)", Area);
            string sql = string.Format(@"select goodsName as 部番,cz as 材料编号,spec as 材料材质,ys as 材料色番,
                                count as 不良数量,price as 单价, moneySum as 金额,produceArea as 不良发生区,
                                badContent as 不良内容,ISNULL( CONVERT(nvarchar(10),  produceTime,126),'') as 生产日期,employeeName as 作业员,
                                ISNULL( CONVERT(nvarchar(10),  inputTime,126),'') as 录入时间                                                               
                                from shatter_Parts 
left join goods on goods.goods_name = shatter_Parts.goodsName
                                where tableSign= " + tableSign
                                       + " and ({0}) and (topManagerConfirm is not null or managerConfirm is not null)", Area);
            string sqlCEOconfirm = string.Format(@"select goodsName from shatter_Parts where topManagerConfirm is not null and ({0})", Area);

            string goodsName = Convert.ToString(new SelectCommandBuilder().ExecuteScalar(sqlCEOconfirm));

            if (goodsName != "")
            {
                LabelAdmin.Text = "承认人:总经理";
            }
            else
            {
                LabelAdmin.Text = "承认人:经理";
            }
            var comm     = new SelectCommandBuilder();
            var moneySum = comm.ExecuteScalar(sqlMoney);

            LabelTime.Text = DateTime.Now.ToString("yyyy-MM-dd");

            //double moneySum = moneySum = Convert.ToDouble();
            Debug.Write(sqlMoney);
            Debug.Write(sql);
            LabelMoney.Text = string.Format("总金额:{0}", DBNull.Value.Equals(moneySum) ? 0 : Convert.ToDouble(moneySum));
            DataTable dt = comm.ExecuteDataTable(sql);

            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
Esempio n. 7
0
        public bool checkIsUpload(string goods_name, string prapareId)
        {
            bool flag = false;
            SelectCommandBuilder s = new SelectCommandBuilder("Goods_Up");

            s.SelectColumn("count(goods_name)");
            s.ConditionsColumn("Prepare_goods_Id", prapareId);
            s.ConditionsColumn("goods_name", goods_name);
            s.getSelectCommand();
            int count = Convert.ToInt32(s.ExecuteScalar());

            if (count != 0)
            {
                flag = true;
            }
            return(flag);
        }
Esempio n. 8
0
        protected void getRoot(string inputArea)
        {
            //金额
            string sqlmoney1 = string.Format(sqlmoney, inputArea);

            Debug.WriteLine(sqlmoney1);
            double moneySum = 0;

            if (!(DBNull.Value.Equals(cmd.ExecuteScalar(sqlmoney1))))
            {
                moneySum = Convert.ToDouble(cmd.ExecuteScalar(sqlmoney1));
            }
            //根据金额判断两个承认按钮的状态
            if (moneySum > 500)
            {
                Button4.Enabled = true;
                string sql       = @"select goodsName from shatter_Parts where
                           (purchaseConfirm is  null or
                            PMCConfirm is  null or
                            directorConfirm is  null or
                            managerConfirm is null )
                            and  " + inputArea + "";
                string goodsName = Convert.ToString(cmd.ExecuteScalar(sql));
                if (goodsName == "")
                {
                    Button5.Enabled = true;
                }
            }
            else
            {
                string sql       = @"select goodsName from shatter_Parts where
                           (purchaseConfirm is  null or
                            PMCConfirm is  null or
                            directorConfirm is  null)
                            and " + inputArea + "";
                string goodsName = Convert.ToString(cmd.ExecuteScalar(sql));
                if (goodsName == "")
                {
                    Button4.Enabled = true;
                }
            }
        }
Esempio n. 9
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(txtgoodsName.Text.Trim()))
         {
             Response.Write("<script>alert('请输入部番!')</script>");
             return;
         }
         SelectCommandBuilder s = new SelectCommandBuilder(constr, "goods_tmp");
         s.SelectColumn("Count(goods_name)");
         s.ConditionsColumn("goods_name", txtgoodsName.Text.Trim());
         if (txtVersion.Text != string.Empty)
         {
             s.ConditionsColumn("Version", txtVersion.Text.Trim());
         }
         s.getSelectCommand();
         int i     = Convert.ToInt32(s.ExecuteScalar());
         int count = 0;
         if (i == 0)
         {
             count = InsertData();
         }
         else
         {
             count = UpdateData();
         }
         if (count != 0)
         {
             ClearTextBox();
             btnAdd.Enabled = false;
         }
         else
         {
             Response.Write("<script>alert('添加失败!')</script>");
         }
     }
     catch (Exception ex)
     {
         Response.Write("<script>alert('" + ex.Message + "!')</script>");
     }
 }
Esempio n. 10
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                lblResult.ForeColor = Color.White;
                if (string.IsNullOrEmpty(txtUserName.Text))
                {
                    lblResult.Text      = "请输入账号";
                    lblResult.ForeColor = Color.Red;
                    //Response.Write("<script>alert('账号不存在')</script>");
                    txtUserName.Focus();
                    txtUserName.Attributes.Add("onfocus", "this.select();");
                    txtPassWords.Attributes.Add("onfocus", "this.select();");
                    return;
                }
                if (string.IsNullOrEmpty(txtPassWords.Text))
                {
                    lblResult.Text      = "请输入密码";
                    lblResult.ForeColor = Color.Red;
                    //Response.Write("<script>alert('账号不存在')</script>");
                    txtPassWords.Focus();
                    return;
                }
                SelectCommandBuilder s = new SelectCommandBuilder(ConnectionFactory.ConnectionString_hudsonwwwroot, "HUDSON_User");
                string sqluser         = "******" + txtUserName.Text.Trim() + "'";
                Debug.WriteLine(sqluser);
                int count = Convert.ToInt32(s.ExecuteScalar(sqluser));
                if (count == 0)
                {
                    lblResult.Text      = "输入的账号不存在";
                    lblResult.ForeColor = Color.Red;
                    //Response.Write("<script>alert('账号不存在')</script>");
                    txtUserName.Focus();
                    txtUserName.Attributes.Add("onfocus", "this.select();");
                    txtPassWords.Attributes.Add("onfocus", "this.select();");
                    return;
                }
                string sqlpwd = @"select count(UserID) from HUDSON_User where UserPassWord = '******' and UserID = '" + txtUserName.Text + "'";
                int countc = Convert.ToInt32(s.ExecuteScalar(sqlpwd));
                if (countc == 0)
                {
                    lblResult.Text      = "密码错误,请重试...";
                    lblResult.ForeColor = Color.Red;
                    //Response.Write("<script>alert('密码错误')</script>");
                    txtPassWords.Focus();
                    return;
                }


                //Hashtable h = (Hashtable)Application["online"];
                //string oldsessionid = null;
                //if (h != null)
                //{
                //    IDictionaryEnumerator e1 = h.GetEnumerator();
                //    bool flag = false;
                //    while (e1.MoveNext())
                //    {

                //        //判断当前登录用户时候存在于application对象中
                //        if (((string)((ArrayList)e1.Value)[0]).Equals(txtUserName.Text))
                //        {
                //            flag = true;
                //            oldsessionid = e1.Key.ToString();
                //            break;
                //        }
                //    }
                //    if (flag)
                //    {

                //        //获取用户成功登录时间到目前现在时间差
                //        TimeSpan ts = System.DateTime.Now.Subtract(Convert.ToDateTime(((ArrayList)e1.Value)[1]));
                //        if (ts.TotalSeconds < 30)
                //        {
                //            //ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "<script> alert('对不起,你输入的账户正在被使用中,如果你是这个账户的真正主人,请在下次登陆时及时的更改你的密码,因为你的密码极有可能被盗窃了!');</script>");
                //            HttpSessionState sessionstate = (HttpSessionState)((ArrayList)e1.Value)[2];
                //            //sessionstate.Clear();
                //            sessionstate.Abandon();
                //            lblResult.Text = "该账号已登录...";
                //            lblResult.ForeColor = Color.Red;
                //            //Response.Write("<script>alert('密码错误')</script>");
                //            txtPassWords.Focus();
                //        }
                //        h.Remove(e1.Key);
                //        return;
                //    }

                //}
                //else
                //{
                //    h = new Hashtable();
                //}
                //ArrayList al = new ArrayList();
                //al.Add(txtUserName.Text);    //当前登录的用户名
                //al.Add(System.DateTime.Now);//登录的时间
                //al.Add(HttpContext.Current.Session);//当前会话
                //h[Session.SessionID] = al;
                //Application["online"] = h;//将当前登录用户信息存入application中
                ////Response.Redirect("~/LoginSuccess.aspx");
                HttpCookie cook = new HttpCookie("cookie");
                cook.Values.Add("id", txtUserName.Text.Trim());
                cook.Values.Add("pwd", txtPassWords.Text.Trim());
                cook.Values.Add("langue", DropDownList1.SelectedItem.Value.Trim().ToLower());
                cook.Values.Add("name", Convert.ToString(s.ExecuteScalar("select UserName from HUDSON_User where userID='" + txtUserName.Text.Trim() + "'")));
                HttpContext.Current.Response.Cookies.Add(cook);
                Session["UserName"] = txtUserName.Text;
                //if (ViewState["UrlReferrer"] == null)
                if (HiddenField1.Value == "")
                {
                }
                else
                {
                    Response.Redirect(HiddenField1.Value);
                }
                Response.Redirect("index.aspx");// 默认
                //else
                //    Response.Redirect(ViewState["UrlReferrer"].ToString());
            }
            catch (Exception ex)
            {
                lblResult.Text      = ex.Message;
                lblResult.ForeColor = Color.Red;
                throw;
            }
        }
Esempio n. 11
0
        protected void btnRun_Click(object sender, EventArgs e)
        {
            btnRun.Attributes["onclick"] = this.GetPostBackEventReference(this.btnRun) + ";this.disabled=true;this.value='处理中...'";
            string id = CommadMethod.getNextId("GID" + DateTime.Now.ToString("yyyyMMdd"), "");

            txtMNo.BackColor = Color.White;
            SelectCommandBuilder s = new SelectCommandBuilder(constr, "");
            string sql             = "select count(*) from goods_tran where goods_no=(select DISTINCT  goods_name from goods_tmp where goods_id = '" + ViewState["id"].ToString() + "')";
            string sql1            = "select count(*) from goods_tmp where goods_name = '" + txtgoodsName.Text.Trim().ToUpper() + "' and version = '" + txtVersion.Text.Trim().ToUpper().ToUpper() + "'";
            string sql2            = "select count(*) from materials where name = '" + txtMNo.Text.Trim().ToUpper() + "'";
            string sql3            = "select count(*) from goods_chage_record where goods_name='" + txtgoodsName.Text.Trim().ToUpper() + "' and version = '" + txtVersion.Text.Trim().ToUpper().ToUpper() + "'";
            int    count           = Convert.ToInt32(s.ExecuteScalar(sql));
            int    count1          = Convert.ToInt32(s.ExecuteScalar(sql1));
            int    count2          = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar(sql2));
            int    count3          = Convert.ToInt32(s.ExecuteScalar(sql3));
            int    i = 0;

            if (count2 == 0)
            {
                Response.Write("<script>alert('材料编号不存在,请确认后再试!')</script>");
                txtMNo.BackColor = Color.Red;
                txtMNo.Focus();
                return;
            }
            if (count3 != 0)
            {
                Response.Write("<script>alert('该部品已经被发行!')</script>");
                return;
            }
            if (count1 == 0)
            {
                InsertData("goods_tmp", id);
                hifId.Value = id;
            }
            if (count != 0)
            {
                //UpdateData("goods_tran");
                new DeleteCommandBuilder(constr, "").ExecuteNonQuery("delete from goods_tran where goods_no = '" + txtgoodsName.Text.Trim().ToUpper() + "'");
                InsertData("goods_tran", hifId.Value.Trim());
            }
            else
            {
                InsertData("goods_tran", hifId.Value.Trim());
            }
            UpdateCommandBuilder u = new UpdateCommandBuilder(constr, "goods_tran");

            u.UpdateColumn("isConfirm", "Waiting");
            u.ConditionsColumn("goods_no", txtgoodsName.Text.Trim().ToUpper());
            u.getUpdateCommand();
            i = Convert.ToInt32(u.ExecuteNonQuery());
            if (i != 0)
            {
                InsertData("goods_chage_record", hifId.Value.Trim());
                new UpdateCommandBuilder(constr, "").ExecuteNonQuery("update goods_tmp set lb8_id = '1'");
                Response.Write("<script>alert('发行成功')</script>");
                dgvList.DataSource = getConfirmGoodsList(ViewState["id"].ToString());
                dgvList.DataBind();
                string _body = "部番:" + txtgoodsName.Text + " 版本:" + txtVersion.Text.Trim() + " 已发行成功," + "<a href='http://192.168.1.199:81/GoodsManager/Goods_Aprove.aspx'>点击此链接快速审核...</a>";
                SendMail.ExecuteSendMail(smtpIp, Port, fromUser, fromPwd, mailList, ccList, "部品发行成功通知", _body, "", "");
            }
            else
            {
                Response.Write("<script>alert('发行失败')</script>");
            }
        }
Esempio n. 12
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            List <goods>  List    = new List <goods>();
            List <string> sqlList = new List <string>();
            string        constr  = "";

            if (ddldept.SelectedItem.Value == "0")
            {
                constr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            }
            else
            {
                constr = ConfigurationManager.ConnectionStrings["ConXG_ZhuSu"].ConnectionString;
            }
            if (dgvList.Rows.Count != 0)
            {
                for (int i = 0; i < dgvList.Rows.Count; i++)
                {
                    if ((dgvList.Rows[i].Cells[0].FindControl("cboCheckItem") as CheckBox).Checked == true)
                    {
                        goods g = new goods()
                        {
                            goodsId         = (dgvList.Rows[i].Cells[0].FindControl("HfId") as HiddenField).Value,
                            goods_name      = (dgvList.Rows[i].Cells[2].FindControl("Label0") as Label).Text,
                            mjh             = (dgvList.Rows[i].Cells[3].FindControl("Label1") as Label).Text,
                            goods_ename     = (dgvList.Rows[i].Cells[4].FindControl("Label2") as Label).Text,
                            Aircraft        = (dgvList.Rows[i].Cells[5].FindControl("Label3") as Label).Text,
                            Materail_Number = (dgvList.Rows[i].Cells[6].FindControl("Label4") as Label).Text,
                            Materail_Name   = (dgvList.Rows[i].Cells[7].FindControl("Label5") as Label).Text,
                            Materail_Model  = (dgvList.Rows[i].Cells[8].FindControl("Label6") as Label).Text,
                            ys = (dgvList.Rows[i].Cells[9].FindControl("Label7") as Label).Text,
                            Materail_Vender_Color = (dgvList.Rows[i].Cells[10].FindControl("Label8") as Label).Text,
                            Materail_Color        = (dgvList.Rows[i].Cells[11].FindControl("Label9") as Label).Text,
                            cpdz = (dgvList.Rows[i].Cells[12].FindControl("Label10") as Label).Text,
                            skdz = (dgvList.Rows[i].Cells[13].FindControl("Label11") as Label).Text,
                            Drying_Temperature   = (dgvList.Rows[i].Cells[14].FindControl("Label12") as Label).Text,
                            Drying_Time          = (dgvList.Rows[i].Cells[15].FindControl("Label13") as Label).Text,
                            sk_scale             = (dgvList.Rows[i].Cells[16].FindControl("Label14") as Label).Text,
                            Fire_Retardant_Grade = (dgvList.Rows[i].Cells[17].FindControl("Label15") as Label).Text,
                            Buyer              = (dgvList.Rows[i].Cells[18].FindControl("Label16") as Label).Text,
                            cxzq               = (dgvList.Rows[i].Cells[19].FindControl("Label17") as Label).Text,
                            Toner_Model        = (dgvList.Rows[i].Cells[20].FindControl("Label18") as Label).Text,
                            Toner_Buyer        = (dgvList.Rows[i].Cells[21].FindControl("Label19") as Label).Text,
                            qs                 = (dgvList.Rows[i].Cells[22].FindControl("Label20") as Label).Text,
                            dw                 = (dgvList.Rows[i].Cells[23].FindControl("Label21") as Label).Text,
                            khdm               = (dgvList.Rows[i].Cells[24].FindControl("Label22") as Label).Text,
                            Rohs_Certification = (dgvList.Rows[i].Cells[25].FindControl("Label23") as Label).Text,
                            Model_Abrasives    = (dgvList.Rows[i].Cells[26].FindControl("Label24") as Label).Text,
                            remark             = (dgvList.Rows[i].Cells[27].FindControl("Label25") as Label).Text
                        };
                        List.Add(g);
                    }
                }
            }
            if (List.Count == 0)
            {
                Response.Write("<script>alert('没有选择任何行')</script>");
                return;
            }
            SelectCommandBuilder s = new SelectCommandBuilder(constr, "");
            string sql             = "SELECT MAX(goods_id) FROM goods";
            long   id        = Convert.ToInt64(s.ExecuteScalar(sql).ToString().Trim());
            string maxId     = new SelectCommandBuilder(constr, "").ExecuteScalar("SELECT MAX(goods_ration_id) FROM goods_ration").ToString();
            int    rationSId = int.Parse(CommadMethod.getNextId("", ""));

            for (int i = 0; i < List.Count; i++)
            {
                if (sList.Count == 0)
                {
                    id += 1;
                    InsertCommandBuilder ins = new InsertCommandBuilder(constr, "goods");
                    ins.InsertColumn("goods_id", id.ToString());
                    ins.InsertColumn("goods_name", List[i].goods_name);
                    ins.InsertColumn("goods_ename", List[i].goods_ename);
                    ins.InsertColumn("mjh", List[i].mjh);
                    ins.InsertColumn("dw", List[i].dw);
                    ins.InsertColumn("qs", List[i].qs);
                    ins.InsertColumn("Materail_Number", List[i].Materail_Number);
                    ins.InsertColumn("Materail_Name", List[i].Materail_Name);
                    ins.InsertColumn("ys", List[i].ys);
                    ins.InsertColumn("Materail_Model", List[i].Materail_Model);
                    ins.InsertColumn("Materail_Vender_Color", List[i].Materail_Vender_Color);
                    ins.InsertColumn("Materail_Color", List[i].Materail_Color);
                    ins.InsertColumn("cpdz", List[i].cpdz);
                    ins.InsertColumn("skdz", List[i].skdz);
                    ins.InsertColumn("Drying_Temperature", List[i].Drying_Temperature);
                    ins.InsertColumn("Drying_Time", List[i].Drying_Time);
                    string sk = List[i].sk_scale.Trim().IndexOf('%') != -1 ? (Convert.ToDecimal(List[i].sk_scale.Trim().Split('%')[0]) / 100).ToString() : (Convert.ToDecimal(List[i].sk_scale.Trim()) / 100).ToString();
                    ins.InsertColumn("sk_scale", sk);
                    ins.InsertColumn("cxzq", List[i].cxzq);
                    ins.InsertColumn("khdm", List[i].khdm);
                    ins.InsertColumn("remark", List[i].remark);
                    ins.InsertColumn("Fire_Retardant_Grade", List[i].Fire_Retardant_Grade);
                    ins.InsertColumn("Buyer", List[i].Buyer);
                    ins.InsertColumn("Toner_Model", List[i].Toner_Model);
                    ins.InsertColumn("Toner_Buyer", List[i].Toner_Buyer);
                    ins.InsertColumn("Aircraft", List[i].Aircraft);
                    ins.InsertColumn("Rohs_Certification", List[i].Rohs_Certification);
                    decimal        qty   = (Convert.ToDecimal(List[i].cpdz) + (Convert.ToDecimal(List[i].skdz) / Convert.ToDecimal(List[i].qs))) * (1 - Convert.ToDecimal(sk));
                    decimal        skqty = (Convert.ToDecimal(List[i].cpdz) + (Convert.ToDecimal(List[i].skdz) / Convert.ToDecimal(List[i].qs))) * Convert.ToDecimal(sk);
                    List <decimal> dlist = new List <decimal>();
                    dlist.Add(qty);
                    dlist.Add(skqty);
                    for (int k = 0; k < dlist.Count; k++)
                    {
                        InsertCommandBuilder inss = new InsertCommandBuilder(constr, "goods_ration");
                        inss.InsertColumn("goods_ration_id", "AG" + rationSId.ToString().PadLeft(8, '0') + "0101");
                        inss.InsertColumn("goods_id", id);
                        inss.InsertColumn("item_Data", "");
                        inss.InsertColumn("item_type", "01");
                        inss.InsertColumn("qty", dlist[k].ToString("0.00#"));
                        inss.InsertColumn("price", "0");
                        inss.InsertColumn("remark", "");
                        inss.InsertColumn("operator_date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        sqlList.Add(inss.getInsertCommand());
                    }
                    CommadMethod.getNextId("", "", dlist.Count);
                    sqlList.Add(ins.getInsertCommand());
                }
                else
                {
                    for (int j = 0; j < sList.Count; j++)
                    {
                        string name = List[i].goods_name.Trim() + sList[j];
                        id += 1;
                        InsertCommandBuilder ins = new InsertCommandBuilder(constr, "goods");
                        ins.InsertColumn("goods_id", id.ToString());
                        ins.InsertColumn("goods_name", name);
                        ins.InsertColumn("goods_ename", List[i].goods_ename);
                        ins.InsertColumn("mjh", List[i].mjh);
                        ins.InsertColumn("dw", List[i].dw);
                        ins.InsertColumn("qs", List[i].qs);
                        ins.InsertColumn("Materail_Number", List[i].Materail_Number);
                        ins.InsertColumn("Materail_Name", List[i].Materail_Name);
                        ins.InsertColumn("ys", List[i].ys);
                        ins.InsertColumn("Materail_Model", List[i].Materail_Model);
                        ins.InsertColumn("Materail_Vender_Color", List[i].Materail_Vender_Color);
                        ins.InsertColumn("Materail_Color", List[i].Materail_Color);
                        ins.InsertColumn("cpdz", List[i].cpdz);
                        ins.InsertColumn("skdz", List[i].skdz);
                        ins.InsertColumn("Drying_Temperature", List[i].Drying_Temperature);
                        ins.InsertColumn("Drying_Time", List[i].Drying_Time);
                        string sk = List[i].sk_scale.Trim().IndexOf('%') != -1 ? (Convert.ToDecimal(List[i].sk_scale.Trim().Split('%')[0]) / 100).ToString() : (Convert.ToDecimal(List[i].sk_scale.Trim()) / 100).ToString();
                        ins.InsertColumn("sk_scale", sk);
                        ins.InsertColumn("cxzq", List[i].cxzq);
                        ins.InsertColumn("khdm", List[i].khdm);
                        ins.InsertColumn("remark", List[i].remark);
                        ins.InsertColumn("Fire_Retardant_Grade", List[i].Fire_Retardant_Grade);
                        ins.InsertColumn("Buyer", List[i].Buyer);
                        ins.InsertColumn("Toner_Model", List[i].Toner_Model);
                        ins.InsertColumn("Toner_Buyer", List[i].Toner_Buyer);
                        ins.InsertColumn("Aircraft", List[i].Aircraft);
                        ins.InsertColumn("Rohs_Certification", List[i].Rohs_Certification);
                        decimal        qty   = (Convert.ToDecimal(List[i].cpdz) + (Convert.ToDecimal(List[i].skdz) / Convert.ToDecimal(List[i].qs))) * (1 - Convert.ToDecimal(sk));
                        decimal        skqty = (Convert.ToDecimal(List[i].cpdz) + (Convert.ToDecimal(List[i].skdz) / Convert.ToDecimal(List[i].qs))) * Convert.ToDecimal(sk);
                        List <decimal> dlist = new List <decimal>();
                        dlist.Add(qty);
                        dlist.Add(skqty);
                        for (int k = 0; k < dlist.Count; k++)
                        {
                            rationSId = int.Parse(CommadMethod.getNextId("", ""));
                            InsertCommandBuilder inss = new InsertCommandBuilder(constr, "goods_ration");
                            inss.InsertColumn("goods_ration_id", "AG" + rationSId.ToString().PadLeft(8, '0') + "0101");
                            inss.InsertColumn("goods_id", id);
                            inss.InsertColumn("item_Data", "");
                            inss.InsertColumn("item_type", "01");
                            inss.InsertColumn("qty", dlist[k].ToString("0.00#"));
                            inss.InsertColumn("price", "0");
                            inss.InsertColumn("remark", "");
                            inss.InsertColumn("operator_date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                            sqlList.Add(inss.getInsertCommand());
                        }
                        //CommadMethod.getNextId("", "", dlist.Count);
                        sqlList.Add(ins.getInsertCommand());
                    }
                }
            }
            InsertCommandBuilder insert = new InsertCommandBuilder(constr, "");

            for (int i = 0; i < List.Count; i++)
            {
                new UpdateCommandBuilder(constr, "").ExecuteNonQuery("update goods_tran set isConfirm = 'Done' where goods_id = '" + List[i].goodsId + "'");
            }
            int count = insert.ExcutTransaction(sqlList);

            Response.Write("<script>alert('执行成功')</script>");
            btnSearch_Click(sender, e);
        }
        protected void sr_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtInput.Text))
                {
                    txtInput.Focus();
                    return;
                }
                switch (step)
                {
                case 0:
                    if (txtInput.Text.ToLower() != "begin")
                    {
                        sList.Insert(0, AppendDateTime("NG,指令错误"));
                        sList.Insert(0, AppendDateTime("开始指令???"));
                        alertMsg();
                        return;
                    }
                    step += 1;
                    sList.Insert(0, AppendDateTime("OK,工号???"));
                    alertMsg();
                    break;

                case 1:
                    if (!getUser(txtInput.Text.Trim().ToUpper()))
                    {
                        sList.Insert(0, AppendDateTime("NG,用户不存在"));
                        alertMsg();
                        return;
                    }
                    step += 1;
                    ViewState["UserId"] = txtInput.Text.Trim().ToUpper();
                    sList.Insert(0, AppendDateTime(ViewState["UserId"].ToString()));
                    sList.Insert(0, AppendDateTime("OK,请扫入区域???"));
                    alertMsg();
                    break;

                case 2:
                    if (txtInput.Text.ToLower() == "end")
                    {
                        sList.Insert(0, AppendDateTime("OK,结束指令,需要操作请重新刷读指令"));
                        alertMsg();
                        step = 0;
                        return;
                    }
                    area = txtInput.Text;
                    if (area.Length > 11)
                    {
                        area = area.Substring(area.Length - 6, 6);
                    }
                    else
                    {
                        area = area;
                    }
                    step += 1;
                    switch (area.ToLower())
                    {
                    case "waitstorge":
                        sList.Insert(0, AppendDateTime("待入库区"));
                        sList.Insert(0, AppendDateTime("OK,入库票???"));
                        alertMsg();
                        break;

                    case "storge":
                        hwh      = txtInput.Text.Trim().ToLower().Split(' ')[0];
                        store_id = txtInput.Text.Trim().ToLower().Split(' ')[1];
                        sList.Insert(0, AppendDateTime("仓库"));
                        sList.Insert(0, AppendDateTime("OK,请扫入库票"));
                        alertMsg();
                        step += 1;
                        break;

                    case "pickarea":
                        sList.Insert(0, AppendDateTime("选别区"));
                        sList.Insert(0, AppendDateTime("OK,请扫入库票???"));
                        alertMsg();
                        break;

                    case "print":
                        sList.Insert(0, AppendDateTime("丝印区"));
                        sList.Insert(0, AppendDateTime("OK,请扫入库票???"));
                        alertMsg();
                        break;

                    case "z_area":
                        sList.Insert(0, AppendDateTime("暂放区域"));
                        sList.Insert(0, AppendDateTime("OK,请扫入库票???"));
                        alertMsg();
                        break;

                    default:
                        sList.Insert(0, AppendDateTime("NG,区域错误"));
                        sList.Insert(0, AppendDateTime("请重新扫描区域???"));
                        alertMsg();
                        step = 2;
                        break;
                    }
                    break;

                case 3:
                    switch (area.ToLower())
                    {
                    case "waitstorge":
                        if (txtInput.Text.ToLower() == "end")
                        {
                            sList.Insert(0, AppendDateTime("OK,结束指令,需要操作请重新刷读指令"));
                            alertMsg();
                            step = 0;
                            return;
                        }
                        string[] List = getBarCode(txtInput.Text);
                        if (List.Length < 7)
                        {
                            sList.Insert(0, AppendDateTime("NG,条码格式错误!"));
                            sList.Insert(0, AppendDateTime("NG,重新入库票"));
                            step = 3;
                            alertMsg();
                            return;
                        }
                        goodsName = List[2];
                        Qty       = int.Parse(List[6]);
                        int wCount = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar("SELECT count(*) FROM Material_control WHERE (label = '" + List[0] + "' and process_id = '" + 1 + "')"));
                        if (wCount != 0)
                        {
                            sList.Insert(0, AppendDateTime("入库票重复"));
                            sList.Insert(0, AppendDateTime("NG,请重新入库票???"));
                            step = 3;
                            alertMsg();
                            return;
                        }
                        waitStorge(List[0], goodsName, Qty, ViewState["UserId"].ToString());
                        sList.Insert(0, AppendDateTime("部番:" + goodsName + "  数量:" + Qty));
                        sList.Insert(0, AppendDateTime("OK,请扫入区域"));
                        step = 2;
                        alertMsg();
                        break;

                    case "z_area":
                        if (txtInput.Text.ToLower() == "end")
                        {
                            sList.Insert(0, AppendDateTime("OK,结束指令,需要操作请重新刷读指令"));
                            alertMsg();
                            step = 0;
                            return;
                        }
                        string[] zList = getBarCode(txtInput.Text);
                        if (zList.Length < 7)
                        {
                            sList.Insert(0, AppendDateTime("NG,入库票格式错误!"));
                            sList.Insert(0, AppendDateTime("NG,重新刷入库票"));
                            return;
                        }
                        goodsName = zList[2];
                        Qty       = int.Parse(zList[6]);
                        int zCount = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar("select count(*) from material_control where label='" + zList[0] + "' and process_id= 5 "));
                        if (zCount != 0)
                        {
                            sList.Insert(0, AppendDateTime("入库票重复"));
                            sList.Insert(0, AppendDateTime("入库票重复"));
                            step = 3;
                            alertMsg();
                            return;
                        }
                        string    sqlz = "SELECT TOP 1 process_id FROM Material_control where label = '" + zList[0] + "' ORDER BY operate_time DESC";
                        DataTable dtz  = new SelectCommandBuilder().ExecuteDataTable(sqlz);
                        if (dtz == null || dtz.Rows.Count == 0)
                        {
                            sList.Insert(0, AppendDateTime("NG,未入待入库区,请确认扫描后再入库!"));
                            sList.Insert(0, AppendDateTime("NG,重新入库票"));
                            step = 3;
                            alertMsg();
                            return;
                        }
                        int    z_areaId = int.Parse(dtz.Rows[0][0].ToString());
                        string z_QtySql = "SELECT ISNULL(SUM(CurrQty), 0) AS CurrQty FROM Material_control_process WHERE (label = '" + zList[0] + "' and process_id = 1)";
                        int    z_Result = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar(z_QtySql));
                        if (z_Result < Qty)
                        {
                            sList.Insert(0, AppendDateTime("NG,数量超出待入库区数量,无法入库!"));
                            sList.Insert(0, AppendDateTime("NG,重新入库票"));
                            step = 4;
                        }
                        else
                        {
                            z_area(zList[0], goodsName, Qty, ViewState["UserId"].ToString());
                            sList.Insert(0, AppendDateTime("部番:" + goodsName + "  数量:" + Qty));
                            sList.Insert(0, AppendDateTime("OK,请扫入区域"));
                            step = 2;
                        }
                        alertMsg();
                        break;

                    case "pickarea":
                        if (txtInput.Text.ToLower() == "end")
                        {
                            sList.Insert(0, AppendDateTime("OK,结束指令,需要操作请重新刷读指令"));
                            alertMsg();
                            step = 0;
                            return;
                        }
                        string[] pList = getBarCode(txtInput.Text);
                        if (pList.Length < 7)
                        {
                            sList.Insert(0, AppendDateTime("NG,条码格式错误!"));
                            sList.Insert(0, AppendDateTime("NG,重新入库票"));
                            step = 3;
                            alertMsg();
                            return;
                        }
                        goodsName = pList[2];
                        Qty       = int.Parse(pList[6]);
                        int pCount = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar("SELECT count(*) FROM Material_control WHERE (label = '" + pList[0] + "' and process_id = '" + 2 + "')"));
                        if (pCount != 0)
                        {
                            sList.Insert(0, AppendDateTime("入库票重复"));
                            sList.Insert(0, AppendDateTime("NG,请重新入库票???"));
                            step = 3;
                            alertMsg();
                            return;
                        }
                        List <string> paList    = new List <string>();
                        string        sql1      = "select count(str_in_bill_id) from pre_str_in_bill where str_in_bill_no = '" + pList[0] + "'";
                        int           hasCount1 = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar(sql1));
                        if (hasCount1 != 0)
                        {
                            sList.Insert(0, AppendDateTime("NG,该入库票已入库???"));
                            sList.Insert(0, AppendDateTime("条码???"));
                            step = 5;
                            alertMsg();
                            return;
                        }
                        str_bill_id = CommadMethod.getNextId("Q");
                        InsertCommandBuilder insert = new InsertCommandBuilder("pre_str_in_bill");
                        insert.InsertColumn("str_in_bill_id", str_bill_id);
                        insert.InsertColumn("str_in_type_id", "C");
                        insert.InsertColumn("str_in_bill_no", pList[0]);
                        insert.InsertColumn("operator_date", "getdate()");
                        insert.InsertColumn("str_in_date", "getdate()");
                        insert.InsertColumn("store_id", "12");
                        insert.InsertColumn("create_user", ViewState["UserId"]);
                        insert.InsertColumn("operator_id", "0000");
                        insert.InsertColumn("dfdh", pList[1]);
                        insert.InsertColumn("come_from", "生产加工入库");
                        insert.InsertColumn("islocal", "Y");
                        insert.InsertColumn("verifier", "0024");
                        insert.InsertColumn("bill_num", "0");
                        insert.InsertColumn("paydate", "1900/1/1");
                        //insert.InsertColumn("is_state", "N");
                        paList.Add(insert.getInsertCommand());
                        //入库操作
                        InsertCommandBuilder ins1 = new InsertCommandBuilder("pre_str_in_bill_detail");
                        ins1.InsertColumn("batch_id", CommadMethod.getNextId("Q"));
                        ins1.InsertColumn("str_in_bill_id", str_bill_id);
                        ins1.InsertColumn("goods_id", new SelectCommandBuilder().ExecuteDataTable("select goods_id from goods where goods_name='" + goodsName + "'").Rows[0][0].ToString());
                        ins1.InsertColumn("qty", Qty);
                        ins1.InsertColumn("pch", pList[0].Substring(2, 6));
                        ins1.InsertColumn("hwh", "NG01");
                        ins1.InsertColumn("piece", "0");
                        ins1.InsertColumn("price", "0");
                        ins1.InsertColumn("inqty", Qty);
                        ins1.InsertColumn("exam", " ");
                        ins1.InsertColumn("yxq", "1900/1/1");
                        ins1.InsertColumn("producedate", "1900/1/1");
                        paList.Add(ins1.getInsertCommand());
                        string QtySql1 = "SELECT ISNULL(SUM(CurrQty), 0) AS CurrQty FROM Material_control_process WHERE (label = '" + pList[0] + "' and process_id = '1')";
                        int    Result1 = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar(QtySql1));
                        if (Result1 < Qty)
                        {
                            sList.Insert(0, AppendDateTime("NG,数量不足,无法入库3!"));
                            sList.Insert(0, AppendDateTime("NG,请注明手动处理,重扫区域???"));
                            step = 2;
                            alertMsg();
                            return;
                        }
                        else
                        {
                            PickArea(pList[0], goodsName, Qty, ViewState["UserId"].ToString());
                            ins1.ExcutTransaction(paList);
                            sList.Insert(0, AppendDateTime("部番:" + goodsName + "  数量:" + Qty));
                            sList.Insert(0, AppendDateTime("OK,请扫描区域???"));
                            step = 2;
                            alertMsg();
                            break;
                        }

                    case "print":
                        if (txtInput.Text.ToLower() == "end")
                        {
                            sList.Insert(0, AppendDateTime("OK,结束指令,需要操作请重新刷读指令"));
                            alertMsg();
                            step = 0;
                            return;
                        }
                        string[] prList = getBarCode(txtInput.Text);
                        if (prList.Length < 7)
                        {
                            sList.Insert(0, AppendDateTime("NG,条码格式错误!"));
                            sList.Insert(0, AppendDateTime("NG,重新入库票"));
                            step = 3;
                            alertMsg();
                            return;
                        }
                        goodsName = prList[2];
                        Qty       = int.Parse(prList[6]);
                        int prCount = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar("SELECT count(*) FROM Material_control WHERE (label = '" + prList[0] + "' and process_id = '" + 3 + "')"));
                        if (prCount != 0)
                        {
                            sList.Insert(0, AppendDateTime("入库票重复"));
                            sList.Insert(0, AppendDateTime("NG,请重新入库票???"));
                            step = 3;
                            alertMsg();
                            return;
                        }
                        string QtySql2 = "SELECT ISNULL(SUM(CurrQty), 0) AS CurrQty FROM Material_control_process WHERE (label = '" + prList[0] + "' and process_id = '" + 1 + "')";
                        int    Result2 = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar(QtySql2));
                        if (Result2 < Qty)
                        {
                            sList.Insert(0, AppendDateTime("NG,数量不足,无法入库1!"));
                            sList.Insert(0, AppendDateTime("NG,重新入库票???"));
                            step = 2;
                            alertMsg();
                            return;
                        }
                        else
                        {
                            print(prList[0], goodsName, Qty, ViewState["UserId"].ToString());
                            sList.Insert(0, AppendDateTime("部番:" + goodsName + "  数量:" + Qty));
                            sList.Insert(0, AppendDateTime("OK,请扫描区域???"));
                            List <string> printList = new List <string>();
                            str_bill_id = CommadMethod.getNextId("Q");
                            InsertCommandBuilder pInser = new InsertCommandBuilder("pre_str_in_bill");
                            pInser.InsertColumn("str_in_bill_id", str_bill_id);
                            pInser.InsertColumn("str_in_type_id", "C");
                            pInser.InsertColumn("str_in_bill_no", prList[0]);
                            pInser.InsertColumn("operator_date", "getdate()");
                            pInser.InsertColumn("str_in_date", "getdate()");
                            pInser.InsertColumn("store_id", "11");
                            pInser.InsertColumn("create_user", ViewState["UserId"]);
                            pInser.InsertColumn("operator_id", "0000");
                            pInser.InsertColumn("dfdh", prList[1]);
                            pInser.InsertColumn("come_from", "生产加工入库");
                            pInser.InsertColumn("islocal", "Y");
                            pInser.InsertColumn("verifier", "0024");
                            pInser.InsertColumn("bill_num", "0");
                            pInser.InsertColumn("paydate", "1900/1/1");
                            //insert.InsertColumn("is_state", "N");
                            printList.Add(pInser.getInsertCommand());
                            //入库操作
                            InsertCommandBuilder pIinserd = new InsertCommandBuilder("pre_str_in_bill_detail");
                            pIinserd.InsertColumn("batch_id", CommadMethod.getNextId("Q"));
                            pIinserd.InsertColumn("str_in_bill_id", str_bill_id);
                            pIinserd.InsertColumn("goods_id", new SelectCommandBuilder().ExecuteDataTable("select goods_id from goods where goods_name='" + goodsName + "'").Rows[0][0].ToString());
                            pIinserd.InsertColumn("qty", Qty);
                            pIinserd.InsertColumn("pch", prList[0].Substring(2, 6));
                            pIinserd.InsertColumn("hwh", "SY");
                            pIinserd.InsertColumn("piece", "0");
                            pIinserd.InsertColumn("price", "0");
                            pIinserd.InsertColumn("inqty", Qty);
                            pIinserd.InsertColumn("exam", " ");
                            pIinserd.InsertColumn("yxq", "1900/1/1");
                            pIinserd.InsertColumn("producedate", "1900/1/1");
                            printList.Add(pIinserd.getInsertCommand());
                            pIinserd.ExcutTransaction(printList);
                        }
                        step = 2;
                        alertMsg();
                        break;
                    }
                    break;

                case 4:
                    if (txtInput.Text.ToLower() == "end")
                    {
                        sList.Insert(0, AppendDateTime("OK,结束指令,需要操作请重新刷读指令"));
                        str_bill_id = string.Empty;
                        alertMsg();
                        step = 0;
                        return;
                    }
                    else if (txtInput.Text.ToLower() == "reenter")
                    {
                        sList.Insert(0, AppendDateTime("OK,货位号???"));
                        step = 3;
                        alertMsg();
                        return;
                    }

                    string[] aList = getBarCode(txtInput.Text);
                    if (aList.Length < 7)
                    {
                        sList.Insert(0, AppendDateTime("NG,条码格式错误!"));
                        sList.Insert(0, AppendDateTime("NG,重新入库票"));
                        step = 4;
                        alertMsg();
                        return;
                    }
                    goodsName = aList[2];
                    Qty       = int.Parse(aList[6]);
                    string        goods_id = new SelectCommandBuilder().ExecuteDataTable("select goods_id from goods where goods_name='" + goodsName + "'").Rows[0][0].ToString();
                    List <string> Alist    = new List <string>();
                    string        sql      = "select count(str_in_bill_id) from pre_str_in_bill where str_in_bill_no = '" + aList[0] + "'";
                    int           hasCount = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar(sql));
                    if (hasCount != 0)
                    {
                        sList.Insert(0, AppendDateTime("NG,该入库票已入库???"));
                        sList.Insert(0, AppendDateTime("条码???"));
                        step = 4;
                        alertMsg();
                        return;
                    }
                    string lbel1 = aList[0].Substring(0, 2).ToString();
                    if (lbel1 == "XB")
                    {
                        List <string>        olist           = new List <string>();
                        string               str_out_bill_id = CommadMethod.getNextId("Q");
                        string               dfdh            = CommadMethod.getNextId("Z");
                        InsertCommandBuilder insertout       = new InsertCommandBuilder("pre_str_out_bill");
                        insertout.InsertColumn("str_out_bill_id", str_out_bill_id);
                        insertout.InsertColumn("str_out_bill_no", aList[0]);
                        insertout.InsertColumn("dfdh", dfdh);
                        insertout.InsertColumn("str_out_type_id", "2");
                        insertout.InsertColumn("str_out_date", "getdate()");
                        insertout.InsertColumn("store_id", "12");
                        insertout.InsertColumn("operator_id", "0000");
                        insertout.InsertColumn("transactor", "曾松林");
                        insertout.InsertColumn("verifier", "曾松林");
                        insertout.InsertColumn("come_to", "成品");
                        insertout.InsertColumn("bill_num", "1");
                        insertout.InsertColumn("operator_date", "getdate()");
                        insertout.InsertColumn("islocal", "Y");
                        insertout.InsertColumn("gsptypeid", "2");
                        olist.Add(insertout.getInsertCommand());
                        string Dsql            = @"SELECT stock_remain.goods_id, stock_remain.qty, batch.batch_id,batch.hwh, stock_remain.store_id FROM 
                            stock_remain INNER JOIN batch ON stock_remain.batch_id = batch.batch_id 
                            WHERE (stock_remain.goods_id = '" + goods_id + "') AND (batch.hwh = 'NG01') and stock_remain.store_id='12' order by right(rtrim(batch.pch),6)";
                        SelectCommandBuilder s = new SelectCommandBuilder();
                        int count = Convert.ToInt32(s.ExecuteScalar(Dsql));
                        if (count == 0)
                        {
                            sList.Insert(0, "选别区数量不足");
                            sList.Insert(0, "NG,请扫描区域");
                            step = 2;
                            alertMsg();
                            return;
                        }
                        DataTable Dqty  = s.ExecuteDataTable(Dsql);
                        int       dbqty = 0;
                        int       xQty  = Qty;
                        for (int i = 0; i < Dqty.Rows.Count; i++)
                        {
                            dbqty = xQty - Convert.ToInt32(Dqty.Rows[i]["qty"]);
                            if (dbqty == 0)
                            {
                                InsertCommandBuilder insd = new InsertCommandBuilder("pre_str_out_bill_detail");
                                insd.InsertColumn("str_out_bill_id", str_out_bill_id);
                                insd.InsertColumn("goods_id", goods_id);
                                insd.InsertColumn("batch_id", Dqty.Rows[i]["batch_id"]);
                                insd.InsertColumn("qty", xQty);
                                insd.InsertColumn("exam", " ");
                                insd.InsertColumn("price", "0");
                                insd.InsertColumn("Can_sale", "Y");
                                insd.InsertColumn("DSort", "1");
                                insd.InsertColumn("CostPrice", "0");
                                insd.InsertColumn("hwh", hwh);
                                olist.Add(insd.getInsertCommand());
                                break;
                            }
                            else if (dbqty > 0)
                            {
                                InsertCommandBuilder insd = new InsertCommandBuilder("pre_str_out_bill_detail");
                                insd.InsertColumn("str_out_bill_id", str_out_bill_id);
                                insd.InsertColumn("goods_id", goods_id);
                                insd.InsertColumn("batch_id", Dqty.Rows[i]["batch_id"]);
                                insd.InsertColumn("qty", Dqty.Rows[i]["qty"]);
                                insd.InsertColumn("exam", " ");
                                insd.InsertColumn("price", "0");
                                insd.InsertColumn("Can_sale", "Y");
                                insd.InsertColumn("DSort", "1");
                                insd.InsertColumn("CostPrice", "0");
                                insd.InsertColumn("hwh", hwh);
                                xQty = dbqty;
                                olist.Add(insd.getInsertCommand());
                                continue;
                            }
                            else if (dbqty < 0)
                            {
                                InsertCommandBuilder insd = new InsertCommandBuilder("pre_str_out_bill_detail");
                                insd.InsertColumn("str_out_bill_id", str_out_bill_id);
                                insd.InsertColumn("goods_id", goods_id);
                                insd.InsertColumn("batch_id", Dqty.Rows[i]["batch_id"]);
                                insd.InsertColumn("qty", xQty);
                                insd.InsertColumn("exam", " ");
                                insd.InsertColumn("price", "0");
                                insd.InsertColumn("Can_sale", "Y");
                                insd.InsertColumn("DSort", "1");
                                insd.InsertColumn("CostPrice", "0");
                                insd.InsertColumn("hwh", hwh);
                                olist.Add(insd.getInsertCommand());
                                break;
                            }
                        }
                        new InsertCommandBuilder().ExcutTransaction(olist);
                        Storge(aList[0], goodsName, Qty, 2, ViewState["UserId"].ToString());    //1:待入库 2:选别
                        sList.Insert(0, AppendDateTime("部番:" + goodsName + "  数量:" + Qty));
                        sList.Insert(0, AppendDateTime("OK,请扫描区域"));
                        step = 2;
                        alertMsg();
                        return;
                    }
                    str_bill_id = CommadMethod.getNextId("Q");
                    InsertCommandBuilder insert3 = new InsertCommandBuilder("pre_str_in_bill");
                    insert3.InsertColumn("str_in_bill_id", str_bill_id);
                    insert3.InsertColumn("dfdh", aList[1]);
                    insert3.InsertColumn("str_in_type_id", "C");
                    insert3.InsertColumn("verifier", "0024");
                    insert3.InsertColumn("bill_num", "0");
                    insert3.InsertColumn("paydate", "1900/1/1");
                    insert3.InsertColumn("str_in_bill_no", aList[0]);
                    insert3.InsertColumn("operator_date", "getdate()");
                    insert3.InsertColumn("str_in_date", "getdate()");
                    insert3.InsertColumn("store_id", "03");    //store_id);//暂时固定为03
                    insert3.InsertColumn("create_user", ViewState["UserId"]);
                    insert3.InsertColumn("operator_id", "0000");
                    insert3.InsertColumn("come_from", "生产加工入库");
                    insert3.InsertColumn("islocal", "Y");
                    Alist.Add(insert3.getInsertCommand());
                    InsertCommandBuilder ins = new InsertCommandBuilder("pre_str_in_bill_detail");
                    ins.InsertColumn("batch_id", CommadMethod.getNextId("Q"));
                    ins.InsertColumn("str_in_bill_id", str_bill_id);
                    ins.InsertColumn("goods_id", new SelectCommandBuilder().ExecuteDataTable("select goods_id from goods where goods_name='" + goodsName + "'").Rows[0][0].ToString());
                    ins.InsertColumn("qty", Qty);
                    ins.InsertColumn("exam", " ");
                    ins.InsertColumn("yxq", "1900/1/1");
                    ins.InsertColumn("Producedate", "1900/1/1");
                    ins.InsertColumn("inqty", Qty);
                    ins.InsertColumn("notin", "1");
                    ins.InsertColumn("tax_rate", "17");
                    ins.InsertColumn("piece", "0");
                    ins.InsertColumn("price", "0");
                    ins.InsertColumn("hwh", hwh);
                    ins.InsertColumn("pch", aList[0].Substring(2, 6));
                    Alist.Add(ins.getInsertCommand());
                    string    sql2 = "SELECT TOP 1 process_id FROM Material_control where label = '" + aList[0] + "' ORDER BY operate_time DESC";
                    DataTable dt   = new SelectCommandBuilder().ExecuteDataTable(sql2);
                    if (dt == null || dt.Rows.Count == 0)
                    {
                        sList.Insert(0, AppendDateTime("NG,前端未扫描,请确认扫描后再入库!"));
                        sList.Insert(0, AppendDateTime("NG,重新入库票"));
                        step = 4;
                        alertMsg();
                        return;
                    }
                    int    areaId = int.Parse(dt.Rows[0][0].ToString());
                    string QtySql = "SELECT ISNULL(SUM(CurrQty), 0) AS CurrQty FROM Material_control_process WHERE (label = '" + aList[0] + "' and process_id = '" + areaId + "')";
                    int    Result = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar(QtySql));
                    if (Result < Qty)
                    {
                        sList.Insert(0, AppendDateTime("NG,数量不足,无法入库2!"));
                        sList.Insert(0, AppendDateTime("NG,重新入库票"));
                        step = 4;
                    }
                    else
                    {
                        Storge(aList[0], goodsName, Qty, areaId, ViewState["UserId"].ToString());    //1:待入库 2:选别
                        ins.ExcutTransaction(Alist);
                        sList.Insert(0, AppendDateTime("部番:" + goodsName + "  数量:" + Qty));
                        sList.Insert(0, AppendDateTime("OK,请扫描区域"));
                        step = 2;
                    }
                    alertMsg();
                    break;
                }
            }

            catch (Exception ex)
            {
                sList.Insert(0, AppendDateTime(ex.Message));
                sList.Insert(0, AppendDateTime("NG,出现错误,请重新刷读"));
                alertMsg();
            }
        }