コード例 #1
0
        private void btn_Upload_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否提交", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
            {
                try
                {
                    Mes_ScrapHeadEntity   ScrapHeadEntity   = new Mes_ScrapHeadEntity();
                    Mes_ScrapHeadBLL      ScrapHeadBLL      = new Mes_ScrapHeadBLL();
                    Mes_ScrapDetailEntity ScrapDetailEntity = new Mes_ScrapDetailEntity();
                    Mes_ScrapDetailBLL    ScrapDetailBLL    = new Mes_ScrapDetailBLL();


                    MesMaterInHeadBLL MaterInHeadBLL = new MesMaterInHeadBLL();
                    string            strScrapNo     = MaterInHeadBLL.GetDH("报废单");
                    ScrapHeadEntity.S_ScrapNo    = strScrapNo;
                    ScrapHeadEntity.S_StockCode  = cmbStock.Text;
                    ScrapHeadEntity.S_StockName  = cmbStockName.Text;
                    ScrapHeadEntity.S_CreateBy   = Globels.strUser;
                    ScrapHeadEntity.S_CreateDate = DateTime.Now;
                    ScrapHeadEntity.S_OrderDate  = DateTime.Now;
                    ScrapHeadEntity.S_Remark     = "";
                    ScrapHeadEntity.S_Status     = 1;

                    ScrapHeadBLL.SaveEntity("", ScrapHeadEntity);
                    int nCount = listView1.Items.Count;
                    for (int i = 0; i < nCount; i++)
                    {
                        ScrapDetailEntity.S_ScrapNo   = strScrapNo;
                        ScrapDetailEntity.S_Batch     = listView1.Items[i].SubItems[4].Text;
                        ScrapDetailEntity.S_GoodsCode = listView1.Items[i].SubItems[2].Text;
                        ScrapDetailEntity.S_GoodsName = listView1.Items[i].SubItems[3].Text;
                        ScrapDetailEntity.S_Price     = Convert.ToDecimal(listView1.Items[i].SubItems[7].Text);
                        ScrapDetailEntity.S_Unit      = listView1.Items[i].SubItems[6].Text;
                        ScrapDetailEntity.S_Qty       = Convert.ToDecimal(listView1.Items[i].SubItems[5].Text);
                        ScrapDetailEntity.S_Remark    = "";

                        ScrapDetailBLL.SaveEntity("", ScrapDetailEntity);
                    }

                    MessageBox.Show("报废提交成功");

                    listView1.Items.Clear();
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.ToString());
                    lblTS.Text = "系统提示:" + ex.ToString();
                }
            }
        }
