Esempio n. 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (insList.Count == 0)
            {
                Response.Write("<script>alert('无数据保存,请先添加数据')</script>");
                return;
            }
            List <string> sqlList = new List <string>();

            sqlList.Add(ViewState["sql"].ToString());
            DateTime date       = DateTime.Now;
            string   IdLeftPart = "PH" + date.Year.ToString().Substring(2, 2) + date.Month.ToString().PadLeft(2, '0') + date.Day.ToString().PadLeft(2, '0');

            for (int i = 0; i < insList.Count; i++)
            {
                string Id = CommadMethod.getNextId(IdLeftPart, "");
                InsertCommandBuilder ins = new InsertCommandBuilder(constr, "pre_str_in_bill_detail");
                ins.InsertColumn("str_in_bill_id", ViewState["str_in_bill_id"].ToString());
                ins.InsertColumn("batch_id", Id);
                ins.InsertColumn("goods_id", new SelectCommandBuilder(constr, "").ExecuteDataTable("select goods_id from goods_tmp where goods_name = '" + insList[i].goods_name + "'").Rows[0][0].ToString().Trim());
                ins.InsertColumn("qty", insList[i].Qty.ToString());
                ins.InsertColumn("pch", insList[i].batch);
                ins.InsertColumn("can_sale", "Y");
                ins.InsertColumn("hwh", insList[i].goodsPost);
                sqlList.Add(ins.getInsertCommand());
            }
            int count = new InsertCommandBuilder(constr, "").ExcutTransaction(sqlList);

            if (count != 0)
            {
                Response.Write("<script>alert('保存成功')</script>");
                insList.Clear();
                Response.Redirect("StockIn_SaveOk.aspx");
            }
        }
        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 btnAdd_Click(object sender, EventArgs e)
        {
            if (ddlMaterialStock.SelectedItem.Value == "0")
            {
                Response.Write("<script>alert('请选择仓位点')</script>");
                return;
            }
            if (txtNo.Text.Trim().Equals(string.Empty))
            {
                Response.Write("<script>alert('请输入单号')</script>");
                return;
            }
            DateTime             date            = DateTime.Now;
            string               IdLeftPart      = "HC" + date.Year.ToString().Substring(2, 2) + date.Month.ToString().PadLeft(2, '0') + date.Day.ToString().PadLeft(2, '0');
            string               str_out_bill_id = CommadMethod.getNextId(IdLeftPart, "");
            InsertCommandBuilder ins             = new InsertCommandBuilder(constr, "pre_str_out_bill");

            ins.InsertColumn("str_out_bill_id", str_out_bill_id);
            ins.InsertColumn("str_out_bill_no", txtNo.Text.Trim().ToUpper());
            ins.InsertColumn("str_out_type_id", rbtType.SelectedItem.Value);
            ins.InsertColumn("str_out_date", txtDate.Text);
            ins.InsertColumn("store_id", ddlMaterialStock.SelectedItem.Value);
            ins.InsertColumn("operator_id", "0000");
            ins.InsertColumn("remark", txtRemark.Text.Trim());
            ins.InsertColumn("operator_date", txtDate.Text);
            ins.InsertColumn("come_to", rbtType.SelectedItem.Text);
            ins.InsertColumn("islocal", "Y");
            ins.InsertColumn("save_state", "Y");
            sql     = ins.getInsertCommand();
            No      = txtNo.Text.Trim();
            bill_id = str_out_bill_id;
            Server.Transfer("StockOut_AddData.aspx");
        }
