private void DoMain(string[] aList)
        {
            List <string> Alist = new List <string>();

            str_bill_id = CommadMethod.getNextId("00000000", "");
            InsertCommandBuilder insert3 = new InsertCommandBuilder("pre_str_in_bill");

            insert3.InsertColumn("str_in_bill_id", str_bill_id);
            insert3.InsertColumn("str_in_type_id", "C");
            insert3.InsertColumn("str_in_bill_no", aList[0].Trim() + aList[2].Trim().Substring(2, 6) + Convert.ToInt32(aList[3].Trim()).ToString());
            insert3.InsertColumn("operator_date", "getdate()");
            insert3.InsertColumn("str_in_date", "getdate()");
            insert3.InsertColumn("store_id", "03");//store_id);//暂时固定为03
            insert3.InsertColumn("create_user", "0000");
            insert3.InsertColumn("operator_id", "0000");
            //insert3.InsertColumn("come_from", aList[1]);
            insert3.InsertColumn("islocal", "y");
            //insert.InsertColumn("is_state", "N");
            Alist.Add(insert3.getInsertCommand());
            InsertCommandBuilder ins = new InsertCommandBuilder("pre_str_in_bill_detail");

            ins.InsertColumn("batch_id", CommadMethod.getNextId("00000000", ""));
            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("hwh", hwh);
            ins.InsertColumn("pch", aList[2]);
            Alist.Add(ins.getInsertCommand());
            ins.ExcutTransaction(Alist);
            sList.Insert(0, AppendDateTime("部番:" + goodsName + "  数量:" + Qty));
            sList.Insert(0, AppendDateTime("OK,条码???"));
        }
        protected void dgvMaterailList_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string name         = (dgvMaterailList.Rows[e.RowIndex].FindControl("Label1") as Label).Text;
            double price        = Convert.ToDouble((dgvMaterailList.Rows[e.RowIndex].FindControl("txtPrice") as TextBox).Text);
            string currency     = (dgvMaterailList.Rows[e.RowIndex].FindControl("ddlcurrency") as DropDownList).SelectedItem.Text;
            double exchangeRate = getexchangeRate(currency);

            UpdateCommandBuilder u = new UpdateCommandBuilder("materials");

            u.UpdateColumn("new_price", price);
            u.UpdateColumn("wb_name", currency);
            u.ConditionsColumn("name", name);
            string mainSql = u.getUpdateCommand();

            InsertCommandBuilder insert = new InsertCommandBuilder("materials_newest_price");

            insert.InsertColumn("name", name);
            insert.InsertColumn("price", price);
            insert.InsertColumn("wb_name", currency);
            insert.InsertColumn("exchange_rate", exchangeRate);
            insert.InsertColumn("update_date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            string insertSql = insert.getInsertCommand();

            List <string> sList = new List <string>();

            sList.Add(mainSql);
            sList.Add(insertSql);
            int i = insert.ExcutTransaction(sList);

            if (i != 0)
            {
                dgvMaterailList.EditIndex = -1;
                if (string.IsNullOrEmpty(txtName.Value.Trim()) && ddlVendorList.SelectedItem.Value.Trim() == "0")
                {
                    dgvMaterailList.DataSource = getIndexPageData();
                }
                else
                {
                    dgvMaterailList.DataSource = getIndexPageData(txtName.Value.Trim(), ddlVendorList.SelectedItem.Value.Trim());
                }
                dgvMaterailList.DataBind();
            }
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (ViewState["name"].ToString() != txtgoodsName.Text.Trim())
         {
             Response.Write("<script>alert('添加记录请点击新增按钮!')</script>");
             return;
         }
         List <string> SqlList = new List <string>();
         string        Usql    = getUpdateDataSQL("goods_tmp", ViewState["id"].ToString());
         int           count   = 0;
         if (Rbt4M.Checked == true)
         {
             string Tsql = getUpdateDataSQL("goods_tran", hifId.Value);
             string Csql = getUpdateDataSQL("goods_chage_record", txtgoodsName.Text.Trim().ToUpper(), txtVersion.Text.Trim().ToUpper().ToUpper());
             SqlList.Add(Tsql);
             SqlList.Add(Csql);
         }
         SqlList.Add(Usql);
         InsertCommandBuilder up = new InsertCommandBuilder(constr, "");
         count = up.ExcutTransaction(SqlList);
         if (count != 0)
         {
             dgvList.DataSource = getConfirmGoodsList(ViewState["id"].ToString());
             dgvList.DataBind();
             Response.Write("<script>alert('保存成功!')</script>");
         }
         else
         {
             Response.Write("<script>alert('保存失败!')</script>");
         }
     }
     catch (Exception ex)
     {
         Response.Write("<script>alert('" + ex.Message + "!')</script>");
     }
 }