コード例 #2
0
ファイル: frmGoodsConvet.cs プロジェクト: zhouyb1/BeiJing_MES
        private void btn_Convet_Click(object sender, EventArgs e)
        {
            try
            {
                List <string> Goods        = new List <string>();
                List <string> strOldGoods  = new List <string>();
                int           nKind        = 0; //计算有几种原物料
                int           nLen         = dataGridView1.Rows.Count;
                string        strStockName = "";
                string        strStockCode = "";

                for (int i = 0; i < nLen - 1; i++)
                {
                    object obj = dataGridView1.Rows[i].Cells["选择"].Value;
                    //if (Convert.ToString(obj) == "True" || Convert.ToString(obj) == "1")
                    //{
                    string strGoods = dataGridView1.Rows[i].Cells["物料"].Value.ToString();
                    string strQty   = dataGridView1.Rows[i].Cells["实用数量"].Value.ToString();
                    string strYLQty = dataGridView1.Rows[i].Cells["数量"].Value.ToString();
                    strStockCode = dataGridView1.Rows[i].Cells["仓库编码"].Value.ToString();
                    strStockName = dataGridView1.Rows[i].Cells["仓库名称"].Value.ToString();

                    //string strPc = dataGridView1.Rows[i].Cells["批次"].Value.ToString();
                    string strPrice = dataGridView1.Rows[i].Cells["价格"].Value.ToString();
                    string strName  = dataGridView1.Rows[i].Cells["物料名称"].Value.ToString();
                    string strUnit  = dataGridView1.Rows[i].Cells["单位"].Value.ToString();

                    if (Convert.ToDecimal(strQty) > Convert.ToDecimal(strYLQty))
                    {
                        lblTS.Text = "系统提示:物料:" + strName + "实用数量不能大于库存数量";
                        return;
                    }
                    if (Convert.ToDecimal(strQty) == 0 || Convert.ToDecimal(strQty) < 0)
                    {
                        lblTS.Text = "系统提示:物料:" + strName + "实用数量不能为0或者负数";
                        return;
                    }

                    if (Jud(strGoods, txtGoodsCode.Text))
                    {
                        if (strOldGoods.Contains(strGoods))
                        {
                        }
                        else
                        {
                            nKind = nKind + 1;
                            strOldGoods.Add(strGoods);
                        }
                        bool bRet = false;
                        for (int j = 0; j < Goods.Count; j++)
                        {
                            string   strTemp      = Goods[j].ToString();
                            string[] str          = strTemp.Split(',');
                            string   strTempGoods = str[0].ToString();
                            string   strTempPc    = str[2].ToString();
                            string   strTempQty   = str[3].ToString();
                            if (strTempGoods == strGoods)
                            {
                                decimal dQty = Convert.ToDecimal(strQty) + Convert.ToDecimal(strTempQty);
                                Goods[j] = strGoods + "," + dQty.ToString() + "," + strPrice + "," + strName + "," + strUnit;
                                bRet     = true;
                            }
                        }
                        if (bRet == false)
                        {
                            Goods.Add(strGoods + "," + strQty + "," + strPrice + "," + strName + "," + strUnit);
                        }
                        //}
                        else
                        {
                            lblTS.Text = "系统提示:选择的物料生成不了下一个物料,请核对";
                            return;
                        }
                    }
                }

                if (!Jud2(nKind, txtGoodsCode.Text))
                {
                    lblTS.Text = "系统提示:选择的转换前的物料不够";
                    return;
                }


                Mes_OrgResHeadBLL      OrgResHeadBLL      = new Mes_OrgResHeadBLL();
                Mes_OrgResDetailBLL    OrgResDetailBLL    = new Mes_OrgResDetailBLL();
                Mes_OrgResHeadEntity   OrgResHeadEntity   = new Mes_OrgResHeadEntity();
                Mes_OrgResDetailEntity OrgResDetailEntity = new Mes_OrgResDetailEntity();

                string strIn_No = "";

                MesMaterInHeadBLL MaterInHeadBLL = new MesMaterInHeadBLL();
                strIn_No = MaterInHeadBLL.GetDH("组装与拆分单");

                OrgResHeadEntity.O_OrgResNo = strIn_No;
                OrgResHeadEntity.O_OrderNo  = "";

                OrgResHeadEntity.O_CreateBy     = Globels.strUser;
                OrgResHeadEntity.O_CreateDate   = DateTime.Now;
                OrgResHeadEntity.O_OrderDate    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                OrgResHeadEntity.O_Remark       = "";
                OrgResHeadEntity.O_Status       = 1;
                OrgResHeadEntity.O_StockCode    = strStockCode;
                OrgResHeadEntity.O_StockName    = strStockName;
                OrgResHeadEntity.O_WorkShopCode = Globels.strWorkShop;
                OrgResHeadEntity.O_WorkShopName = Globels.strWorkShopName;
                OrgResHeadEntity.O_Record       = "";
                OrgResHeadEntity.O_ProCode      = Globels.strProce;
                OrgResHeadEntity.O_TeamCode     = Globels.strTeam;
                OrgResHeadEntity.O_TeamName     = Globels.strTeamName;

                int     nRow      = OrgResHeadBLL.SaveEntity("", OrgResHeadEntity);
                decimal dSecPrice = 0;
                decimal dTotal    = 0;
                for (int i = 0; i < Goods.Count; i++)
                {
                    string[] strTemp = Goods[i].ToString().Split(',');
                    dTotal = dTotal + (Convert.ToDecimal(strTemp[2].ToString()) * Convert.ToDecimal(strTemp[1].ToString()));
                }
                dSecPrice = dTotal / Convert.ToDecimal(txtQty.Text);


                for (int i = 0; i < Goods.Count; i++)
                {
                    OrgResDetailEntity.O_OrgResNo     = strIn_No;
                    OrgResDetailEntity.O_SecGoodsCode = txtGoodsCode.Text;
                    OrgResDetailEntity.O_SecGoodsName = txtGoodsName.Text;
                    OrgResDetailEntity.O_SecPrice     = 0;
                    OrgResDetailEntity.O_SecQty       = Convert.ToDecimal(txtQty.Text);
                    OrgResDetailEntity.O_SecUnit      = m_strUnit;
                    OrgResDetailEntity.O_SecBatch     = txtPc.Text;

                    string[] strTemp = Goods[i].ToString().Split(',');

                    string strGoodsCode = strTemp[0].ToString();
                    //Mes_ConvertBLL ConvertBLL = new Mes_ConvertBLL();
                    //var Convert_rows = ConvertBLL.GetList_Mes_Convert(" where C_SecCode = '" + strGoodsCode + "'");
                    //string strC_GoodsCode = "";
                    //if (Convert_rows.Count > 0)
                    //{
                    //    strC_GoodsCode = Convert_rows[0].C_Code;
                    //}
                    MesInventoryBLL InventoryBLL  = new MesInventoryBLL();
                    var             Inventory_row = InventoryBLL.GetData(" where I_StockCode = '" + Globels.strStockCode + "' and I_GoodsCode = '" + strGoodsCode + "' and I_Qty > 0 order by I_Batch");
                    if (Inventory_row.Count > 0)
                    {
                        Decimal dTotalQty = Convert.ToDecimal(strTemp[1].ToString());
                        for (int j = 0; j < Inventory_row.Count; j++)
                        {
                            if (dTotalQty > 0)
                            {
                                if (dTotalQty < Inventory_row[j].I_Qty)
                                {
                                    OrgResDetailEntity.O_GoodsCode = strTemp[0].ToString();
                                    OrgResDetailEntity.O_GoodsName = strTemp[3].ToString();
                                    OrgResDetailEntity.O_Price     = Convert.ToDecimal(strTemp[2].ToString());
                                    OrgResDetailEntity.O_Qty       = dTotalQty;
                                    OrgResDetailEntity.O_Unit      = strTemp[4].ToString();
                                    OrgResDetailEntity.O_Batch     = Inventory_row[j].I_Batch;
                                    OrgResDetailEntity.O_SecPrice  = dSecPrice;
                                    nRow = OrgResDetailBLL.SaveEntity("", OrgResDetailEntity);
                                    //UpdateData(Inventory_row[j].ID, Inventory_row[j].I_Qty - dTotalQty);
                                    break;
                                }
                                else
                                {
                                    OrgResDetailEntity.O_GoodsCode = strTemp[0].ToString();
                                    OrgResDetailEntity.O_GoodsName = strTemp[3].ToString();
                                    OrgResDetailEntity.O_Price     = Convert.ToDecimal(strTemp[2].ToString());
                                    OrgResDetailEntity.O_Qty       = Inventory_row[j].I_Qty;
                                    OrgResDetailEntity.O_Unit      = strTemp[4].ToString();
                                    OrgResDetailEntity.O_Batch     = Inventory_row[j].I_Batch;
                                    OrgResDetailEntity.O_SecPrice  = dSecPrice;
                                    nRow      = OrgResDetailBLL.SaveEntity("", OrgResDetailEntity);
                                    dTotalQty = dTotalQty - Inventory_row[j].I_Qty;
                                    //DeleteData(Inventory_row[j].ID);
                                }
                            }
                        }
                    }

                    //OrgResDetailEntity.O_GoodsCode = strTemp[0].ToString();
                    //OrgResDetailEntity.O_GoodsName = strTemp[4].ToString();
                    //OrgResDetailEntity.O_Price = Convert.ToDecimal(strTemp[3].ToString());
                    //OrgResDetailEntity.O_Qty = Convert.ToDecimal(strTemp[1].ToString());
                    //OrgResDetailEntity.O_Unit = strTemp[5].ToString();
                    //OrgResDetailEntity.O_Batch = strTemp[2].ToString();
                    //OrgResDetailEntity.O_SecPrice = dSecPrice;
                    //nRow = OrgResDetailBLL.SaveEntity("", OrgResDetailEntity);
                }
                Upload(strIn_No);
                MessageBox.Show("保存成功");
                lblTS.Text = "";
                //UpdatePrice(strSecGoods, dSecPrice);  已经在存储过程中处理
                Delete();
                //Update();
                this.Close();
            }
            catch (Exception ex)
            {
                lblTS.Text = ex.ToString();
                return;
            }
        }
