示例#1
0
        /// <summary>
        /// 审核,提交单据 以前在网页端
        /// </summary>
        private void Upload(string strDH)
        {
            Mes_OrgResHeadBLL OrgResHeadBLL = new Mes_OrgResHeadBLL();

            OrgResHeadBLL.SH(strDH);
            OrgResHeadBLL.UPLOAD(strDH, Globels.strUser);
        }
示例#2
0
        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 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();
                }
            }
        }