Exemple #4
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (AddList.Count == 0)
         {
             ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('无数据')</script>", false);
             return;
         }
         if (string.IsNullOrEmpty(txtInternalNo.Text))
         {
             ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('输入社内编号')</script>", false);
             txtInternalNo.Focus();
             return;
         }
         if (string.IsNullOrEmpty(txtDate.Text))
         {
             ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('输入声请日期')</script>", false);
             txtDate.Focus();
             return;
         }
         List <string>        sqlList = new List <string>();
         InsertCommandBuilder ins     = new InsertCommandBuilder("m_materails_apply");
         string applyNo = CommadMethod.getNextId("APN" + DateTime.Now.ToString("yyyyMMdd"), "").Trim();
         ins.InsertColumn("apply_no", applyNo);
         if (!string.IsNullOrEmpty(txtModeNo.Text))
         {
             ins.InsertColumn("mode_no", txtModeNo.Text);
         }
         ins.InsertColumn("internal_no", txtInternalNo.Text);
         ins.InsertColumn("type", cbxNomal.Checked == true ? 1 : 2);
         ins.InsertColumn("apply_date", "getdate()");
         ins.InsertColumn("apply_by", "0000");
         if (!string.IsNullOrEmpty(txtRemark.Text))
         {
             ins.InsertColumn("remark", txtRemark.Text);
         }
         ins.InsertColumn("is_confirm", "N");
         for (int i = 0; i < AddList.Count; i++)
         {
             InsertCommandBuilder insDetail = new InsertCommandBuilder("m_materails_apply_detail");
             insDetail.InsertColumn("apply_no", applyNo);
             insDetail.InsertColumn("name", AddList[i].name);
             insDetail.InsertColumn("texture", AddList[i].cz);
             insDetail.InsertColumn("spec", AddList[i].spec);
             insDetail.InsertColumn("qty", AddList[i].qty);
             insDetail.InsertColumn("is_check", 'N');
             sqlList.Add(insDetail.getInsertCommand());
         }
         sqlList.Add(ins.getInsertCommand());
         int count = ins.ExcutTransaction(sqlList);
         if (count != 0)
         {
             ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('保存成功')</script>", false);
             txtModeNo.Text     = string.Empty;
             txtDate.Text       = string.Empty;
             txtInternalNo.Text = string.Empty;
             txtRemark.Text     = string.Empty;
             cbxNomal.Checked   = false;
             cbxSpec.Checked    = false;
             AddList.Clear();
             gvAddData.DataSource = null;
             gvAddData.DataBind();
         }
         else
         {
             ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('保存失败')</script>", false);
         }
     }
     catch (Exception ex)
     {
         ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('" + ex.Message + "')</script>", false);
     }
 }
        protected void btnDone_Click(object sender, EventArgs e)
        {
            if (ddlDemp.SelectedItem.Value == "0")
            {
                Response.Write("<script>alert('请选择处理区域!')</script>");
                return;
            }
            else
            {
                ViewState["area"] = ddlDemp.SelectedItem.Value;
            }
            List <CrushedMaterialDetail> cmList = new List <CrushedMaterialDetail>();
            List <string> sqlList = new List <string>();

            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)
                    {
                        CrushedMaterialDetail c = new CrushedMaterialDetail()
                        {
                            id         = int.Parse((dgvList.Rows[i].Cells[0].FindControl("Hfid") as HiddenField).Value),
                            Name       = (dgvList.Rows[i].Cells[1].FindControl("Label1") as Label).Text,
                            MaterialNo = (dgvList.Rows[i].Cells[2].FindControl("Label2") as Label).Text,
                            Material   = (dgvList.Rows[i].Cells[3].FindControl("Label3") as Label).Text,
                            JigLeader  = (dgvList.Rows[i].Cells[4].FindControl("Label4") as Label).Text,
                            addtime    = (dgvList.Rows[i].Cells[5].FindControl("Label5") as Label).Text,
                            area1style = (dgvList.Rows[i].Cells[6].FindControl("Label6") as Label).Text,
                            area2style = (dgvList.Rows[i].Cells[7].FindControl("Label7") as Label).Text,
                            area3style = (dgvList.Rows[i].Cells[8].FindControl("Label8") as Label).Text,
                            area4style = (dgvList.Rows[i].Cells[9].FindControl("Label9") as Label).Text,
                            Qty        = int.Parse((dgvList.Rows[i].Cells[10].FindControl("TextBox1") as TextBox).Text == string.Empty ? "0" : (dgvList.Rows[i].Cells[10].FindControl("TextBox1") as TextBox).Text)
                        };
                        cmList.Add(c);
                    }
                }
                if (cmList.Count == 0)
                {
                    Response.Write("<script>alert('没有选择任何行!')</script>");
                    return;
                }
                for (int i = 0; i < cmList.Count; i++)
                {
                    UpdateCommandBuilder up = new UpdateCommandBuilder(ConnectionFactory.ConnectionString_hudsonwwwroot, "trymolde");
                    string status           = "";
                    switch (ViewState["area"].ToString())
                    {
                    case "1":
                        up.UpdateColumn("area1style", "Done(" + cmList[i].Qty + ")");
                        up.UpdateColumn("area1CrushedDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        status = cmList[i].area1style;
                        break;

                    case "2":
                        up.UpdateColumn("area2style", "Done(" + cmList[i].Qty + ")");
                        up.UpdateColumn("area2CrushedDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        status = cmList[i].area2style;
                        break;

                    case "3":
                        up.UpdateColumn("area3style", "Done(" + cmList[i].Qty + ")");
                        up.UpdateColumn("area3CrushedDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        status = cmList[i].area3style;
                        break;

                    case "4":
                        up.UpdateColumn("area4style", "Done(" + cmList[i].Qty + ")");
                        up.UpdateColumn("area4CrushedDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        status = cmList[i].area4style;
                        break;

                    default:
                        break;
                    }
                    up.ConditionsColumn("id", cmList[i].id);
                    sqlList.Add(up.getUpdateCommand());
                    if (status != "粉碎中")
                    {
                        Response.Write("<script>alert('选择行中数据有误,请选择<粉碎中>的部番!')</script>");
                        return;
                    }
                }
                InsertCommandBuilder ins = new InsertCommandBuilder(ConnectionFactory.ConnectionString_hudsonwwwroot, "trymolde");
                int count = ins.ExcutTransaction(sqlList);
                if (count != 0)
                {
                    dgvList.DataSource = getAllCrushedMaterial();
                    dgvList.DataBind();
                }
            }
        }
        protected void btnBegin_Click(object sender, EventArgs e)
        {
            //string sql = "INSERT INTO pre_pk ( pk_id, pk_no, pk_date, store_id, verifier, operator_id, remark, str_in_bill_id, str_out_bill_id, islocal, pkms ) VALUES ( 'PK000009420101', '', '2012-7-17 8:49:33.056', '03', '', '0000', '', 'RK001406270101', 'CK000548050101', 'Y', '正常按批次盘库' )";
            string ss    = "select count(*) from pre_prd_pk where store_id='" + ddlMaterialStock.SelectedItem.Value.Trim() + "' and CONVERT(varchar(100), prd_pk_Date, 112) = '" + DateTime.Now.ToString("yyyyMMdd") + "'";
            int    count = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar(ss));

            if (count != 0)
            {
                Response.Write("<script>alert('" + Resources.Resource.alertWxqd + "')</script>");
                gvData.DataSource = getData();
                gvData.DataBind();
                return;
            }
            string    sql = @" SELECT materials.dm,
                            materials.name,    
                            materials.spec,    
                            sccj.sccj_name as sccjname,    
                            materials.unit,  
                            prd_batch.pch as pch,  
                            price =  prd_batch.price,    
                            prd_stock.qty as zmsl,    
                            prd_stock.qty as pdsl,
                            prd_batch.yxq,
                            ' ' as stock_type_id,  
                            prd_stock.is_can_sale, 
                            prd_batch.str_in_date ,
                            prd_stock.prd_batch_id ,
                            prd_stock.prd_stock_id  ,
                            prd_stock.materials_id,
                            'ddd' as pk_id,
                            'N' as disobey,
                            prd_stock.qty as zmsl1, 
                            prd_stock.qty as pdsl1,
                            prd_batch.mjpch,
                            materials.texture,
                            materials.color,
                            prd_batch.hwh
                                FROM materials,    
                            prd_stock,
                            prd_batch,
                            sccj
                               WHERE ( prd_stock.materials_id = materials.id ) and
                            prd_stock.prd_batch_id = prd_batch.prd_batch_id and 
                            materials.sccj_id *= sccj.sccj_id and 
                              prd_stock.store_id = '" + ddlMaterialStock.SelectedItem.Value.Trim() + @"'  and 
                              prd_stock.materials_id like '%' and 1 = 1 ";
            DataTable dt  = new SelectCommandBuilder().ExecuteDataTable(sql);

            if (dt == null || dt.Rows.Count == 0)
            {
                Response.Write("<script>alert('" + Resources.Resource.alertWsj + "')</script>");
                return;
            }
            List <string>        sqlList = new List <string>();
            InsertCommandBuilder ins     = new InsertCommandBuilder("pre_prd_pk");
            string pkId = CommadMethod.getNextId("HPR", "0101");;

            ins.InsertColumn("prd_pk_id", pkId);
            ins.InsertColumn("prd_pk_no", "");
            ins.InsertColumn("prd_pk_date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            ins.InsertColumn("store_id", ddlMaterialStock.SelectedItem.Value.Trim());
            ins.InsertColumn("verifier", "");
            ins.InsertColumn("operator_id", HttpContext.Current.Request.Cookies["cookie"].Values["id"]);
            ins.InsertColumn("remark", txtRemark.Text.Trim().ToUpper());
            //ins.InsertColumn("str_in_bill_id", getId());
            //ins.InsertColumn("str_out_bill_id", getId());
            ins.InsertColumn("islocal", "Y");
            ins.InsertColumn("prd_pkms", "正常按批次盘库");
            sqlList.Add(ins.getInsertCommand());
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ins = new InsertCommandBuilder("pre_prd_pk_detail");
                ins.InsertColumn("prd_pk_id", pkId);
                ins.InsertColumn("stock_remain_id", dt.Rows[i]["prd_stock_id"]);
                ins.InsertColumn("materials_id", dt.Rows[i]["materials_id"]);
                ins.InsertColumn("pdsl", 0);
                ins.InsertColumn("zmsl", dt.Rows[i]["zmsl"]);
                ins.InsertColumn("prd_batch_id", dt.Rows[i]["prd_batch_id"]);
                ins.InsertColumn("zmsl1", dt.Rows[i]["zmsl1"]);
                ins.InsertColumn("pdsl1", 0);
                ins.InsertColumn("is_can_sale", dt.Rows[i]["is_can_sale"]);
                sqlList.Add(ins.getInsertCommand());
            }
            ins.ExcutTransaction(sqlList);
            gvData.DataSource = getData();
            gvData.DataBind();
        }
Exemple #7
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);
        }