Esempio n. 4
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (ddlMaterialStock.SelectedItem.Value == "0")
            {
                Response.Write("<script>alert('请选择仓位点')</script>");
                return;
            }
            if (txtNo.Text.Trim().Equals(string.Empty))
            {
                Response.Write("<script>alert('请输入单号')</script>");
                txtNo.Focus();
                return;
            }
            if (rbtType.SelectedIndex != 0)
            {
                if (txtgoodsName.Text == string.Empty)
                {
                    Response.Write("<script>alert('请输入部番')</script>");
                    txtgoodsName.Focus();
                    return;
                }
                if (gvList.SelectedIndex == -1)
                {
                    Response.Write("<script>alert('没有选择计划')</script>");
                    return;
                }
            }
            DateTime             date           = DateTime.Now;
            string               IdLeftPart     = "HC" + date.Year.ToString().Substring(2, 2) + date.Month.ToString().PadLeft(2, '0') + date.Day.ToString().PadLeft(2, '0');
            string               str_in_bill_id = CommadMethod.getNextId(IdLeftPart, "");
            InsertCommandBuilder ins            = new InsertCommandBuilder(constr, "pre_str_in_bill");

            ins.InsertColumn("str_in_bill_id", str_in_bill_id);
            ins.InsertColumn("str_in_bill_no", txtNo.Text);
            ins.InsertColumn("operator_id", "0000");
            ins.InsertColumn("operator_date", txtDate.Text);
            ins.InsertColumn("store_id", ddlMaterialStock.SelectedItem.Value.Trim());
            ins.InsertColumn("str_in_type_id", rbtType.SelectedItem.Value);
            ins.InsertColumn("come_from", rbtType.SelectedIndex == 0 ? rbtType.SelectedItem.Text.Trim() : gvList.SelectedRow.Cells[1].Text.Trim());
            ins.InsertColumn("is_state", "Y");
            sql     = ins.getInsertCommand();
            No      = txtNo.Text.Trim();
            bill_id = str_in_bill_id;
            if (rbtType.SelectedIndex == 0)
            {
                Server.Transfer("StockIn_AddData.aspx");
            }
            else if (rbtType.SelectedIndex == 1)
            {
                DId = gvList.SelectedRow.Cells[1].Text.Trim();
                Server.Transfer("StockIn_AddDictateData.aspx");
            }
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (checkInput() != true)
            {
                return;
            }
            Id = CommadMethod.getNextId("Fix" + DateTime.Now.ToString("yyyyMMdd"), "").Trim();
            string docType = System.IO.Path.GetExtension(FileUpload1.FileName).ToString().ToLower();

            imgId = Id + docType;
            InsertCommandBuilder ins = new InsertCommandBuilder("Repair_records");

            ins.InsertColumn("id", Id);
            ins.InsertColumn("eqp_no", tags.Text);
            ins.InsertColumn("rely_date", txtDate.Text);
            ins.InsertColumn("repair_time", Convert.ToDecimal(txtHours.Text));
            ins.InsertColumn("repair_record", txtRecords.Text);
            ins.InsertColumn("type", ddlType.SelectedItem.Text);
            ins.InsertColumn("rely_dept", ddlDept.SelectedItem.Text);
            string person = string.Empty;

            for (int i = 0; i < cblPerson.Items.Count; i++)
            {
                if (cblPerson.Items[i].Selected == true)
                {
                    person += cblPerson.Items[i].Text + ",";
                }
            }
            if (!string.IsNullOrEmpty(txtPerson.Text))
            {
                person += txtPerson.Text;
            }
            else
            {
                person = person.Substring(0, person.Length - 1);
            }
            ins.InsertColumn("repairman", person);
            ins.InsertColumn("create_date", "getdate()");
            ins.InsertColumn("doc_url", imgId);
            ins.getInsertCommand();
            int count = ins.ExecuteNonQuery();

            if (count != 0)
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('添加成功')</script>", false);
                uploadImg();
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('添加失败')</script>", false);
            }
        }
Esempio n. 6
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         string sql1  = "select count(*) from goods_tmp where goods_name = '" + txtgoodsName.Text.Trim().ToUpper() + "' and version = '" + txtVersion.Text.Trim().ToUpper().ToUpper() + "'";
         int    count = Convert.ToInt32(new SelectCommandBuilder(constr, "").ExecuteScalar(sql1));
         if (count != 0)
         {
             Response.Write("<script>alert('资料重复,请确认后再试!')</script>");
             return;
         }
         string id = CommadMethod.getNextId("GID" + DateTime.Now.ToString("yyyyMMdd"), "");
         if (InsertData("goods_tmp", id) != 0)
         {
             Response.Write("<script>alert('新增成功!')</script>");
         }
     }
     catch (Exception ex)
     {
         Response.Write("<script>alert('" + ex.Message + "!')</script>");
     }
 }
Esempio n. 7
0
        protected void btnRun_Click(object sender, EventArgs e)
        {
            btnRun.Attributes["onclick"] = this.GetPostBackEventReference(this.btnRun) + ";this.disabled=true;this.value='处理中...'";
            string id = CommadMethod.getNextId("GID" + DateTime.Now.ToString("yyyyMMdd"), "");

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

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

            u.UpdateColumn("isConfirm", "Waiting");
            u.ConditionsColumn("goods_no", txtgoodsName.Text.Trim().ToUpper());
            u.getUpdateCommand();
            i = Convert.ToInt32(u.ExecuteNonQuery());
            if (i != 0)
            {
                InsertData("goods_chage_record", hifId.Value.Trim());
                new UpdateCommandBuilder(constr, "").ExecuteNonQuery("update goods_tmp set lb8_id = '1'");
                Response.Write("<script>alert('发行成功')</script>");
                dgvList.DataSource = getConfirmGoodsList(ViewState["id"].ToString());
                dgvList.DataBind();
                string _body = "部番:" + txtgoodsName.Text + " 版本:" + txtVersion.Text.Trim() + " 已发行成功," + "<a href='http://192.168.1.199:81/GoodsManager/Goods_Aprove.aspx'>点击此链接快速审核...</a>";
                SendMail.ExecuteSendMail(smtpIp, Port, fromUser, fromPwd, mailList, ccList, "部品发行成功通知", _body, "", "");
            }
            else
            {
                Response.Write("<script>alert('发行失败')</script>");
            }
        }
        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();
        }
Esempio n. 9
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();
        }
