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

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

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

            if (count != 0)
            {
                UpdateCommandBuilder up = new UpdateCommandBuilder();
                sql = "update Material_control_process set InQty = InQty + " + Qty + " ,CurrQty = CurrQty + " + Qty + " where label = '" + label + "' and process_id = 1";
            }
            else
            {
                InsertCommandBuilder ins = new InsertCommandBuilder("Material_control_process");
                ins.InsertColumn("label", label);
                ins.InsertColumn("goods_name", goodsName);
                ins.InsertColumn("process_id", 1);
                ins.InsertColumn("InQty", Qty);
                ins.InsertColumn("OutQty", 0);
                ins.InsertColumn("CurrQty", Qty);
                ins.InsertColumn("in_date", "getDate()");
                sql = ins.getInsertCommand();
            }
            new InsertCommandBuilder().ExecuteNonQuery(sql);
        }
示例#5
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");
            }
        }
        protected void dgvMaterailList_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string name         = (dgvMaterailList.Rows[e.RowIndex].FindControl("Label1") as Label).Text;
            double price        = Convert.ToDouble((dgvMaterailList.Rows[e.RowIndex].FindControl("txtPrice") as TextBox).Text);
            string currency     = (dgvMaterailList.Rows[e.RowIndex].FindControl("ddlcurrency") as DropDownList).SelectedItem.Text;
            double exchangeRate = getexchangeRate(currency);

            UpdateCommandBuilder u = new UpdateCommandBuilder("materials");

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

            InsertCommandBuilder insert = new InsertCommandBuilder("materials_newest_price");

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

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

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

            if (i != 0)
            {
                dgvMaterailList.EditIndex = -1;
                if (string.IsNullOrEmpty(txtName.Value.Trim()) && ddlVendorList.SelectedItem.Value.Trim() == "0")
                {
                    dgvMaterailList.DataSource = getIndexPageData();
                }
                else
                {
                    dgvMaterailList.DataSource = getIndexPageData(txtName.Value.Trim(), ddlVendorList.SelectedItem.Value.Trim());
                }
                dgvMaterailList.DataBind();
            }
        }
示例#7
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");
            }
        }
示例#8
0
        protected void btnSure_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtinvoice_date.Text))
            {
                txtinvoice_date.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtRecipt_Date.Text))
            {
                txtRecipt_Date.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtAmount.Text))
            {
                txtAmount.Focus();
                return;
            }
            InsertCommandBuilder ins = new InsertCommandBuilder("Mode_receipt_accounting");

            ins.InsertColumn("receipt_date", txtRecipt_Date.Text);
            ins.InsertColumn("Amount", double.Parse(txtAmount.Text).ToString("0.00#"));
            ins.InsertColumn("M_id", Id);
            ins.InsertColumn("invoice_date", txtinvoice_date.Text);
            if (!string.IsNullOrEmpty(txtinvoice_no.Text))
            {
                ins.InsertColumn("invoice_no", txtinvoice_no.Text);
            }
            ins.getInsertCommand();
            int count = ins.ExecuteNonQuery();

            if (count != 0)
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "<script>alert('收款成功!')</script>");
                getReciptData(Id);
                txtAmount.Text      = string.Empty;
                txtRecipt_Date.Text = string.Empty;
                txtAmount.Focus();
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "<script>alert('收款失败!')</script>");
            }
        }
示例#9
0
        public int excutInsert(string Barcode, string goods_name, int qty, string pdate, string sn, string customerID, string machine, string classid)
        {
            InsertCommandBuilder insert = new InsertCommandBuilder("BarCodeRecords");

            insert.InsertColumn("Barcode", Barcode);
            insert.InsertColumn("goods_name", goods_name);
            insert.InsertColumn("qty", qty);
            insert.InsertColumn("pdate", pdate);
            insert.InsertColumn("sn", sn);
            insert.InsertColumn("customerId", customerID);
            insert.InsertColumn("equip", machine);
            insert.InsertColumn("classid", classid);
            insert.InsertColumn("create_date", "getdate()");
            insert.getInsertCommand();
            return(insert.ExecuteNonQuery());
        }
