| | |
| | | using Newtonsoft.Json.Linq; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using Pub_Class; |
| | | using SQLHelper; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.IO; |
| | | using System.Web; |
| | | using System.Web.Http; |
| | | using WebAPI.Controllers.SCGL.æ¥è®¡å管ç; |
| | | using WebAPI.Models; |
| | | |
| | | namespace WebAPI.Controllers |
| | |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | DataSet ds; |
| | | |
| | | DAL.ClsIF_Material_View oMaterHlp = new DAL.ClsIF_Material_View(); |
| | | public DAL.ClsGy_Process_View oProcHlp = new DAL.ClsGy_Process_View(); |
| | | DAL.ClsGy_WorkCenter_View oCenHlp = new DAL.ClsGy_WorkCenter_View(); |
| | | Gy_RoutingBill_temporary omdelMian = new Gy_RoutingBill_temporary(); |
| | | public string BillType = "3301"; |
| | | |
| | | #region å·¥èºè·¯çº¿ å表 |
| | | /// <summary> |
| | | /// è¿åå·¥èºè·¯çº¿å表 |
| | | ///åæ°ï¼string sqlã |
| | |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region å·¥èºè·¯çº¿ æ°å¢ |
| | | /// <summary> |
| | | /// æ°å¢åæ®-ä¿åæé® |
| | | ///åæ°ï¼string sqlã |
| | |
| | | |
| | | msg2 = "[" + msg2.ToString() + "]"; |
| | | List<Gy_RoutingBill> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_RoutingBill>>(msg2); |
| | | string BillType = "3301"; |
| | | |
| | | long HInterID = mainList[0].HInterID;//éå
¥typeå¾å°çåæ®ID |
| | | string HBillNo = mainList[0].HBillNo;//éå
¥typeå¾å°çåæ®å· |
| | | DateTime HDate = mainList[0].HDate;//æ¥æ |
| | |
| | | double HDelSourceRate = mainList[0].HDelSourceRate;//åèµæºåé |
| | | int HPRDORGID = mainList[0].HPRDORGID; //ç产ç»ç» |
| | | int HOrgID = mainList[0].HOrgID; //ç»ç» |
| | | |
| | | string HPicNumVer = mainList[0].HPicNumVer;//å¾å·çæ¬ |
| | | string HPicNumAssemble = mainList[0].HPicNumAssemble;//æ»è£
å¾å· |
| | | string HMaterTexture = mainList[0].HMaterTexture;//æè´¨ |
| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | // |
| | | #endregion |
| | | |
| | | #region å·¥èºè·¯çº¿ æä»¶ä¸ä¼ |
| | | [Route("Gy_RoutingBill/Gy_RoutingBillimport")] |
| | | [HttpPost] |
| | | public object Gy_RoutingBillimport() |
| | | { |
| | | try |
| | | { |
| | | var WorkBookName = HttpContext.Current.Request["WorkBookName"]; |
| | | //è·åæä»¶åç§° |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //è·åæä»¶ç©çè·¯å¾ |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //ä¿åæä»¶ |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1,2, WorkBookName); |
| | | |
| | | //å 餿件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //å建临æ¶è¡¨ |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | |
| | | //æ·»å åå |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | |
| | | //æ·»å æ°æ® |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = tb2.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | } |
| | | |
| | | |
| | | var error = ""; |
| | | |
| | | //æ¥è¯¢å·¥èºè·¯çº¿æ²¡æçå |
| | | if (!tb2.Columns.Contains("ç©æä»£ç ")) |
| | | error += "æ²¡ææ¾å°ãç©æä»£ç ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("å·¥åº")) |
| | | error += "æ²¡ææ¾å°ãå·¥åºãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("å·¥ä½ä¸å¿åç§°")) |
| | | error += "æ²¡ææ¾å°ãå·¥ä½ä¸å¿åç§°ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("å å·¥æ°é")) |
| | | error += "æ²¡ææ¾å°ãå å·¥æ°éãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("å¼å·¥ä½éåºæ°")) |
| | | error += "æ²¡ææ¾å°ãå¼å·¥ä½éåºæ°ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("å¼å·¥ä½é天æ°")) |
| | | error += "æ²¡ææ¾å°ãå¼å·¥ä½é天æ°ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("ç产å®é¢")) |
| | | error += "æ²¡ææ¾å°ãç产å®é¢ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("工价")) |
| | | error += "æ²¡ææ¾å°ã工价ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("å·¥åºå·")) |
| | | error += "æ²¡ææ¾å°ãå·¥åºå·ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("å·¥èºåæ°")) |
| | | error += "æ²¡ææ¾å°ãå·¥èºåæ°ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("å¾çº¸ç¼å·")) |
| | | error += "æ²¡ææ¾å°ãå¾çº¸ç¼å·ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("æ¬å·¥åºç¡®è®¤è®°å½")) |
| | | error += "æ²¡ææ¾å°ãæ¬å·¥åºç¡®è®¤è®°å½ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("å¾å·çæ¬")) |
| | | error += "æ²¡ææ¾å°ãå¾å·çæ¬ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("æ»è£
å¾å·")) |
| | | error += "æ²¡ææ¾å°ãæ»è£
å¾å·ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("æè´¨")) |
| | | error += "æ²¡ææ¾å°ãæè´¨ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("æåç¼å·")) |
| | | error += "æ²¡ææ¾å°ãæåç¼å·ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("çæ¬")) |
| | | error += "æ²¡ææ¾å°ãçæ¬ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("模å
·ç¼å·")) |
| | | error += "æ²¡ææ¾å°ã模å
·ç¼å·ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("ç¨åºå·")) |
| | | error += "æ²¡ææ¾å°ãç¨åºå·ãçæ é¢,"; |
| | | |
| | | if (!tb2.Columns.Contains("è¯ç")) |
| | | error += "æ²¡ææ¾å°ãè¯çãçæ é¢"; |
| | | |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = $"Excel模æ¿åå¨é误,{error}\r\n" ; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | Checkdata(tb2); |
| | | |
| | | string hnumber = ""; |
| | | if (tb2.Rows.Count > 0) |
| | | { |
| | | hnumber = DBUtility.ClsPub.isStrNull(tb2.Rows[0]["ç©æä»£ç "].ToString()); |
| | | } |
| | | |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string sHNumber = ""; |
| | | if (DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ç©æä»£ç "].ToString()) != "") |
| | | { |
| | | // |
| | | sHNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ç©æä»£ç "].ToString()); |
| | | //å®¡æ ¸ä»£ç æ¯å¦åç |
| | | if (!DBUtility.ClsPub.AllowNumber(sHNumber)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ç©æä»£ç ä¸ä¸è½åºç°è¿ç»â.âå¹¶ä¸é¦ä½æ«ä½ä¸è½ä¸ºâ.âï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (hnumber == DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ç©æä»£ç "].ToString())) |
| | | { |
| | | //å¾å°ç©æå
ç |
| | | if (!oMaterHlp.GetInfoByNumber(sHNumber)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + i.ToString() + "è¡," + sHNumber + "æ²¡ææ¾å°å¯¹åºçç©æï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | DataSet Ds; |
| | | ClsCN oCn = new ClsCN(); |
| | | bool b = false; |
| | | // 夿æ¯å¦åå¨å·¥èºè·¯çº¿ |
| | | Ds = oCn.RunProcReturn("Select HMaterID from Gy_RoutingBillMain Where HMaterID=" + oMaterHlp.omodel.HItemID.ToString(), "Gy_RoutingBillMain"); |
| | | |
| | | |
| | | hnumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ç©æä»£ç "].ToString()); |
| | | sHNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["ç©æä»£ç "].ToString()); |
| | | |
| | | //å®¡æ ¸ä»£ç æ¯å¦åç |
| | | if (!DBUtility.ClsPub.AllowNumber(sHNumber)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ç©æä»£ç ä¸ä¸è½åºç°è¿ç»â.âå¹¶ä¸é¦ä½æ«ä½ä¸è½ä¸ºâ.âï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //å¾å°ç©æå
ç |
| | | if (!oMaterHlp.GetInfoByNumber(sHNumber)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + i.ToString() + "è¡," + sHNumber + "æ²¡ææ¾å°å¯¹åºçç©æï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + i.ToString() + "è¡,æ²¡ææ¾å°å¯¹åºçç©æï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | //æ£æ¥ç©æ |
| | | private object Checkdata(DataTable dt) |
| | | { |
| | | bool b = false; |
| | | string sErrMsg = ""; |
| | | string sMsg = ""; |
| | | for (int i = 0; i <= dt.Rows.Count - 1; i++) |
| | | { |
| | | string sHNumber = ""; |
| | | string sHNamePoc = ""; |
| | | string sHNumberCen = ""; |
| | | Single sWorkQty = 0; |
| | | Single sHPassRate = 0; |
| | | |
| | | // |
| | | sHNumber = DBUtility.ClsPub.isStrNull(dt.Rows[i]["ç©æä»£ç "].ToString()); |
| | | sHNumberCen = DBUtility.ClsPub.isStrNull(dt.Rows[i]["å·¥ä½ä¸å¿åç§°"].ToString()); |
| | | sHNamePoc = DBUtility.ClsPub.isStrNull(dt.Rows[i]["å·¥åº"].ToString()); |
| | | sWorkQty = DBUtility.ClsPub.isSingle(dt.Rows[i]["å å·¥æ°é"].ToString()); |
| | | sHPassRate = DBUtility.ClsPub.isSingle(dt.Rows[i]["è¯ç"].ToString()); |
| | | if (sHNumber != "") |
| | | { |
| | | // |
| | | int index = i + 1; |
| | | //å å·¥æ°éä¸è½å°äºçäºé¶ |
| | | if (sWorkQty <= 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡å å·¥æ°éä¸è½å°äºçäºé¶ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //è¯çä¸è½å°äºçäºé¶ |
| | | if (sHPassRate <= 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + index + "è¡è¯çä¸è½å°äºçäºé¶ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //å®¡æ ¸ä»£ç æ¯å¦åç |
| | | if (!DBUtility.ClsPub.AllowNumber(sHNumber)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ç©æä»£ç ä¸ä¸è½åºç°è¿ç»â.âå¹¶ä¸é¦ä½æ«ä½ä¸è½ä¸ºâ.âï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //å¾å°ç©æå
ç |
| | | int j = i + 2; |
| | | if (!oMaterHlp.GetInfoByNumber(sHNumber)) |
| | | { |
| | | sMsg = "[" + sHNumber + "]ç©æä¸åå¨"; |
| | | if (sErrMsg.Contains(sMsg) == false) |
| | | { |
| | | sErrMsg = sErrMsg + "[" + sHNumber + "]ç©æä¸åå¨\r\n"; |
| | | } |
| | | b = true; |
| | | } |
| | | //å¾å°å·¥åºå
ç |
| | | if (!oProcHlp.GetInfoByName(sHNamePoc)) |
| | | { |
| | | sMsg = "[" + sHNamePoc + "]å·¥åºä¸åå¨"; |
| | | if (sErrMsg.Contains(sMsg) == false) |
| | | { |
| | | sErrMsg = sErrMsg + "[" + sHNamePoc + "]å·¥åºä¸åå¨\r\n"; |
| | | } |
| | | b = true; |
| | | } |
| | | |
| | | //å¾å°å·¥ä½ä¸å¿å
ç |
| | | if (!oCenHlp.GetInfoByName(sHNumberCen)) |
| | | { |
| | | sMsg = "[" + sHNumberCen + "]å·¥ä½ä¸å¿ä¸åå¨"; |
| | | if (sErrMsg.Contains(sMsg) == false) |
| | | { |
| | | sErrMsg = sErrMsg + "[" + sHNumberCen + "]å·¥ä½ä¸å¿ä¸åå¨\r\n"; |
| | | } |
| | | b = true; |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | if (b == true) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = sErrMsg; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = sErrMsg; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | #region å·¥èºè·¯çº¿ 导å
¥(ä¿å) |
| | | //临æ¶å段 |
| | | public class Gy_RoutingBill_temporary |
| | | { |
| | | public string HYear; |
| | | public string HPeriod; |
| | | public string DataAppend; |
| | | public string HOrgID; |
| | | } |
| | | |
| | | [Route("Gy_RoutingBill/Gy_RoutingBill_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_RoutingBill_btnSave([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | oCN.BeginTran(); |
| | | //ä¿å主表 |
| | | objJsonResult = RoutAddBillMain(msg1); |
| | | if (objJsonResult.code == "0") |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | oCN.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "åæ®ä¿åæåï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | public json RoutAddBillMain(string msg1) |
| | | { |
| | | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string msg3 = sArray[1].ToString(); |
| | | string user = sArray[2].ToString(); |
| | | |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_RoutingBill_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ ä¿åæéï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //è¡¨å¤´åæ®µ |
| | | omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<Gy_RoutingBill_temporary>(msg2); |
| | | |
| | | //JSONåºåå转æ¢åå
¸éå |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | List<object> jb = JsonConvert.DeserializeObject<List<object>>(msg3); |
| | | foreach (JObject item in jb) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | |
| | | |
| | | int TrueCount = 0, SumCount = 0; |
| | | |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | long HInterID = 0; |
| | | var HBillNo = ""; |
| | | if (list[i]["åæ®å·"].ToString() == "" && list[i]["hmainid"].ToString() == "") |
| | | { |
| | | HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);//è·å¾ä¸ä¸ªæ°çåæ®å· |
| | | HInterID = DBUtility.ClsPub.CreateBillID_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo);//è·å¾ä¸ä¸ªæ°çid |
| | | var HICMOBillNo = list[i]["ç产订åå·*"].ToString(); |
| | | var HICMOEntrySEQ = list[i]["ç产订åæç»è¡å·*"].ToString(); |
| | | var HWorkShopID = list[i]["HWorkShopID"].ToString(); |
| | | var HSourceID = list[i]["HSourceID"].ToString(); |
| | | var HYX = list[i]["ä¼å
级"].ToString(); |
| | | var HEmpID = list[i]["HEmpID"].ToString(); |
| | | var HMaterID = list[i]["HMaterID"].ToString(); |
| | | var HMaterName = list[i]["ç©æåç§°"].ToString(); |
| | | var HMaterModel = list[i]["è§æ ¼åå·"].ToString(); |
| | | var HUnitID = list[i]["HUnitID"].ToString(); |
| | | var HBatchNo = list[i]["æ¹æ¬¡å·"].ToString(); |
| | | var HSeOrderBillQty = list[i]["éå®è®¢åæ°é"].ToString(); |
| | | var HPlanQty = list[i]["çäº§è®¢åæ°é"].ToString(); |
| | | var HCompleteQty = list[i]["æ»é½å¥æ°é"].ToString(); |
| | | var HOrderType = ""; |
| | | var HDate = ""; |
| | | var HMainSourceInterID = list[i]["ICMOBillHInterID"].ToString(); |
| | | var HMainSourceEntryID = list[i]["ICMOBillHEntryID"].ToString(); |
| | | |
| | | ds = oCN.RunProcReturn($"select * from Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" + |
| | | $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID}", "Sc_WorkBillSortBillMain"); |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = $"第{i + 1}è¡çäº§èµæºæéå¤,请修æ¹!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //主表 |
| | | oCN.RunProc("insert into Sc_WorkBillSortBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType," + |
| | | "HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HICMOBillNo,HOrderType," + |
| | | "HICMOEntrySEQ,HWorkShopID,HSourceID, HYX, HEmpID," + |
| | | " HMaterID, HMaterName, HMaterModel, HUnitID, HBatchNo," + |
| | | " HSeOrderBillQty, HPlanQty, HCompleteQty,HPreparatDate," + |
| | | "HMainSourceInterID,HMainSourceEntryID)values" + |
| | | $"({HInterID},'{HBillNo}',{DateTime.Now.Year},{DateTime.Now.Month},'{BillType}'," + |
| | | $"'{BillType}',GETDATE(),1,'{user}','{HDate}','{HICMOBillNo}','{HOrderType}'," + |
| | | $"{(HICMOEntrySEQ == "" ? 0.ToString() : HICMOEntrySEQ)},{(HWorkShopID == "" ? 0.ToString() : HWorkShopID)},{(HSourceID == "" ? 0.ToString() : HSourceID)}, {(HYX == "" ? 0.ToString() : HYX)}, {(HEmpID == "" ? 0.ToString() : HEmpID)}," + |
| | | $" {(HMaterID == "" ? 0.ToString() : HMaterID)}, '{HMaterName}', '{HMaterModel}', {(HUnitID == "" ? 0.ToString() : HUnitID)}, '{HBatchNo}'," + |
| | | $" {(HSeOrderBillQty == "" ? 0.ToString() : HSeOrderBillQty)}, {(HPlanQty == "" ? 0.ToString() : HPlanQty)}, {(HCompleteQty == "" ? 0.ToString() : HCompleteQty)},getdate()," + |
| | | $" {HMainSourceInterID},{HMainSourceEntryID})"); |
| | | } |
| | | |
| | | int SumDay = 31; //卿䏤æä¹å·® DateTime.Now.AddMonths(1).AddDays(-1).Subtract(DateTime.Now).Days; |
| | | |
| | | for (int j = 0; j < SumDay; j++) |
| | | { |
| | | //主表åè¡¨é½ææ°æ® |
| | | if (list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString() != "") |
| | | { |
| | | SumCount += 1; |
| | | ////ä¿åå表 |
| | | objJsonResult = RoutAddBillSub(HInterID == 0 ? list[i]["hmainid"].ToString() : HInterID.ToString() |
| | | , HBillNo == "" ? list[i]["åæ®å·"].ToString() : HBillNo |
| | | , DateTime.Parse(DateTime.Now.AddDays(j).ToString("yyyy-MM-dd").ToString()) |
| | | , int.Parse(list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString())); |
| | | |
| | | if (objJsonResult.count == 1) |
| | | { |
| | | TrueCount += 1; |
| | | } |
| | | } |
| | | //ä¸»è¡¨ææ°æ® åè¡¨æ æ°æ® |
| | | if (j == 30 && SumCount == 0 && HInterID != 0 && HBillNo != "") |
| | | { |
| | | objJsonResult = RoutAddBillSub(HInterID.ToString(), HBillNo, DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd").ToString()), 0); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (TrueCount != SumCount) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | public json RoutAddBillSub(string HInterID, string HBillNo, DateTime date, int HQTY) |
| | | { |
| | | //è·åè¡¨æ ¼æ°æ® |
| | | ds = oCN.RunProcReturn($"select * from h_v_JIT_Sc_WorkBillSortBillList where åæ®å·='{HBillNo}'", "h_v_JIT_Sc_WorkBillSortBillList"); |
| | | |
| | | int count = 0; |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | //夿å表æ¯å¦æå½æ¥çæ¥æä»¥åæ¥ææå¯¹åºçæ°é |
| | | for (int i = 0; i < ds.Tables[0].Rows.Count; i++) |
| | | { |
| | | if (DateTime.Parse(ds.Tables[0].Rows[i]["æ¥è®¡åçäº§æ¥æ"].ToString()) == date) |
| | | { |
| | | oCN.RunProc($"update Sc_WorkBillSortBillSub set HMasterDate='{date}',HQty={HQTY}" + |
| | | $" where HInterID={HInterID} and HEntryID={ds.Tables[0].Rows[i]["hsubid"].ToString()}"); |
| | | count += 1; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (count != 1) |
| | | { |
| | | //æå
¥å表 |
| | | oCN.RunProc("insert into Sc_WorkBillSortBillSub(HInterID,HEntryID," + |
| | | "HMasterDate,HQty)" + |
| | | $"values({HInterID}, {(ds.Tables[0].Rows.Count + 1)}," + |
| | | $" '{date}', {HQTY})"); |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | #endregion |
| | | } |
| | | } |