Esempio n. 10
0
        protected string InsertData(string goods_name, string version, string mjh, string goods_ename, string dw, string Aircraft, string Materail_Number, string Materail_Name, string Materail_Model, string ys, string Materail_Vender_Color, string Materail_Color, string Fire_Retardant_Grade, string Buyer, string Toner_Model, string Toner_Buyer, string Rohs_Certification, string cpdz, string skdz, string Drying_Temperature, string Drying_Time, string sk_scale, string cxzq, string qs, string modeType, string remark, string khdm)
        {
            string id = CommadMethod.getNextId("GD" + DateTime.Now.ToString("yyyyMMdd"), "");
            InsertCommandBuilder ins = new InsertCommandBuilder(constr, "goods_tmp");

            ins.InsertColumn("goods_id", id.ToString());
            ins.InsertColumn("goods_no", goods_name);
            ins.InsertColumn("goods_name", goods_name);
            ins.InsertColumn("IsNew", "Y");
            if (!"&NBSP;".Equals(goods_ename))
            {
                ins.InsertColumn("goods_ename", goods_ename);
            }
            if (!"&NBSP;".Equals(version))
            {
                ins.InsertColumn("Version", version);
            }
            if (!"&NBSP;".Equals(mjh))
            {
                ins.InsertColumn("mjh", mjh);
            }
            if (!"&NBSP;".Equals(dw))
            {
                ins.InsertColumn("dw", dw);
            }
            if (!"&NBSP;".Equals(qs))
            {
                ins.InsertColumn("qs", qs);
            }
            if (!"&NBSP;".Equals(Materail_Number))
            {
                ins.InsertColumn("Materail_Number", Materail_Number);
            }
            if (!"&NBSP;".Equals(Materail_Name))
            {
                ins.InsertColumn("Materail_Name", Materail_Name);
            }
            if (!"&NBSP;".Equals(ys))
            {
                ins.InsertColumn("ys", ys);
            }
            if (!"&NBSP;".Equals(Materail_Model))
            {
                ins.InsertColumn("Materail_Model", Materail_Model);
            }
            if (!"&NBSP;".Equals(Materail_Vender_Color))
            {
                ins.InsertColumn("Materail_Vender_Color", Materail_Vender_Color);
            }
            if (!"&NBSP;".Equals(Materail_Color))
            {
                ins.InsertColumn("Materail_Color", Materail_Color);
            }
            if (!"&NBSP;".Equals(cpdz))
            {
                ins.InsertColumn("cpdz", cpdz);
            }
            if (!"&NBSP;".Equals(skdz))
            {
                ins.InsertColumn("skdz", skdz);
            }
            if (!"&NBSP;".Equals(Drying_Temperature))
            {
                ins.InsertColumn("Drying_Temperature", Drying_Temperature);
            }
            if (!"&NBSP;".Equals(Drying_Time))
            {
                ins.InsertColumn("Drying_Time", Drying_Time);
            }
            if (!"&NBSP;".Equals(sk_scale))
            {
                ins.InsertColumn("sk_scale", sk_scale);
            }
            if (!"&NBSP;".Equals(cxzq))
            {
                ins.InsertColumn("cxzq", cxzq);
            }
            if (!"&NBSP;".Equals(khdm))
            {
                ins.InsertColumn("khdm", khdm);
            }
            if (!"&NBSP;".Equals(remark))
            {
                ins.InsertColumn("remark", remark);
            }
            if (!"&NBSP;".Equals(modeType))
            {
                if (modeType == "贩卖")
                {
                    ins.InsertColumn("Model_Type", 1);
                }
                else if (modeType == "量产")
                {
                    ins.InsertColumn("Model_Type", 0);
                }
            }
            if (!"&NBSP;".Equals(Fire_Retardant_Grade))
            {
                ins.InsertColumn("Fire_Retardant_Grade", Fire_Retardant_Grade);
            }
            if (!"&NBSP;".Equals(Buyer))
            {
                ins.InsertColumn("Buyer", Buyer);
            }
            if (!"&NBSP;".Equals(Toner_Model))
            {
                ins.InsertColumn("Toner_Model", Toner_Model);
            }
            if (!"&NBSP;".Equals(Toner_Buyer))
            {
                ins.InsertColumn("Toner_Buyer", Toner_Buyer);
            }
            if (!"&NBSP;".Equals(Aircraft))
            {
                ins.InsertColumn("Aircraft", Aircraft);
            }
            if (!"&NBSP;".Equals(Rohs_Certification))
            {
                ins.InsertColumn("Rohs_Certification", Rohs_Certification);
            }
            return(ins.getInsertCommand());
        }
Esempio n. 11
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);
            }
        }
        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();
            }
        }
