protected void btnImport_Click(object sender, EventArgs e) { try { IList <RollingForecast> rollingForecastList = TheImportMgr.ReadRollingForecastFromXls(fileUpload.PostedFile.InputStream, this.CurrentUser); TheRollingForecastMgr.SaveRollingForecast(rollingForecastList); ShowSuccessMessage("Import.Result.Successfully"); } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } }
protected void btnImport_Click(object sender, EventArgs e) { try { CycleCount cycleCount = TheCycleCountMgr.LoadCycleCount(this.OrderNo); IList <CycleCountDetail> cycleCountDetailList = TheImportMgr.ReadCycleCountFromXls(fileUpload.PostedFile.InputStream, this.CurrentUser, cycleCount); this.TheCycleCountMgr.RecordCycleCountDetail(this.OrderNo, cycleCountDetailList, this.CurrentUser); ShowSuccessMessage("Import.Result.Successfully"); } catch (BusinessErrorException ex) { this.ShowErrorMessage(ex); } }
private void Import() { try { string flowCode = this.tbFlow.Text.Trim() != string.Empty ? this.tbFlow.Text.Trim() : string.Empty; OrderHead orderHead = TheImportMgr.ReadBatchTransferFromXls(fileUpload.PostedFile.InputStream, this.CurrentUser, flowCode); Receipt receipt = TheOrderMgr.QuickReceiveOrder(flowCode, orderHead.OrderDetails, this.CurrentUser.Code); this.ShowSuccessMessage("Receipt.Receive.Successfully", receipt.ReceiptNo); } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } }
protected void btnImport_Click(object sender, EventArgs e) { try { IList <OrderLocationTransaction> orderLoctransList = TheImportMgr.ReadOrderLocationTransactionFromXls(fileUpload.PostedFile.InputStream, OrderNo); TheOrderMgr.AddOrderLocationTransaction(orderLoctransList, this.CurrentUser); ShowSuccessMessage("Import.Result.Successfully"); if (BtnImportEvent != null) { this.Visible = false; BtnImportEvent(sender, e); } } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } }
protected void btnImport_Click(object sender, EventArgs e) { try { CycleCount cycleCount = this.GetCycleCount(); if (cycleCount == null) return; IList<CycleCountDetail> cycleCountDetailList = TheImportMgr.ReadCycleCountFromXls(fileUpload.PostedFile.InputStream, this.CurrentUser, cycleCount); TheCycleCountMgr.SaveCycleCount(cycleCount, cycleCountDetailList, this.CurrentUser); ShowSuccessMessage("Import.Result.Successfully"); if (BtnImportClick != null) { BtnImportClick(cycleCount.Code, null); } } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } }
private void Import() { try { string partyCode = this.tbRegion.Text.Trim() != string.Empty ? this.tbRegion.Text.Trim() : string.Empty; string timePeriodType = this.ucDateSelect.TimePeriodType; DateTime date = this.ucDateSelect.Date; IList <FlowPlan> flowPlanList = TheImportMgr.ReadShipScheduleYFKFromXls(fileUpload.PostedFile.InputStream, this.CurrentUser, this.ModuleType, partyCode, timePeriodType, date); IList <OrderHead> ohList = TheOrderMgr.ConvertFlowPlanToOrders(flowPlanList); if (ImportEvent != null) { ImportEvent(new object[] { ohList }, null); } ShowSuccessMessage("Import.Result.Successfully"); } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } }
protected void btnImport_Click(object sender, EventArgs e) { try { if (this.tbScheduleNo.Text.Trim() == string.Empty) { this.rfvScheduleNo.IsValid = false; return; } string flowCode = this.tbFlow.Text.Trim() != string.Empty ? this.tbFlow.Text.Trim() : string.Empty; IList <CustomerSchedule> customerScheduleList = TheImportMgr.ReadCustomerScheduleFromXls(fileUpload.PostedFile.InputStream, this.CurrentUser, null, null, flowCode, this.tbScheduleNo.Text.Trim(), false); if (customerScheduleList.Count > 0) { foreach (CustomerSchedule c in customerScheduleList) { c.CreateDate = DateTime.Now; c.CreateUser = this.CurrentUser.Code; c.LastModifyDate = DateTime.Now; c.LastModifyUser = this.CurrentUser.Code; c.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE; TheCustomerScheduleMgr.CreateCustomerSchedule(c); TheCustomerScheduleMgr.ReleaseCustomerSchedule(c.Id, this.CurrentUser.Code); } ShowSuccessMessage("MRP.Schedule.Create.Successfully"); if (this.backClickEvent != null) { this.backClickEvent(this, e); } } } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } }
private void Import() { try { string region = this.tbRegion.Text.Trim() != string.Empty ? this.tbRegion.Text.Trim() : string.Empty; string flowCode = this.tbFlow.Text.Trim() != string.Empty ? this.tbFlow.Text.Trim() : string.Empty; DateTime date = DateTime.Parse(this.tbDate.Text); string shiftCode = this.ucShift.ShiftCode; decimal leadTime = decimal.Parse(this.tbLeadTime.Text.Trim()); IList <ShiftPlanSchedule> spsList = TheImportMgr.ReadPSModelFromXls(fileUpload.PostedFile.InputStream, this.CurrentUser, region, flowCode, date, shiftCode); TheShiftPlanScheduleMgr.SaveShiftPlanSchedule(spsList, this.CurrentUser); IList <OrderHead> ohList = TheOrderMgr.ConvertShiftPlanScheduleToOrders(spsList, leadTime); if (ImportEvent != null) { ImportEvent(new object[] { ohList }, null); } ShowSuccessMessage("Import.Result.Successfully"); } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } }
protected void btnUpload_Click(object sender, EventArgs e) { try { HSSFWorkbook excel = new HSSFWorkbook(fileUpload.PostedFile.InputStream); Sheet sheet = excel.GetSheetAt(0); IEnumerator rows = sheet.GetRowEnumerator(); ImportHelper.JumpRows(rows, 10); //供货路线 窗口时间 物料号 订单数 #region 列定义 int colFlow = 1; //供货路线 int colWindowTime = 2; //窗口时间 int colItem = 3; // 物料号 int colQty = 4; //订单数 #endregion int rowCount = 10; //IList<Exception> exceptionList = new List<Exception>(); //Exception exceptio = new Exception(); string errorMessage = string.Empty; IList <OrderHead> orderHeadList = new List <OrderHead>(); while (rows.MoveNext()) { rowCount++; HSSFRow row = (HSSFRow)rows.Current; if (!TheImportMgr.CheckValidDataRow(row, 1, 4)) { break;//边界 } string flowCode = string.Empty; DateTime windowTime = DateTime.Now; string itemCode = string.Empty; decimal qty = 0; OrderHead orderHead = new OrderHead(); Flow currentFlow = new Flow(); #region 读取数据 #region 供货路线 flowCode = row.GetCell(colFlow) != null?row.GetCell(colFlow).StringCellValue : string.Empty; if (string.IsNullOrEmpty(flowCode)) { //ShowErrorMessage(string.Format("第{0}行:供货路线不能为空。", rowCount)); errorMessage += string.Format("第{0}行:供货路线不能为空。<br/>", rowCount); continue; } else { currentFlow = TheFlowMgr.LoadFlow(flowCode, this.CurrentUser.Code, true); } #endregion #region 读取窗口时间 try { string readwindowTime = row.GetCell(colWindowTime).StringCellValue; if (DateTime.TryParse(readwindowTime, out windowTime)) { orderHead.WindowTime = windowTime; } else { errorMessage += string.Format("第{0}行:窗口时间填写有误。<br/>", rowCount); continue; } } catch { errorMessage += string.Format("第{0}行:窗口时间填写有误。<br/>", rowCount); //ShowErrorMessage(string.Format("第{0}行:窗口时间填写有误。", rowCount)); continue; } #endregion #region 读取物料代码 itemCode = row.GetCell(colItem) != null?row.GetCell(colItem).StringCellValue : string.Empty; if (itemCode == null || itemCode.Trim() == string.Empty) { errorMessage += string.Format("第{0}行:物料代码不能为空。<br/>", rowCount); //ShowErrorMessage(string.Format("第{0}行:物料代码不能为空。", rowCount)); continue; } else { currentFlow.FlowDetails = currentFlow.FlowDetails.Where(f => f.Item.Code == itemCode).ToList(); if (currentFlow.FlowDetails.Count == 0) { errorMessage += string.Format("第{0}行:物料代码{1}在路线{2}中不存在。<br/>", rowCount, itemCode, flowCode); continue; } } #endregion #region 读取数量 try { qty = Convert.ToDecimal(row.GetCell(colQty).NumericCellValue); } catch { //ShowErrorMessage(string.Format("第{0}行:订单数量填写有误。<br/>", rowCount)); errorMessage += string.Format("第{0}行:订单数量填写有误。<br/>", rowCount); continue; } #endregion #endregion #region 填充数据 orderHead = TheOrderMgr.TransferFlow2Order(currentFlow); orderHead.SubType = "Nml"; orderHead.WindowTime = windowTime; orderHead.Priority = "Normal"; //orderHead.Type = "Procurement"; orderHead.StartTime = System.DateTime.Now; orderHead.IsAutoRelease = true; foreach (OrderDetail det in orderHead.OrderDetails) { det.RequiredQty = qty; det.OrderedQty = qty; } orderHeadList.Add(orderHead); #endregion } if (!string.IsNullOrEmpty(errorMessage)) { throw new Exception(errorMessage); } if (orderHeadList.Count == 0) { throw new Exception("导入的有效数据为0."); } var groups = (from tak in orderHeadList group tak by new { tak.WindowTime, tak.Flow, } into result select new { WindowTime = result.Key.WindowTime, Flow = result.Key.Flow, list = result.ToList() } ).ToList(); string orderNos = "导入成功,生成单号:"; foreach (var order in groups) { OrderHead newOrderHead = order.list.First(); IList <OrderDetail> detList = new List <OrderDetail>(); //OrderHead newOrderHead = new OrderHead(); foreach (var d in order.list) { OrderDetail det = d.OrderDetails.First(); det.OrderHead = newOrderHead; detList.Add(det); } newOrderHead.OrderDetails = detList; CreateOrder(newOrderHead); orderNos += newOrderHead.OrderNo + ","; } ShowSuccessMessage(orderNos); } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } catch (Exception ex) { ShowErrorMessage(ex.Message); return; } }
protected void btnUpload_Click(object sender, EventArgs e) { try { HSSFWorkbook excel = new HSSFWorkbook(fileUpload.PostedFile.InputStream); Sheet sheet = excel.GetSheetAt(0); IEnumerator rows = sheet.GetRowEnumerator(); ImportHelper.JumpRows(rows, 10); //生产线 物料号 物料描述 条码 数量 上线日期 上线时间 生产单号 #region 列定义 int colProdLine = 1; //供货路线 int colItemCode = 2; //物料号 int colHuId = 4; // 条码号 int colQty = 5; //订单数 int colOfflineDateStr = 6; //上线日期 int colOfflineTimeStr = 7; //上线时间 int colOrderNo = 8; //生产单号 #endregion int rowCount = 10; //IList<Exception> exceptionList = new List<Exception>(); //Exception exceptio = new Exception(); string errorMessage = string.Empty; DateTime nowTime = DateTime.Now; DssInboundControl control = TheGenericMgr.FindById <DssInboundControl>(9); IList <DssImportHistory> importList = new List <DssImportHistory>(); while (rows.MoveNext()) { rowCount++; HSSFRow row = (HSSFRow)rows.Current; if (!TheImportMgr.CheckValidDataRow(row, 1, 4)) { break;//边界 } string prodLineCode = string.Empty; Item Item = null; string huId = string.Empty; decimal qty = 0; string offlineDateStr = string.Empty; string offlineTimeStr = string.Empty; string orderNo = string.Empty; #region 读取数据 #region 生产线 prodLineCode = row.GetCell(colProdLine) != null?row.GetCell(colProdLine).StringCellValue : string.Empty; if (string.IsNullOrEmpty(prodLineCode)) { //ShowErrorMessage(string.Format("第{0}行:供货路线不能为空。", rowCount)); errorMessage += string.Format("第{0}行:生产线不能为空。<br/>", rowCount); continue; } #endregion #region 读取物料代码 string itemCode = row.GetCell(colItemCode) != null?row.GetCell(colItemCode).StringCellValue : string.Empty; if (itemCode == null || itemCode.Trim() == string.Empty) { errorMessage += string.Format("第{0}行:物料代码不能为空。<br/>", rowCount); //ShowErrorMessage(string.Format("第{0}行:物料代码不能为空。", rowCount)); continue; } else { Item = this.TheGenericMgr.FindById <Item>(itemCode); if (Item == null) { errorMessage += string.Format("第{0}行:物料代码{1}不存在。<br/>", rowCount, itemCode); continue; } } #endregion #region 条码 huId = row.GetCell(colHuId) != null?row.GetCell(colHuId).StringCellValue : string.Empty; if (string.IsNullOrEmpty(huId)) { errorMessage += string.Format("第{0}行:条码不能为空。<br/>", rowCount); continue; } else { if (huId.Length < 9) { errorMessage += string.Format("第{0}行:条码长度不能小于9。<br/>", rowCount); continue; } var yearCodeArr = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "S", "T", "V", "W", "X", "Y" }; var monthCodeArr = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C" }; var yearCode = huId.Substring(huId.Length - 8, 1); if (yearCodeArr.Where(a => a == yearCode).Count() == 0) { errorMessage += string.Format("第{0}行:批号的年份格式不正确。。<br/>", rowCount); continue; } var monthCode = huId.Substring(huId.Length - 7, 1); if (monthCodeArr.Where(a => a == monthCode).Count() == 0) { errorMessage += string.Format("第{0}行:批号的月份格式不正确。。。<br/>", rowCount); continue; } var dayCode = int.Parse(huId.Substring(huId.Length - 6, 2)); if (dayCode < 1 || dayCode > 31) { errorMessage += string.Format("第{0}行:批号的日期格式不正确。<br/>", rowCount); continue; } } #endregion #region 读取数量 try { qty = Convert.ToDecimal(row.GetCell(colQty).NumericCellValue); } catch { errorMessage += string.Format("第{0}行:数量填写有误。<br/>", rowCount); continue; } #endregion #region 线日期 offlineDateStr = row.GetCell(colOfflineDateStr) != null?row.GetCell(colOfflineDateStr).StringCellValue : string.Empty; if (string.IsNullOrEmpty(offlineDateStr)) { errorMessage += string.Format("第{0}行:上线日期不能为空。<br/>", rowCount); continue; } #endregion #region 线时间 offlineTimeStr = row.GetCell(colOfflineTimeStr) != null?row.GetCell(colOfflineTimeStr).StringCellValue : string.Empty; if (string.IsNullOrEmpty(offlineTimeStr)) { errorMessage += string.Format("第{0}行:上线时间不能为空。<br/>", rowCount); continue; } else { try { var offlineDateTime = DateTime.Parse(offlineDateStr + " " + offlineTimeStr); } catch (Exception ex) { errorMessage += string.Format("第{0}行:[上线日期{1}+上线时间{2}]不符合要求。<br/>", rowCount, offlineDateStr, offlineTimeStr); continue; } } #endregion #region 生产线 orderNo = row.GetCell(colOrderNo) != null?row.GetCell(colOrderNo).StringCellValue : string.Empty; if (string.IsNullOrEmpty(orderNo)) { errorMessage += string.Format("第{0}行:生产单号不能为空。<br/>", rowCount); continue; } #endregion #endregion #region 填充数据 DssImportHistory dssImportHistory = new DssImportHistory { data0 = prodLineCode, data1 = Item.Code, data2 = huId, data3 = qty.ToString(), data7 = offlineDateStr, data8 = offlineTimeStr, data12 = orderNo, IsActive = true, ErrorCount = 0, CreateDate = nowTime, LastModifyDate = nowTime, LastModifyUser = CurrentUser.Code, DssInboundCtrl = control, EventCode = "CREATE", KeyCode = "EXCEL", }; importList.Add(dssImportHistory); #endregion } if (!string.IsNullOrEmpty(errorMessage)) { throw new Exception(errorMessage); } if (importList.Count == 0) { throw new Exception("导入的有效数据为0."); } //try //{ // foreach (var dssImpHis in importList) // { // TheGenericMgr.Create(dssImpHis); // } //} //catch (Exception ex) //{ // throw ex; //} TheMaterialFlushBackMgr.ImportProdItemHuId(importList); ShowSuccessMessage("导入成功。"); } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } catch (Exception ex) { ShowErrorMessage(ex.Message); return; } }
protected void btnUpload_Click(object sender, EventArgs e) { try { HSSFWorkbook excel = new HSSFWorkbook(fileUpload.PostedFile.InputStream); Sheet sheet = excel.GetSheetAt(0); IEnumerator rows = sheet.GetRowEnumerator(); ImportHelper.JumpRows(rows, 10); //发货路线 窗口时间 外部订单号 参考订单号 物料号 订单数 #region 列定义 int colFlow = 1; //发货路线 int colExtOrderNo = 2; //外部订单号 int colItem = 3; // 物料号 int colQty = 4; //订单数 #endregion int rowCount = 10; //IList<Exception> exceptionList = new List<Exception>(); //Exception exceptio = new Exception(); string errorMessage = string.Empty; IList <OrderHead> orderHeadList = new List <OrderHead>(); while (rows.MoveNext()) { rowCount++; HSSFRow row = (HSSFRow)rows.Current; if (!TheImportMgr.CheckValidDataRow(row, 1, 4)) { break;//边界 } string flowCode = string.Empty; string extOrderNo = string.Empty; string itemCode = string.Empty; decimal qty = 0; OrderHead orderHead = new OrderHead(); Flow currentFlow = new Flow(); #region 读取数据 #region 发货路线 flowCode = row.GetCell(colFlow) != null?row.GetCell(colFlow).StringCellValue : string.Empty; if (string.IsNullOrEmpty(flowCode)) { errorMessage += string.Format("第{0}行:发货路线不能为空。<br/>", rowCount); continue; } else { currentFlow = TheFlowMgr.LoadFlow(flowCode, this.CurrentUser.Code, true); } #endregion #region 读取窗口时间 //try //{ // string readwindowTime = row.GetCell(colWindowTime).StringCellValue; // if (DateTime.TryParse(readwindowTime, out windowTime)) // { // orderHead.WindowTime = windowTime; // } // else // { // errorMessage += string.Format("第{0}行:窗口时间填写有误。<br/>", rowCount); // continue; // } //} //catch //{ // errorMessage += string.Format("第{0}行:窗口时间填写有误。<br/>", rowCount); // continue; //} #endregion extOrderNo = row.GetCell(colExtOrderNo) != null?row.GetCell(colExtOrderNo).StringCellValue : string.Empty; //refOrderNo = row.GetCell(colRefOrderNo) != null ? row.GetCell(colRefOrderNo).StringCellValue : string.Empty; #region 读取物料代码 itemCode = row.GetCell(colItem) != null?row.GetCell(colItem).StringCellValue : string.Empty; if (itemCode == null || itemCode.Trim() == string.Empty) { errorMessage += string.Format("第{0}行:物料代码不能为空。<br/>", rowCount); //ShowErrorMessage(string.Format("第{0}行:物料代码不能为空。", rowCount)); continue; } else { currentFlow.FlowDetails = currentFlow.FlowDetails.Where(f => f.Item.Code == itemCode).ToList(); if (currentFlow.FlowDetails.Count == 0) { errorMessage += string.Format("第{0}行:物料代码{1}在路线{2}中不存在。<br/>", rowCount, itemCode, flowCode); continue; } } #endregion #region 读取数量 try { qty = Convert.ToDecimal(row.GetCell(colQty).NumericCellValue); } catch { //ShowErrorMessage(string.Format("第{0}行:订单数量填写有误。<br/>", rowCount)); errorMessage += string.Format("第{0}行:订单数量填写有误。<br/>", rowCount); continue; } #endregion #endregion #region 填充数据 orderHead = TheOrderMgr.TransferFlow2Order(currentFlow); orderHead.SubType = this.ModuleSubType; orderHead.WindowTime = System.DateTime.Now; orderHead.Priority = "Normal"; orderHead.Type = this.ModuleType; orderHead.StartTime = System.DateTime.Now; orderHead.ExternalOrderNo = extOrderNo; //orderHead.ReferenceOrderNo = refOrderNo; orderHead.IsAutoRelease = true; orderHead.IsAutoStart = true; orderHead.IsAutoShip = true; orderHead.IsAutoReceive = true; orderHead.StartLatency = 0; orderHead.CompleteLatency = 0; foreach (OrderDetail det in orderHead.OrderDetails) { det.RequiredQty = qty; det.OrderedQty = qty; } orderHeadList.Add(orderHead); #endregion } if (!string.IsNullOrEmpty(errorMessage)) { throw new Exception(errorMessage); } if (orderHeadList.Count == 0) { throw new Exception("导入的有效数据为0."); } string successMessage = TheOrderMgr.QuickImportDistributionOrder(orderHeadList, this.CurrentUser.Code, this.ModuleSubType); ShowSuccessMessage(successMessage); //var groups = (from tak in orderHeadList // group tak by new // { // tak.Flow, // tak.ExternalOrderNo, // } // into result // select new // { // Flow = result.Key.Flow, // ExternalOrderNo = result.Key.ExternalOrderNo, // list = result.ToList() // } // ).ToList(); //string orderNos = "导入成功,生成送货单号:"; //foreach (var order in groups) //{ // OrderHead newOrderHead = order.list.First(); // IList<OrderDetail> detList = new List<OrderDetail>(); // //OrderHead newOrderHead = new OrderHead(); // foreach (var d in order.list) // { // OrderDetail det = d.OrderDetails.First(); // det.OrderHead = newOrderHead; // detList.Add(det); // } // newOrderHead.OrderDetails = detList; // orderNos += CreateOrder(newOrderHead); //} //ShowSuccessMessage(orderNos); } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } catch (Exception ex) { ShowErrorMessage(ex.Message); return; } }