Exemple #8
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            List <Details> DList = new List <Details>();
            List <string>  SList = new List <string>();

            for (int i = 0; i < gvDetailData.Rows.Count; i++)
            {
                if ((gvDetailData.Rows[i].Cells[0].FindControl("checkbox1") as CheckBox).Checked == true)
                {
                    if (string.IsNullOrEmpty((gvDetailData.Rows[i].Cells[5].FindControl("txtPrice") as TextBox).Text.Trim()))
                    {
                        ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('请输入数量')</script>", false);
                        (gvDetailData.Rows[i].Cells[6].FindControl("txtPrice") as TextBox).Focus();
                        return;
                    }
                    Details dItem = new Details()
                    {
                        Apply_No = orderNo,
                        MNo      = Mno,
                        Name     = gvDetailData.Rows[i].Cells[2].Text.Trim(),
                        Texture  = gvDetailData.Rows[i].Cells[3].Text.Trim(),
                        Spec     = gvDetailData.Rows[i].Cells[4].Text.Trim(),
                        Qty      = Convert.ToInt32((gvDetailData.Rows[i].Cells[6].FindControl("txtPrice") as TextBox).Text.Trim()),
                        Hwh      = (gvDetailData.Rows[i].Cells[7].FindControl("txtHwh") as TextBox).Text.Trim(),
                        Id       = Convert.ToInt64(gvDetailData.Rows[i].Cells[8].Text.Trim())
                    };
                    DList.Add(dItem);
                }
            }
            if (DList.Count == 0)
            {
                ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('无选择数据')</script>", false);
                return;
            }
            string Id = CommadMethod.getNextId("SI" + DateTime.Now.ToString("yyyyMMdd"), "").Trim();

            for (int i = 0; i < DList.Count; i++)
            {
                InsertCommandBuilder insert = new InsertCommandBuilder("m_materails_pre_str_in_detail");
                UpdateCommandBuilder up     = new UpdateCommandBuilder("m_materails_pch_order_detail");
                up.UpdateColumn("is_end", "Y");
                up.ConditionsColumn("Id", DList[i].Id);
                insert.InsertColumn("str_in_no", Id);
                insert.InsertColumn("name", DList[i].Name);
                insert.InsertColumn("texture", DList[i].Texture);
                insert.InsertColumn("spec", DList[i].Spec);
                insert.InsertColumn("qty", DList[i].Qty);
                insert.InsertColumn("hwh", DList[i].Hwh);
                insert.InsertColumn("is_check", "N");
                SList.Add(insert.getInsertCommand());
                SList.Add(up.getUpdateCommand());
            }
            InsertCommandBuilder ins = new InsertCommandBuilder("m_materails_pre_str_in");

            ins.InsertColumn("str_in_no", Id);
            if (!string.IsNullOrEmpty(Mno))
            {
                ins.InsertColumn("mode_no", Mno);
            }
            ins.InsertColumn("order_no", orderNo);
            ins.InsertColumn("Operator", "0000");
            ins.InsertColumn("str_in_date", "getDate()");
            ins.InsertColumn("Operate_Date", "getDate()");
            ins.InsertColumn("is_confirm", "N");
            SList.Add(ins.getInsertCommand());
            int count = ins.ExcutTransaction(SList);

            if (count != 0)
            {
                ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('保存成功')</script>", false);
                gvDetailData.DataSource = null;
                gvDetailData.DataBind();
                string updateSql = "update m_materails_pch_order set isCheck = 'Y' where Order_No='" + orderNo.Trim() + "'";
                int    countY    = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar("select count(*) from m_materails_pch_order_detail where Order_No='" + orderNo.Trim() + "' and is_end = 'N' "));
                if (countY == 0)
                {
                    new UpdateCommandBuilder().ExecuteNonQuery(updateSql);
                }
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('保存失败')</script>", false);
            }
        }