Esempio n. 13
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (true)
            {
                if (ddlMode_Type.SelectedIndex == 0)
                {
                    return;
                }
            }
            InsertCommandBuilder ins = new InsertCommandBuilder("Mold_management_accounting");
            string id = CommadMethod.getNextId("M" + DateTime.Now.ToString("yyyyMMddHHmm"), "");

            ins.InsertColumn("id", id);
            ins.InsertColumn("type_id", ddlMode_Type.SelectedItem.Value);
            ins.InsertColumn("mode", txtMode.Text.Trim());
            ins.InsertColumn("goods_name", txtGoods_Name.Text.Trim());
            ins.InsertColumn("goods_no", txtGoods_No.Text.Trim());
            ins.InsertColumn("qty", int.Parse(txtCount.Text.Trim()));
            ins.InsertColumn("quotation_number", txtQuotation_number.Text.Trim());
            ins.InsertColumn("price", double.Parse(txtPrice.Text));
            ins.InsertColumn("rate", double.Parse(txtRate.Value));
            ins.InsertColumn("total", double.Parse(txtTotal.Value));
            ins.InsertColumn("currency", ddlCurrency.Text);
            ins.InsertColumn("order_receipt_date", txtRecive_Date.Text);
            ins.InsertColumn("delivery_date", txtDelivery_Date.Text);
            ins.InsertColumn("tax_rate", double.Parse(rate));
            if (!string.IsNullOrEmpty(txtContent_Remark.Text))
            {
                ins.InsertColumn("content_remark", txtContent_Remark.Text);
            }
            if (!string.IsNullOrEmpty(txtdelivery_no.Text))
            {
                ins.InsertColumn("delivery_no", txtdelivery_no.Text);
            }
            if (!string.IsNullOrEmpty(txtcustomer_order_no.Text))
            {
                ins.InsertColumn("customer_order_no", txtcustomer_order_no.Text);
            }
            if (!string.IsNullOrEmpty(txtrevenue_time.Text))
            {
                ins.InsertColumn("revenue_time", Convert.ToDateTime(txtrevenue_time.Text).ToString("yyyy-MM-dd"));
            }
            if (!string.IsNullOrEmpty(txtreconciliation_time.Text))
            {
                ins.InsertColumn("reconciliation_time", txtreconciliation_time.Text);
            }
            if (!string.IsNullOrEmpty(txtreceipt_date.Text))
            {
                ins.InsertColumn("receipt_date", txtreceipt_date.Text);
            }
            if (!string.IsNullOrEmpty(txtRemark.Text))
            {
                ins.InsertColumn("remarks", txtRemark.Text);
            }
            ins.getInsertCommand();
            int count = ins.ExecuteNonQuery();

            if (count != 0)
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "<script>alert('添加成功!')</script>");
                clearTextBox();
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "<script>alert('添加失败!')</script>");
            }
        }
