zzr99
2021-12-28 68ec8814570d08ebc67dc3c35d0e8f9f9a65c06e
WarM/ÌõÂë´òÓ¡/Sc_ICMOToBarCode.cs
@@ -57,6 +57,9 @@
            //}
            string HICMOBillNo = "";
            HICMOBillNo = txtHICMOBillNo.Text.Trim().ToString();
            //销售订单号
            string HSeOrderBillNo = "";
            HICMOBillNo = txtHSeOrderBillNo.Text.Trim().ToString();
            //物料
            //if (txtHMaterID.Text.Trim() != "")
            //{
@@ -98,7 +101,7 @@
            //过滤条件
            //
            DSet = SubCn.RunProcReturn("exec h_p_KSTMSC '" + HICMOBillNo + "' , '" + HMaterName + "' , '" + HSourceName + "' ,'" + HEmpName + "' ,'" + HBeginDate + "', '" + HEndDate + "'", "h_p_KSTMSC", ref DBUtility.ClsPub.sExeReturnInfo);
            DSet = SubCn.RunProcReturn("exec h_p_KSTMSC '" + HSeOrderBillNo + "' ,'" + HICMOBillNo + "' , '" + HMaterName + "' , '" + HSourceName + "' ,'" + HEmpName + "' ,'" + HBeginDate + "', '" + HEndDate + "'", "h_p_KSTMSC", ref DBUtility.ClsPub.sExeReturnInfo);
            //生成首行标题
            if (DSet == null)
            {
@@ -757,6 +760,97 @@
        private void button4_Click(object sender, EventArgs e)
        {
            //1.获取界面上面整箱数量框输入的数量 èµ‹å€¼ç»™å˜é‡  å¹¶åˆ·æ–°ç½‘æ ¼
            double HBarCodeQty = 0;
            double HZXQty = 0;
            HZXQty = ClsPub.isDoule(txtHZXQty.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);
            //5.从网格第一行循环至最后一行  åˆ¤æ–­I行的物料内码与M是否一致;如果不一致则循环下一行;
            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 (HMaterID == HGrdMaterID)
                {
                    double HDDQty = 0;
                    HDDQty = DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.Rows[i].Index].Cells[Fun_GetCol("订单数量")].Value);
                    if (HDDQty >= HZXQty)
                    {
                        HBarCodeQty = HZXQty;
                        this.Sub_SaveBill();
                        Display();
                        Mul = Mul + 1;
                        break;
                    }
                    else if(HDDQty < HZXQty)
                    {
                        HBarCodeQty = HDDQty;
                        HZXQty = HZXQty - HDDQty;
                        this.Sub_SaveBill();
                        Mul = Mul + 1;
                    }
                }
            }
            //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
                //{
                //}
            }
        }
        private void Sub_SaveBill()
        {
            HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
            string HMaterNumber = "";
            string HBatchNo = "";
@@ -769,8 +863,8 @@
            DataSet Ds;
            int LSH = 0;                //流水号
            string LSH2 = "";           //流水号转换成字符
            double HSumQty = 0;         //产品数量
            double HMinQty = 0;         //最小包装数
            double HZXQty = 0;         //装箱数量
            double HDDQty = 0;         //订单数量
            double HBQty = 0;         //箱数
            int k = 0;
            int n = 0;                  //同一批生成条码中的第几条
@@ -788,23 +882,11 @@
                HDay = "0" + ClsPub.isDate(HDate).Day.ToString();
                HDay = HDay.Substring(HDay.Length - 2, 2);
                HOrgNumber = ClsPub.HOrgNumber;
                //箱数列=数量/最小包装数
                //double sMoney = 0;
                //if ((DBUtility.ClsPub.isLong(grdMain.SelectedRows[j].Cells[Fun_GetCol("HMiniQty")].Value) == 0))
                //{
                //    sMoney = 0;
                //}
                //else
                //{
                //    sMoney = ClsPub.isDoule(grdMain.SelectedRows[j].Cells[Fun_GetCol("HQty")].Value) / ClsPub.isDoule(grdMain.SelectedRows[j].Cells[Fun_GetCol("HMiniQty")].Value);
                //}
                //sMoney = Math.Ceiling(sMoney);
                //grdMain.SelectedRows[j].Cells[Fun_GetCol("HBQty")].Value = sMoney;
                HBQty = HBQty + ClsPub.isInt(txtHBQty.Text);
                HMinQty = ClsPub.isDoule(txtHMiniQty.Text);
                HSumQty = ClsPub.isDoule(txtHICMOQty.Text);
                //HBQty = HBQty + ClsPub.isInt(txtHBQty.Text);
                HZXQty = ClsPub.isDoule(txtHZXQty.Text);
                HDDQty = DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.SelectedRows[j].Index].Cells[Fun_GetCol("订单数量")].Value);
                if (cmbHBarCodeType.Text == "唯一条码")