示例#10
0
        protected List <string> getSQLList(GridView dgv)
        {
            List <string>        sList  = new List <string>();
            InsertCommandBuilder insert = new InsertCommandBuilder("Goods_Up");

            for (int i = 0; i < dgv.Rows.Count; i++)
            {
                string goods_name = dgv.Rows[i].Cells[0].Text.ToString();
                string prapareId  = txtPrapareID.Text.Trim().ToUpper();
                if (!checkCustomer(goods_name))
                {
                    int j = i + 1;
                    dgv.Rows[i].BackColor = Color.Pink;
                    Response.Write("<script>alert('第" + j + "行客户代码错误')</script>");
                    btnUpload.Text = Resources.Resource.yl;
                    sList.Clear();
                    break;
                }
                else if (checkIsUpload(goods_name, prapareId))
                {
                    int j = i + 1;
                    dgv.Rows[i].BackColor = Color.Pink;
                    Response.Write("<script>alert('第" + j + "行已上传至数据库,请检查数据是否重复!')</script>");
                    btnUpload.Text = Resources.Resource.yl;
                    sList.Clear();
                    break;
                }
                else
                {
                    insert.InsertColumn("goods_name", goods_name);
                    insert.InsertColumn("qty", dgv.Rows[i].Cells[1].Text.ToString());
                    insert.InsertColumn("khdm", ddlCustomers.SelectedItem.Value);
                    insert.InsertColumn("Prepare_goods_Id", prapareId);
                    insert.InsertColumn("delivery_date", txtdelivery_date.Text);
                    string sql = insert.getInsertCommand();
                    insert.CommandClear();
                    sList.Add(sql);
                }
            }
            return(sList);
        }
        public void stockin(string id, string type_id, string goods_id, int qty, string hwh)
        {
            List <string>        sList  = new List <string>();
            InsertCommandBuilder insert = new InsertCommandBuilder("pre_str_in_bill");

            insert.InsertColumn("str_in_bill_id", id);
            insert.InsertColumn("str_in_type_id", type_id);
            insert.InsertColumn("operator_date", "getdate()");
            insert.InsertColumn("str_in_date", "getdate");
            insert.InsertColumn("store_id", "12");
            insert.InsertColumn("create_user", ViewState["UserId"]);
            insert.InsertColumn("come_from", "生产入库");
            insert.InsertColumn("is_local", "y");
            insert.InsertColumn("is_state", "N");
            sList.Add(insert.getInsertCommand());
            insert.CommandClear();
            insert = new InsertCommandBuilder("pre_str_in_bill_detail");
            insert.InsertColumn("batch_id", id);
            insert.InsertColumn("str_in_bill_id", id);
            insert.InsertColumn("goods_id", goods_id);
            insert.InsertColumn("qty", qty);
            insert.InsertColumn("hwh", hwh);
            sList.Add(insert.getInsertCommand());
        }
示例#12
0
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            InsertCommandBuilder insert = new InsertCommandBuilder("m_materials");

            insert.InsertColumn("name", txtName.Text);
            insert.InsertColumn("spec", txtSpec.Text);
            insert.InsertColumn("sccj_id", ddlVendor.SelectedItem.Value);
            insert.InsertColumn("new_price", txtPrie.Text);
            insert.InsertColumn("wb_name", moneyType.Text);
            insert.InsertColumn("lb1_id", type.Text);
            insert.InsertColumn("texture", txtCz.Text);
            insert.InsertColumn("color", txtColor.Text);
            insert.InsertColumn("dm", txtShotName.Text);
            insert.getInsertCommand();
            int i = insert.ExecuteNonQuery();

            if (i != 0)
            {
                ClientScript.RegisterStartupScript(ClientScript.GetType(), "showwindow", "<script>alert('添加成功')</script>");
            }
        }
        private static void InsertData(string label, string goodsName, int Qty, int areaId, string userId)
        {
            InsertCommandBuilder ins = new InsertCommandBuilder("Material_control");

            ins.InsertColumn("label", label);
            ins.InsertColumn("goods_name", goodsName);
            ins.InsertColumn("process_id", areaId);
            ins.InsertColumn("qty", Qty);
            ins.InsertColumn("operate_time", "getDate()");
            ins.InsertColumn("operator", userId);
            ins.getInsertCommand();
            ins.ExecuteNonQuery();
        }
