Beispiel #1
0
        private void btnBack_Click(object sender, EventArgs e)
        {
            try
            {
                //string strOrderNo = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["生产订单号"].Value.ToString();
                string strWorkShop  = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["车间"].Value.ToString();
                string strGoodsCode = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["物料"].Value.ToString();
                string strBatch     = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["批次"].Value.ToString();
                string strQty       = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["数量"].Value.ToString();
                string strPrice     = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["价格"].Value.ToString();
                string strGoodsName = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["物料名称"].Value.ToString();
                string strUnit      = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["单位"].Value.ToString();
                string strId        = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["Id"].Value.ToString();
                string strStockCode = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["仓库编码"].Value.ToString();
                string strStockName = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["仓库名称"].Value.ToString();
                //string strDate = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["W_Price"].Value.ToString();

                if (MessageBox.Show("物料是否要退回仓库?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                {
                    Mes_OutWorkShopHeadBLL OutWorkShopHeadBLL = new Mes_OutWorkShopHeadBLL();

                    try
                    {
                        this.Enabled   = false;
                        Cursor.Current = Cursors.WaitCursor;



                        Mes_OutWorkShopDetailBLL    OutWorkShopDetailBLL    = new Mes_OutWorkShopDetailBLL();
                        Mes_OutWorkShopHeadEntity   OutWorkShopHeadEntity   = new Mes_OutWorkShopHeadEntity();
                        Mes_OutWorkShopDetailEntity OutWorkShopDetailEntity = new Mes_OutWorkShopDetailEntity();

                        string strIn_No = "";


                        MesMaterInHeadBLL MaterInHeadBLL = new MesMaterInHeadBLL();
                        strIn_No = MaterInHeadBLL.GetDH("线边仓出库到车间单");

                        //var rowsHead = OutWorkShopHeadBLL.GetList_OutWorkShopHead("where 1 = 1 order by O_OutNo DESC");
                        //if (rowsHead == null || rowsHead.Count < 1)
                        //{
                        //    strIn_No = "OW" + DateTime.Now.ToString("yyyyMMdd") + "000001";
                        //}
                        //else
                        //{
                        //    string strDate = rowsHead[0].O_OutNo.Substring(2, 8);
                        //    if (strDate == DateTime.Now.ToString("yyyyMMdd"))
                        //    {
                        //        string strList = rowsHead[0].O_OutNo.Substring(10, 4);
                        //        int nList = Convert.ToInt32(strList) + 1;
                        //        strIn_No = "OW" + DateTime.Now.ToString("yyyyMMdd") + nList.ToString().PadLeft(4, '0');
                        //    }
                        //    else
                        //    {
                        //        strIn_No = "OW" + DateTime.Now.ToString("yyyyMMdd") + "000001";
                        //    }

                        //}

                        OutWorkShopHeadEntity.O_OutNo      = strIn_No;
                        OutWorkShopHeadEntity.O_OrderNo    = "";
                        OutWorkShopHeadEntity.O_StockCode  = strStockCode;
                        OutWorkShopHeadEntity.O_StockName  = strStockName;
                        OutWorkShopHeadEntity.O_CreateBy   = Globels.strUser;
                        OutWorkShopHeadEntity.O_CreateDate = DateTime.Now;
                        OutWorkShopHeadEntity.O_OrderDate  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        OutWorkShopHeadEntity.O_Remark     = "";
                        OutWorkShopHeadEntity.O_Status     = 1;
                        OutWorkShopHeadEntity.O_WorkShop   = txtWorkShop.Text;
                        OutWorkShopHeadEntity.O_Kind       = 2;



                        int nRow = OutWorkShopHeadBLL.SaveEntity("", OutWorkShopHeadEntity);

                        //for (int i = 0; i < rows.Count; i++)
                        //{
                        OutWorkShopDetailEntity.O_GoodsCode = strGoodsCode;
                        OutWorkShopDetailEntity.O_GoodsName = strGoodsName;
                        OutWorkShopDetailEntity.O_OutNo     = strIn_No;
                        OutWorkShopDetailEntity.O_Price     = Convert.ToDecimal(strPrice);
                        OutWorkShopDetailEntity.O_Qty       = Convert.ToDecimal(strQty);
                        OutWorkShopDetailEntity.O_Remark    = "";
                        OutWorkShopDetailEntity.O_Unit      = strUnit;
                        OutWorkShopDetailEntity.O_Batch     = strBatch;

                        nRow = OutWorkShopDetailBLL.SaveEntity("", OutWorkShopDetailEntity);

                        //}
                        MessageBox.Show("保存成功");
                        Upload(strIn_No);
                        string Barcode = strGoodsCode + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        //GetImg("物料" + strGoodsCode + "批次" + strBatch + "单号" + Globels.strOrderNo, strGoodsName, strQty, strGoodsCode, strBatch, Barcode);
                        //SaveBarcode(Barcode, strGoodsCode, strGoodsName, OutWorkShopDetailEntity.O_Qty, OutWorkShopHeadEntity.O_WorkShop);
                        DeleteData(strId);

                        UpdateGoods();

                        this.Enabled   = true;
                        Cursor.Current = Cursors.Default;
                    }
                    catch (Exception ex)
                    {
                        this.Enabled   = true;
                        Cursor.Current = Cursors.Default;
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show("请选中某一行进行退仓库");
                lblTS.Text = "系统提示:请选中某一行进行退仓库";
            }
        }
Beispiel #2
0
        private void btn_upload_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("是否要完工?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                {
                    Mes_OutWorkShopTempBLL OutWorkShopTempBLL = new Mes_OutWorkShopTempBLL();
                    var rows = OutWorkShopTempBLL.GetList_OutWorkShopTemp("where O_StockCode = '" + cmbStock.Text + "' and O_WorkShop = '" + cmbWorkShop.Text + "' and O_OrderNo = '" + comOrderNo.Text + "'");
                    if (rows == null || rows.Count < 1)
                    {
                        //untCommon.InfoMsg("没有任何数据!");
                        lblTS.Text = "没有任何数据!";
                        return;
                    }

                    Mes_OutWorkShopHeadBLL      OutWorkShopHeadBLL      = new Mes_OutWorkShopHeadBLL();
                    Mes_OutWorkShopDetailBLL    OutWorkShopDetailBLL    = new Mes_OutWorkShopDetailBLL();
                    Mes_OutWorkShopHeadEntity   OutWorkShopHeadEntity   = new Mes_OutWorkShopHeadEntity();
                    Mes_OutWorkShopDetailEntity OutWorkShopDetailEntity = new Mes_OutWorkShopDetailEntity();

                    string            strIn_No       = "";
                    MesMaterInHeadBLL MaterInHeadBLL = new MesMaterInHeadBLL();
                    strIn_No = MaterInHeadBLL.GetDH("线边仓出库到车间单");

                    /*var rowsHead = OutWorkShopHeadBLL.GetList_OutWorkShopHead("where 1 = 1 order by O_OutNo DESC");
                     * if (rowsHead == null || rowsHead.Count < 1)
                     * {
                     *  strIn_No = "OW" + DateTime.Now.ToString("yyyyMMdd") + "000001";
                     * }
                     * else
                     * {
                     *  string strDate = rowsHead[0].O_OutNo.Substring(2, 8);
                     *  if (strDate == DateTime.Now.ToString("yyyyMMdd"))
                     *  {
                     *      string strList = rowsHead[0].O_OutNo.Substring(10, 6);
                     *      int nList = Convert.ToInt32(strList) + 1;
                     *      strIn_No = "OW" + DateTime.Now.ToString("yyyyMMdd") + nList.ToString().PadLeft(6, '0');
                     *  }
                     *  else
                     *  {
                     *      strIn_No = "OW" + DateTime.Now.ToString("yyyyMMdd") + "000001";
                     *  }
                     *
                     * }*/

                    OutWorkShopHeadEntity.O_OutNo      = strIn_No;
                    OutWorkShopHeadEntity.O_OrderNo    = comOrderNo.Text;
                    OutWorkShopHeadEntity.O_StockCode  = cmbStock.Text;
                    OutWorkShopHeadEntity.O_StockName  = cmbStockName.Text;
                    OutWorkShopHeadEntity.O_CreateBy   = Globels.strUser;
                    OutWorkShopHeadEntity.O_CreateDate = DateTime.Now;
                    OutWorkShopHeadEntity.O_OrderDate  = txtOrderDate.Text;
                    OutWorkShopHeadEntity.O_Remark     = "";
                    OutWorkShopHeadEntity.O_Status     = 1;
                    OutWorkShopHeadEntity.O_WorkShop   = cmbWorkShop.Text;
                    OutWorkShopHeadEntity.O_Kind       = 1;



                    int nRow = OutWorkShopHeadBLL.SaveEntity("", OutWorkShopHeadEntity);

                    for (int i = 0; i < rows.Count; i++)
                    {
                        OutWorkShopDetailEntity.O_GoodsCode = rows[i].O_GoodsCode;
                        OutWorkShopDetailEntity.O_GoodsName = rows[i].O_GoodsName;
                        OutWorkShopDetailEntity.O_OutNo     = strIn_No;
                        OutWorkShopDetailEntity.O_Price     = rows[i].O_Price;
                        OutWorkShopDetailEntity.O_Qty       = rows[i].O_Qty;
                        OutWorkShopDetailEntity.O_Remark    = rows[i].O_Remark;
                        OutWorkShopDetailEntity.O_Unit      = rows[i].O_Unit;
                        OutWorkShopDetailEntity.O_Batch     = rows[i].O_Batch;

                        nRow = OutWorkShopDetailBLL.SaveEntity("", OutWorkShopDetailEntity);
                    }
                    Upload(strIn_No);
                    MessageBox.Show("保存成功");
                    lblTS.Text = "";
                    DeleteData();
                    Update();
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.ToString());
                lblTS.Text = ex.ToString();
            }
        }