Example #1
0
        //产品出库
        public static int CPOutsert(Model.CP cp)
        {
            SqlHelper.connectionStr = GetSQLConnect();
            string   ID     = cp.Id;
            string   CPTYPE = cp.Cptype;
            string   CPBH   = cp.Cpbh;
            string   CPMC   = cp.Cpmc;
            string   BDBH   = cp.Bdbh;
            string   SCBH   = cp.Scbh;
            string   CW     = cp.Cw;
            long     SL1    = cp.Sl1;
            long     SL2    = cp.Sl2;
            long     DDSL   = cp.Ddsl;
            DateTime ZDRQ   = cp.Zdrq;
            DateTime RQ     = cp.Rq;
            string   DW     = cp.Dw;
            string   REMARK = cp.Remark;
            string   TYDH   = cp.TYDH;
            string   sqlstr = "INSERT INTO  WMS_CP (ID,CPTYPE,CPBH,CPMC,BDBH,SCBH,CW,SL1,SL2,DDSL,ZDRQ,RQ,DW,TYDH,REMARK)";

            sqlstr += "  VALUES('" + ID + "','" + CPTYPE + "','" + CPBH + "','" + CPMC + "','" + BDBH + "','" + SCBH + "','" + CW + "'";
            sqlstr += ",'" + SL1 + "','" + SL2 + "','" + DDSL + "','" + ZDRQ + "','" + RQ + "','" + DW + "','" + TYDH + "','" + REMARK + "')";
            try
            {
                SqlHelper.ExecCommand(sqlstr);
                return(0);
            }
            catch
            {
                return(-1);
            }
        }