示例#14
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtTypeName.Text))
            {
                return;
            }
            InsertCommandBuilder ins = new InsertCommandBuilder("Mode_type");

            ins.InsertColumn("Mode_type_name", txtTypeName.Text.Trim());
            ins.getInsertCommand();
            int count = ins.ExecuteNonQuery();

            if (count != 0)
            {
                getType();
                txtTypeName.Text = string.Empty;
                ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "<script>alert('添加成功!')</script>");
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "<script>alert('添加失败!')</script>");
            }
        }
        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;

            for (int i = 0; i < insList.Count; i++)
            {
                string               goodsId = new SelectCommandBuilder(constr, "").ExecuteDataTable("select goods_id from goods_tmp where goods_name = '" + insList[i].goods_name + "'").Rows[0][0].ToString().Trim();
                string               sql     = @"SELECT stock_remain.goods_id, stock_remain.batch_id, stock_remain.store_id, 
                                      stock_remain.qty, batch.hwh
                                FROM batch INNER JOIN
                                      stock_remain ON batch.batch_id = stock_remain.batch_id
                                WHERE (batch.hwh = '" + insList[i].goodsPost + @"') AND (stock_remain.goods_id ='" + goodsId + "')";
                DataTable            dt      = new SelectCommandBuilder(constr, "").ExecuteDataTable(sql);
                string               batchId = dt.Rows[0]["batch_id"].ToString();
                InsertCommandBuilder ins     = new InsertCommandBuilder(constr, "pre_str_out_bill_Detail");
                ins.InsertColumn("str_out_bill_id", ViewState["str_out_bill_id"].ToString());
                ins.InsertColumn("goods_id", goodsId);
                ins.InsertColumn("batch_id", batchId);
                ins.InsertColumn("qty", insList[i].Qty);
                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");
            }
        }
示例#16
0
 protected void btnEdit_Click(object sender, EventArgs e)
 {
     if (inputCheck() == true)
     {
         InsertCommandBuilder insert = new InsertCommandBuilder("vendor");
         insert.InsertColumn("vendor_id", vendor_id.Text);
         insert.InsertColumn("vendor_aname", vendor_aname.Text.Trim());
         insert.InsertColumn("vendor_name", vendor_name.Text.Trim());
         insert.InsertColumn("vendor_address", vendor_address.Text.Trim());
         insert.InsertColumn("city", city.Text.Trim());
         insert.InsertColumn("tel", tel.Text.Trim());
         insert.InsertColumn("fax", fax.Text.Trim());
         insert.InsertColumn("contact", contact.Text.Trim());
         insert.InsertColumn("crt_date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
         insert.InsertColumn("operator_name", HttpContext.Current.Request.Cookies["cookie"].Values["id"]);
         insert.InsertColumn("is_sccj", cboIsSCCJ.Checked == true ? "是" : "");
         insert.getInsertCommand();
         int count = insert.ExecuteNonQuery();
         if (count != 0)
         {
             ClientScript.RegisterStartupScript(ClientScript.GetType(), "showwindow", "<script>alert('" + Resources.Resource.alterOk + "!')</script>");
             getMaxId();
             vendor_aname.Text   = "";
             vendor_name.Text    = "";
             vendor_address.Text = "";
             city.Text           = "";
             tel.Text            = "";
             fax.Text            = "";
             contact.Text        = "";
             cboIsSCCJ.Checked   = false;
         }
     }
     else
     {
         ClientScript.RegisterStartupScript(ClientScript.GetType(), "showwindow", "<script>alert('" + Resources.Resource.alerttx + "')</script>");
     }
 }
示例#17
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);
        }
 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>");
     }
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (gvAddData.Rows.Count == 0)
            {
                return;
            }
            List <string>        sqlList = new List <string>();
            InsertCommandBuilder insert  = new InsertCommandBuilder();

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

            if (count != 0)
            {
                Response.Write("<script>alert('" + Resources.Resource.alterOk + "')</script>");
                lList.Clear();
                aList.Clear();
                gvAddData.DataSource = lList;
                gvAddData.DataBind();
                ClearTextBox();
                ddlMaterialStock.Enabled       = true;
                ddlMaterialStock.SelectedIndex = 0;
                gvDetailData.DataSource        = null;
                gvDetailData.DataBind();
            }
        }