Esempio n. 14
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            List <string> sqlList = new List <string>();

            string    sql  = @"INSERT INTO str_in_bill
                                  (str_in_bill_id, str_in_bill_no, str_in_type_id, operator_date, str_in_date, store_id, 
                                  operator_id, come_from, remark, islocal, ComputerName, is_end)
                            SELECT str_in_bill_id, str_in_bill_no, str_in_type_id, operator_date, str_in_date, store_id, 
                                  operator_id, come_from, remark, islocal, ComputerName, 'N' AS is_end
                            FROM pre_str_in_bill
                            WHERE (str_in_bill_id = '" + ViewState["Id"].ToString() + "')";
            string    sql1 = @"INSERT INTO str_in_bill_Detail(str_in_bill_id, goods_id, batch_id, qty, Can_sale)
                            SELECT str_in_bill_id, goods_id, batch_id, qty, Can_sale
                            FROM pre_str_in_bill_detail where str_in_bill_id = '" + ViewState["Id"].ToString() + "'";
            string    sql2 = @"INSERT INTO batch(batch_id, goods_id, pch,hwh,str_in_date)
                            SELECT batch_id, goods_id,pch,hwh,getdate()
                            FROM pre_str_in_bill_detail where str_in_bill_id ='" + ViewState["Id"].ToString() + "'";
            string    B_Id = new SelectCommandBuilder(constr, "").ExecuteDataTable("SELECT RTRIM(goods_id) + RTRIM(hwh) + RTRIM(pch) AS SumId FROM pre_str_in_bill_detail where str_in_bill_id ='" + ViewState["Id"].ToString() + "'").Rows[0]["SumId"].ToString();
            DataTable dt   = new SelectCommandBuilder(constr, "").ExecuteDataTable("SELECT stock_remain.goods_id, stock_remain.batch_id, stock_remain.store_id, stock_remain.qty, stock_remain.is_can_sale, stock_remain.stock_remain_id, batch.hwh FROM stock_remain INNER JOIN batch ON stock_remain.batch_id = batch.batch_id WHERE (RTRIM(stock_remain.goods_id) + batch.hwh + RTRIM(batch.pch)='" + B_Id + "')");
            DataTable ddt  = new SelectCommandBuilder(constr, "").ExecuteDataTable("SELECT str_in_bill_id, goods_id, batch_id, qty, pch, Can_sale, hwh FROM pre_str_in_bill_detail where str_in_bill_id='" + ViewState["Id"].ToString() + "'");
            DataTable ddtt = new SelectCommandBuilder(constr, "").ExecuteDataTable("SELECT store_id,come_from FROM pre_str_in_bill where str_in_bill_id='" + ViewState["Id"].ToString() + "' ");

            if (dt != null && dt.Rows.Count != 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string stock_remain_id = dt.Rows[i]["stock_remain_id"].ToString();
                    int    qty             = Convert.ToInt32(dt.Rows[i]["qty"]);
                    sqlList.Add("update stock_remain set qty = qty +" + qty + "where stock_remain_id='" + stock_remain_id + "'");
                }
            }
            else
            {
                DateTime date       = DateTime.Now;
                string   IdLeftPart = "PR" + date.Year.ToString().Substring(2, 2) + date.Month.ToString().PadLeft(2, '0') + date.Day.ToString().PadLeft(2, '0');
                for (int i = 0; i < ddt.Rows.Count; i++)
                {
                    string Id = CommadMethod.getNextId(IdLeftPart, "");
                    InsertCommandBuilder insert = new InsertCommandBuilder(constr, "stock_remain");
                    insert.InsertColumn("stock_remain_id", Id);
                    insert.InsertColumn("goods_id", ddt.Rows[i]["goods_id"].ToString().Trim());
                    insert.InsertColumn("batch_id", ddt.Rows[i]["batch_id"].ToString().Trim());
                    insert.InsertColumn("store_id", ddtt.Rows[0]["store_id"].ToString().Trim());
                    insert.InsertColumn("qty", Convert.ToInt32(ddt.Rows[i]["qty"]));
                    insert.InsertColumn("is_can_sale", "Y");
                    sqlList.Add(insert.getInsertCommand());
                }
            }
            if (this.sty.Text.Trim() != "期初入库")
            {
                int       InQty        = Convert.ToInt32(ddt.Rows[0]["qty"]);
                DataTable df           = new SelectCommandBuilder(constr, "").ExecuteDataTable("SELECT prd_qty, ISNULL(plan_get_qty, 0) AS plan_get_qty FROM prd_dictate WHERE (is_End = 'N') AND (dictate_id = '" + ddtt.Rows[0]["come_from"].ToString() + "')");
                int       prd_qty      = Convert.ToInt32(df.Rows[0]["prd_qty"]);
                int       plan_get_qty = Convert.ToInt32(df.Rows[0]["plan_get_qty"]);
                if ((InQty + plan_get_qty) >= prd_qty)
                {
                    sqlList.Add("update prd_dictate set is_End = 'Y' where dictate_id = '" + ddtt.Rows[0]["come_from"].ToString() + "'");
                }
                string sql3 = "update prd_dictate set plan_get_qty = plan_get_qty +" + InQty + " where dictate_id = '" + ddtt.Rows[0]["come_from"].ToString() + "'";
                sqlList.Add(sql3);
            }
            string sql4 = "delete from pre_str_in_bill where str_in_bill_id='" + ViewState["Id"].ToString() + "'";
            string sql5 = "delete from pre_str_in_bill_detail where str_in_bill_id='" + ViewState["Id"].ToString() + "'";

            sqlList.Add(sql);
            sqlList.Add(sql1);
            sqlList.Add(sql2);
            sqlList.Add(sql4);
            sqlList.Add(sql5);
            int count = new InsertCommandBuilder(constr, "").ExcutTransaction(sqlList);

            if (count != 0)
            {
                Response.Redirect("StockIn_SaveOk.aspx", false);
            }
            else
            {
                getTitle(ViewState["Id"].ToString());
                gvData.DataSource = getConfirmData(ViewState["Id"].ToString());
                gvData.DataBind();
                Response.Write("<script>alert('操作失败')</script>");
            }
        }
Esempio n. 15
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);
     }
 }
