From 77841dec99bfba72112a66a17dfc69f9aff35f6a Mon Sep 17 00:00:00 2001
From: 王 垚 <1402714037@qq.com>
Date: 星期一, 27 十二月 2021 19:21:17 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WarM/条码打印/Sc_ICMOToBarCode.cs |  157 ++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 109 insertions(+), 48 deletions(-)

diff --git "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Sc_ICMOToBarCode.cs" "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Sc_ICMOToBarCode.cs"
index 657158f..29ed5b8 100644
--- "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Sc_ICMOToBarCode.cs"
+++ "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/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.鑾峰彇缃戞牸閫変腑琛岀墿鏂橧D
+            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.鏍规嵁鍗曟嵁绫诲瀷鑾峰彇鏈鏉$爜涓诲唴鐮丠InterID
+            HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+            //5.浠庣綉鏍肩涓�琛屽惊鐜嚦鏈�鍚庝竴琛�  鍒ゆ柇I琛岀殑鐗╂枡鍐呯爜涓嶮鏄惁涓�鑷达紱濡傛灉涓嶄竴鑷村垯寰幆涓嬩竴琛岋紱
+            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 = "";

--
Gitblit v1.9.1