public IList <ReceiptDetail> PopulateReceiptDetailList() { IList <ReceiptDetail> receiptDetailList = new List <ReceiptDetail>(); for (int i = 0; i < this.GV_List.Rows.Count; i++) { GridViewRow row = this.GV_List.Rows[i]; HiddenField hfId = (HiddenField)row.FindControl("hfId"); HiddenField hfOrderDetailId = (HiddenField)row.FindControl("hfOrderDetailId"); TextBox tbHuId = (TextBox)row.FindControl("tbHuId"); TextBox tbHuReceiveQty = (TextBox)row.FindControl("tbHuReceiveQty"); TextBox tbReceiveQty = (TextBox)row.FindControl("tbReceiveQty"); TextBox tbRejectQty = (TextBox)row.FindControl("tbRejectQty"); TextBox tbScrapQty = (TextBox)row.FindControl("tbScrapQty"); decimal reveiveQty = tbHuId.Text != string.Empty ? (tbHuReceiveQty.Text.Trim() != string.Empty ? Decimal.Parse(tbHuReceiveQty.Text.Trim()) : 0) : (tbReceiveQty.Text.Trim() != string.Empty ? Decimal.Parse(tbReceiveQty.Text.Trim()) : 0); decimal rejectQty = tbRejectQty.Text.Trim() == string.Empty ? 0 : Decimal.Parse(tbRejectQty.Text.Trim()); decimal scrapQty = tbScrapQty.Text.Trim() == string.Empty ? 0 : Decimal.Parse(tbScrapQty.Text.Trim()); if (reveiveQty != 0 || rejectQty != 0 || scrapQty != 0) { ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.OrderLocationTransaction = TheOrderLocationTransactionMgr.LoadOrderLocationTransaction(Int32.Parse(hfId.Value)); receiptDetail.ReceivedQty = reveiveQty; receiptDetail.RejectedQty = rejectQty; receiptDetail.ScrapQty = scrapQty; receiptDetail.HuId = tbHuId.Text.Trim() == string.Empty ? null : tbHuId.Text.Trim(); receiptDetailList.Add(receiptDetail); } } return(receiptDetailList); }
public void InitPageParameter(string itemCode) { OrderLocationTransaction currentOrderLocTrans = TheOrderLocationTransactionMgr.LoadOrderLocationTransaction(this.LocTransId); OrderHead orderHead = currentOrderLocTrans.OrderDetail.OrderHead; //IList<BomDetail> bomDetailList = new List<BomDetail>(); IList <BomDetail> bomDetailList = TheBomDetailMgr.GetBomDetailListForAbstractItem(itemCode, orderHead.Routing, orderHead.StartTime, currentOrderLocTrans.OrderDetail.DefaultLocationFrom); IList <OrderLocationTransaction> orderLocTransList = new List <OrderLocationTransaction>(); // OrderLocationTransaction orderLocTrans = OrderLocationTransactionMgr.LoadOrderLocationTransaction(this.LocTransId); foreach (BomDetail bomDetail in bomDetailList) { OrderLocationTransaction newOrderLocTrans = TheOrderLocationTransactionMgr.LoadOrderLocationTransaction(this.LocTransId); newOrderLocTrans.Id = 0; newOrderLocTrans.Item = bomDetail.Item; newOrderLocTrans.Uom = bomDetail.Item.Uom; newOrderLocTrans.BomDetail = bomDetail; newOrderLocTrans.Operation = bomDetail.Operation; newOrderLocTrans.Location = bomDetail.Location; newOrderLocTrans.OrderedQty = newOrderLocTrans.OrderedQty * bomDetail.RateQty; newOrderLocTrans.AccumulateQty = newOrderLocTrans.AccumulateQty == null ? null : newOrderLocTrans.AccumulateQty * bomDetail.RateQty; newOrderLocTrans.AccumulateRejectQty = newOrderLocTrans.AccumulateRejectQty == null ? null : newOrderLocTrans.AccumulateRejectQty * bomDetail.RateQty; newOrderLocTrans.AccumulateScrapQty = newOrderLocTrans.AccumulateScrapQty == null ? null : newOrderLocTrans.AccumulateScrapQty * bomDetail.RateQty; orderLocTransList.Add(newOrderLocTrans); } this.OrderLocTransList = orderLocTransList; this.GV_List.DataSource = orderLocTransList; this.GV_List.DataBind(); }
private void RefreshGv_List() { OrderHead orderHead = TheOrderHeadMgr.LoadOrderHead(this.OrderNo, true); if (orderHead != null) { IList <OrderLocationTransaction> orderLocTransList = new List <OrderLocationTransaction>(); orderLocTransList = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(orderHead, BusinessConstants.IO_TYPE_IN); this.GV_List.DataSource = orderLocTransList; this.GV_List.DataBind(); UpdateView(orderHead); } else { ShowErrorMessage("MasterData.Order.NotExists", this.OrderNo); } }
protected void lbtnDelete_Click(object sender, EventArgs e) { int id = int.Parse(((LinkButton)sender).CommandArgument); OrderLocationTransaction orderLocationTrans = TheOrderLocationTransactionMgr.LoadOrderLocationTransaction(id); try { TheOrderMgr.DeleteOrderLocationTransaction(id, this.CurrentUser.Code); ShowSuccessMessage("MasterData.Order.LocTrans.Delete.Successfully"); UpdateRoutingEvent(this.OrderNo, e); UpdateView(); } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } }
protected void btnSave_Click(object sender, EventArgs e) { int currentLocTransId = -1; foreach (GridViewRow row in this.GV_List.Rows) { RadioButton rbSelect = (RadioButton)row.FindControl("rbSelect"); HiddenField hfRowIndex = (HiddenField)row.FindControl("hfRowIndex"); if (rbSelect.Checked) { currentLocTransId = int.Parse(hfRowIndex.Value); break; } } if (currentLocTransId == -1) { ShowErrorMessage("Common.Message.Record.Not.Select"); } else { OrderLocationTransaction currentLocationTrans = OrderLocTransList[currentLocTransId]; OrderLocationTransaction oldLocationTrans = TheOrderLocationTransactionMgr.LoadOrderLocationTransaction(this.LocTransId); OrderDetail orderDetail = TheOrderDetailMgr.LoadOrderDetail(oldLocationTrans.OrderDetail.Id, true); orderDetail.OrderHead = TheOrderHeadMgr.LoadOrderHead(orderDetail.OrderHead.OrderNo, true, true, true); oldLocationTrans.OrderDetail = orderDetail; try { TheOrderLocationTransactionMgr.ReplaceAbstractItem(oldLocationTrans, currentLocationTrans.BomDetail); if (SaveEvent != null) { SaveEvent(currentLocationTrans.OrderDetail.OrderHead.OrderNo, e); this.Visible = false; } } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } } }
public void SaveAllDetail() { IList <OrderLocationTransaction> orderLocTransList = new List <OrderLocationTransaction>(); int count = this.GV_List.Rows.Count; if (!this.IsReuse) { count = count - 1; } for (int i = 0; i < count; i++) { GridViewRow row = this.GV_List.Rows[i]; HiddenField hfId = (HiddenField)row.FindControl("hfId"); OrderLocationTransaction orderLocTrans = TheOrderLocationTransactionMgr.LoadOrderLocationTransaction(int.Parse(hfId.Value)); orderLocTrans.IsAssemble = ((CheckBox)row.FindControl("cbIsAssemble")).Checked; orderLocTrans.OrderedQty = decimal.Parse(((TextBox)row.FindControl("tbOrderdQty")).Text.Trim()); orderLocTrans.UnitQty = decimal.Parse(((TextBox)row.FindControl("tbUnitQty")).Text.Trim()); orderLocTrans.ItemVersion = ((TextBox)row.FindControl("tbUnitQty")).Text.Trim(); Controls_TextBox tbLocation = (Controls_TextBox)row.FindControl("tbLocation"); if (tbLocation.Text.Trim() != string.Empty) { orderLocTrans.Location = TheLocationMgr.LoadLocation(tbLocation.Text.Trim()); } orderLocTrans.NeedPrint = ((CheckBox)row.FindControl("cbNeedPrint")).Checked; orderLocTransList.Add(orderLocTrans); } //更新orderloctrans foreach (OrderLocationTransaction orderLocTrans in orderLocTransList) { TheOrderLocationTransactionMgr.UpdateOrderLocationTransaction(orderLocTrans); } // ShowSuccessMessage("MasterData.Order.LocTrans.Update.Successfully"); }
private void SaveRender(object sender, EventArgs e) { if (this.cvStartTime.IsValid || this.IsReject) { IList <OrderDetail> resultOrderDetailList = new List <OrderDetail>(); OrderHead orderHead = CloneHelper.DeepClone <OrderHead>((OrderHead)sender); //Clone:避免修改List Page的TheOrder,导致出错 if (orderHead != null && orderHead.OrderDetails != null && orderHead.OrderDetails.Count > 0) { foreach (OrderDetail orderDetail in orderHead.OrderDetails) { if (orderDetail.OrderedQty != 0) { if (orderDetail.Item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_K) { IList <Item> newItemList = new List <Item>(); //填充套件子件 decimal? convertRate = null; IList <ItemKit> itemKitList = null; var maxSequence = orderHead.OrderDetails.Max(o => o.Sequence); itemKitList = this.TheItemKitMgr.GetChildItemKit(orderDetail.Item); for (int i = 0; i < itemKitList.Count; i++) { Item item = itemKitList[i].ChildItem; if (!convertRate.HasValue) { if (itemKitList[i].ParentItem.Uom.Code != orderDetail.Item.Uom.Code) { convertRate = this.TheUomConversionMgr.ConvertUomQty(orderDetail.Item, orderDetail.Item.Uom, 1, itemKitList[i].ParentItem.Uom); } else { convertRate = 1; } } OrderDetail newOrderDetail = new OrderDetail(); newOrderDetail.OrderHead = orderDetail.OrderHead; newOrderDetail.Sequence = maxSequence + (i + 1); newOrderDetail.IsBlankDetail = false; newOrderDetail.Item = item; newOrderDetail.Uom = item.Uom; newOrderDetail.UnitCount = orderDetail.Item.UnitCount * itemKitList[i].Qty * convertRate.Value; newOrderDetail.OrderedQty = orderDetail.OrderedQty * itemKitList[i].Qty * convertRate.Value; newOrderDetail.PackageType = orderDetail.PackageType; #region 价格字段 if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT) { if (orderDetail.PriceListFrom != null && orderDetail.PriceListFrom.Code != string.Empty) { newOrderDetail.PriceListFrom = ThePurchasePriceListMgr.LoadPurchasePriceList(orderDetail.PriceListFrom.Code); if (newOrderDetail.PriceListFrom != null) { newOrderDetail.PriceListDetailFrom = this.ThePriceListDetailMgr.GetLastestPriceListDetail(newOrderDetail.PriceListFrom, item, DateTime.Now, newOrderDetail.OrderHead.Currency, item.Uom); } } } else if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION) { if (orderDetail.PriceListTo != null && orderDetail.PriceListTo.Code != string.Empty) { newOrderDetail.PriceListTo = TheSalesPriceListMgr.LoadSalesPriceList(orderDetail.PriceListTo.Code); } if (newOrderDetail.PriceListTo != null) { newOrderDetail.PriceListDetailTo = this.ThePriceListDetailMgr.GetLastestPriceListDetail(newOrderDetail.PriceListTo, item, DateTime.Now, newOrderDetail.OrderHead.Currency, item.Uom); } } #endregion resultOrderDetailList.Add(newOrderDetail); } } else { resultOrderDetailList.Add(orderDetail); } } } } if (resultOrderDetailList.Count == 0) { this.ShowErrorMessage("MasterData.Order.OrderHead.OrderDetail.Required"); return; } else { Flow currentFlow = TheFlowMgr.LoadFlow(CurrentFlowCode, true); DateTime winTime = this.tbWinTime.Text.Trim() == string.Empty ? DateTime.Now : DateTime.Parse(this.tbWinTime.Text); DateTime startTime = winTime; if (this.tbStartTime.Text != string.Empty) { startTime = DateTime.Parse(this.tbStartTime.Text.Trim()); } else { double leadTime = this.hfLeadTime.Value == string.Empty ? 0 : double.Parse(this.hfLeadTime.Value); double emTime = this.hfEmTime.Value == string.Empty ? 0 : double.Parse(this.hfEmTime.Value); double lTime = this.cbIsUrgent.Checked ? emTime : leadTime; startTime = winTime.AddHours(0 - lTime); } orderHead.OrderDetails = resultOrderDetailList; orderHead.WindowTime = winTime; orderHead.StartTime = startTime; orderHead.IsAutoRelease = this.cbReleaseOrder.Checked; orderHead.IsNewItem = this.NewItem; if (this.cbIsUrgent.Checked) { orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_URGENT; } else { orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_NORMAL; } if (this.tbRefOrderNo.Text.Trim() != string.Empty) { orderHead.ReferenceOrderNo = this.tbRefOrderNo.Text.Trim(); } if (this.tbExtOrderNo.Text.Trim() != string.Empty) { orderHead.ExternalOrderNo = this.tbExtOrderNo.Text.Trim(); } } //创建订单 try { if (this.IsQuick) { Receipt receipt = TheOrderMgr.QuickReceiveOrder(orderHead.Flow, orderHead.OrderDetails, this.CurrentUser.Code, this.ModuleSubType, orderHead.WindowTime, orderHead.StartTime, this.cbIsUrgent.Checked, orderHead.ReferenceOrderNo, orderHead.ExternalOrderNo); if (receipt.ReceiptDetails != null && receipt.ReceiptDetails.Count > 0) { orderHead = receipt.ReceiptDetails[0].OrderLocationTransaction.OrderDetail.OrderHead; if (this.cbPrintOrder.Checked) { IList <OrderDetail> orderDetails = orderHead.OrderDetails; IList <object> list = new List <object>(); list.Add(orderHead); list.Add(orderDetails); IList <OrderLocationTransaction> orderLocationTransactions = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(orderHead.OrderNo); list.Add(orderLocationTransactions); //TheReportProductionMgr.FillValues(orderHead.OrderTemplate, list); string printUrl = TheReportMgr.WriteToFile(orderHead.OrderTemplate, list); Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + printUrl + "'); </script>"); } } this.ShowSuccessMessage("Receipt.Receive.Successfully", receipt.ReceiptNo); if (!this.cbContinuousCreate.Checked) { this.PageCleanup(); if (QuickCreateEvent != null) { QuickCreateEvent(new Object[] { receipt, orderHead.NeedPrintReceipt }, e); } } else { orderHead = TheOrderMgr.TransferFlow2Order(this.tbFlow.Text.Trim()); InitDetailParamater(orderHead); } } else { TheOrderMgr.CreateOrder(orderHead, this.CurrentUser); if (this.cbPrintOrder.Checked) { IList <OrderDetail> orderDetails = orderHead.OrderDetails; IList <object> list = new List <object>(); list.Add(orderHead); list.Add(orderDetails); IList <OrderLocationTransaction> orderLocationTransactions = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(orderHead.OrderNo); list.Add(orderLocationTransactions); //TheReportProductionMgr.FillValues(orderHead.OrderTemplate, list); string printUrl = TheReportMgr.WriteToFile(orderHead.OrderTemplate, list); Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + printUrl + "'); </script>"); } this.ShowSuccessMessage("MasterData.Order.OrderHead.AddOrder.Successfully", orderHead.OrderNo); if (!this.cbContinuousCreate.Checked) { this.PageCleanup(); if (CreateEvent != null) { CreateEvent(orderHead.OrderNo, e); } } else { orderHead = TheOrderMgr.TransferFlow2Order(this.tbFlow.Text.Trim()); InitDetailParamater(orderHead); } } } catch (BusinessErrorException ex) { this.ShowErrorMessage(ex); return; } } }
public string AdjustInProcessLocationTo() { try { InProcessLocation ip = TheInProcessLocationMgr.LoadInProcessLocation(this.IpNo, true); Receipt receipt = new Receipt(); InProcessLocation nmlIp = CloneHelper.DeepClone(ip); IList <InProcessLocationDetail> nmlReceiptDetailList = new List <InProcessLocationDetail>(); foreach (InProcessLocationDetail ipdet in ip.InProcessLocationDetails) { #region 对应的ipdet InProcessLocationDetail nmlInProcessLocationDetail = new InProcessLocationDetail(); nmlInProcessLocationDetail.Qty = 0 - ipdet.Qty; nmlInProcessLocationDetail.OrderLocationTransaction = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(ipdet.OrderLocationTransaction.OrderDetail, BusinessConstants.IO_TYPE_IN)[0]; nmlInProcessLocationDetail.IsConsignment = ipdet.IsConsignment; nmlInProcessLocationDetail.PlannedBill = ipdet.PlannedBill; nmlReceiptDetailList.Add(nmlInProcessLocationDetail); #endregion #region 收货单明细 ReceiptDetail receiptDetail = new ReceiptDetail(); receiptDetail.Receipt = receipt; receiptDetail.ReceivedQty = nmlInProcessLocationDetail.Qty; receiptDetail.ShippedQty = nmlInProcessLocationDetail.Qty; receiptDetail.OrderLocationTransaction = nmlInProcessLocationDetail.OrderLocationTransaction; receiptDetail.IsConsignment = ipdet.IsConsignment; nmlInProcessLocationDetail.PlannedBill = ipdet.PlannedBill; OrderDetail orderDetail = receiptDetail.OrderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT) { PriceListDetail priceListDetail = ThePriceListDetailMgr.GetLastestPriceListDetail(orderDetail.DefaultPriceListFrom, orderDetail.Item, DateTime.Now, orderDetail.OrderHead.Currency); if (priceListDetail == null) { throw new BusinessErrorException("Order.Error.NoPriceListReceipt", new string[] { orderDetail.Item.Code }); } receiptDetail.PlannedAmount = priceListDetail.UnitPrice * (decimal)receiptDetail.ReceivedQty; } else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION) { PriceListDetail priceListDetail = ThePriceListDetailMgr.GetLastestPriceListDetail(orderDetail.DefaultPriceListTo, orderDetail.Item, DateTime.Now, orderDetail.OrderHead.Currency); if (priceListDetail == null) { throw new BusinessErrorException("Order.Error.NoPriceListReceipt", new string[] { orderDetail.Item.Code }); } receiptDetail.PlannedAmount = priceListDetail.UnitPrice * (decimal)receiptDetail.ReceivedQty; } receipt.AddReceiptDetail(receiptDetail); #endregion } nmlIp.InProcessLocationDetails = nmlReceiptDetailList; if (receipt.InProcessLocations == null) { receipt.InProcessLocations = new List <InProcessLocation>(); } receipt.InProcessLocations.Add(nmlIp); TheReceiptMgr.CreateReceipt(receipt, this.CurrentUser); return(receipt.ReceiptNo); } catch (BusinessErrorException ex) { throw (ex); } }
protected void btnConfirm_Click(object sender, EventArgs e) { try { IList<TransformerDetail> transformerDetailList = this.ucList.PopulateTransformerDetailList(); IList<OrderDetail> orderDetailList = new List<OrderDetail>(); string currentFlow = string.Empty; foreach (TransformerDetail transformerDetail in transformerDetailList) { if (transformerDetail.CurrentQty != transformerDetail.AdjustQty) { OrderLocationTransaction orderLocTrans = TheOrderLocationTransactionMgr.LoadOrderLocationTransaction(transformerDetail.OrderLocTransId); if (currentFlow == string.Empty) { currentFlow = orderLocTrans.OrderDetail.OrderHead.Flow; } OrderDetail orderDetail = new OrderDetail(); orderDetail.Item = TheItemMgr.LoadItem(transformerDetail.ItemCode); orderDetail.Uom = TheUomMgr.LoadUom(transformerDetail.UomCode); if (transformerDetail.HuId != null && transformerDetail.HuId.Trim() != string.Empty) { Hu hu = this.TheHuMgr.CheckAndLoadHu(transformerDetail.HuId.Trim()); orderDetail.OrderedQty = transformerDetail.AdjustQty - hu.Qty; } else { orderDetail.OrderedQty = transformerDetail.AdjustQty - transformerDetail.CurrentQty; } orderDetail.UnitCount = transformerDetail.UnitCount; orderDetail.HuId = transformerDetail.HuId; orderDetail.HuLotNo = transformerDetail.LotNo; if (transformerDetail.LocationFromCode != null) { orderDetail.LocationFrom = TheLocationMgr.LoadLocation(transformerDetail.LocationFromCode); } if (transformerDetail.LocationToCode != null) { orderDetail.LocationTo = TheLocationMgr.LoadLocation(transformerDetail.LocationToCode); } orderDetailList.Add(orderDetail); } } if (orderDetailList.Count > 0) { Receipt receipt = TheOrderMgr.QuickReceiveOrder(currentFlow, orderDetailList, this.CurrentUser.Code, BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_ADJ, DateTime.Now, DateTime.Now, false, this.ReceiptNo, null); this.Visible = false; ShowSuccessMessage("MasterData.Receipt.Adjust.Successfully", this.ReceiptNo); if (AdjustEvent != null) { AdjustEvent(receipt.ReceiptNo, e); } } else { ShowSuccessMessage("MasterData.Receipt.NoDetail.Adjust", this.ReceiptNo); } } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } }
protected void btnCreate_Click(object sender, EventArgs e) { try { if (this.tbFlow.Text == string.Empty) { ShowErrorMessage("MRP.Schedule.Import.CustomerSchedule.Result.SelectFlow"); return; } Flow flow = TheFlowMgr.CheckAndLoadFlow(this.tbFlow.Text); OrderHead orderHead = this.TheOrderMgr.TransferFlow2Order(flow); foreach (GridViewRow row in this.GV_Order.Rows) { if (row.RowType == DataControlRowType.DataRow) { string item = row.Cells[1].Text; string uom = row.Cells[4].Text; string qtyStr = ((TextBox)row.Cells[7].FindControl("tbQty")).Text; decimal?qty = null; try { qty = decimal.Parse(qtyStr); } catch (Exception) { this.ShowErrorMessage("MasterData.MiscOrder.WarningMessage.InputQtyFormat.Error"); return; } if (qty.HasValue && qty > 0) { OrderDetail orderDetail = (from det in orderHead.OrderDetails where det.Item.Code == item select det).FirstOrDefault(); if (orderDetail != null) { orderDetail.OrderedQty = qty.Value; if (orderDetail.Uom.Code != uom) { orderDetail.OrderedQty = this.TheUomConversionMgr.ConvertUomQty(item, uom, orderDetail.OrderedQty, orderDetail.Uom.Code); } } } } } IList <OrderDetail> resultOrderDetailList = new List <OrderDetail>(); if (orderHead != null && orderHead.OrderDetails != null && orderHead.OrderDetails.Count > 0) { foreach (OrderDetail orderDetail in orderHead.OrderDetails) { if (orderDetail.OrderedQty != 0) { if (orderDetail.Item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_K) { IList <Item> newItemList = new List <Item>(); //填充套件子件 decimal? convertRate = null; IList <ItemKit> itemKitList = null; var maxSequence = orderHead.OrderDetails.Max(o => o.Sequence); itemKitList = this.TheItemKitMgr.GetChildItemKit(orderDetail.Item); for (int i = 0; i < itemKitList.Count; i++) { Item item = itemKitList[i].ChildItem; if (!convertRate.HasValue) { if (itemKitList[i].ParentItem.Uom.Code != orderDetail.Item.Uom.Code) { convertRate = this.TheUomConversionMgr.ConvertUomQty(orderDetail.Item, orderDetail.Item.Uom, 1, itemKitList[i].ParentItem.Uom); } else { convertRate = 1; } } OrderDetail newOrderDetail = new OrderDetail(); newOrderDetail.OrderHead = orderDetail.OrderHead; newOrderDetail.Sequence = maxSequence + (i + 1); newOrderDetail.IsBlankDetail = false; newOrderDetail.Item = item; newOrderDetail.Uom = item.Uom; newOrderDetail.UnitCount = orderDetail.Item.UnitCount * itemKitList[i].Qty * convertRate.Value; newOrderDetail.OrderedQty = orderDetail.OrderedQty * itemKitList[i].Qty * convertRate.Value; newOrderDetail.PackageType = orderDetail.PackageType; #region 价格字段 if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT) { if (orderDetail.PriceListFrom != null && orderDetail.PriceListFrom.Code != string.Empty) { //newOrderDetail.PriceListFrom = ThePurchasePriceListMgr.l //if (newOrderDetail.PriceList != null) //{ // PriceListDetail priceListDetail = this.ThePriceListDetailMgr.GetLastestPriceListDetail(newOrderDetail.PriceList, item, DateTime.Now, newOrderDetail.OrderHead.Currency, item.Uom); // newOrderDetail.IsProvisionalEstimate = priceListDetail == null ? true : priceListDetail.IsProvisionalEstimate; // if (priceListDetail != null) // { // newOrderDetail.UnitPrice = priceListDetail.UnitPrice; // newOrderDetail.TaxCode = priceListDetail.TaxCode; // newOrderDetail.IsIncludeTax = priceListDetail.IsIncludeTax; // } //} } } #endregion resultOrderDetailList.Add(newOrderDetail); } } else { resultOrderDetailList.Add(orderDetail); } } } } if (resultOrderDetailList.Count == 0) { this.ShowErrorMessage("MasterData.Order.OrderHead.OrderDetail.Required"); return; } else { DateTime winTime = this.tbWinTime.Text.Trim() == string.Empty ? DateTime.Now : DateTime.Parse(this.tbWinTime.Text); DateTime startTime = winTime; if (this.tbSettleTime.Text.Trim() != string.Empty) { //orderHead.SettleTime = DateTime.Parse(this.tbSettleTime.Text); } if (this.tbStartTime.Text != string.Empty) { startTime = DateTime.Parse(this.tbStartTime.Text.Trim()); } else { double leadTime = this.hfLeadTime.Value == string.Empty ? 0 : double.Parse(this.hfLeadTime.Value); double emTime = this.hfEmTime.Value == string.Empty ? 0 : double.Parse(this.hfEmTime.Value); double lTime = this.cbIsUrgent.Checked ? emTime : leadTime; startTime = winTime.AddHours(0 - lTime); } if (orderHead.Type == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_PRODUCTION) { if (this.ucShift.ShiftCode == string.Empty) { ShowErrorMessage("MasterData.Order.Shift.Empty"); return; } orderHead.Shift = TheShiftMgr.LoadShift(this.ucShift.ShiftCode); } orderHead.OrderDetails = resultOrderDetailList; orderHead.WindowTime = winTime; orderHead.StartTime = startTime; orderHead.IsAutoRelease = this.cbReleaseOrder.Checked; if (this.cbIsUrgent.Checked) { orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_URGENT; } else { orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_NORMAL; } if (this.tbRefOrderNo.Text.Trim() != string.Empty) { orderHead.ReferenceOrderNo = this.tbRefOrderNo.Text.Trim(); } if (this.tbExtOrderNo.Text.Trim() != string.Empty) { orderHead.ExternalOrderNo = this.tbExtOrderNo.Text.Trim(); } } TheOrderMgr.CreateOrder(orderHead, this.CurrentUser); if (this.cbPrintOrder.Checked && false)//不要打印 { IList <OrderDetail> orderDetails = orderHead.OrderDetails; IList <object> list = new List <object>(); list.Add(orderHead); list.Add(orderDetails); IList <OrderLocationTransaction> orderLocationTransactions = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(orderHead.OrderNo); list.Add(orderLocationTransactions); string printUrl = TheReportMgr.WriteToFile(orderHead.OrderTemplate, list); Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + printUrl + "'); </script>"); } this.ShowSuccessMessage("MasterData.Order.OrderHead.AddOrder.Successfully", orderHead.OrderNo); //跳转到相应的订单查询一面 string url = null; if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) { url = "Main.aspx?mid=Order.OrderHead.Production__mp--ModuleType-Production_ModuleSubType-Nml_StatusGroupId-4__act--ListAction"; } else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_SUBCONCTRACTING || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_CUSTOMERGOODS) { url = "Main.aspx?mid=Order.OrderHead.Procurement__mp--ModuleType-Procurement_ModuleSubType-Nml_StatusGroupId-4__act--ListAction"; } else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION || orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER) { url = "Main.aspx?mid=Order.OrderHead.Distribution__mp--ModuleType-Distribution_ModuleSubType-Nml_StatusGroupId-4__act--ListAction"; } else { return; } Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>timedMsg('" + url + "'); </script>"); } catch (BusinessErrorException ex) { this.ShowErrorMessage(ex); } catch (Exception) { } }
private void SaveRender(object sender, EventArgs e) { if (this.cvStartTime.IsValid) { IList <OrderDetail> resultOrderDetailList = new List <OrderDetail>(); OrderHead orderHead = CloneHelper.DeepClone <OrderHead>((OrderHead)sender); //Clone:避免修改List Page的TheOrder,导致出错 if (orderHead != null && orderHead.OrderDetails != null && orderHead.OrderDetails.Count > 0) { foreach (OrderDetail orderDetail in orderHead.OrderDetails) { if (orderDetail.OrderedQty != 0) { resultOrderDetailList.Add(orderDetail); } } } if (resultOrderDetailList.Count == 0) { this.ShowErrorMessage("MasterData.Order.OrderHead.OrderDetail.Required"); return; } else { Flow currentFlow = TheFlowMgr.LoadFlow(CurrentFlowCode, true); DateTime winTime = DateTime.Parse(this.tbWinTime.Text); DateTime startTime = DateTime.Parse(this.tbWinTime.Text); string shiftCode = this.ucShift.ShiftCode; if (this.tbStartTime.Text != string.Empty) { startTime = DateTime.Parse(this.tbStartTime.Text.Trim()); } else { double leadTime = this.hfLeadTime.Value == string.Empty ? 0 : double.Parse(this.hfLeadTime.Value); double emTime = this.hfEmTime.Value == string.Empty ? 0 : double.Parse(this.hfEmTime.Value); double lTime = this.cbIsUrgent.Checked ? emTime : leadTime; startTime = winTime.AddHours(0 - lTime); } orderHead.OrderDetails = resultOrderDetailList; orderHead.WindowTime = winTime; orderHead.StartTime = startTime; orderHead.IsAutoRelease = this.cbReleaseOrder.Checked; orderHead.IsNewItem = this.NewItem; if (this.ucShift.ShiftCode != string.Empty) { orderHead.Shift = TheShiftMgr.LoadShift(this.ucShift.ShiftCode); } if (this.cbIsUrgent.Checked) { orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_URGENT; } else { orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_NORMAL; } if (this.tbRefOrderNo.Text.Trim() != string.Empty) { orderHead.ReferenceOrderNo = this.tbRefOrderNo.Text.Trim(); } if (this.tbExtOrderNo.Text.Trim() != string.Empty) { orderHead.ExternalOrderNo = this.tbExtOrderNo.Text.Trim(); } if (this.IsQuick) { orderHead.IsAutoRelease = true; orderHead.IsAutoStart = true; orderHead.IsAutoShip = true; orderHead.IsAutoReceive = true; orderHead.StartLatency = 0; orderHead.CompleteLatency = 0; } if (orderHead.ReferenceOrderNo != null && orderHead.ReferenceOrderNo != string.Empty) { orderHead.IsAdditional = true; } } //创建订单 try { //if (this.IsQuick) //{ // Receipt receipt = TheOrderMgr.QuickReceiveOrder(orderHead.Flow, orderHead.OrderDetails, this.CurrentUser, this.ModuleSubType, orderHead.WindowTime, orderHead.StartTime, this.cbIsUrgent.Checked, orderHead.ReferenceOrderNo, orderHead.ExternalOrderNo); // if (receipt.ReceiptDetails != null && receipt.ReceiptDetails.Count > 0) // { // orderHead = receipt.ReceiptDetails[0].OrderLocationTransaction.OrderDetail.OrderHead; // if (this.cbPrintOrder.Checked) // { // IList<OrderDetail> orderDetails = orderHead.OrderDetails; // IList<object> list = new List<object>(); // list.Add(orderHead); // list.Add(orderDetails); // IList<OrderLocationTransaction> orderLocationTransactions = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(orderHead.OrderNo); // list.Add(orderLocationTransactions); // //TheReportProductionMgr.FillValues(orderHead.OrderTemplate, list); // string printUrl = TheReportMgr.WriteToFile(orderHead.OrderTemplate, list); // Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + printUrl + "'); </script>"); // } // } // this.ShowSuccessMessage("Receipt.Receive.Successfully", receipt.ReceiptNo); // this.PageCleanup(); // if (!this.cbContinuousCreate.Checked) // { // if (QuickCreateEvent != null) // { // QuickCreateEvent(new Object[] { receipt, orderHead.NeedPrintReceipt }, e); // } // } //} //else //{ TheOrderMgr.CreateOrder(orderHead, this.CurrentUser); if (this.cbPrintOrder.Checked) { IList <OrderDetail> orderDetails = orderHead.OrderDetails; IList <object> list = new List <object>(); list.Add(orderHead); list.Add(orderDetails); IList <OrderLocationTransaction> orderLocationTransactions = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(orderHead.OrderNo); list.Add(orderLocationTransactions); //TheReportProductionMgr.FillValues(orderHead.OrderTemplate, list); string printUrl = TheReportMgr.WriteToFile(orderHead.OrderTemplate, list); Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + printUrl + "'); </script>"); } this.ShowSuccessMessage("MasterData.Order.OrderHead.AddOrder.Successfully", orderHead.OrderNo); if (!this.cbContinuousCreate.Checked) { this.PageCleanup(); if (CreateEvent != null) { CreateEvent(orderHead.OrderNo, e); } } else { orderHead = TheOrderMgr.TransferFlow2Order(this.tbFlow.Text.Trim()); this.ucList.InitPageParameter(orderHead); } //} } catch (BusinessErrorException ex) { this.ShowErrorMessage(ex); return; } } }
private void SaveRender(object sender, EventArgs e) { if (this.IsReject || this.IsQuick) { IList <OrderDetail> resultOrderDetailList = new List <OrderDetail>(); OrderHead orderHead = CloneHelper.DeepClone <OrderHead>((OrderHead)sender); //Clone:避免修改List Page的TheOrder,导致出错 if (orderHead != null && orderHead.OrderDetails != null && orderHead.OrderDetails.Count > 0) { foreach (OrderDetail orderDetail in orderHead.OrderDetails) { if (orderDetail.OrderedQty != 0) { resultOrderDetailList.Add(orderDetail); } } } if (resultOrderDetailList.Count == 0) { this.ShowErrorMessage("MasterData.Order.OrderHead.OrderDetail.Required"); return; } else { Flow currentFlow = TheFlowMgr.LoadFlow(CurrentFlowCode, true); DateTime winTime = DateTime.Now; DateTime startTime = winTime; orderHead.OrderDetails = resultOrderDetailList; orderHead.WindowTime = winTime; orderHead.StartTime = startTime; orderHead.IsNewItem = this.NewItem; if (this.tbRefOrderNo.Text.Trim() != string.Empty) { orderHead.ReferenceOrderNo = this.tbRefOrderNo.Text.Trim(); } if (this.tbExtOrderNo.Text.Trim() != string.Empty) { orderHead.ExternalOrderNo = this.tbExtOrderNo.Text.Trim(); } } //创建订单 try { if (this.IsQuick) { Receipt receipt = TheOrderMgr.QuickReceiveOrder(orderHead.Flow, orderHead.OrderDetails, this.CurrentUser.Code, this.ModuleSubType, orderHead.WindowTime, orderHead.StartTime, false, orderHead.ReferenceOrderNo, orderHead.ExternalOrderNo); if (receipt.ReceiptDetails != null && receipt.ReceiptDetails.Count > 0) { orderHead = receipt.ReceiptDetails[0].OrderLocationTransaction.OrderDetail.OrderHead; if (this.cbPrintOrder.Checked) { IList <OrderDetail> orderDetails = orderHead.OrderDetails; IList <object> list = new List <object>(); list.Add(orderHead); list.Add(orderDetails); IList <OrderLocationTransaction> orderLocationTransactions = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(orderHead.OrderNo); list.Add(orderLocationTransactions); string printUrl = TheReportMgr.WriteToFile(orderHead.OrderTemplate, list); Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + printUrl + "'); </script>"); } } this.ShowSuccessMessage("Receipt.Receive.Successfully", receipt.ReceiptNo); if (QuickCreateEvent != null) { QuickCreateEvent(new Object[] { receipt, orderHead.NeedPrintReceipt }, e); } } else { this.ShowErrorMessage("MasterData.Order.OrderHead.Not.Quick"); } } catch (BusinessErrorException ex) { this.ShowErrorMessage(ex); return; } } }
private void SaveRender(object sender, EventArgs e) { //创建订单 try { OrderHead orderHead = CloneHelper.DeepClone <OrderHead>((OrderHead)sender); //Clone:避免修改List Page的TheOrder,导致出错 IList <OrderDetail> resultOrderDetailList = new List <OrderDetail>(); if (orderHead.OrderDetails != null && orderHead.OrderDetails.Count > 0) { foreach (OrderDetail orderDetail in orderHead.OrderDetails) { if (orderDetail.OrderedQty != 0) { if (!this.IsReuse) { orderDetail.LocationFrom = TheLocationMgr.LoadLocation(this.ddlLocationFrom.SelectedValue); orderDetail.LocationTo = null; } if (orderHead.Status != null) { orderDetail.ScrapQty = orderDetail.OrderedQty; } } } } orderHead.WindowTime = DateTime.Now; orderHead.StartTime = DateTime.Now; orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_NORMAL; orderHead.ReferenceOrderNo = this.tbRefOrderNo.Text.Trim(); orderHead.ExternalOrderNo = this.tbExtOrderNo.Text.Trim(); orderHead.IsAutoRelease = false; orderHead.IsAutoStart = true; orderHead.IsAutoShip = false; orderHead.IsAutoReceive = false; orderHead.Shift = TheShiftMgr.GetAllShift()[0]; TheOrderMgr.CreateOrder(orderHead, this.CurrentUser); if (this.cbPrintOrder.Checked) { IList <OrderDetail> orderDetails = orderHead.OrderDetails; IList <object> list = new List <object>(); list.Add(orderHead); list.Add(orderDetails); IList <OrderLocationTransaction> orderLocationTransactions = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(orderHead.OrderNo); list.Add(orderLocationTransactions); string printUrl = TheReportMgr.WriteToFile(orderHead.OrderTemplate, list); Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + printUrl + "'); </script>"); } this.ShowSuccessMessage("MasterData.Order.OrderHead.AddOrder.Successfully", orderHead.OrderNo); PageCleanup(); if (CreateEvent != null) { CreateEvent(orderHead.OrderNo, e); } } catch (BusinessErrorException ex) { this.ShowErrorMessage(ex); return; } }
private void SaveRender(object sender, EventArgs e) { IList <OrderDetail> resultOrderDetailList = new List <OrderDetail>(); OrderHead orderHead = CloneHelper.DeepClone <OrderHead>((OrderHead)sender); //Clone:避免修改List Page的TheOrder,导致出错 if (orderHead != null && orderHead.OrderDetails != null && orderHead.OrderDetails.Count > 0) { foreach (OrderDetail orderDetail in orderHead.OrderDetails) { if (orderDetail.OrderedQty != 0) { resultOrderDetailList.Add(orderDetail); } } } if (resultOrderDetailList.Count == 0) { this.ShowErrorMessage("MasterData.Order.OrderHead.OrderDetail.Required"); return; } //创建订单 try { Receipt receipt = TheOrderMgr.QuickReceiveOrder(this.CurrentFlowCode, resultOrderDetailList, this.CurrentUser.Code, BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML, DateTime.Now, DateTime.Now, true, null, null); if (receipt.ReceiptDetails != null && receipt.ReceiptDetails.Count > 0) { orderHead = receipt.ReceiptDetails[0].OrderLocationTransaction.OrderDetail.OrderHead; if (this.cbPrintOrder.Checked) { IList <OrderDetail> orderDetails = orderHead.OrderDetails; IList <object> list = new List <object>(); list.Add(orderHead); list.Add(orderDetails); IList <OrderLocationTransaction> orderLocationTransactions = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(orderHead.OrderNo); list.Add(orderLocationTransactions); //TheReportProductionMgr.FillValues(orderHead.OrderTemplate,list); string printUrl = TheReportMgr.WriteToFile(orderHead.OrderTemplate, list); Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + printUrl + "'); </script>"); } } this.ShowSuccessMessage("MasterData.Order.OrderHead.Transfer.AddOrder.Successfully"); if (!this.cbContinuousCreate.Checked) { this.PageCleanup(); if (CreateEvent != null) { CreateEvent(new Object[] { receipt, orderHead.NeedPrintReceipt }, e); } } else { orderHead = TheOrderMgr.TransferFlow2Order(this.tbFlow.Text.Trim()); InitDetailParamater(orderHead); } } catch (BusinessErrorException ex) { this.ShowErrorMessage(ex); return; } }