| | |
| | | string HEmpName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["èå"].ToString()); |
| | | |
| | | string HICMOBillNo = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["ç产订åå·"].ToString()); |
| | | string HProc = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["å·¥åº"].ToString()); |
| | | |
| | | string HCostItemNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["ææ¬é¡¹ç®ä»£ç "].ToString()); |
| | | string HCostItemName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["ææ¬é¡¹ç®"].ToString()); |
| | | |
| | | //string HEntryID = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["å表å
ç "].ToString()); |
| | | |
| | | string HDepNumber_sub = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["åé¨é¨ä»£ç "].ToString()); |
| | | string HDepName_sub = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["åé¨é¨"].ToString()); |
| | | //string HDepNumber_sub = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["åé¨é¨ä»£ç "].ToString()); |
| | | //string HDepName_sub = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["åé¨é¨"].ToString()); |
| | | |
| | | string HMaterNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["ç©æç¼ç "].ToString()); |
| | | string HMaterName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["ç©æåç§°"].ToString()); |
| | |
| | | |
| | | // 1. æ¶éææéè¦æ¥è¯¢çæ°æ® |
| | | var HBillnos = list.Select(x => x["åæ®å·"].ToString()).Distinct().ToList(); |
| | | var HDeptNames = list.Select(x => x["é¨é¨"].ToString()).Distinct().ToList(); |
| | | var HDeptNumbers = list.Select(x => x["é¨é¨ä»£ç "].ToString()).Distinct().ToList(); |
| | | var HDeptNames_sub = list.Select(x => x["åé¨é¨"].ToString()).Distinct().ToList(); |
| | | var HDeptNumbers_sub = list.Select(x => x["åé¨é¨ä»£ç "].ToString()).Distinct().ToList(); |
| | | var HProc = list.Select(x => x["å·¥åº"].ToString()).Distinct().ToList(); |
| | | //var HDeptNames = list.Select(x => x["é¨é¨"].ToString()).Distinct().ToList(); |
| | | //var HDeptNumbers = list.Select(x => x["é¨é¨ä»£ç "].ToString()).Distinct().ToList(); |
| | | var HDeptNames_sub = list.Select(x => x["é¨é¨"].ToString()).Distinct().ToList(); |
| | | var HDeptNumbers_sub = list.Select(x => x["é¨é¨ä»£ç "].ToString()).Distinct().ToList(); |
| | | var materialNumbers = list.Select(x => x["ç©æç¼ç "].ToString()).Distinct().ToList(); |
| | | var materialNames = list.Select(x => x["ç©æåç§°"].ToString()).Distinct().ToList(); |
| | | var EmpNumbers = list.Select(x => x["èå代ç "].ToString()).Distinct().ToList(); |
| | |
| | | ICMODict[row["HBillNo"].ToString()] = (int)row["HInterID"]; |
| | | } |
| | | |
| | | // 2. æ¹éæ¥è¯¢ä¸»å表é¨é¨ä¿¡æ¯ |
| | | string supplierQuery = $"SELECT HItemID, HName FROM Gy_Department WHERE HName IN ({string.Join(",", HDeptNames.Select(s => $"'{s.Replace("'", "''")}'"))})"; |
| | | DataSet supData = oCN.RunProcReturn(supplierQuery, "Gy_Department"); |
| | | Dictionary<string, int> supplierDict = new Dictionary<string, int>(); |
| | | foreach (DataRow row in supData.Tables[0].Rows) |
| | | { |
| | | supplierDict[row["HName"].ToString()] = (int)row["HItemID"]; |
| | | } |
| | | //// 2. æ¹éæ¥è¯¢ä¸»å表é¨é¨ä¿¡æ¯ |
| | | //string supplierQuery = $"SELECT HItemID, HName FROM Gy_Department WHERE HName IN ({string.Join(",", HDeptNames.Select(s => $"'{s.Replace("'", "''")}'"))})"; |
| | | //DataSet supData = oCN.RunProcReturn(supplierQuery, "Gy_Department"); |
| | | //Dictionary<string, int> supplierDict = new Dictionary<string, int>(); |
| | | //foreach (DataRow row in supData.Tables[0].Rows) |
| | | //{ |
| | | // supplierDict[row["HName"].ToString()] = (int)row["HItemID"]; |
| | | //} |
| | | |
| | | // 2.1 æ¹éæ¥è¯¢ä¸»å表é¨é¨ä¿¡æ¯ |
| | | string supplierQuery_sub = $"SELECT HItemID, HName FROM Gy_Department WHERE HName IN ({string.Join(",", HDeptNames_sub.Select(s => $"'{s.Replace("'", "''")}'"))})"; |
| | |
| | | string key = $"{row["HName"].ToString()}"; |
| | | CostDict[key] = (int)row["HItemID"]; |
| | | } |
| | | |
| | | // 3.1 æ¹éæ¥è¯¢å·¥åºä¿¡æ¯ |
| | | string ProcessQuery = $"SELECT HItemID, HNumber, HName FROM Gy_Process WHERE HName IN ({string.Join(",", HProc.Select(m => $"'{m.Replace("'", "''")}'"))})"; |
| | | DataSet ProcData = oCN.RunProcReturn(ProcessQuery, "Gy_Process"); |
| | | Dictionary<string, int> ProcDict = new Dictionary<string, int>(); |
| | | foreach (DataRow row in ProcData.Tables[0].Rows) |
| | | { |
| | | string key = $"{row["HName"].ToString()}"; |
| | | ProcDict[key] = (int)row["HItemID"]; |
| | | } |
| | | // 4. æ¥è¯¢ç¨æ·ä¿¡æ¯ |
| | | DataSet emp = oCN.RunProcReturn($"SELECT Czybm FROM Gy_Czygl WHERE Czymc = '{user.Replace("'", "''")}'", "Gy_Czygl"); |
| | | if (emp.Tables[0].Rows.Count == 0) |
| | |
| | | string materialKey = $"{materialNumber}_{materialName}"; |
| | | |
| | | // æ£æ¥ä¾åºå |
| | | if (!supplierDict.ContainsKey(supplier)) |
| | | if (!supplierDict_sub.ContainsKey(supplier)) |
| | | { |
| | | missingSupplierMessages.Add($"第{lineNumber}è¡çé¨é¨ã{supplier}ã"); |
| | | } |
| | |
| | | { |
| | | int HMaterID = materialDict[$"{item["ç©æç¼ç "]}_{item["ç©æåç§°"]}"]; |
| | | int HCostID = CostDict[item["ææ¬é¡¹ç®"]]; |
| | | int HProcID = ProcDict[item["å·¥åº"]]; |
| | | |
| | | insertSql_sub.AppendLine($"INSERT INTO [CB_ItemMoneyBillSub] ([HInterID], [HEntryID], [HCloseMan], [HEntryCloseDate], [HCloseType], [HRemark],[HSourceInterID], [HSourceEntryID], [HSourceBillNo], [HSourceBillType],[HRelationQty], [HRelationMoney], [HBillNo_bak], [HCostItemID],[HDeptID], [HQty], [HPrice], [HMoney],[HMaterID], [HWaster], [HDate], [HBeginBalance], [HEndBalance], [HTimes]) VALUES ("); |
| | | insertSql_sub.AppendLine($"'{HInterID}', '{HEntryID}', '{""}', '{DateTime.Now}', '{"0"}', '{"excel导å
¥"}','{"0"}', '{"0"}', '{"0"}', '{"0"}','{"0"}', '{"0"}', '{""}', '{HCostID}', '{HSupplierID}', '{item["æ°é"]}', '{item["åä»·"]}', '{item["éé¢"]}','{HMaterID}', '{item["æèé"] ?? "0"}', '{DateTime.Now}', '{"0"}', '{"0"}', '{"0"}');"); |
| | | insertSql_sub.AppendLine($"INSERT INTO [CB_ItemMoneyBillSub] ([HInterID], [HEntryID], [HCloseMan], [HEntryCloseDate], [HCloseType], [HRemark],[HSourceInterID], [HSourceEntryID], [HSourceBillNo], [HSourceBillType],[HRelationQty], [HRelationMoney], [HBillNo_bak], [HCostItemID],[HDeptID], [HQty], [HPrice], [HMoney],[HMaterID], [HWaster], [HDate], [HBeginBalance], [HEndBalance], [HTimes],[HProcID]) VALUES ("); |
| | | insertSql_sub.AppendLine($"'{HInterID}', '{HEntryID}', '{""}', '{DateTime.Now}', '{"0"}', '{"excel导å
¥"}','{"0"}', '{"0"}', '{"0"}', '{"0"}','{"0"}', '{"0"}', '{""}', '{HCostID}', '{HSupplierID}', '{item["æ°é"]}', '{item["åä»·"]}', '{item["éé¢"]}','{HMaterID}', '{item["æèé"] ?? "0"}', '{DateTime.Now}', '{"0"}', '{"0"}', '{"0"}', '{HProcID}');"); |
| | | HEntryID++; |
| | | } |
| | | } |