コード例 #3
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 = "系统提示:请选中某一行进行退仓库";
            }
        }
コード例 #4
0
ファイル: frmStorageAdd.cs プロジェクト: zhouyb1/BeiJing_MES
        /// <summary>
        /// 保存
        /// </summary>
        private void addStorage()
        {
            try
            {
                //MesProductOrderHeadBLL MesProductOrderHeadBLL = new MesProductOrderHeadBLL();
                //var rows = MesProductOrderHeadBLL.GetList(txtOrderNo.Text.Trim());
                //if (rows == null || rows.Count < 1)
                //{
                //    untCommon.InfoMsg("输入的生产订单号错误,请重新输入!");
                //    txtOrderNo.Focus();
                //    txtOrderNo.SelectAll();
                //    return;
                //}

                string[] strStock   = comStock.Text.ToString().Split('$');
                string[] strProduct = comProductNo.Text.ToString().Split('$');
                string[] strSupply  = cmbSupply.Text.ToString().Split('$');

                MesMaterInHeadBLL MesMaterInHeadBLL = new MesMaterInHeadBLL();
                if (checkInput())
                {
                    MesMaterInHeadEntity MesMaterInHead = new MesMaterInHeadEntity();

                    MesMaterInHead.M_MaterInNo = txtMaterInNo.Text;
                    MesMaterInHead.M_OrderKind = 0;
                    MesMaterInHead.M_StockCode = strStock[0];
                    //MesMaterInHead.M_Kind = "0";
                    MesMaterInHead.M_StockName  = strStock[1];
                    MesMaterInHead.M_SupplyCode = strSupply[0];
                    MesMaterInHead.M_SupplyName = strSupply[1];
                    MesMaterInHead.M_OrderNo    = strProduct[0];
                    MesMaterInHead.M_OrderDate  = DateTime.Parse(strProduct[1].ToString());
                    MesMaterInHead.M_Status     = 1;
                    MesMaterInHead.M_CreateBy   = txtCreateBy.Text;
                    MesMaterInHead.M_CreateDate = DateTime.Now;
                    MesMaterInHead.M_UpdateDate = null;
                    MesMaterInHead.M_DeleteDate = null;
                    MesMaterInHead.M_UploadDate = null;



                    if (MesMaterInHeadBLL.SaveEntity("", MesMaterInHead) > 0)
                    {
                        untCommon.InfoMsg("添加成功!");
                        string strTime      = DateTime.Now.ToString("yyyy-MM-dd ");
                        string strStartTime = strTime + "00:00:00";
                        string strEndTime   = strTime + "23:59:59";
                        string strCondit    = " and M_CreateDate > '" + strStartTime + "' and M_CreateDate < '" + strEndTime + "'";
                        frmStorage.loadData(strCondit);
                        Close();
                        //frmStorage.Refresh();
                    }
                    else
                    {
                        untCommon.InfoMsg("添加失败!");
                    }
                }
            }
            catch (Exception ex)
            {
                untCommon.ErrorMsg("设备管理添加数据异常:" + ex.Message);
            }
        }
