ch
2022-07-08 b029aae7c61b1bff5c008cf7afe6f2b0f890c1c3
WarM/ÌõÂë´òÓ¡/Sc_ICMOToBarCode.cs
@@ -997,191 +997,95 @@
        private void button4_Click(object sender, EventArgs e)
        {
            //根据本箱数量 æ¥ åˆ†é…åˆ° æ¯ä¸ªç”Ÿäº§è®¢å•上(分配时 è¦è€ƒè™‘ è®¢å•剩余数量已经是 è´Ÿæ•°çš„æƒ…况)
            //如果有标准装箱数量 å…ˆé»˜è®¤å–标准装箱数量  æ²¡æœ‰å†å–手输的本箱数量
            //1.判断本箱数量 å¿…须大于0
            double HZXQty = 0;//整箱数量
            if (txtHZXQty.Text.Trim() != "")
            {
                HZXQty = ClsPub.isDoule(txtHZXQty.Text);
            }
            else
            {
                HZXQty = ClsPub.isDoule(txtHMiniQty.Text);
            }
            if (HZXQty <= 0)
            {
                MessageBox.Show("请输入整箱数量!");
                return;
            }
            //2.刷新网格
            //Display();
            //3.把整箱数量 åˆ†é…åˆ° ç½‘格下面的每一个 ç”Ÿäº§è®¢å•上去。  å¾ªçŽ¯ç½‘æ ¼
            for(int i =0;i<grdMain.Rows.Count;i++)
            {
                if (HZXQty > 0)
                {
                    if (HZXQty > DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["生产订单数量"].Value))
                    {
                        HZXQty = HZXQty - DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["生产订单数量"].Value);
                        grdMain.Rows[i].Cells["本次数量"].Value = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["生产订单数量"].Value);
                        //MessageBox.Show("请点击超额生产按钮生成条码!");
                        //return;
                    }
                    else
                    {
                        grdMain.Rows[i].Cells["本次数量"].Value = HZXQty;
                        //
                        //HZXQty = HZXQty - DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["生产订单数量"].Value);
                        //grdMain.Rows[i].Cells["本次数量"].Value = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["生产订单数量"].Value);
                    }
                }
                else
                {
                    break;
                }
            }
            Sub_SaveBarCode();
            //
            ////1.获取界面上面整箱数量框输入的数量 èµ‹å€¼ç»™å˜é‡  å¹¶åˆ·æ–°ç½‘æ ¼
            //double HBarCodeQty = 0;
            //double HZXQty = 0;
            //HZXQty = ClsPub.isDoule(txtHZXQty.Text);
            //if (HZXQty ==0)
            ////根据本箱数量 æ¥ åˆ†é…åˆ° æ¯ä¸ªç”Ÿäº§è®¢å•上(分配时 è¦è€ƒè™‘ è®¢å•剩余数量已经是 è´Ÿæ•°çš„æƒ…况)
            ////如果有标准装箱数量 å…ˆé»˜è®¤å–标准装箱数量  æ²¡æœ‰å†å–手输的本箱数量
            ////1.判断本箱数量 å¿…须大于0
            //double HZXQty = 0;//整箱数量
            //if (txtHZXQty.Text.Trim() != "")
            //{
            //    HZXQty = ClsPub.isDoule(txtHZXQty.Text);
            //}
            //else
            //{
            //    HZXQty = ClsPub.isDoule(txtHMiniQty.Text);
            //}
            //if (HZXQty <= 0)
            //{
            //    MessageBox.Show("请输入整箱数量!");
            //    return;
            //}
            //Display();
            ////2.获取网格选中行物料ID
            ////int a = grdMain.CurrentRow.Index;
            ////long HMaterID = 0;
            //////HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[a].Cells[Fun_GetCol("HMaterID")].Value);
            ////    if (HMaterID == 0)
            ////    {
            ////        MessageBox.Show("没有选中任何记录!");
            ////        return;
            ////    }
            ////3.定义是否组托的变量
            //int Mul = 0;
            ////4.根据单据类型获取本次条码主内码HInterID
            //HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
            //for (int i = 0; i < grdMain.Rows.Count; i++)
            ////2.刷新网格
            ////Display();
            ////3.把整箱数量 åˆ†é…åˆ° ç½‘格下面的每一个 ç”Ÿäº§è®¢å•上去。  å¾ªçŽ¯ç½‘æ ¼
            //for(int i =0;i<grdMain.Rows.Count;i++)
            //{
            //    //获取网格里面每一行订单对应的订单数量
            //    double HDDQty = 0;
            //    HDDQty = DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.Rows[i].Index].Cells[Fun_GetCol("订单数量")].Value);
            //    //获取当前系统登陆组织代码
            //    HOrgNumber = ClsPub.HOrgNumber;
            //    //自动匹配逻辑  åˆ¤æ–­è®¢å•数量是否大于整箱数量   å¦‚果订单数量大于整箱数量  ç›´æŽ¥ç”Ÿæˆå”¯ä¸€ç 
            //    //如果订单数量小于整箱数量  åˆ™å¾ªçŽ¯ç”Ÿæˆå”¯ä¸€ç    ç”Ÿæˆå¯¹åº”的托条码
            //        if (HDDQty >= HZXQty)
            //    if (HZXQty > 0)
            //    {
            //        if (HZXQty > DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["生产订单数量"].Value))
            //        {
            //            HBarCodeQty = HZXQty;
            //            this.Sub_SaveBill_TTM();
            //            Display();
            //            Mul = Mul + 1;
            //            break;
            //            HZXQty = HZXQty - DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["生产订单数量"].Value);
            //            grdMain.Rows[i].Cells["本次数量"].Value = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["生产订单数量"].Value);
            //            //MessageBox.Show("请点击超额生产按钮生成条码!");
            //            //return;
            //        }
            //        else if(HDDQty < HZXQty)
            //        else if (HZXQty == 0)
            //        {
            //            HBarCodeQty = HDDQty;
            //            HZXQty = HZXQty - HDDQty;
            //            this.Sub_SaveBill_TTM();
            //            Mul = Mul + 1;
            //            continue;
            //            return;
            //        }
            //        else
            //        {
            //            grdMain.Rows[i].Cells["本次数量"].Value = HZXQty;
            //            //
            //    //如果Mul>1 æ–°å¢žç»„托单主表
            //            //HZXQty = HZXQty - DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["生产订单数量"].Value);
            //            //grdMain.Rows[i].Cells["本次数量"].Value = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["生产订单数量"].Value);
            //        }
            //    }
            //    else
            //    {
            //        break;
            //    }
            //}
            //Sub_SaveBarCode();
            ////
            //if (Mul > 1)
            //{
            //    //HICMOBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("生产订单号")].Value);
            //    DataSet DS1;
            //    HTTMNumber = HOrgNumber + HICMOBillNo;
            //    DS1 = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + HTTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
            //    TLSH = ClsPub.isInt(DS1.Tables[0].Rows[0][0]);
            //    TLSH2 = TLSH.ToString();
            //    TTM = HTTMNumber + TLSH2;
            //    HInterID_TTM = DBUtility.ClsPub.CreateBillID_Prod(ModName1, ref DBUtility.ClsPub.sExeReturnInfo);
            //    HBillNo_TTM = DBUtility.ClsPub.CreateBillCode_Prod(ModName1, ref DBUtility.ClsPub.sExeReturnInfo, true);//得到新单号
            //    string HDate = "";
            //    string HYear = "";
            //    string HPeriod = "";
            //    string HDay = "";
            //    HDate = DateTime.Now.ToShortDateString();
            //    HYear = ClsPub.isDate(HDate).Year.ToString().Substring(2, 2);
            //    HPeriod = "0" + ClsPub.isDate(HDate).Month.ToString();
            //    HPeriod = HPeriod.Substring(HPeriod.Length - 2, 2);
            //    HDay = "0" + ClsPub.isDate(HDate).Day.ToString();
            //    HDay = HDay.Substring(HDay.Length - 2, 2);
            //    oCn.RunProc("insert into Sc_PackUnionBillMain (HYear,HPeriod,HBillType,HInterID,HDate" +
            //                       ",HBillNo,HBillStatus,HICMOBillNo,HBarCode_Pack,HMaterID,HUnitID,HWeight" +
            //                       ",HPWeight,HProdOrgID,HDeptID,HEmpID,HSNum,HPackNum,HBarCode_Cus,HBatchNo " +
            //                       ") values ("
            //                       + HYear + "," + HPeriod + ",'3783'," + HInterID_TTM + ",'" + HDate + "'"
            //                       + ", " + HBillNo_TTM.ToString() + ",1,''," + TTM.ToString() + ",0,0,0"
            //                       + ",0,1,0,0,0,0,'','')");
            //}
            ////3.先判断物料是否一致  å¦‚果一致开始循环网格
            //for (int i = 0; i < grdMain.Rows.Count; i++)
            //{
            //    //long HGrdMaterID = 0;
            //    //HGrdMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.Rows[i].Index].Cells[Fun_GetCol("HMaterID")].Value);
            //    //if (HGrdMaterID == HMaterID)
            //    //{
            //    //    double HDDQty = 0;
            //    //    HDDQty = DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.Rows[i].Index].Cells[Fun_GetCol("订单数量")].Value);
            //    //    //如果循环的该行记录的订单数量已经大于等于本次装箱数量  åˆ™ç›´æŽ¥ç”Ÿæˆå”¯ä¸€ç   å¹¶ä¸”刷新网格  åˆ·æ–°æ¡ç ä¿¡æ¯é¡µ
            //    //    if (HDDQty >= HZXQty)
            //    //    {
            //    //        double HBarCodeQty = 0;
            //    //        HBarCodeQty = HZXQty;
            //    //        this.Sub_SaveBill();
            //    //        Display();
            //    //    }
            //    //    //如果改行记录订单数量小于本次装箱数量 åˆ™ç»§ç»­å¾ªçޝ  èµ°ç”Ÿæˆæ‰˜æ¡ç æ–¹æ³•
            //    //    else
            //    //    {
            //    //        //查出符合条件的选中这条数量跟装箱数量的差异值
            //    //        double HCYQty = 0;
            //    //        HCYQty = HZXQty - DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.Rows[i].Index].Cells[Fun_GetCol("订单数量")].Value);
            //    //    }
            //    //}
            //    //else
            //    //{
            //    //}
            //}
            bool flag = this.txtHZXQty.Text.Trim() != "";
            double num;
            if (flag)
            {
                num = Pub_Class.ClsPub.isDoule(this.txtHZXQty.Text);
            }
            else
            {
                num = Pub_Class.ClsPub.isDoule(this.txtHMiniQty.Text);
            }
            bool flag2 = num <= 0.0;
            if (flag2)
            {
                MessageBox.Show("请输入整箱数量!");
            }
            else
            {
                for (int i = 0; i < this.grdMain.Rows.Count; i++)
                {
                    bool flag3 = num > 0.0;
                    if (!flag3)
                    {
                        break;
                    }
                    bool flag4 = num > Pub_Class.ClsPub.isDoule(this.grdMain.Rows[i].Cells["生产订单数量"].Value);
                    if (!flag4)
                    {
                        this.grdMain.Rows[i].Cells["本次数量"].Value = num;
                        break;
                    }
                    num -= Pub_Class.ClsPub.isDoule(this.grdMain.Rows[i].Cells["生产订单数量"].Value);
                    this.grdMain.Rows[i].Cells["本次数量"].Value = Pub_Class.ClsPub.isDoule(this.grdMain.Rows[i].Cells["生产订单数量"].Value);
                }
                this.Sub_SaveBarCode();
            }
        }
        private void Sub_SaveBill()