示例#20
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);
     }
 }
示例#21
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());
        }
示例#22
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            List <string>        sqlList = new List <string>();
            SelectCommandBuilder select  = new SelectCommandBuilder(constr, "");
            string    sql         = "SELECT goods_id, qty, hwh FROM pre_str_out_bill_detail where str_out_bill_id='" + ViewState["Id"].ToString() + "'";
            DataTable DToutDetial = select.ExecuteDataTable(sql);

            if (DToutDetial != null && DToutDetial.Rows.Count != 0)
            {
                for (int i = 0; i < DToutDetial.Rows.Count; i++)
                {
                    string    goodsId = DToutDetial.Rows[i]["goods_id"].ToString();
                    int       dQty    = Convert.ToInt32(DToutDetial.Rows[i]["qty"]);
                    string    hwh     = DToutDetial.Rows[i]["hwh"].ToString();
                    string    sql1    = "SELECT stock_remain.goods_id, stock_remain.batch_id, stock_remain.qty,stock_remain.store_id, batch.hwh, batch.pch FROM stock_remain INNER JOIN batch ON stock_remain.batch_id = batch.batch_id where stock_remain.goods_id='" + goodsId + "' and batch.hwh='" + hwh + "' ORDER BY stock_remain.str_in_date";
                    DataTable DTQty   = select.ExecuteDataTable(sql1);
                    int       diffqty = 0;
                    for (int j = 0; j < DTQty.Rows.Count; j++)
                    {
                        diffqty = dQty - Convert.ToInt32(DTQty.Rows[j]["qty"]);
                        if (diffqty == 0)
                        {
                            InsertCommandBuilder ins = new InsertCommandBuilder(constr, "str_out_bill_detail");
                            ins.InsertColumn("str_out_bill_id", ViewState["Id"].ToString());
                            ins.InsertColumn("goods_id", DTQty.Rows[j]["goods_id"].ToString());
                            ins.InsertColumn("batch_id", DTQty.Rows[j]["batch_id"].ToString());
                            ins.InsertColumn("qty", dQty);
                            ins.InsertColumn("Can_sale", "Y");
                            ins.InsertColumn("delivery_plan_id", "");
                            sqlList.Add(ins.getInsertCommand());
                            string Rsql = "delete from stock_remain where goods_id='" + DTQty.Rows[j]["goods_id"].ToString() + "' and batch_id='" + DTQty.Rows[j]["batch_id"].ToString() + "'";
                            string Dsql = "delete from batch where goods_id='" + DTQty.Rows[j]["goods_id"].ToString() + "' and batch_id='" + DTQty.Rows[j]["batch_id"].ToString() + "'";
                            sqlList.Add(Rsql);
                            sqlList.Add(Dsql);
                            break;
                        }
                        else if (diffqty > 0)
                        {
                            InsertCommandBuilder ins = new InsertCommandBuilder(constr, "str_out_bill_detail");
                            ins.InsertColumn("str_out_bill_id", ViewState["Id"].ToString());
                            ins.InsertColumn("goods_id", DTQty.Rows[j]["goods_id"].ToString());
                            ins.InsertColumn("batch_id", DTQty.Rows[j]["batch_id"].ToString());
                            ins.InsertColumn("qty", Convert.ToInt32(DTQty.Rows[j]["qty"]));
                            ins.InsertColumn("Can_sale", "Y");
                            ins.InsertColumn("delivery_plan_id", "");
                            string Rsql = "delete from stock_remain where goods_id='" + DTQty.Rows[j]["goods_id"].ToString() + "' and batch_id='" + DTQty.Rows[j]["batch_id"].ToString() + "'";
                            string Dsql = "delete from batch where goods_id='" + DTQty.Rows[j]["goods_id"].ToString() + "' and batch_id='" + DTQty.Rows[j]["batch_id"].ToString() + "'";
                            sqlList.Add(ins.getInsertCommand());
                            sqlList.Add(Rsql);
                            sqlList.Add(Dsql);
                            dQty = diffqty;
                            continue;
                        }
                        else if (diffqty < 0)
                        {
                            InsertCommandBuilder ins = new InsertCommandBuilder(constr, "str_out_bill_detail");
                            ins.InsertColumn("str_out_bill_id", ViewState["Id"].ToString());
                            ins.InsertColumn("goods_id", DTQty.Rows[j]["goods_id"].ToString());
                            ins.InsertColumn("batch_id", DTQty.Rows[j]["batch_id"].ToString());
                            ins.InsertColumn("qty", diffqty);
                            ins.InsertColumn("Can_sale", "Y");
                            ins.InsertColumn("delivery_plan_id", "");
                            sqlList.Add(ins.getInsertCommand());
                            string Usql = "update stock_remain set qty = '" + Math.Abs(diffqty) + "' where goods_id='" + DTQty.Rows[j]["goods_id"].ToString() + "' and batch_id='" + DTQty.Rows[j]["batch_id"].ToString() + "'";
                            sqlList.Add(Usql);
                            break;
                        }
                    }
                }
            }
            sqlList.Add("insert into str_out_bill(str_out_bill_id,str_out_bill_no,str_out_type_id,str_out_date,operator_date,operator_id,come_to,remark) select str_out_bill_id,str_out_bill_no,lxrid,gatherdate,operator_date,operator_id,lxrname,remark  from  pre_str_out_bill where str_out_bill_id='" + ViewState["Id"].ToString() + "'");
            sqlList.Add("delete from pre_str_out_bill_detail where str_out_bill_id='" + ViewState["Id"].ToString() + "'");
            sqlList.Add("delete from pre_str_out_bill where str_out_bill_id='" + ViewState["Id"].ToString() + "'");
            int count = new InsertCommandBuilder(constr, "").ExcutTransaction(sqlList);

            if (count != 0)
            {
                Response.Redirect("StockIn_SaveOk.aspx", false);
            }
            else
            {
                gvData.DataSource = getConfirmData(ViewState["Id"].ToString());
                gvData.DataBind();
                Response.Write("<script>alert('操作失败')</script>");
            }
        }