Esempio n. 16
0
        protected void btnChange_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(FileUpload1.FileName))
            {
                string doctype = System.IO.Path.GetExtension(FileUpload1.FileName).ToString().ToLower();
                if (doctype.ToLower() != ".pdf")
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "Alert", "<script>alert('上传文档必须是PDF格式!')</script>", false);
                    return;
                }
            }
            NewId = CommadMethod.getNextId("GD" + DateTime.Now.ToString("yyyyMMdd"), "");
            string        sql     = @"insert into goods_tmp (goods_id, goods_no, goods_name, goods_ename, goods_lname, spec, sccj_id, 
                              goods_unit, pack_unit, szb, min_storage, max_storage, best_storage, is_mx, 
                              is_valid, lb1_id, lb2_id, lb3_id, lb4_id, lb5_id, lb6_id, lb7_id, lb8_id, lb9_id, lb10_id, 
                              dm, py, barcode, yxq, jjfs_id, yzh, km_id, lb11_id, lb12_id, lb13_id, lb14_id, price_id, 
                              szb2, tax_rate, zxbz, exam2, select_code, yjts, rkys, jyfw_id, isother, remark, 
                              sccj_add, Crt_Operator, crt_date, modi_operator, modi_date, CheckFirst, ImportId, 
                              TCBL, StatCode, tag_id, sls_Taxrate, hwh, jfbz, cz, ys, cpdz, skdz, qs, cxzq, mjh, 
                              istm, khdm, sbdm, bysbdm, bzlb, bzxx, jzl, ksscrq, jsscrq, dw, xkh, CostPrice, LrTcxs, 
                              Customs_Goods_id, sk_scale, Customs_Weight, new_price, customs_lab, 仕向地, 
                              外箱箱入数, 内装箱入数, LOT, PO, OPR, 外箱格式文件, 内装格式文件, 尾数格式文件, 
                              xstcbl, tssj, use_days, zzgn, yjsx_id, yzh_yxq, zbz, zczyxq, lb15_id, FT, 
                              Materail_Number, Materail_Name, Materail_Model, Materail_Vender_Color, 
                              Materail_Color, Drying_Temperature, Drying_Time, Fire_Retardant_Grade, Buyer, 
                              Toner_Model, Toner_Buyer, Rohs_Certification, Aircraft, Model_Abrasives, isConfirm, 
                              Version, Model_Type, Semi_Product_Type, Semi_Product_Goods, IsNew,TNumber,ChangeContent ,FileName) select '" + NewId + @"', goods_no, goods_name, goods_ename, goods_lname, spec, sccj_id, 
                              goods_unit, pack_unit, szb, min_storage, max_storage, best_storage, is_mx, 
                              is_valid, lb1_id, lb2_id, lb3_id, lb4_id, lb5_id, lb6_id, lb7_id, lb8_id, lb9_id, lb10_id, 
                              dm, py, barcode, yxq, jjfs_id, yzh, km_id, lb11_id, lb12_id, lb13_id, lb14_id, price_id, 
                              szb2, tax_rate, zxbz, exam2, select_code, yjts, rkys, jyfw_id, isother, remark, 
                              sccj_add, Crt_Operator, getdate(), modi_operator, modi_date, CheckFirst, ImportId, 
                              TCBL, StatCode, tag_id, sls_Taxrate, hwh, jfbz, cz, ys, cpdz, skdz, qs, cxzq, mjh, 
                              istm, khdm, sbdm, bysbdm, bzlb, bzxx, jzl, ksscrq, jsscrq, dw, xkh, CostPrice, LrTcxs, 
                              Customs_Goods_id, sk_scale, Customs_Weight, new_price, customs_lab, 仕向地, 
                              外箱箱入数, 内装箱入数, LOT, PO, OPR, 外箱格式文件, 内装格式文件, 尾数格式文件, 
                              xstcbl, tssj, use_days, zzgn, yjsx_id, yzh_yxq, zbz, zczyxq, lb15_id, FT, 
                              Materail_Number, Materail_Name, Materail_Model, Materail_Vender_Color, 
                              Materail_Color, Drying_Temperature, Drying_Time, Fire_Retardant_Grade, Buyer, 
                              Toner_Model, Toner_Buyer, Rohs_Certification, Aircraft, Model_Abrasives, isConfirm, 
                              '" + txtNewVersion.Text.Trim().ToUpper() + "', Model_Type, Semi_Product_Type, Semi_Product_Goods, 'Y','" + txtNo.Text.Trim() + "','" + txtContent.Text.Trim() + "','" + NewId + ".pdf'" + " from goods_tmp where goods_id = '" + Id + "'";
            string        Usql    = "update goods_tmp set isNew = 'N' where goods_id = '" + Id + "'";
            string        Isql    = "insert into Mold_management_accounting (id,Mode_type_id,currency,goods_no)values('" + NewId + "',1,'N','" + txtgoodsName.Text.Trim() + txtNewVersion.Text.Trim().ToUpper() + "')";
            List <string> sqlList = new List <string>();

            sqlList.Add(sql);
            sqlList.Add(Usql);
            sqlList.Add(Isql);
            int count = new InsertCommandBuilder(constr, "").ExcutTransaction(sqlList);

            if (count != 0)
            {
                string path    = Server.MapPath("~/UploadFile/");
                string strpath = FileUpload1.PostedFile.FileName.ToString();
                FileUpload1.PostedFile.SaveAs(path + NewId + ".pdf");
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "Alert", "<script>alert('操作已完成!')</script>", false);
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "Alert", "<script>alert('操作不成功!')</script>", false);
            }
        }
Esempio n. 17
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            List <goods>  List    = new List <goods>();
            List <string> sqlList = new List <string>();
            string        constr  = "";

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

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

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

            Response.Write("<script>alert('执行成功')</script>");
            btnSearch_Click(sender, e);
        }
 protected void 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>");
     }
 }
