public string GetProductLineInfo(string itoken, string Id, string iselectDate) { if (itoken == null || itoken.equalIgnoreCase(string.Empty)) { return(string.Empty); } if (!AlDataService.Instance.ClickTokenStatus(itoken))//token比對失敗,表示帳密輸入錯誤 { return(string.Empty); } //日期格式要有8位元ex:20171231 if (iselectDate == null || iselectDate.Length < 8) { iselectDate = NowTime.ToString("yyyyMMdd"); } List <MachineLineClass> data = new List <MachineLineClass>(); int?LineID = null; if (Id != null) { if (!Id.Equals(string.Empty)) { LineID = Convert.ToInt32(Id); } } AL_AssmblingDataTable dt = AlDataService.Instance.AL_Assmbling_getProductLine(LineID); List <string> MCIDList = new List <string>(); foreach (AL_AssmblingRow item in dt.Rows) { MCIDList.Add(item.ALA_MCID);//取得所有機台的MCID } var Detail_dt = AlDataService.Instance.AlAssmblingDetail_getDayTotalByMCID(iselectDate, MCIDList); Dictionary <string, SumValueClass> mQtyTotalList = SumTotalValue(Detail_dt, iselectDate); if (mQtyTotalList != null && mQtyTotalList.Values != null && mQtyTotalList.Values.Count > 0) { data = SelectLines(dt, mQtyTotalList); } else { return(string.Empty); } return(JsonConvert.SerializeObject(data)); }
/// <summary> /// 取得目前生產線所有線別 /// </summary> /// <param name="colId">哪條線(不傳就取全部)</param> /// <returns>線別數量</returns> public AL_AssmblingDataTable AL_Assmbling_getProductLine(int?colId) { AL_AssmblingDataTable dt = NsDmHelper.AL_Assmbling .selectAll(t => t.AllExt) .where (t => t.ALA_SEQCol == colId.toConstOpt1()) .orderby(t => t.ALA_SEQCol.Asc) .query(); if (dt == null || dt.Rows.Count == 0) { return(null); } return(dt); }
public AL_AssmblingDataTable AlAssmbling_create(int rowCount = 1) { var dt = new AL_AssmblingDataTable(); if (rowCount < 0) { rowCount = 0; } for (int i = 0; i < rowCount; i++) { var row = dt.newTypedRow(); row.ns_AssignNewId(); dt.addTypedRow(row); } return(dt); }
/// <summary> /// 轉換加總所有機台資訊 /// </summary> /// <param name="idt">機台主檔</param> /// <param name="iSumValue">所有機台總合資料</param> /// <returns>所有機台資料</returns> private List <MachineLineClass> SelectLines(AL_AssmblingDataTable idt, Dictionary <string, SumValueClass> iSumValue) { //<機台線別,所有機台加總資料> Dictionary <int, List <MachineClass> > lineList = new Dictionary <int, List <MachineClass> >(); foreach (var item in iSumValue) { foreach (AL_AssmblingRow idr in idt.Rows) { if (idr.ALA_MCID.Equals(item.Key)) { MachineClass MachineData = new MachineClass { MachineId = idr.ALA_MCID, MachineName = idr.ALA_MCName, MachineCol = (idr.ALA_SEQCol.Value + 1).ToString(), //UI顯示從1開始 MachineRow = (idr.ALA_SEQRow.Value + 1).ToString(), //UI顯示從1開始 MachineDay = item.Value.Day_Value.ToString(), MachineNight = item.Value.Night_Value.ToString(), MachineProduct = item.Value.ProductName.Replace("\0", string.Empty).Trim() }; if (lineList.ContainsKey(idr.ALA_SEQCol.Value))//已建立該線別 { lineList[idr.ALA_SEQCol.Value].Add(MachineData); } else { List <MachineClass> machineList = new List <MachineClass>(); machineList.Add(MachineData); lineList.Add(idr.ALA_SEQCol.Value, machineList); } } } } //線別排序 var SorList = lineList.OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value); //機台位置排序 foreach (var item in SorList.Values) { item.Sort((x, y) => x.MachineRow.CompareTo(y.MachineRow)); } List <MachineLineClass> mlineList = new List <MachineLineClass>(); foreach (var item in SorList) { string mProductName = GetProductName(item.Value, iSumValue); MachineLineClass machineLineData = new MachineLineClass { Line = (item.Key + 1).ToString(),//UI顯示從1開始 MachineList = item.Value }; //取得機台產品名稱 if (mProductName != null && !mProductName.Equals(string.Empty)) { machineLineData.Product = mProductName; } mlineList.Add(machineLineData); } return(mlineList); }
public ActionResult Edit(FormCollection collection) { var token = collection["__RequestVerificationToken"]; var mode = collection["ViewMode"]; var id = collection[AppDataName.ALA_AssmblingId]; var msgOK = "OK"; AL_AssmblingDataTable dt = null; AL_AssmblingRow row = null; try { if (mode.equalIgnoreCase("create")) { dt = AlDataService.Instance.AlAssmbling_create(); msgOK = FtdStatus.InsertSuccess.ToString(); } else { //找出該筆資料 dt = AlDataService.Instance.AlAssmbling_getById(id); if (dt == null || dt.Count == 0) { return(Json(new { Result = jTable_ERROR_CODE, Message = "資料不存在" })); } msgOK = FtdStatus.UpdateSuccess.ToString(); } //將Form sumit的資料更新至DataRow row = dt.FirstRow; var isOK = this.TryUpdateModel(row); //若驗證失敗-->回傳錯誤訊息 if (!ModelState.IsValid) { var errors = ModelState.Values.Where(x => x.Errors.Count > 0).SelectMany(x => x.Errors.Select(y => y.ErrorMessage)).ToArray(); return(Json(new { Result = jTable_ERROR_CODE, Message = string.Join("<br/>", errors) })); } #region //驗證欄位 List <string> lstError = new List <string>(); if (row.ALA_AssmblingId.isNullOrEmpty()) { lstError.Add("後工程組立ID不能為空"); } if (row.ALA_MCID.isNullOrEmpty()) { lstError.Add("機臺編碼不能為空"); } if (!row.ALA_SEQRow.HasValue) { lstError.Add("列位置不能為空"); } if (!row.ALA_SEQCol.HasValue) { lstError.Add("行位置不能為空"); } if (row.ALA_MCCode.isNullOrEmpty()) { lstError.Add("工程代碼不能為空"); } if (row.ALA_MCName.isNullOrEmpty()) { lstError.Add("工程描述不能為空"); } //回傳錯誤訊息 if (lstError.Count > 0) { return(Json(new { Result = jTable_ERROR_CODE, Message = string.Join("<br/>", lstError.ToArray()) })); } //檢查鍵值是否重覆 #endregion dt.ns_update(); dt.AcceptChanges(); return(Json(new { Result = msgOK })); } catch (Exception ex) { return(Json(new { Result = jTable_ERROR_CODE, Message = ex.Message })); } }