コード例 #5
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("是否要提交", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                {
                    Mes_InWorkShopTempBLL InWorkShopTempBLL = new Mes_InWorkShopTempBLL();
                    var rows = InWorkShopTempBLL.GetList_InWorkShopTemp("where I_StockCode = '" + cmbStock.Text + "' and I_WorkShop = '" + cmbWorkShop.Text + "' and I_OrderNo = '" + comOrderNo.Text + "'");
                    if (rows == null || rows.Count < 1)
                    {
                        //untCommon.InfoMsg("没有任何数据!");
                        lblTS.Text = "系统提示:没有任何数据!";
                        return;
                    }

                    Mes_InWorkShopHeadBLL      InWorkShopHeadBLL      = new Mes_InWorkShopHeadBLL();
                    Mes_InWorkShopDetailBLL    InWorkShopDetailBLL    = new Mes_InWorkShopDetailBLL();
                    Mes_InWorkShopHeadEntity   InWorkShopHeadEntity   = new Mes_InWorkShopHeadEntity();
                    Mes_InWorkShopDetailEntity InWorkShopDetailEntity = new Mes_InWorkShopDetailEntity();

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

                    InWorkShopHeadEntity.I_InNo       = strIn_No;
                    InWorkShopHeadEntity.I_OrderNo    = comOrderNo.Text;
                    InWorkShopHeadEntity.I_StockCode  = cmbStock.Text;
                    InWorkShopHeadEntity.I_StockName  = cmbStockName.Text;
                    InWorkShopHeadEntity.I_CreateBy   = "";
                    InWorkShopHeadEntity.I_CreateDate = DateTime.Now;
                    InWorkShopHeadEntity.I_OrderDate  = txtOrderDate.Text;
                    InWorkShopHeadEntity.I_Remark     = "";
                    InWorkShopHeadEntity.I_Status     = 1;
                    InWorkShopHeadEntity.I_WorkShop   = cmbWorkShop.Text;

                    int nRow = InWorkShopHeadBLL.SaveEntity("", InWorkShopHeadEntity);

                    for (int i = 0; i < rows.Count; i++)
                    {
                        InWorkShopDetailEntity.I_GoodsCode = rows[i].I_GoodsCode;
                        InWorkShopDetailEntity.I_GoodsName = rows[i].I_GoodsName;
                        InWorkShopDetailEntity.I_InNo      = strIn_No;
                        InWorkShopDetailEntity.I_Price     = rows[i].I_Price;
                        InWorkShopDetailEntity.I_Qty       = rows[i].I_Qty;
                        InWorkShopDetailEntity.I_Remark    = rows[i].I_Remark;
                        InWorkShopDetailEntity.I_Unit      = rows[i].I_Unit;
                        InWorkShopDetailEntity.I_Batch     = rows[i].I_Batch;
                        nRow = InWorkShopDetailBLL.SaveEntity("", InWorkShopDetailEntity);
                    }
                    //更改临时数据状态
                    Upload(strIn_No);
                    MessageBox.Show("保存成功");
                    lblTS.Text = "";
                    DeleteData();
                    UpdataNew();
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #6
0
        private void btn_upload_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否要提交", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
            {
                try
                {
                    if (cmbTeam.Text == "")
                    {
                        lblTS.Text = "系统提示:先选择班组";
                        return;
                    }
                    Mes_WorkShopScanBLL   WorkShopScanBLL  = new Mes_WorkShopScanBLL();
                    Mes_WorkShopWeightBLL WorkShopWeightBL = new Mes_WorkShopWeightBLL();

                    List <string> insertList  = new List <string>();
                    string        strSecGoods = "";
                    string        strSecPc    = "";
                    string        strSecName  = "";
                    string        strSecUnit  = "";
                    decimal       dSecQty     = 0;
                    int           nLen2       = dataGridView2.Rows.Count;
                    for (int i = 0; i < nLen2; i++)
                    {
                        object obj = dataGridView2.Rows[i].Cells["选择2"].Value;
                        if (Convert.ToString(obj) == "True" || Convert.ToString(obj) == "1")
                        {
                            strSecGoods = dataGridView2.Rows[i].Cells["物料2"].Value.ToString();
                            strSecPc    = dataGridView2.Rows[i].Cells["批次2"].Value.ToString();
                            strSecName  = dataGridView2.Rows[i].Cells["物料名称2"].Value.ToString();
                            strSecUnit  = dataGridView2.Rows[i].Cells["单位2"].Value.ToString();

                            string strSecQty = dataGridView2.Rows[i].Cells["数量2"].Value.ToString();
                            string strTemp   = dataGridView2.Rows[i].Cells["物料2"].Value.ToString() + "," + dataGridView2.Rows[i].Cells["批次2"].Value.ToString() + "," + dataGridView2.Rows[i].Cells["数量2"].Value.ToString();
                            if (insertList.Count > 0)
                            {
                                string[] str = insertList[0].ToString().Split(',');
                                if (str[0].ToString() == strSecGoods)
                                {
                                    if (str[1].ToString() == strSecPc)
                                    {
                                        dSecQty = dSecQty + Convert.ToDecimal(strSecQty);
                                    }
                                    else
                                    {
                                        lblTS.Text = "系统提示:生成的物料只允许同一物料,同一批次";
                                        return;
                                    }
                                }
                                else
                                {
                                    lblTS.Text = "系统提示:生成的物料只允许同一物料,同一批次";
                                    return;
                                }
                            }
                            else
                            {
                                dSecQty = dSecQty + Convert.ToDecimal(strSecQty);
                                insertList.Add(strTemp);
                            }
                        }
                    }

                    List <string> Goods       = new List <string>();
                    List <string> strOldGoods = new List <string>();
                    int           nKind       = 0; //计算有几种原物料
                    int           nLen        = dataGridView1.Rows.Count;
                    for (int i = 0; i < nLen; i++)
                    {
                        object obj = dataGridView1.Rows[i].Cells["选择"].Value;
                        if (Convert.ToString(obj) == "True" || Convert.ToString(obj) == "1")
                        {
                            string strGoods = dataGridView1.Rows[i].Cells["物料"].Value.ToString();
                            string strQty   = dataGridView1.Rows[i].Cells["实用数量"].Value.ToString();
                            string strYLQty = dataGridView1.Rows[i].Cells["数量"].Value.ToString();

                            string strPc    = dataGridView1.Rows[i].Cells["批次"].Value.ToString();
                            string strPrice = dataGridView1.Rows[i].Cells["价格"].Value.ToString();
                            string strName  = dataGridView1.Rows[i].Cells["物料名称"].Value.ToString();
                            string strUnit  = dataGridView1.Rows[i].Cells["单位"].Value.ToString();
                            if (Jud(strGoods, strSecGoods))
                            {
                                if (strOldGoods.Contains(strGoods))
                                {
                                }
                                else
                                {
                                    nKind = nKind + 1;
                                    strOldGoods.Add(strGoods);
                                }
                                bool bRet = false;
                                for (int j = 0; j < Goods.Count; j++)
                                {
                                    string   strTemp      = Goods[j].ToString();
                                    string[] str          = strTemp.Split(',');
                                    string   strTempGoods = str[0].ToString();
                                    string   strTempPc    = str[2].ToString();
                                    string   strTempQty   = str[3].ToString();
                                    if (strTempGoods == strGoods && strTempPc == strPc)
                                    {
                                        decimal dQty = Convert.ToDecimal(strQty) + Convert.ToDecimal(strTempQty);
                                        Goods[j] = strGoods + "," + dQty.ToString() + "," + strPc + "," + strPrice + "," + strName + "," + strUnit;
                                        bRet     = true;
                                    }
                                }
                                if (bRet == false)
                                {
                                    Goods.Add(strGoods + "," + strQty + "," + strPc + "," + strPrice + "," + strName + "," + strUnit);
                                }
                            }
                            else
                            {
                                lblTS.Text = "系统提示:选择的物料生成不了下一个物料,请核对";
                                return;
                            }
                        }
                    }

                    if (!Jud2(nKind, strSecGoods))
                    {
                        lblTS.Text = "系统提示:选择的转换前的物料不够";
                        return;
                    }

                    if (insertList.Count == 0 || Goods.Count == 0)
                    {
                        lblTS.Text = "系统提示:请选择物料";
                        return;
                    }
                    Mes_OrgResHeadBLL      OrgResHeadBLL      = new Mes_OrgResHeadBLL();
                    Mes_OrgResDetailBLL    OrgResDetailBLL    = new Mes_OrgResDetailBLL();
                    Mes_OrgResHeadEntity   OrgResHeadEntity   = new Mes_OrgResHeadEntity();
                    Mes_OrgResDetailEntity OrgResDetailEntity = new Mes_OrgResDetailEntity();

                    string strIn_No = "";

                    MesMaterInHeadBLL MaterInHeadBLL = new MesMaterInHeadBLL();
                    strIn_No = MaterInHeadBLL.GetDH("组装与拆分单");

                    OrgResHeadEntity.O_OrgResNo = strIn_No;
                    OrgResHeadEntity.O_OrderNo  = comOrderNo.Text;

                    OrgResHeadEntity.O_CreateBy     = Globels.strUser;
                    OrgResHeadEntity.O_CreateDate   = DateTime.Now;
                    OrgResHeadEntity.O_OrderDate    = txtOrderDate.Text;
                    OrgResHeadEntity.O_Remark       = "";
                    OrgResHeadEntity.O_Status       = 1;
                    OrgResHeadEntity.O_WorkShopCode = cmbWorkShop.Text;
                    OrgResHeadEntity.O_WorkShopName = cmbWorkShopName.Text;
                    OrgResHeadEntity.O_Record       = cmbRecord.Text;
                    OrgResHeadEntity.O_ProCode      = cmbProce.Text;
                    OrgResHeadEntity.O_TeamCode     = cmbTeam.Text;
                    OrgResHeadEntity.O_TeamName     = cmbTeamName.Text;

                    int     nRow      = OrgResHeadBLL.SaveEntity("", OrgResHeadEntity);
                    decimal dSecPrice = 0;
                    decimal dTotal    = 0;
                    for (int i = 0; i < Goods.Count; i++)
                    {
                        string[] strTemp = Goods[i].ToString().Split(',');
                        dTotal = dTotal + (Convert.ToDecimal(strTemp[3].ToString()) * Convert.ToDecimal(strTemp[1].ToString()));
                    }
                    dSecPrice = dTotal / dSecQty;


                    for (int i = 0; i < Goods.Count; i++)
                    {
                        OrgResDetailEntity.O_OrgResNo     = strIn_No;
                        OrgResDetailEntity.O_SecGoodsCode = strSecGoods;
                        OrgResDetailEntity.O_SecGoodsName = strSecName;
                        OrgResDetailEntity.O_SecPrice     = 0;
                        OrgResDetailEntity.O_SecQty       = dSecQty;
                        OrgResDetailEntity.O_SecUnit      = strSecUnit;
                        OrgResDetailEntity.O_SecBatch     = strSecPc;

                        string[] strTemp = Goods[i].ToString().Split(',');

                        string         strGoodsCode   = strTemp[0].ToString();
                        Mes_ConvertBLL ConvertBLL     = new Mes_ConvertBLL();
                        var            Convert_rows   = ConvertBLL.GetList_Mes_Convert(" where C_SecCode = '" + strGoodsCode + "'");
                        string         strC_GoodsCode = "";
                        if (Convert_rows.Count > 0)
                        {
                            strC_GoodsCode = Convert_rows[0].C_Code;
                        }

                        OrgResDetailEntity.O_GoodsCode = strTemp[0].ToString();
                        OrgResDetailEntity.O_GoodsName = strTemp[4].ToString();
                        OrgResDetailEntity.O_Price     = Convert.ToDecimal(strTemp[3].ToString());
                        OrgResDetailEntity.O_Qty       = Convert.ToDecimal(strTemp[1].ToString());
                        OrgResDetailEntity.O_Unit      = strTemp[5].ToString();
                        OrgResDetailEntity.O_Batch     = strTemp[2].ToString();
                        OrgResDetailEntity.O_SecPrice  = dSecPrice;
                        nRow = OrgResDetailBLL.SaveEntity("", OrgResDetailEntity);
                    }
                    Upload(strIn_No);
                    MessageBox.Show("保存成功");
                    lblTS.Text = "";
                    //UpdatePrice(strSecGoods, dSecPrice);  已经在存储过程中处理
                    Delete();
                    UpdateGoods();
                }
                catch (Exception ex)
                {
                    lblTS.Text = "系统提示:" + ex.ToString();
                }
            }
        }
コード例 #7
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();
            }
        }