Esempio n. 19
0
        protected int InsertData()
        {
            string id = CommadMethod.getNextId("GD" + DateTime.Now.ToString("yyyyMMdd"), "");
            InsertCommandBuilder ins = new InsertCommandBuilder(constr, "goods_tmp");

            ins.InsertColumn("goods_id", id.ToString());
            ins.InsertColumn("goods_name", txtgoodsName.Text.Trim().ToUpper());
            ins.InsertColumn("goods_no", txtgoodsName.Text.Trim().ToUpper());
            if (!string.IsNullOrEmpty(txtgoodsEName.Text.Trim()))
            {
                ins.InsertColumn("goods_ename", txtgoodsEName.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtVersion.Text.Trim()))
            {
                ins.InsertColumn("Version", txtVersion.Text.Trim().ToUpper());
            }
            if (!string.IsNullOrEmpty(txtjigNo.Text.Trim()))
            {
                ins.InsertColumn("mjh", txtjigNo.Text.Trim());
            }
            if (!ddlMachine.SelectedItem.Value.Equals("0"))
            {
                ins.InsertColumn("dw", ddlMachine.SelectedItem.Value);
            }
            if (!string.IsNullOrEmpty(txtQty.Text.Trim()))
            {
                ins.InsertColumn("qs", txtQty.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtMNo.Text.Trim()))
            {
                ins.InsertColumn("Materail_Number", txtMNo.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtMName.Text.Trim()))
            {
                ins.InsertColumn("Materail_Name", txtMName.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtMColor.Text.Trim()))
            {
                ins.InsertColumn("ys", txtMColor.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtMModel.Text.Trim()))
            {
                ins.InsertColumn("Materail_Model", txtMModel.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtMVenderColor.Text.Trim()))
            {
                ins.InsertColumn("Materail_Vender_Color", txtMVenderColor.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtColor.Text.Trim()))
            {
                ins.InsertColumn("Materail_Color", txtColor.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtWeight.Text.Trim()))
            {
                ins.InsertColumn("cpdz", txtWeight.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtSKWeight.Text.Trim()))
            {
                ins.InsertColumn("skdz", txtSKWeight.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtTemp.Text.Trim()))
            {
                ins.InsertColumn("Drying_Temperature", txtTemp.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtTime.Text.Trim()))
            {
                ins.InsertColumn("Drying_Time", txtTime.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtCrushedscale.Text.Trim()))
            {
                ins.InsertColumn("sk_scale", txtCrushedscale.Text.Trim().IndexOf('%') != -1 ? (Convert.ToDecimal(txtCrushedscale.Text.Trim().Split('%')[0]) / 100).ToString() : (Convert.ToDecimal(txtCrushedscale.Text.Trim()) / 100).ToString());
            }
            if (!string.IsNullOrEmpty(txtCycle.Text.Trim()))
            {
                ins.InsertColumn("cxzq", txtCycle.Text.Trim());
            }
            if (!ddlCustomer.SelectedItem.Value.Equals("0"))
            {
                ins.InsertColumn("khdm", ddlCustomer.SelectedItem.Value);
            }
            if (!string.IsNullOrEmpty(txtRemark.Text.Trim()))
            {
                ins.InsertColumn("remark", txtRemark.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtLevel.Text.Trim()))
            {
                ins.InsertColumn("Fire_Retardant_Grade", txtLevel.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtBuyer.Text.Trim()))
            {
                ins.InsertColumn("Buyer", txtBuyer.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtCModel.Text.Trim()))
            {
                ins.InsertColumn("Toner_Model", txtCModel.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtCBuyer.Text.Trim()))
            {
                ins.InsertColumn("Toner_Buyer", txtCBuyer.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtAircraft.Text.Trim()))
            {
                ins.InsertColumn("Aircraft", txtAircraft.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtCharge.Text.Trim()))
            {
                ins.InsertColumn("Model_Abrasives", txtCharge.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtlb7.Text))
            {
                ins.InsertColumn("Semi_Product_Goods", txtlb7.Text.Trim());
            }
            if (ddlLb7.SelectedItem.Value != "00")
            {
                ins.InsertColumn("Semi_Product_Type", ddlLb7.SelectedItem.Value);
            }
            ins.InsertColumn("crt_date", "getdate()");
            ins.InsertColumn("Model_Type", ddlModeType.SelectedItem.Value);
            ins.InsertColumn("Rohs_Certification", ddlROHS.SelectedItem.Text);
            ins.getInsertCommand();
            return(ins.ExecuteNonQuery());
        }