Example #2
0
        //确定
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            //验证出库数量是否大于申请数量
            long sum = 0;

            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                DataGridViewCheckBoxCell cb = (DataGridViewCheckBoxCell)this.dataGridView1.Rows[i].Cells[0];
                bool flag = Convert.ToBoolean(cb.Value);
                if (flag == true)
                {
                    sum = sum + Convert.ToInt64(this.dataGridView1.Rows[i].Cells["数量"].Value);
                }
            }
            if (sum > SQSL)
            {
                MessageBox.Show("实际出库数量不能大于申请出库数量", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            List <string> IDNEW = new List <string>();

            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                //判断是否选中
                DataGridViewCheckBoxCell cb = (DataGridViewCheckBoxCell)this.dataGridView1.Rows[i].Cells[0];
                bool flag = Convert.ToBoolean(cb.Value);
                if (flag == true)
                {
                    //判断数量是否有修改
                    string         id   = dt.Rows[i]["序号"].ToString();
                    SqlParameter[] para = { new SqlParameter("@DAH", SqlDbType.Text) };
                    para[0].Value = id;
                    DataTable dttemp = SqlHelper.ExecStoredProcedureDataTable("WMS_CheckCPCK", para);
                    //查询数量-界面获取数量
                    Int64 sl3 = Convert.ToInt64(dttemp.Rows[0][0].ToString()) - Convert.ToInt64(this.dataGridView1.Rows[i].Cells["数量"].Value);
                    if (sl3.Equals(0))
                    {
                        //数值没发生变化
                        Model.CP cp = new Model.CP();
                        cp.Id = Guid.NewGuid().ToString();
                        IDNEW.Add(cp.Id);
                        cp.Cptype = "1";
                        cp.Cpbh   = CPBH;
                        cp.Cpmc   = CPMC;
                        cp.Bdbh   = BDBH;
                        cp.Scbh   = id;
                        cp.Cw     = this.dataGridView1.Rows[i].Cells["仓位"].Value.ToString();
                        cp.Zdrq   = Convert.ToDateTime(ZDRQ);
                        cp.Rq     = DateTime.Now;
                        cp.Sl1    = SQSL;
                        cp.Dw     = DWMC;
                        cp.Sl2    = Convert.ToInt64(dttemp.Rows[0][0].ToString());
                        cp.Ddsl   = DDSL;
                        cp.TYDH   = DDBH;
                        cp.Remark = richTextBox1.Text;
                        SQL.SqlExecute.CPInsert(cp);
                        //更新出库余量
                        //查询现在余量
                        int xh = XH(BDBH, DDBH, CPBH);
                        SqlHelper.ExecCommand("UPDATE KC_CPCK_D SET YL=" + (Convert.ToUInt64(SQSL) - (Convert.ToUInt64(this.dataGridView1.Rows[i].Cells["数量"].Value))) + " WHERE xh=" + xh + "");
                        //更新入库记录
                        SqlHelper.ExecCommand("UPDATE WMS_CP SET SL3=" + sl3 + " WHERE ID='" + id + "'");

                        #region dtpublic插入数据
                        DataRow drrow = dtpublic.NewRow();//创建新行
                        drrow["出库单号"]   = BDBH;
                        drrow["产品编号"]   = CPBH;
                        drrow["产品名称"]   = CPMC;
                        drrow["仓位名称"]   = this.dataGridView1.Rows[i].Cells["仓位"].Value.ToString();
                        drrow["每盘出库数量"] = Convert.ToInt64(dttemp.Rows[0][0].ToString());
                        drrow["单位"]     = DWMC;
                        drrow["出库时间"]   = DateTime.Now;
                        dtpublic.Rows.Add(drrow);  //将新行加入到表中
                        #endregion
                    }
                    else if (sl3 > 0)
                    {
                        //数值修改变化
                        //写入出库记录
                        Model.CP cp = new Model.CP();
                        cp.Id = Guid.NewGuid().ToString();
                        IDNEW.Add(cp.Id);
                        cp.Cptype = "1";
                        cp.Cpbh   = CPBH;
                        cp.Cpmc   = CPMC;
                        cp.Bdbh   = BDBH;
                        cp.Scbh   = id;
                        cp.Cw     = this.dataGridView1.Rows[i].Cells["仓位"].Value.ToString();
                        cp.Sl1    = SQSL;
                        cp.Sl2    = Convert.ToUInt32(this.dataGridView1.Rows[i].Cells["数量"].Value);
                        cp.Ddsl   = DDSL;
                        cp.Dw     = DWMC;
                        cp.Zdrq   = Convert.ToDateTime(ZDRQ);
                        cp.Rq     = DateTime.Now;
                        cp.TYDH   = DDBH;
                        cp.Remark = richTextBox1.Text;
                        SQL.SqlExecute.CPInsert(cp);
                        //更新出库余量
                        //查询现在余量
                        int xh = XH(BDBH, DDBH, CPBH);
                        SqlHelper.ExecCommand("UPDATE KC_CPCK_D SET YL=" + (Convert.ToUInt64(SQSL) - (Convert.ToUInt64(this.dataGridView1.Rows[i].Cells["数量"].Value))) + " WHERE xh=" + xh + "");
                        //写入入库余量
                        SqlHelper.ExecCommand("UPDATE WMS_CP SET SL3=" + sl3 + " WHERE ID='" + id + "'");

                        #region dtpublic插入数据
                        DataRow drrow = dtpublic.NewRow();  //创建新行
                        drrow["出库单号"]   = BDBH;
                        drrow["产品编号"]   = CPBH;
                        drrow["产品名称"]   = CPMC;
                        drrow["仓位名称"]   = this.dataGridView1.Rows[i].Cells["仓位"].Value.ToString();
                        drrow["每盘出库数量"] = Convert.ToUInt32(this.dataGridView1.Rows[i].Cells["数量"].Value);
                        drrow["单位"]     = DWMC;
                        drrow["出库时间"]   = DateTime.Now;
                        dtpublic.Rows.Add(drrow);  //将新行加入到表中
                        #endregion
                    }
                    else if (sl3 < 0)
                    {
                        MessageBox.Show("出库数量不能大于每盘现存数量", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            WMS_Gimped.Controls.ProductsC.dtpublic = dtpublic;
            DialogResult = DialogResult.OK;
        }
Example #3
0
        //确定
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            int    index = 0;
            string cw    = null;

            //判断CheckList选择项不能为多个
            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                if (checkedListBox1.GetItemChecked(i))
                {
                    index = index + 1;
                    cw    = checkedListBox1.Items[i].ToString();
                }
            }
            if (index >= 2)
            {
                MessageBox.Show("仓位不能为多个", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cw.Equals(null))
            {
                MessageBox.Show("仓位不能为空", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (cw.Equals(CW))
            {
                Int32 SLL = (Convert.ToInt32(SL) - Convert.ToInt32(textEdit2.Text));
                if (!SLL.Equals(0))
                {
                    MessageBox.Show("整盘移仓操作,数量不能修改", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                //整盘移库
                SqlHelper.ExecCommand("UPDATE WMS_CP SET CW='" + cw + "' WHERE ID='" + ID + "'");
            }
            else
            {
                //部分移库
                //原仓位
                Int32 SLL = (Convert.ToInt32(SL) - Convert.ToInt32(textEdit2.Text));
                if (SLL < 0)
                {
                    MessageBox.Show("移库数量不能大于原仓位数量", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                string sql = "UPDATE WMS_CP SET SL3=" + SLL + ",SCBH='" + ID + "' WHERE ID='" + ID + "'";
                SqlHelper.ExecCommand(sql);
                //新仓位
                //查找原数据
                DataTable dttemp = SqlHelper.ExecuteDataTable("SELECT * FROM WMS_CP WHERE ID='" + ID + "'");
                #region 插入新数据
                Model.CP C1 = new Model.CP();
                C1.Id     = Guid.NewGuid().ToString(); //ID
                C1.Cptype = "0";                       //类型
                C1.Cpbh   = dttemp.Rows[0]["CPBH"].ToString();
                C1.Cpmc   = dttemp.Rows[0]["CPMC"].ToString();
                C1.Bdbh   = dttemp.Rows[0]["BDBH"].ToString();
                C1.Cw     = cw;
                C1.Scbh   = ID;
                C1.Sl1    = Convert.ToUInt32(dttemp.Rows[0]["SL1"].ToString());
                C1.Sl3    = Convert.ToUInt32(textEdit2.Text);
                C1.Ddsl   = Convert.ToUInt32(dttemp.Rows[0]["DDSL"].ToString());
                C1.Zdrq   = Convert.ToDateTime(dttemp.Rows[0]["ZDRQ"].ToString());
                C1.Rq     = Convert.ToDateTime(dttemp.Rows[0]["RQ"].ToString());
                C1.Dw     = (dttemp.Rows[0]["DW"].ToString());
                C1.Remark = (dttemp.Rows[0]["REMARK"].ToString());
                SQL.SqlExecute.CPInsert(C1);
                #endregion
            }
            DialogResult = DialogResult.OK;
        }
Example #4
0
        //确定分盘操作结果
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            if (!Convert.ToUInt64(textBox7.Text).Equals(0))
            {
                MessageBox.Show("存在未入库的产品", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (dataGridView1.RowCount.Equals(0))
            {
                MessageBox.Show("请添加每盘入库明细", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #region 审核入库单
            SqlParameter[] para =
            {
                new SqlParameter("@BDBH", SqlDbType.Text),
                new SqlParameter("@SHR",  SqlDbType.Text),
            };
            ERPInquire3.HelpClass.iniFileHelper ini = new ERPInquire3.HelpClass.iniFileHelper(Application.StartupPath + "/data/Config.ini");
            para[0].Value = BDBH;
            para[1].Value = ini.ReadString("Login", "Code", "");
            SqlHelper.ExecStoredProcedureDataTable("WMS_RKBJ", para);
            #endregion

            #region 将数据录入系统中
            Model.CP C1 = new Model.CP();
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                C1.Id     = Guid.NewGuid().ToString();                                         //ID
                C1.Cptype = "0";                                                               //类型
                C1.Cpbh   = CPBH;                                                              //产品编号
                C1.Cpmc   = CPMC;                                                              //产品名称
                C1.Bdbh   = BDBH;                                                              //入库单号
                C1.Cw     = dataGridView1.Rows[i].Cells[0].Value.ToString();                   //仓位名称
                C1.Sl1    = Convert.ToUInt32(RKSL);                                            //入库数量
                C1.Sl2    = Convert.ToUInt32(dataGridView1.Rows[i].Cells[1].Value.ToString()); //每盘入库数量
                C1.Sl3    = Convert.ToUInt32(dataGridView1.Rows[i].Cells[1].Value.ToString()); //每盘出库余量
                C1.Ddsl   = Convert.ToInt64(DDSL);                                             //订单数量
                C1.Zdrq   = Convert.ToDateTime(ZDRQ);                                          //制单日期
                C1.Rq     = DateTime.Now;                                                      //入库时间
                C1.Dw     = DWMC;                                                              //单位
                C1.Remark = richTextBox1.Text;                                                 //备注
                C1.TYDH   = GetGDH(BDBH);
                SQL.SqlExecute.CPInsert(C1);

                #region dtpublic创建时间
                DataRow drrow = dtpublic.NewRow();     //创建新行
                drrow["入库单号"]   = BDBH;
                drrow["产品编号"]   = CPBH;
                drrow["产品名称"]   = CPMC;
                drrow["仓位名称"]   = dataGridView1.Rows[i].Cells[0].Value.ToString();
                drrow["每盘入库数量"] = dataGridView1.Rows[i].Cells[1].Value.ToString();
                drrow["单位"]     = DWMC;
                drrow["入库时间"]   = DateTime.Now;
                dtpublic.Rows.Add(drrow);     //将新行加入到表中
                #endregion
            }
            #endregion

            #region 返回页面刷新页面
            DialogResult = DialogResult.OK;
            #endregion
        }