From a71757967fbaf9d300c81e7502ff455d4a482564 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期五, 29 十二月 2023 16:57:30 +0800
Subject: [PATCH] 增加csv格式读取

---
 WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs |  113 +++++++++++++++++++++++++++++++-------------------------
 1 files changed, 63 insertions(+), 50 deletions(-)

diff --git a/WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs b/WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs
index 76107a0..e896c25 100644
--- a/WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs
+++ b/WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs
@@ -24,8 +24,8 @@
         //璇诲彇鏁版嵁
         private void btnReadData_Click(object sender, EventArgs e)
         {
-
-            DataTable list = oCN.RunProcReturn("select  * from Sb_EquipMentCollection_SN where HFlag=0 order by HCreateTime", "Sb_EquipMentCollection_SN").Tables[0];
+            
+            DataTable list = oCN.RunProcReturn("select  * from Sb_EquipMentCollection_SN  WITH(NOLOCK) where HFlag=0  order by HCreateTime", "Sb_EquipMentCollection_SN").Tables[0];
           
             //寰幆闆嗗悎
             for (int i = 0; i < list.Rows.Count; i++)
@@ -70,15 +70,29 @@
                 else if (num == 1)
                 {
                     //鍒ゆ柇杩欎釜鏉$爜涔嬪墠鐨勭姸鎬佹槸鍚︿负NG
-                    DataSet ds = oCN.RunProcReturn(@"select * from Sb_EquipMentCollection_SN where HBarCode='" + HBadCodeSN + "' and HCreateTime<'" + dic["HCreateTime"].ToString() + "' and HResult='NG'", "Gy_BarCodeBill");
-                    if (ds.Tables[0].Rows.Count > 0)
+                    DataSet ds = oCN.RunProcReturn(@"select * from Sb_EquipMentCollection_SN  WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "' and HCreateTime<'" + dic["HCreateTime"].ToString() + "' and HResult='NG'  and HProcNumber='" + dic["HProcNumber"].ToString() + "'", "Sb_EquipMentCollection_SN");
+
+                    DataSet ds1 = oCN.RunProcReturn(@"select a.HSourceID,a.HProcID,* from Sc_StationOutBillMain a WITH(NOLOCK)
+inner join Sc_StationOutBillSub_SN sn WITH(NOLOCK) on a.HInterID=sn.HInterID
+left join Gy_Source s WITH(NOLOCK) on a.HSourceID=s.HItemID
+left join Gy_Process p WITH(NOLOCK) on a.HProcID=p.HItemID
+where  p.HNumber='" + dic["HProcNumber"].ToString() + "' and sn.HBarCode='" + HBadCodeSN + "'", "Sc_StationOutBillSub_SN");
+
+                    if (ds.Tables[0].Rows.Count > 0 && ds1.Tables[0].Rows.Count == 0)
                     {
                         flag = getOKOutBillAdd(dic, HBadCodeSN, "OK");
                     }
                     else
                     {
-                        flag = false;
-                        oCN.RollBack();
+                        if (ds1.Tables[0].Rows.Count > 0)
+                        {
+                            flag = true;
+                            //oCN.RollBack();
+                        }
+                        else
+                        {
+                            flag = getOutBillAdd(dic, HBadCodeSN, "OK");
+                        }
                     }
                 }
                 else if (num == 2)
@@ -148,11 +162,11 @@
             try
             {
                 //鑾峰彇缁戝畾娴佽浆鍗�
-                DataSet ds = oCN.RunProcReturn(@"select * from Gy_BarCodeBill where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
+                DataSet ds = oCN.RunProcReturn(@"select * from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
                 string HProcExchBillNo = ds.Tables[0].Rows[0]["HSourceBillNo"].ToString();
                 string HProcNumber = dic["HProcNumber"].ToString();
 
-                ds = oCN.RunProcReturn("select * from Gy_Source where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
+                ds = oCN.RunProcReturn("select * from Gy_Source WITH(NOLOCK) where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
                 long HSourceID = 0;
                 if (ds.Tables[0].Rows.Count != 0)
                 {
@@ -160,7 +174,7 @@
                 }
 
                 //鏌ヨ鑱屽憳
-                ds = oCN.RunProcReturn("select * from Gy_Employee where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
+                ds = oCN.RunProcReturn("select * from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
                 long HEmpIDs = 0;
                 if (ds.Tables[0].Rows.Count != 0)
                 {
@@ -187,9 +201,9 @@
 
              
 
-                ds = oCN.RunProcReturn(@"select   b.HProcNo,b.HProcID,a.HMaterID,a.HQty,a.HInterID,HEntryID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo from Sc_ProcessExchangeBillMain a
-inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID
-left join Gy_Process p on  b.HProcID=p.HItemID 
+                ds = oCN.RunProcReturn(@"select   b.HProcNo,b.HProcID,a.HMaterID,a.HQty,a.HInterID,HEntryID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
+inner join Sc_ProcessExchangeBillSub b WITH(NOLOCK) on a.HInterID=b.HInterID
+left join Gy_Process p WITH(NOLOCK) on  b.HProcID=p.HItemID 
 where a.HBillNo='" + HProcExchBillNo + "'  and p.HNumber='" + HProcNumber + "'", "Sc_ProcessExchangeBillMain");
 
                 string sExeReturnInfo = "";
@@ -226,7 +240,7 @@
                 long HGroupID = 22;//鐝粍ID 鐧界彮
 
                 long HEmpID = HEmpIDs;//鎿嶄綔鍛業D
-                long HEmpID2 = 0;////鎿嶄綔鍛�2ID
+                long HEmpID2 = HEmpIDs;////鎿嶄綔鍛�2ID
                 string HBarCode = HProcExchBillNo;//鏉″舰鐮�
                 string HAddr = "";
                 string HBarCodeMaker = "";
@@ -262,8 +276,8 @@
 
 
                 //鍒ゆ柇褰撳墠娴佽浆鍗$殑鍑虹珯鍗� 鏄惁鏈夋暟鎹�
-                ds = oCN.RunProcReturn(@"select  * from Sc_StationOutBillMain a
-left join Gy_Process p on  a.HProcID=p.HItemID
+                ds = oCN.RunProcReturn(@"select  * from Sc_StationOutBillMain a WITH(NOLOCK)
+left join Gy_Process p WITH(NOLOCK) on  a.HProcID=p.HItemID
 where HProcExchBillNo='" + HProcExchBillNo + "' and p.HNumber='" + HProcNumber + "' and CONVERT(varchar(10),HDate,20) ='" + DateTime.Now.ToString("yyyy-MM-dd") + "'", "Sc_StationOutBillMain");
 
                 if (ds.Tables[0].Rows.Count != 0)
@@ -303,19 +317,19 @@
 
                 if (HResult == "OK")
                 {
-                    ds = oCN.RunProcReturn("select  * from Sc_StationOutBillSub_SN where HInterID='" + HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
+                    ds = oCN.RunProcReturn("select  * from Sc_StationOutBillSub_SN WITH(NOLOCK) where HInterID='" + HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
 
                     string HMakeTime = dic["HCreateTime"].ToString();
                     oCN.RunProc($@"insert into Sc_StationOutBillSub_SN(HInterID,HBillNo_bak,HEntryID,HBarCode,HBarCodeQty,HMakeTime,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)
 values({ HInterID}, '{ HBillNo}', {(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)}, '{HBadCodeSN}', 1, '"+ HMakeTime + "', '', " + HProcExchInterID + "," + HProcExchEntryID + ", '" + HProcExchBillNo + "', '', 0, 0)");
 
                     //鍙嶅啓宸ュ簭鍑虹珯鍗曠殑鍚堟牸鏁伴噺
-                    oCN.RunProc("update Sc_StationOutBillMain set HQty+=1  where HInterID='" + HInterID + "'");
+                    oCN.RunProc("update Sc_StationOutBillMain  set HQty+=1  where HInterID='" + HInterID + "'");
                 }
                 else if (HResult == "NG")
                 {
                     //鍙嶅啓宸ュ簭鍑虹珯鍗曠殑涓嶈壇鏁伴噺
-                    oCN.RunProc("update Sc_StationOutBillMain set HBadCount+=1 where HInterID='" + HInterID + "'");
+                    oCN.RunProc("update Sc_StationOutBillMain  set HBadCount+=1 where HInterID='" + HInterID + "'");
                 }
                 else
                 {
@@ -353,7 +367,7 @@
 
 
                     //鏌ヨ鑱屽憳
-                    ds = oCN.RunProcReturn("select * from Gy_Employee where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
+                    ds = oCN.RunProcReturn("select * from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
                     string HMakers = "";
                     if (ds.Tables[0].Rows.Count != 0)
                     {
@@ -404,11 +418,11 @@
             try
             {
                 //鑾峰彇缁戝畾娴佽浆鍗�
-                DataSet ds = oCN.RunProcReturn(@"select * from Gy_BarCodeBill where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
+                DataSet ds = oCN.RunProcReturn(@"select * from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
                 string HProcExchBillNo = ds.Tables[0].Rows[0]["HSourceBillNo"].ToString();
                 string HProcNumber = dic["HProcNumber"].ToString();
 
-                ds = oCN.RunProcReturn("select * from Gy_Source where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
+                ds = oCN.RunProcReturn("select * from Gy_Source WITH(NOLOCK) where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
                 long HSourceID = 0;
                 if (ds.Tables[0].Rows.Count != 0)
                 {
@@ -416,7 +430,7 @@
                 }
 
                 //鏌ヨ鑱屽憳
-                ds = oCN.RunProcReturn("select * from Gy_Employee where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
+                ds = oCN.RunProcReturn("select * from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
                 long HEmpIDs = 0;
                 if (ds.Tables[0].Rows.Count != 0)
                 {
@@ -443,9 +457,9 @@
                 }
 
                 ds = oCN.RunProcReturn(@"select   b.HProcNo,b.HProcID,a.HMaterID,a.HQty,a.HInterID,HEntryID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo 
-                from Sc_ProcessExchangeBillMain a
-                inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID
-                left join Gy_Process p on  b.HProcID=p.HItemID 
+                from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
+                inner join Sc_ProcessExchangeBillSub b WITH(NOLOCK) on a.HInterID=b.HInterID
+                left join Gy_Process p WITH(NOLOCK) on  b.HProcID=p.HItemID 
                 where a.HBillNo='" + HProcExchBillNo + "'  and p.HNumber='" + HProcNumber + "'", "Sc_ProcessExchangeBillMain");
 
                 long HICMOInterID = long.Parse(ds.Tables[0].Rows[0]["HICMOInterID"].ToString());//浠诲姟鍗旾D
@@ -458,12 +472,12 @@
                 long HInterID = 0;
                 string HBillNo = "";
 
-                ds = oCN.RunProcReturn("select  * from Sc_AssemblyBillMain where HMainSourceInterID=" + HProcExchInterID + " and HMainSourceEntryID=" + HProcExchEntryID, "Sc_AssemblyBillMain");
+                ds = oCN.RunProcReturn("select  * from Sc_AssemblyBillMain WITH(NOLOCK) where HMainSourceInterID=" + HProcExchInterID + " and HMainSourceEntryID=" + HProcExchEntryID, "Sc_AssemblyBillMain");
                 DateTime HDate=DateTime.Now;
                 //褰撲骇鍝佹病鏈夐厤浠剁殑鏃跺�� 鏌ヨ 涓嶈壇璁板綍
                 if (ds.Tables[0].Rows.Count == 0)
                 {
-                    ds = oCN.RunProcReturn("select  * from Sc_QualityReportBillSub where HProcExchInterID=" + HProcExchInterID + " and HProcExchEntryID=" + HProcExchEntryID, "Sc_AssemblyBillMain");
+                    ds = oCN.RunProcReturn("select  * from Sc_QualityReportBillSub WITH(NOLOCK) where HProcExchInterID=" + HProcExchInterID + " and HProcExchEntryID=" + HProcExchEntryID+ " and HBarCode='" + HBadCodeSN + "'", "Sc_AssemblyBillMain");
                     HDate = DateTime.Parse(ds.Tables[0].Rows[0]["HMakeDate"].ToString());
                 }
                 else {
@@ -471,9 +485,9 @@
                 }
 
                 //鏌ヨ鏄惁鏈夎繑淇褰�
-                ds = oCN.RunProcReturn(@"select a.HBarCode,a.HProcess,b.HSourceInterID,b.HSourceEntryID,b.HRepairResult from Sc_SourceLineRepairBillMain a
-inner join Sc_SourceLineRepairBillSub b on a.HInterID = b.HInterID
-where a.HBarCode = '"+ HBadCodeSN + "' and  a.HProcess ="+ HProcID + " and  b.HSourceInterID ="+ HProcExchInterID + " " +
+                ds = oCN.RunProcReturn(@"select a.HBarCode,a.HProcess,b.HSourceInterID,b.HSourceEntryID,b.HRepairResult from Sc_SourceLineRepairBillMain a WITH(NOLOCK)
+inner join Sc_SourceLineRepairBillSub b WITH(NOLOCK) on a.HInterID = b.HInterID
+where a.HBarCode = '" + HBadCodeSN + "' and  a.HProcess ="+ HProcID + " and  b.HSourceInterID ="+ HProcExchInterID + " " +
 "and b.HSourceEntryID="+ HProcExchEntryID + " and b.HRepairResult = 'OK'", "Sc_SourceLineRepairBillMain");
 
                 if (ds.Tables[0].Rows.Count == 0)
@@ -484,8 +498,8 @@
                 }
 
                 //鍒ゆ柇褰撳墠娴佽浆鍗$殑鍑虹珯鍗� 鏄惁鏈夋暟鎹�
-                ds = oCN.RunProcReturn(@"select  * from Sc_StationOutBillMain a
-left join Gy_Process p on  a.HProcID=p.HItemID
+                ds = oCN.RunProcReturn(@"select  * from Sc_StationOutBillMain a WITH(NOLOCK)
+left join Gy_Process p WITH(NOLOCK) on  a.HProcID=p.HItemID
 where HProcExchBillNo='" + HProcExchBillNo + "' and p.HNumber='" + HProcNumber + "' and CONVERT(varchar(10),HDate,20) ='" + HDate.ToString("yyyy-MM-dd") + "'", "Sc_StationOutBillMain");
 
                 if (ds.Tables[0].Rows.Count != 0)
@@ -496,7 +510,7 @@
 
                 if (HResult == "OK")
                 {
-                    ds = oCN.RunProcReturn("select  * from Sc_StationOutBillSub_SN where HInterID='" + HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
+                    ds = oCN.RunProcReturn("select  * from Sc_StationOutBillSub_SN  WITH(NOLOCK) where HInterID='" + HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
 
                     string HMakeTime = dic["HCreateTime"].ToString();
                     oCN.RunProc($@"insert into Sc_StationOutBillSub_SN(HInterID,HBillNo_bak,HEntryID,HBarCode,HBarCodeQty,HMakeTime,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)
@@ -530,14 +544,14 @@
             {
 
 
-                DataSet ds = oCN.RunProcReturn("select  * from Sc_StationOutBillMain where HInterID=" + HInterID + " and HBillNo='" + HBillNo + "'", "Sc_StationOutBillMain");
+                DataSet ds = oCN.RunProcReturn("select  * from Sc_StationOutBillMain WITH(NOLOCK) where HInterID=" + HInterID + " and HBillNo='" + HBillNo + "'", "Sc_StationOutBillMain");
                 string HProcExchInterID = ds.Tables[0].Rows[0]["HProcExchInterID"].ToString();
                 string HProcExchEntryID = ds.Tables[0].Rows[0]["HProcExchEntryID"].ToString();
                 string HProcExchBillNo = ds.Tables[0].Rows[0]["HProcExchBillNo"].ToString();
 
-                ds = oCN.RunProcReturn(@"select  s.HItemID HMouldID,t.HItemID HTechParamID,HCount,HCreateTime from  Sb_EquipMentCollectionTechParam_SN a
-left join Gy_Source s on a.HSourceCode=s.HNumber
-left join Gy_TechnologyParameter t on a.HType=t.HName
+                ds = oCN.RunProcReturn(@"select  s.HItemID HMouldID,t.HItemID HTechParamID,HCount,HCreateTime from  Sb_EquipMentCollectionTechParam_SN a WITH(NOLOCK)
+left join Gy_Source s WITH(NOLOCK) on a.HSourceCode=s.HNumber
+left join Gy_TechnologyParameter t WITH(NOLOCK) on a.HType=t.HNumber
 where a.HFlag=0 and a.HBarCode='" + HBadCodeSN + "'", "Sb_EquipMentCollectionTechParam_SN");
 
                 if (ds.Tables[0].Rows.Count != 0) {
@@ -549,7 +563,7 @@
                         string HCount = ds.Tables[0].Rows[i]["HCount"].ToString();
                         string HGetTime = ds.Tables[0].Rows[i]["HCreateTime"].ToString();
 
-                        DataSet dataSet = oCN.RunProcReturn("select * from Sc_StationOutBillSub_TechParam where HInterID=" + HInterID + " and HBillNo_bak='" + HBillNo + "' and HBarCode='" + HBadCodeSN + "'", "Sc_StationOutBillSub_TechParam");
+                        DataSet dataSet = oCN.RunProcReturn("select * from Sc_StationOutBillSub_TechParam WITH(NOLOCK) where HInterID=" + HInterID + " and HBillNo_bak='" + HBillNo + "' and HBarCode='" + HBadCodeSN + "'", "Sc_StationOutBillSub_TechParam");
 
                         oCN.RunProc("insert into Sc_StationOutBillSub_TechParam(HInterID,HBillNo_bak,HEntryID ,HSourceInterID,HSourceEntryID,HSourceBillNo,HTechParamID,HRelValue,HGetTime,HBarCode,HMouldID)" +
                             $"values({HInterID},'{HBillNo}',{(dataSet.Tables[0].Rows.Count + 1)},{HProcExchInterID},{HProcExchEntryID},'{HProcExchBillNo}',{HTechParamID},{HCount},'{HGetTime}','{HBadCodeSN}',{HMouldID})");
@@ -621,10 +635,10 @@
             try
             {
                 //鏌ヨ娴佽浆鍗℃暟鎹�
-                DataSet dataSet = oCN.RunProcReturn(@"select  a.HPRDORGID, m.HModel 鐗╂枡瑙勬牸,m.HName 鍚嶇墿鏂欑О,a.HBillNo,a.HInterID,a.HMaterID,m.HNumber 鐗╂枡浠g爜,o.HNumber 缁勭粐浠g爜,a.HUnitID,u.HNumber 鍗曚綅浠g爜 from Sc_ProcessExchangeBillMain a
-left join Gy_Material m on a.HMaterID=m.HItemID
-left join Xt_ORGANIZATIONS o on a.HPRDORGID=o.HItemID
-left join Gy_Unit u on a.HUnitID=u.HItemID 
+                DataSet dataSet = oCN.RunProcReturn(@"select  a.HPRDORGID, m.HModel 鐗╂枡瑙勬牸,m.HName 鍚嶇墿鏂欑О,a.HBillNo,a.HInterID,a.HMaterID,m.HNumber 鐗╂枡浠g爜,o.HNumber 缁勭粐浠g爜,a.HUnitID,u.HNumber 鍗曚綅浠g爜 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
+left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
+left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID
+left join Gy_Unit u WITH(NOLOCK) on a.HUnitID=u.HItemID 
 where HBillNo='" + HProcExchBillNo + "'", "Sc_ProcessExchangeBillMain");
 
 
@@ -726,7 +740,7 @@
         //瀹氭椂璇诲彇鏁版嵁
         private void timer1_Tick(object sender, EventArgs e)
         {
-            DataTable list = oCN.RunProcReturn("select  * from Sb_EquipMentCollection_SN where HFlag=0", "Sb_EquipMentCollection_SN").Tables[0];
+            DataTable list = oCN.RunProcReturn("select  * from Sb_EquipMentCollection_SN WITH(NOLOCK) where HFlag=0  order by HCreateTime", "Sb_EquipMentCollection_SN").Tables[0];
 
             //寰幆闆嗗悎
             for (int i = 0; i < list.Rows.Count; i++)
@@ -762,7 +776,7 @@
             {
 
                 //鏌ヨ鑱屽憳
-                DataSet ds = oCN.RunProcReturn("select * from Gy_Employee where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
+                DataSet ds = oCN.RunProcReturn("select * from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
                 long HEmpIDs = 0;
                 string HMakers = "";
                 if (ds.Tables[0].Rows.Count != 0)
@@ -796,10 +810,10 @@
                 long HICMOInterID = 0;
                 long HICMOEntryID = 0;
                 string HICMOBillNo = "";
-                ds = oCN.RunProcReturn(@"select  HMaterID,HUnitID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo,HBillNo,a.HInterID,b.HEntryID,a.HBillNo from Sc_ProcessExchangeBillMain a
-inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID
-left join Gy_Process p on b.HProcID=p.HItemID
-where HBillNo=(select HSourceBillNo from Gy_BarCodeBill where HBarCode='" + dic["HBarCode"].ToString() + "') and p.HNumber='" + dic["HProcNumber"].ToString() + "'  ", "Sc_ProcessExchangeBillMain");
+                ds = oCN.RunProcReturn(@"select  HMaterID,HUnitID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo,HBillNo,a.HInterID,b.HEntryID,a.HBillNo from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
+inner join Sc_ProcessExchangeBillSub b  WITH(NOLOCK) on a.HInterID=b.HInterID
+left join Gy_Process p WITH(NOLOCK) on b.HProcID=p.HItemID
+where HBillNo=(select HSourceBillNo from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + dic["HBarCode"].ToString() + "') and p.HNumber='" + dic["HProcNumber"].ToString() + "'  ", "Sc_ProcessExchangeBillMain");
                 if (ds.Tables[0].Rows.Count != 0)
                 {
                     HMaterID = int.Parse(ds.Tables[0].Rows[0]["HMaterID"].ToString());
@@ -813,7 +827,7 @@
                 }
 
 
-                ds = oCN.RunProcReturn("select * from Gy_Source where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
+                ds = oCN.RunProcReturn("select * from Gy_Source WITH(NOLOCK) where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
                 long HSourceID = 0;
                 if (ds.Tables[0].Rows.Count != 0)
                 {
@@ -840,7 +854,6 @@
                         values('3717','3717',1," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
                 "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + HRemark + "','" + HMaker + "',getdate()" +
                 ",'" + HEmpID + "'," + HGroupID + "," + HDeptID + "," + HMainSourceInterID + "," + HMainSourceEntryID + ",'" + HMainSourceBillNo + "') ");
-
 
                 string HBarCode = dic["HBarCode"].ToString();
                 string HMakeDate = dic["HCreateTime"].ToString();

--
Gitblit v1.9.1