Esempio n. 20
0
        private List <string> doStockIn(string pk_id, string store_id)
        {
            int           remainQty = 0;
            List <string> sqlList   = new List <string>();
            string        detailsql = @"select tmp_pk_detail.Goods_id, tmp_pk_detail.Qty, tmp_pk_detail.Pch,tmp_pk_detail.hwh
                                 FROM tmp_pk_detail INNER JOIN tmp_pk_bill ON tmp_pk_detail.Bill_id = tmp_pk_bill.Bill_Id where tmp_pk_bill.Pk_id = '" + pk_id + "' and tmp_pk_bill.isAdd = 'Y'";
            DataTable     dt        = new SelectCommandBuilder().ExecuteDataTable(detailsql);

            if (dt == null || dt.Rows.Count == 0)
            {
                return(null);
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                string id   = i == 0 ? "" : dt.Rows[i - 1]["goods_id"].ToString().Trim();
                //DataTable rdt = new SelectCommandBuilder().ExecuteDataTable("SELECT sum(Qty) FROM stock_remain where goods_id ='" + dt.Rows[i]["goods_id"].ToString().Trim() + "' and store_id='" + store_id + "'");
                string inbatchId          = CommadMethod.getNextId("SL", "1010A");
                InsertCommandBuilder inst = new InsertCommandBuilder("stock_remain");
                inst.InsertColumn("stock_remain_id", CommadMethod.getNextId("", "").Trim().PadLeft(14, '0'));
                inst.InsertColumn("goods_id", dt.Rows[i]["goods_id"].ToString().Trim().Trim());
                inst.InsertColumn("qty", dt.Rows[i]["Qty"]);
                inst.InsertColumn("batch_id", inbatchId);
                inst.InsertColumn("store_id", store_id);
                inst.InsertColumn("is_can_sale", "Y");
                sqlList.Add(inst.getInsertCommand());
                DateTime             date       = DateTime.Now;
                string               IdLeftPart = "PH" + date.Year.ToString().Substring(2, 2) + date.Month.ToString().PadLeft(2, '0') + date.Day.ToString().PadLeft(2, '0');
                string               Id         = CommadMethod.getNextId(IdLeftPart, "");
                InsertCommandBuilder ins        = new InsertCommandBuilder("str_in_bill");
                ins.InsertColumn("str_in_bill_id", Id);
                ins.InsertColumn("str_in_type_id", 2);
                ins.InsertColumn("str_in_date", time);
                ins.InsertColumn("operator_date", time);
                ins.InsertColumn("store_id", store_id);
                ins.InsertColumn("operator_id", HttpContext.Current.Request.Cookies["cookie"].Values["id"]);
                ins.InsertColumn("modifier_id", HttpContext.Current.Request.Cookies["cookie"].Values["id"]);
                ins.InsertColumn("modify_date", time);
                ins.InsertColumn("auditer_id", HttpContext.Current.Request.Cookies["cookie"].Values["id"]);
                ins.InsertColumn("audit_date", time);
                ins.InsertColumn("bill_num", 1);
                ins.InsertColumn("is_statics", "Y");
                ins.InsertColumn("is_mine", 1);
                ins.InsertColumn("islocal", "Y");
                ins.InsertColumn("FinImport", "N");
                ins.InsertColumn("is_end", "N");
                ins.InsertColumn("print_cs", 1);
                string str_in_bill_Sql    = ins.getInsertCommand();
                InsertCommandBuilder inss = new InsertCommandBuilder("str_in_bill_detail");
                inss.InsertColumn("str_in_bill_id", Id);
                inss.InsertColumn("batch_id", inbatchId);
                inss.InsertColumn("goods_id", dt.Rows[i]["goods_id"].ToString().Trim());
                inss.InsertColumn("qty", dt.Rows[i]["Qty"]);
                inss.InsertColumn("can_sale", "Y");
                inss.InsertColumn("piece", 1);
                string str_in_detail_Sql   = inss.getInsertCommand();
                InsertCommandBuilder insss = new InsertCommandBuilder("batch");
                insss.InsertColumn("batch_id", inbatchId);
                insss.InsertColumn("goods_id", dt.Rows[i]["goods_id"].ToString().Trim());
                insss.InsertColumn("pch", dt.Rows[i]["pch"].ToString());
                insss.InsertColumn("hwh", dt.Rows[i]["hwh"].ToString());
                insss.InsertColumn("str_in_date", time);
                sqlList.Add(insss.getInsertCommand());
                sqlList.Add(str_in_bill_Sql);
                sqlList.Add(str_in_detail_Sql);
                if (id != dt.Rows[i]["goods_id"].ToString().Trim())
                {
                    if (!dicRemainQty.ContainsKey(dt.Rows[i]["goods_id"].ToString().Trim()))
                    {
                        dicRemainQty.Add(dt.Rows[i]["goods_id"].ToString().Trim(), 0);
                    }
                    id        = dt.Rows[i]["goods_id"].ToString().Trim();
                    remainQty = dicRemainQty[id];
                }
                remainQty += Convert.ToInt32(dt.Rows[i]["Qty"]);
                if (dicRemainQty.ContainsKey(dt.Rows[i]["goods_id"].ToString().Trim()))
                {
                    dicRemainQty[dt.Rows[i]["goods_id"].ToString().Trim()] = remainQty;
                }
                else
                {
                    dicRemainQty.Add(dt.Rows[i]["goods_id"].ToString().Trim(), remainQty);
                }
                string sqlDetail = "insert into goods_detail(goods_detail_id,goods_id,str_date,store_id,batch_id,qty,remain_qty,is_str_in,str_type_name,str_bill_id,operator_name,down)";
                sqlDetail += " values ('" + CommadMethod.getNextId("SM", "0101") + "','" + dt.Rows[i]["goods_id"].ToString().Trim() + "', getdate(), '" + store_id + "','" + inbatchId + "',";
                sqlDetail += dt.Rows[i]["Qty"] + ", " + dicRemainQty[dt.Rows[i]["goods_id"].ToString().Trim()] + ",'Y','21','" + pk_id + "','Admin','N')";
                sqlList.Add(sqlDetail);
            }
            return(sqlList);
        }
Esempio n. 21
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);
            }
        }