Exemple #9
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            List <goods>  List    = new List <goods>();
            List <string> sqlList = new List <string>();

            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;
            }
            for (int i = 0; i < List.Count; i++)
            {
                UpdateCommandBuilder up = new UpdateCommandBuilder(constr, "goods_tran");
                up.UpdateColumn("isConfirm", "Approved");
                up.ConditionsColumn("goods_id", List[i].goodsId);
                sqlList.Add(up.getUpdateCommand());
            }
            InsertCommandBuilder ins = new InsertCommandBuilder(constr, "");
            int count = ins.ExcutTransaction(sqlList);

            //int count = new InsertCommandBuilder().ExcutTransaction(sqlList);
            if (count != 0)
            {
                Response.Write("<script>alert('审核成功!')</script>");
                dgvList.DataSource = getConfirmGoodsList();
                dgvList.DataBind();
                gvData.DataSource = null;
                gvData.DataBind();
            }
        }
        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();
            }
        }
        protected void Unnamed2_Click(object sender, EventArgs e)
        {
            if (btnUpload.Text == Resources.Resource.yl)
            {
                #region  将上传的Excel数据显示在GridView中
                if (FileUpload1.HasFile == false)
                {
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "error", "<script>alert('" + Resources.Resource.alertxzwj + "!')</script>");
                    //Response.Write("<script>alert('请您选择Excel文件')</script> ");
                    return;//当无文件时,返回
                }
                string IsXls = System.IO.Path.GetExtension(FileUpload1.FileName).ToString().ToLower();
                if (IsXls != ".xls")
                {
                    Response.Write("<script>alert('" + Resources.Resource.alertxzexcel + "')</script>");
                    return;//当选择的不是Excel文件时,返回
                }

                btnUpload.Text = Resources.Resource.qr;
                Button1.Text   = Resources.Resource.qx;
                string path    = Server.MapPath("~/UploadExcel/");
                string strpath = FileUpload1.PostedFile.FileName.ToString();
                //string filename = FileUpload1.FileName;
                FileUpload1.PostedFile.SaveAs(path + FileUpload1.FileName);
                string Filename = path + FileUpload1.FileName;

                FileStream   file         = new FileStream(Filename, FileMode.Open, FileAccess.Read);
                HSSFWorkbook hssfworkbook = new HSSFWorkbook(file);
                Sheet        sheet        = hssfworkbook.GetSheetAt(0);
                DataTable    table        = new DataTable();
                Row          headerRow    = sheet.GetRow(0);
                int          cellCount    = headerRow.LastCellNum;
                for (int i = headerRow.FirstCellNum; i < cellCount; i++)
                {
                    DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
                    table.Columns.Add(column);
                }
                int rowCount = sheet.LastRowNum;
                for (int i = (sheet.FirstRowNum + 1); i < sheet.LastRowNum + 1; i++)
                {
                    Row     row     = sheet.GetRow(i);
                    DataRow dataRow = table.NewRow();

                    for (int j = row.FirstCellNum; j < cellCount; j++)
                    {
                        if (row.GetCell(j) != null)
                        {
                            dataRow[j] = row.GetCell(j).ToString();
                        }
                    }
                    table.Rows.Add(dataRow);
                }
                hssfworkbook            = null;
                sheet                   = null;
                this.gvExcel.DataSource = table;
                this.gvExcel.DataBind();
                File.Delete(Filename);
                #endregion
            }
            else
            {
                #region 确认上传数据
                if (gvExcel.Rows.Count != 0 && checkInput())
                {
                    List <string>        sList  = getSQLList(this.gvExcel);
                    InsertCommandBuilder insert = new InsertCommandBuilder();
                    int count = insert.ExcutTransaction(sList);
                    if (count != 0)
                    {
                        Response.Write("<script>alert('" + Resources.Resource.alterOk + "')</script>");
                        this.gvExcel.DataSource = null;
                        this.gvExcel.DataBind();
                        btnUpload.Text = Resources.Resource.yl;
                    }
                }
                #endregion
            }
        }
        protected void btnVerify_Click(object sender, EventArgs e)
        {
            try
            {
                List <CrushedMaterial> cmList  = new List <CrushedMaterial>();
                List <string>          sqlList = new List <string>();
                if (dgvList.Rows.Count != 0 && checkVerifyInput())
                {
                    for (int i = 0; i < dgvList.Rows.Count; i++)
                    {
                        if ((dgvList.Rows[i].Cells[0].FindControl("cboCheckItem") as CheckBox).Checked == true)
                        {
                            CrushedMaterial c = new CrushedMaterial()
                            {
                                id         = int.Parse((dgvList.Rows[i].Cells[0].FindControl("Hfid") as HiddenField).Value),
                                Name       = (dgvList.Rows[i].Cells[1].FindControl("Label1") as Label).Text,
                                MaterialNo = (dgvList.Rows[i].Cells[2].FindControl("Label2") as Label).Text,
                                Material   = (dgvList.Rows[i].Cells[3].FindControl("Label3") as Label).Text,
                                JigLeader  = (dgvList.Rows[i].Cells[4].FindControl("Label4") as Label).Text,
                                addtime    = (dgvList.Rows[i].Cells[5].FindControl("Label5") as Label).Text
                            };
                            cmList.Add(c);
                        }
                    }
                    if (cmList.Count == 0)
                    {
                        Response.Write("<script>alert('没有选择任何行!')</script>");
                        return;
                    }
                    string        body = "部番:";
                    List <string> bd   = new List <string>();
                    string        list = "";
                    for (int i = 0; i < cmList.Count; i++)
                    {
                        if (i != cmList.Count - 1)
                        {
                            body += cmList[i].Name + ",";
                            list += cmList[i].JigLeader + ";";
                        }
                        else
                        {
                            body += cmList[i].Name;
                            list += cmList[i].JigLeader;
                        }

                        UpdateCommandBuilder up = new UpdateCommandBuilder(ConnectionFactory.ConnectionString_hudsonwwwroot, "trymolde");
                        up.UpdateColumn("isApprove", ddlVerify.SelectedItem.Text);
                        up.UpdateColumn("ApprovedDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        up.UpdateColumn("Reason", txtReason.Text.Trim());
                        if (string.IsNullOrEmpty(txtReason.Text.Trim()))
                        {
                            up.UpdateColumn("area1style", "Wait");
                            up.UpdateColumn("area2style", "Wait");
                            up.UpdateColumn("area3style", "Wait");
                            up.UpdateColumn("area4style", "Wait");
                        }
                        up.ConditionsColumn("id", cmList[i].id);
                        sqlList.Add(up.getUpdateCommand());
                    }
                    if (ddlVerify.SelectedItem.Text == "NG")
                    {
                        body    += "审核未通过,原因为:" + txtReason.Text;
                        mailList = getUserMailAddress(list);
                    }
                    else
                    {
                        bd.Add(body + "审核已通过!" + "   <a href='" + url + "?status=Wait&&area=1'>点击此链接开始进行粉碎...</a>");
                        bd.Add(body + "审核已通过!" + "   <a href='" + url + "?status=Wait&&area=2'>点击此链接开始进行粉碎...</a>");
                        bd.Add(body + "审核已通过!" + "   <a href='" + url + "?status=Wait&&area=3'>点击此链接开始进行粉碎...</a>");
                        bd.Add(body + "审核已通过!" + "   <a href='" + url + "?status=Wait&&area=4'>点击此链接开始进行粉碎...</a>");
                    }
                    InsertCommandBuilder ins = new InsertCommandBuilder(ConnectionFactory.ConnectionString_hudsonwwwroot, "trymolde");
                    int count = ins.ExcutTransaction(sqlList);
                    if (count != 0)
                    {
                        Response.Write("<script>alert('审核成功!')</script>");
                        if (mailList != "")
                        {
                            if (ddlVerify.SelectedItem.Text == "NG")
                            {
                                SendMail.ExecuteSendMail(smtpIp, Port, fromUser, fromPwd, mailList, "", "试作品粉碎审核通告(系统邮件,请勿回复!)", body, "", "");
                            }
                            else
                            {
                                for (int i = 0; i <= 3; i++)
                                {
                                    SendMail.ExecuteSendMail(smtpIp, Port, fromUser, fromPwd, ConfigurationManager.AppSettings["area" + (i + 1)].ToString(), "", "试作品粉碎审核通告(系统邮件,请勿回复!)", bd[i], "", "");
                                }
                            }
                        }

                        dgvList.DataSource = getAllCrushedMaterial();
                        dgvList.DataBind();
                        //Response.Write("<script>alert('" + s + "!')</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('审核失败!')</script>");
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('" + ex.Message + "!')</script>");;
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (gvAddData.Rows.Count == 0)
            {
                return;
            }
            List <string>        sqlList = new List <string>();
            InsertCommandBuilder insert  = new InsertCommandBuilder();

            if (gvAddData.Columns[11].Visible == false)
            {
                for (int i = 0; i < aList.Count; i++)
                {
                    UpdateCommandBuilder up = new UpdateCommandBuilder("pd_detail");
                    up.UpdateColumn("Qty", aList[i].pdsl);
                    up.UpdateColumn("pch", aList[i].pch);
                    up.UpdateColumn("hwh", aList[i].hwh);
                    up.ConditionsColumn("Detail_id", aList[i].id);
                    sqlList.Add(up.getUpdateCommand());
                    //UpdateCommandBuilder up1 = new UpdateCommandBuilder("pre_prd_pk_detail");
                    //up1.UpdateColumn("pdsl", aList[i].pdsl);
                    //up1.ConditionsColumn("Detail_id", aList[i].id);
                    //sqlList.Add(up1.getUpdateCommand());
                }
            }
            else
            {
                InsertCommandBuilder ins = new InsertCommandBuilder("pd_detail");
                string Bill_id           = "PD" + DateTime.Now.ToString("ddHHmmssfff");
                for (int i = 0; i < lList.Count; i++)
                {
                    List <string> sList     = getBatch_id(lList[i].pm, lList[i].pch);
                    string        detail_id = Bill_id + (i + 1).ToString().PadLeft(4, '0');
                    //string sql = "INSERT INTO tmp_pk_detail ( Bill_id, Batch_id, Goods_id, Qty, Pch, Detail_id, Price, is_can_sale, hwh ) VALUES ( '" + Bill_id + "', '盘盈入库', '3034', 500.000000, '无库存', 'PB2012072109381211401010938257800002', 1.225000, 'Y', '' )";
                    ins.CommandClear();
                    ins.InsertColumn("Bill_id", Bill_id);
                    ins.InsertColumn("prd_Batch_id", sList[1].Trim());
                    ins.InsertColumn("materials_id", sList[0].Trim());
                    ins.InsertColumn("Qty", lList[i].pdsl);
                    ins.InsertColumn("Pch", lList[i].pch);
                    ins.InsertColumn("Detail_id", detail_id);
                    ins.InsertColumn("Price", lList[i].Price);
                    ins.InsertColumn("is_can_sale", "Y");
                    ins.InsertColumn("hwh", lList[i].hwh);
                    ins.InsertColumn("is_new", "Y");
                    sqlList.Add(ins.getInsertCommand());
                    int countPD = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar("select count(*) from pre_prd_pk_detail WHERE (prd_pk_id = '" + txtPK_Id.Text.Trim().ToUpper() + "') AND (prd_batch_id = '" + lList[i].b_id + "') AND (stock_remain_id = '" + lList[i].s_id + "') "));
                    if (countPD != 0)
                    {
                        string updateSQL = "update pre_prd_pk_detail set pdsl =" + lList[i].pdsl + ",detail_id = '" + detail_id + "' WHERE (prd_pk_id = '" + txtPK_Id.Text.Trim().ToUpper() + "') AND (prd_batch_id = '" + lList[i].b_id + "') AND (stock_remain_id = '" + lList[i].s_id + "') ";
                        sqlList.Add(updateSQL);
                    }
                }
                ins.CommandClear();
                ins = new InsertCommandBuilder("pd");
                ins.InsertColumn("Bill_Id", Bill_id);
                ins.InsertColumn("Bill_no", txtPK_No.Text.Trim());
                ins.InsertColumn("Pk_id", txtPK_Id.Text.Trim().ToUpper());
                ins.InsertColumn("store_id", ddlMaterialStock.SelectedItem.Value.Trim());
                ins.InsertColumn("Crt_emp", HttpContext.Current.Request.Cookies["cookie"].Values["id"]);
                ins.InsertColumn("Crt_Date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                ins.InsertColumn("Status", "N");
                ins.InsertColumn("Remark", txtRemark.Text.Trim().ToUpper());
                sqlList.Add(ins.getInsertCommand());
            }
            int count = insert.ExcutTransaction(sqlList);

            if (count != 0)
            {
                Response.Write("<script>alert('" + Resources.Resource.alterOk + "')</script>");
                lList.Clear();
                aList.Clear();
                gvAddData.DataSource = lList;
                gvAddData.DataBind();
                ClearTextBox();
                ddlMaterialStock.Enabled       = true;
                ddlMaterialStock.SelectedIndex = 0;
                gvDetailData.DataSource        = null;
                gvDetailData.DataBind();
            }
        }
Exemple #14
0
        protected void btnBegin_Click(object sender, EventArgs e)
        {
            //string sql = "INSERT INTO pre_pk ( pk_id, pk_no, pk_date, store_id, verifier, operator_id, remark, str_in_bill_id, str_out_bill_id, islocal, pkms ) VALUES ( 'PK000009420101', '', '2012-7-17 8:49:33.056', '03', '', '0000', '', 'RK001406270101', 'CK000548050101', 'Y', '正常按批次盘库' )";
            string ss    = "select count(*) from pre_pk where store_id='" + ddlMaterialStock.SelectedItem.Value.Trim() + "' and CONVERT(varchar(100), pk_Date, 112) = '" + DateTime.Now.ToString("yyyyMMdd") + "'";
            int    count = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar(ss));

            if (count != 0)
            {
                Response.Write("<script>alert('" + Resources.Resource.alertWxqd + "')</script>");
                gvData.DataSource = getData();
                gvData.DataBind();
                return;
            }
            string    sql = @" SELECT goods.dm,
			goods.goods_name,    
			goods.spec,    
			sccj.sccj_name as sccjname,    
			goods.goods_unit,  
			batch.pch as pch,  
			price =  isnull(batch.price,0.0),    
			stock_remain.qty as zmsl,    
			stock_remain.qty as pdsl,
			batch.yxq,
			' ' as stock_type_id,  
			stock_remain.is_can_sale, 
			batch.str_in_date,
			stock_remain.batch_id ,
			stock_remain.stock_remain_id,
			stock_remain.goods_id,
			'ddd' as pk_id,
			'N' as disobey,
			stock_remain.qty as zmsl1, 
			stock_remain.qty as pdsl1,
			price.price as saleprice,
			batch.mjpch,
			c.location as location,
			isnull(( select counter_name from counter where counter.counter_id = c.counter_id), '未设置') as counter ,
			d.style,
			d.dictate_name,
			customer_name = (select bb.customer_name 
									from xsht aa,customer bb
									where aa.customer_id = bb.customer_id
										and aa.xsht_id = d.order_id ),
			batch.hwh  as 'hwh',	
			goods.cz,
			goods.ys
    FROM goods,    
			stock_remain,
			batch ,
			price  ,
			sccj,
			goods_counter c ,
			prd_dictate d 
   WHERE ( stock_remain.goods_id = goods.goods_id ) and   
			stock_Remain.batch_id = batch.batch_id and 
			batch.dictate_id *= d.dictate_id and 
			goods.sccj_id *= sccj.sccj_id and 
			stock_remain.stockstatus = 'N' and 
			goods.price_id *= price.price_id and 
            stock_remain.store_id = '"             + ddlMaterialStock.SelectedItem.Value.Trim() + @"'  and 
            stock_remain.goods_id like '%' and
			goods.goods_id *= c.goods_id and
			stock_remain.store_id *= c.store_id and 1 = 1"            ;
            DataTable dt  = new SelectCommandBuilder().ExecuteDataTable(sql);

            if (dt == null || dt.Rows.Count == 0)
            {
                Response.Write("<script>alert('" + Resources.Resource.alertWsj + "')</script>");
                return;
            }
            List <string>        sqlList = new List <string>();
            InsertCommandBuilder ins     = new InsertCommandBuilder("pre_pk");
            string pkId = CommadMethod.getNextId("HPD", "0101");

            ins.InsertColumn("pk_id", pkId);
            ins.InsertColumn("pk_no", "");
            ins.InsertColumn("pk_date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            ins.InsertColumn("store_id", ddlMaterialStock.SelectedItem.Value.Trim());
            ins.InsertColumn("verifier", "");
            ins.InsertColumn("operator_id", HttpContext.Current.Request.Cookies["cookie"].Values["id"]);
            ins.InsertColumn("remark", txtRemark.Text.Trim().ToUpper());
            //ins.InsertColumn("str_in_bill_id", getId());
            //ins.InsertColumn("str_out_bill_id", getId());
            ins.InsertColumn("islocal", "Y");
            ins.InsertColumn("pkms", "正常按批次盘库");
            sqlList.Add(ins.getInsertCommand());
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ins = new InsertCommandBuilder("pre_pk_Detail");
                ins.InsertColumn("pk_id", pkId);
                ins.InsertColumn("stock_remain_id", dt.Rows[i]["stock_remain_id"]);
                ins.InsertColumn("goods_id", dt.Rows[i]["goods_id"]);
                ins.InsertColumn("pdsl", 0);
                ins.InsertColumn("zmsl", dt.Rows[i]["zmsl"]);
                ins.InsertColumn("batch_id", dt.Rows[i]["batch_id"]);
                ins.InsertColumn("zmsl1", dt.Rows[i]["zmsl1"]);
                ins.InsertColumn("pdsl1", dt.Rows[i]["pdsl1"]);
                ins.InsertColumn("is_can_sale", dt.Rows[i]["is_can_sale"]);
                sqlList.Add(ins.getInsertCommand());
            }
            ins.ExcutTransaction(sqlList);
            gvData.DataSource = getData();
            gvData.DataBind();
        }
Exemple #15
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            if (ddlVendor.SelectedIndex == 0)
            {
                ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('请选择供应商')</script>", false);
                return;
            }
            if (string.IsNullOrEmpty(txtDate.Text))
            {
                ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('请选择采购日期')</script>", false);
                return;
            }
            List <Details> DList = new List <Details>();
            List <string>  SList = new List <string>();

            for (int i = 0; i < gvDetailData.Rows.Count; i++)
            {
                if ((gvDetailData.Rows[i].Cells[0].FindControl("checkbox1") as CheckBox).Checked == true)
                {
                    if (string.IsNullOrEmpty((gvDetailData.Rows[i].Cells[6].FindControl("txtPrice") as TextBox).Text.Trim()))
                    {
                        ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('请输入价格')</script>", false);
                        (gvDetailData.Rows[i].Cells[6].FindControl("txtPrice") as TextBox).Focus();
                        return;
                    }
                    Details dItem = new Details()
                    {
                        Apply_No = Apply_No,
                        MNo      = Mno,
                        Name     = gvDetailData.Rows[i].Cells[2].Text.Trim(),
                        Texture  = gvDetailData.Rows[i].Cells[3].Text.Trim(),
                        Spec     = gvDetailData.Rows[i].Cells[4].Text.Trim(),
                        Qty      = Convert.ToInt32(gvDetailData.Rows[i].Cells[5].Text.Trim()),
                        Price    = Convert.ToDouble((gvDetailData.Rows[i].Cells[6].FindControl("txtPrice") as TextBox).Text.Trim()),
                        Id       = Convert.ToInt64(gvDetailData.Rows[i].Cells[7].Text.Trim())
                    };
                    DList.Add(dItem);
                }
            }
            if (DList.Count == 0)
            {
                ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('无选择数据')</script>", false);
                return;
            }
            string Id = CommadMethod.getNextId("PCH" + DateTime.Now.ToString("yyyyMMdd"), "").Trim();
            InsertCommandBuilder insert = new InsertCommandBuilder("m_materails_pch_order_detail");

            for (int i = 0; i < DList.Count; i++)
            {
                UpdateCommandBuilder up = new UpdateCommandBuilder("m_materails_apply_detail");
                up.UpdateColumn("is_check", "Y");
                up.ConditionsColumn("Id", DList[i].Id);
                insert.InsertColumn("Order_No", Id);
                insert.InsertColumn("name", DList[i].Name);
                insert.InsertColumn("texture", DList[i].Texture);
                insert.InsertColumn("spec", DList[i].Spec);
                insert.InsertColumn("qty", DList[i].Qty);
                insert.InsertColumn("price", DList[i].Price);
                insert.InsertColumn("is_end", "N");
                insert.InsertColumn("wb_id", ddlwb.SelectedItem.Value);
                SList.Add(insert.getInsertCommand());
                SList.Add(up.getUpdateCommand());
                insert.CommandClear();
            }
            InsertCommandBuilder ins = new InsertCommandBuilder("m_materails_pch_order");

            ins.InsertColumn("Order_date", txtDate.Text);
            ins.InsertColumn("Order_No", Id);
            if (!string.IsNullOrEmpty(Mno))
            {
                ins.InsertColumn("mode_no", Mno);
            }
            ins.InsertColumn("Vendor_id", ddlVendor.SelectedItem.Value);
            ins.InsertColumn("Remark", txtRemark.Text.Trim());
            ins.InsertColumn("Operator_id", "0000");
            ins.InsertColumn("Operator_Date", "getDate()");
            ins.InsertColumn("isCheck", "N");
            SList.Add(ins.getInsertCommand());
            int count = ins.ExcutTransaction(SList);

            if (count != 0)
            {
                ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('保存成功')</script>", false);
                gvDetailData.DataSource = null;
                gvDetailData.DataBind();
                txtDate.Text            = string.Empty;
                txtRemark.Text          = string.Empty;
                ddlVendor.SelectedIndex = 0;
                ddlwb.SelectedIndex     = 0;
                string updateSql = "";
                int    countY    = 0;
                if (string.IsNullOrEmpty(Mno))
                {
                    updateSql = "update m_materails_apply set is_confirm = 'E' where apply_no='" + Apply_No.Trim() + "'";
                    countY    = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar("select count(*) from m_materails_apply_detail where apply_no='" + Id.Trim() + "' and is_check = 'N' "));
                }
                else
                {
                    updateSql = "update m_materails_apply set is_confirm = 'E' where mode_no = '" + Mno.Trim() + "'";
                    countY    = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar("select count(*) from m_materails_apply_detail where apply_no='" + Id.Trim() + "' and is_check = 'N' "));
                }
                if (countY == 0)
                {
                    new UpdateCommandBuilder().ExecuteNonQuery(updateSql);
                }
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('保存失败')</script>", false);
            }
        }