示例#23
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>");
            }
        }
示例#24
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>");
            }
        }
示例#25
0
        protected int InsertData(string tableName, string id)
        {
            InsertCommandBuilder ins = new InsertCommandBuilder(constr, tableName);

            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", Convert.ToDecimal(txtCrushedscale.Text.Trim().Split('%')[0]) / 100);
            }
            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());
        }
        protected void sr_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtInput.Text))
                {
                    txtInput.Focus();
                    return;
                }
                switch (step)
                {
                case 0:
                    if (txtInput.Text.ToLower() != "begin")
                    {
                        sList.Insert(0, AppendDateTime("NG,指令错误"));
                        sList.Insert(0, AppendDateTime("开始指令???"));
                        alertMsg();
                        return;
                    }
                    step += 1;
                    sList.Insert(0, AppendDateTime("OK,工号???"));
                    alertMsg();
                    break;

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

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

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

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

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

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

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

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

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

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

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

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

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

            catch (Exception ex)
            {
                sList.Insert(0, AppendDateTime(ex.Message));
                sList.Insert(0, AppendDateTime("NG,出现错误,请重新刷读"));
                alertMsg();
            }
        }
        protected void 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();
        }
示例#28
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);
            }
        }
示例#29
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);
        }
示例#30
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>");
                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");
        }