@@ -818,27 +900,7 @@
                    TM = HOrgNumber + HMaterNumber + HBatchNo;
                }
                n = 0;
                for (int i = k; i < HBQty; i++)
                {
                    if (HSumQty - HMinQty > 0)
                    {
                        WeiShu = "";
                        HSumQty = HSumQty - HMinQty;
                    }
                    else
                    {
                        if (HSumQty == HMinQty)
                        {
                            WeiShu = "";
                        }
                        else
                        {
                            WeiShu = "尾数";
                        }
                        HMinQty = HSumQty;
                    }
                    //
                    LSH = LSH + 1;
                    LSH2 = LSH.ToString();
                    while (LSH2.Length < LSHlen)  //如果流水号小于6位数前面补0
                    {
@@ -857,7 +919,7 @@
                    string HWei = "";      //尾数
                    string HBarCode = "";
                    string HBarCodeType = "";
                    Int64 HMaterID = 0;
                    Int64 HMaterID1 = 0;
                    Int64 HAuxPropID = 0;
                    Int64 HUnitID = 0;
                    double HQty2 = 0;
@@ -891,10 +953,10 @@
                        HWei = WeiShu;
                        HBarCode = TM;
                        HBarCodeType = ClsPub.isStrNull(cmbHBarCodeType.Text);
                        HMaterID = ClsPub.isLong(grdMain.SelectedRows[j].Cells[Fun_GetCol("HMaterID")].Value);
                        HMaterID1 = ClsPub.isLong(grdMain.SelectedRows[j].Cells[Fun_GetCol("HMaterID")].Value);
                        HAuxPropID = 0;
                        HUnitID = 0;
                        HQty2 = HMinQty;
                        HQty2 = HZXQty;
                        HBatchNo2 = ClsPub.isStrNull(grdMain.SelectedRows[j].Cells[Fun_GetCol("批次")].Value);
                        HSourceInterID = 0;
                        HSourceEntryID = 0;
@@ -925,7 +987,7 @@
                                            ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID " +
                                            ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " +
                                            ") values ("
                                            + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString()
                                            + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID1.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString()
                                            + ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() + "," + HQty2.ToString()
                                            + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "'"
                                            + ", " + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'"
@@ -943,10 +1005,9 @@
                        oCn.RollBack();
                        MessageBox.Show("条码生成失败!" + e1.Message);
                    }
                }
            }
        }
        private void DisplayTM()
@@ -1197,9 +1258,9 @@
            for (int i = 0; i < grdMain.SelectedRows.Count; i++)
            {
                txtHICMOQty.Text = DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("订单数量")].Value);
                txtHZXQty.Text = DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("订单数量")].Value);
            }
            HICMOQty = DBUtility.ClsPub.isDoule(txtHICMOQty.Text.Trim());
            HICMOQty = DBUtility.ClsPub.isDoule(txtHZXQty.Text.Trim());
            HMiniQty = DBUtility.ClsPub.isDoule(txtHMiniQty.Text.Trim());
            if (HMiniQty == 0)
            {
@@ -1293,7 +1354,7 @@
            txtHEmpID.Text = "";
            txtHICMOBillNo.Text = "";
            txtHICMOBillNo1.Text = "";
            txtHICMOQty.Text = "";
            txtHZXQty.Text = "";
            txtHMaterID.Text = "";
            txtHMaterID1.Text = "";
            txtHMiniQty.Text = "";