Exemple #16
0
        protected void Unnamed2_Click(object sender, EventArgs e)
        {
            try
            {
                if (btnUpload.Text == "预 览")
                {
                    #region  将上传的Excel数据显示在GridView中
                    if (FileUpload1.HasFile == false)
                    {
                        ClientScript.RegisterStartupScript(ClientScript.GetType(), "error", "<script>alert('请您选择Excel文件!')</script>");
                        //Response.Write("<script>alert('请您选择Excel文件')</script> ");
                        return;//当无文件时,返回
                    }
                    string IsXls = System.IO.Path.GetExtension(FileUpload1.FileName).ToString().ToLower();
                    if (IsXls != ".xls")
                    {
                        Response.Write("<script>alert('只可以选择Excel文件')</script>");
                        return;//当选择的不是Excel文件时,返回
                    }
                    btnUpload.Text = "确认上传";
                    Button1.Text   = "取 消";
                    string path    = Server.MapPath("~/UploadExcel/");
                    string strpath = FileUpload1.PostedFile.FileName.ToString();
                    //string filename = FileUpload1.FileName;
                    FileUpload1.PostedFile.SaveAs(path + FileUpload1.FileName);
                    string Filename = path + FileUpload1.FileName;

                    FileStream   file         = new FileStream(Filename, FileMode.Open, FileAccess.Read);
                    HSSFWorkbook hssfworkbook = new HSSFWorkbook(file);
                    Sheet        sheet        = hssfworkbook.GetSheetAt(0);
                    DataTable    table        = new DataTable();
                    Row          headerRow    = sheet.GetRow(1);
                    int          cellCount    = headerRow.LastCellNum;
                    for (int i = headerRow.FirstCellNum; i < cellCount; i++)
                    {
                        DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
                        table.Columns.Add(column);
                    }
                    int rowCount = sheet.LastRowNum;
                    for (int i = (sheet.FirstRowNum + 2); i < sheet.LastRowNum + 1; i++)
                    {
                        Row     row     = sheet.GetRow(i);
                        DataRow dataRow = table.NewRow();
                        if (string.IsNullOrEmpty(row.GetCell(0).ToString()))
                        {
                            continue;
                        }
                        for (int j = row.FirstCellNum; j < cellCount; j++)
                        {
                            if (row.GetCell(j) != null)
                            {
                                dataRow[j] = row.GetCell(j).ToString();
                            }
                        }
                        table.Rows.Add(dataRow);
                    }
                    hssfworkbook            = null;
                    sheet                   = null;
                    this.gvExcel.DataSource = table;
                    this.gvExcel.DataBind();
                    File.Delete(Filename);
                    ViewState["value"] = validate();
                    #endregion
                }
                else
                {
                    #region 确认上传数据
                    if (Convert.ToInt32(ViewState["value"]) != 0)
                    {
                        Response.Write("<script>alert('系统出现以下错误:\\n验证未通过,请修正背景色为红色的数据后再试!')</script>");
                        return;
                    }
                    if (gvExcel.Rows.Count == 0)
                    {
                        Response.Write("<script>alert('数据为空,请重新确认后重试!')</script>");
                        return;
                    }
                    if (ddlCustomer.SelectedItem.Value == "0")
                    {
                        Response.Write("<script>alert('请选择客户名称!')</script>");
                        return;
                    }
                    List <string>        sList  = getSQLList(this.gvExcel);
                    InsertCommandBuilder insert = new InsertCommandBuilder(constr, "");
                    int count = insert.ExcutTransaction(sList);
                    if (count != 0)
                    {
                        Response.Write("<script>alert('上传成功')</script>");
                        this.gvExcel.DataSource = null;
                        this.gvExcel.DataBind();
                        btnUpload.Text = "预 览";
                    }
                    else
                    {
                        Response.Write("<script>alert('上传失败')</script>");
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('系统出现以下错误:\\n" + ex.Message + "!')</script>");
            }
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     txtAlert.Text = string.Empty;
     try
     {
         List <string>        sqlList = new List <string>();
         InsertCommandBuilder ins     = new InsertCommandBuilder("tmp_pk_detail");
         //InsertCommandBuilder insert = new InsertCommandBuilder("pre_prd_pk_detail");
         string Bill_id = CommadMethod.getNextId("PB", "0101");
         for (int i = 0; i < iList.Count; i++)
         {
             List <string> sList     = getBatch_id(iList[i].pm, iList[i].pch);
             string        detail_id = Bill_id + (i + 1).ToString().PadLeft(4, '0');
             //string sql = "INSERT INTO tmp_pk_detail ( Bill_id, Batch_id, Goods_id, Qty, Pch, Detail_id, Price, is_can_sale, hwh ) VALUES ( '" + Bill_id + "', '盘盈入库', '3034', 500.000000, '无库存', 'PB2012072109381211401010938257800002', 1.225000, 'Y', '' )";
             ins.CommandClear();
             ins.InsertColumn("Bill_id", Bill_id);
             ins.InsertColumn("Batch_id", sList[1].Trim());
             ins.InsertColumn("Goods_id", sList[0].Trim());
             ins.InsertColumn("Qty", iList[i].pdsl);
             ins.InsertColumn("Pch", iList[i].pch);
             ins.InsertColumn("Detail_id", detail_id);
             ins.InsertColumn("is_can_sale", "Y");
             ins.InsertColumn("hwh", iList[i].hwh);
             sqlList.Add(ins.getInsertCommand());
             //insert.CommandClear();
             //insert.InsertColumn("prd_pk_id", ViewState["bill_id"]);
             //insert.InsertColumn("stock_remain_id", ViewState["bill_no"]);
             //insert.InsertColumn("materials_id", sList[0].Trim());
             //insert.InsertColumn("pdsl", iList[i].pdsl);
             //insert.InsertColumn("zmsl", 0);
             //insert.InsertColumn("prd_batch_id", sList[1].Trim());
             //insert.InsertColumn("zmsl1", 0);
             //insert.InsertColumn("pdsl1", iList[i].pdsl);
             //insert.InsertColumn("is_can_sale", "Y");
             //insert.InsertColumn("detail_id", detail_id);
             //sqlList.Add(insert.getInsertCommand());
         }
         ins.CommandClear();
         ins = new InsertCommandBuilder("tmp_pk_bill");
         ins.InsertColumn("Bill_Id", Bill_id);
         ins.InsertColumn("Bill_no", ViewState["bill_no"]);
         ins.InsertColumn("Pk_id", ViewState["bill_id"]);
         ins.InsertColumn("store_id", ViewState["s"]);
         ins.InsertColumn("Crt_emp", HttpContext.Current.Request.Cookies["cookie"].Values["id"]);
         ins.InsertColumn("Crt_Date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
         ins.InsertColumn("Status", "N");
         ins.InsertColumn("isAdd", "Y");
         //ins.InsertColumn("Remark", txtRemark.Text.Trim().ToUpper());
         sqlList.Add(ins.getInsertCommand());
         int c = ins.ExcutTransaction(sqlList);
         if (c != 0)
         {
             //Response.Write("<script>alert('" + Resources.Resource.alterOk + "')</script>");
             txtAlert.Text        = Resources.Resource.alterOk;
             gvAddData.DataSource = null;
             gvAddData.DataBind();
             iList.Clear();
         }
         else
         {
             //Response.Write("<script>alert('" + Resources.Resource.alterfiald + "')</script>");
             txtAlert.Text = Resources.Resource.alterfiald;
         }
     }
     catch (Exception ex)
     {
         txtAlert.Text = ex.Message;
         //Response.Write("<script>alert('" + ex.Message + "')</script>");
     }
 }
Exemple #18
0
        protected void Unnamed2_Click(object sender, EventArgs e)
        {
            if (btnUpload.Text == Resources.Resource.yl)
            {
                #region  将上传的Excel数据显示在GridView中
                if (FileUpload1.HasFile == false)
                {
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "error", "<script>alert('" + Resources.Resource.alertxzwj + "!')</script>");
                    return;
                }
                string IsXls = System.IO.Path.GetExtension(FileUpload1.FileName).ToString().ToLower();
                if (IsXls != ".xls")
                {
                    Response.Write("<script>alert('" + Resources.Resource.alertxzexcel + "')</script>");
                    return;
                }
                btnUpload.Text = Resources.Resource.qr;
                Button1.Text   = Resources.Resource.qx;
                string path    = Server.MapPath("~/UploadExcel/");
                string strpath = FileUpload1.PostedFile.FileName.ToString();
                //string filename = FileUpload1.FileName;
                FileUpload1.PostedFile.SaveAs(path + FileUpload1.FileName);
                string Filename = path + FileUpload1.FileName;

                FileStream   file         = new FileStream(Filename, FileMode.Open, FileAccess.Read);
                HSSFWorkbook hssfworkbook = new HSSFWorkbook(file);
                Sheet        sheet        = hssfworkbook.GetSheetAt(0);
                DataTable    table        = new DataTable();
                Row          headerRow    = sheet.GetRow(0);
                int          cellCount    = headerRow.LastCellNum;
                for (int i = headerRow.FirstCellNum; i < cellCount; i++)
                {
                    DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
                    table.Columns.Add(column);
                }
                int rowCount = sheet.LastRowNum;
                for (int i = (sheet.FirstRowNum + 1); i < sheet.LastRowNum + 1; i++)
                {
                    Row     row     = sheet.GetRow(i);
                    DataRow dataRow = table.NewRow();

                    for (int j = row.FirstCellNum; j < cellCount; j++)
                    {
                        if (row.GetCell(j) != null)
                        {
                            dataRow[j] = row.GetCell(j).ToString();
                        }
                    }
                    table.Rows.Add(dataRow);
                }
                hssfworkbook            = null;
                sheet                   = null;
                this.gvExcel.DataSource = table;
                this.gvExcel.DataBind();
                File.Delete(Filename);
                #endregion
            }
            else
            {
                #region 确认上传数据
                if (gvExcel.Rows.Count == 0)
                {
                    Response.Write("<script>alert('" + Resources.Resource.alertksj + "')</script>");
                    return;
                }
                string               Text10 = "";
                List <string>        sList  = getSQLList(this.gvExcel);
                UpdateCommandBuilder up     = new UpdateCommandBuilder();
                up.ExecuteNonQuery("update Client_FC set status='Y' where len(no_id)>1");
                up.ExecuteNonQuery("update Client_FC set delivery_no='" + Text10 + "'+convert(varchar(6),delivery_date,112) where ( len(delivery_no) =0 and status='N')");
                up.ExecuteNonQuery("update Client_FC set operation_flag='N' where (operation_flag is null and status='N' )");
                SqlParameter[] parm = new SqlParameter[]
                {
                    new SqlParameter("@Kh_id", txtCName.SelectedItem.Value.Split('|')[0].Trim()),
                    new SqlParameter("@Dly_no", txtCName.SelectedItem.Value.Split('|')[1].Trim() + Convert.ToDateTime(txtDate.Text).ToString("yyyyMM")),
                    new SqlParameter("@dat", Convert.ToDateTime(txtDate.Text).ToString("yyyyMM"))
                };
                SqlHelper.ExecuteNonQuery(base.ConnectionString, CommandType.StoredProcedure, "Client_FC_Ver", parm);
                up.ExecuteNonQuery("Update Client_FC Set lb1_id = goods.lb1_id FROM Client_FC INNER JOIN goods ON goods.goods_name = Client_FC.goods_name WHERE status = 'N'");
                parm = new SqlParameter[] { new SqlParameter("@Op_id", ip.Trim() + HttpContext.Current.Request.Cookies["cookie"].Values["id"].Trim()) };
                SqlHelper.ExecuteNonQuery(base.ConnectionString, CommandType.StoredProcedure, "Demands_goods_expand", parm);
                parm = new SqlParameter[] { new SqlParameter("@Kh_id", txtCName.SelectedItem.Value.Split('|')[0].Trim()), new SqlParameter("@Op_id", ip.Trim() + HttpContext.Current.Request.Cookies["cookie"].Values["id"].Trim()), new SqlParameter("@dat", Convert.ToDateTime(txtDate.Text).ToString("yyyyMM")) };
                SqlHelper.ExecuteNonQuery(base.ConnectionString, CommandType.StoredProcedure, "Client_FC_ID", parm);
                up.ExecuteNonQuery("update Client_FC set status='Y' where len(no_id)>1");
                InsertCommandBuilder insert = new InsertCommandBuilder();
                int count = insert.ExcutTransaction(sList);
                if (count != 0)
                {
                    Response.Write("<script>alert('" + Resources.Resource.alterOk + "')</script>");
                    this.gvExcel.DataSource = null;
                    this.gvExcel.DataBind();
                    btnUpload.Text = Resources.Resource.yl;
                }
                else
                {
                    Response.Write("<script>alert('" + Resources.Resource.alterfiald + "')</script>");
                }
                #endregion
            }
        }