protected void btnPickup_Click(object sender, EventArgs e) { try { // ExecuteSubmit(); DetachedCriteria criter = DetachedCriteria.For(typeof(LocationLotDetail)); criter.Add(Expression.Eq("Location", TheLocationMgr.LoadLocation(tbMiscOrderLocation.Text))); criter.Add(Expression.In("StorageBin", TheStorageBinMgr.GetStorageBin(tbStorageBin.Text).ToList())); criter.Add(Expression.IsNotNull("StorageBin")); IList <LocationLotDetail> result = TheCriteriaMgr.FindAll <LocationLotDetail>(criter); foreach (LocationLotDetail lot in result) { lot.StorageBin = null; lot.Hu.StorageBin = null; TheLocationLotDetailMgr.UpdateLocationLotDetail(lot); } ShowSuccessMessage("Warehouse.PickUp.Successfully"); GridView1.DataSource = null; GridView1.DataBind(); this.InitialAll(); } catch (BusinessErrorException ex) { this.ShowErrorMessage(ex); } }
protected void btnSearch_Click(object sender, EventArgs e) { DateTime?createDate = null; try { if (this.tbCreateDate.Text.Trim() != string.Empty) { createDate = DateTime.Parse(this.tbCreateDate.Text.Trim()); } } catch { ShowErrorMessage("Common.Date.Error"); } IList <LocationLotDetail> huLocationLotDetailList = TheLocationLotDetailMgr.GetHuLocationLotDetail(this.tbLocation.Text, this.tbArea.Text, this.tbBin.Text, this.tbHuId.Text, this.tbItem.Text, this.tbLotNo.Text, false, null, null, null, false, false, createDate, 501); if (huLocationLotDetailList.Count() > 500) { string count = huLocationLotDetailList.Count().ToString(); huLocationLotDetailList = huLocationLotDetailList.Take(500).ToList(); ShowWarningMessage("Common.ListCount.Warning.GreatThan500"); } this.ucList.InitPageParameter(huLocationLotDetailList); this.ucList.Visible = true; }
public void DoPick() { if (ConfirmEvent != null) { int resultCount = 0; PickList pickList = ThePickListMgr.LoadPickList(this.PickListNo); pickList.PickListDetails = new List <PickListDetail>(); foreach (GridViewRow row in GV_List.Rows) { Label lblLoc = (Label)row.FindControl("lblLoc"); HiddenField hfId = (HiddenField)row.FindControl("hfId"); Hu_HuInput ucHuInput = (Hu_HuInput)row.FindControl("ucHuInput"); PickListDetail pickListDetail = ThePickListDetailMgr.LoadPickListDetail(int.Parse(hfId.Value), true); IList <Hu> huList = ucHuInput.GetHuList(); if (huList != null && huList.Count > 0) { foreach (Hu hu in huList) { IList <LocationLotDetail> locationLotDetailList = TheLocationLotDetailMgr.GetHuLocationLotDetail(lblLoc.Text.Trim(), hu.HuId); if (locationLotDetailList != null && locationLotDetailList.Count > 0) { PickListResult pickListResult = new PickListResult(); pickListResult.LocationLotDetail = locationLotDetailList[0]; pickListResult.PickListDetail = pickListDetail; pickListResult.Qty = hu.Qty * pickListDetail.OrderLocationTransaction.UnitQty; pickListDetail.AddPickListResult(pickListResult); resultCount++; } } } pickList.AddPickListDetail(pickListDetail); } if (resultCount == 0) { ShowErrorMessage("MasterData.No.PickListResult"); return; } try { ThePickListMgr.DoPick(pickList, this.CurrentUser); ShowSuccessMessage("MasterData.PickList.Pick.Successfully", pickList.PickListNo); ConfirmEvent(this.PickListNo, null); } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } } }
private void HuInput(string huId) { try { if (MiscOrder.MiscOrderDetails != null) { foreach (MiscOrderDetail miscOrderDetail in MiscOrder.MiscOrderDetails) { if (miscOrderDetail.HuId == huId) { ShowErrorMessage("MasterData.MiscOrder.Location.Exists"); } } } if (this.ModuleType != BusinessConstants.CODE_MASTER_MISC_ORDER_TYPE_VALUE_GR) { if (this.tbMiscOrderLocation.Text.Trim() == string.Empty) { ShowErrorMessage("MasterData.MiscOrder.Location.Empty"); return; } IList <LocationLotDetail> locationLotDetailList = TheLocationLotDetailMgr.GetHuLocationLotDetail(this.tbMiscOrderLocation.Text.Trim(), huId); if (locationLotDetailList.Count == 0) { ShowErrorMessage("MasterData.MiscOrder.Location.NotExists.Hu", huId); } } Hu hu = TheHuMgr.LoadHu(huId); MiscOrderDetail newMiscOrderDetail = new MiscOrderDetail(); newMiscOrderDetail.HuId = huId; newMiscOrderDetail.Item = hu.Item; newMiscOrderDetail.LotNo = hu.LotNo; newMiscOrderDetail.Qty = hu.Qty * hu.UnitQty; MiscOrder.AddMiscOrderDetail(newMiscOrderDetail); BindMiscOrderDetails(); } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } }
protected void tbHuScan_TextChanged(object sender, EventArgs e) { string huId = this.tbHuScan.Text.Trim(); foreach (Hu hu in this.huList) { if (hu.HuId == huId) { ShowErrorMessage("Warehouse.Error.HuNotExist", huId); return; } } IList <LocationLotDetail> locationLotDetailList = TheLocationLotDetailMgr.GetHuLocationLotDetail(huId); if (locationLotDetailList.Count == 0) { ShowErrorMessage("Warehouse.Error.HuNotExist", huId); return; } if (this.LocationCode == null) { this.LocationCode = locationLotDetailList[0].Location.Code; } if (this.LocationCode != locationLotDetailList[0].Location.Code) { ShowErrorMessage("Hu.Error.Location.NotEqual"); return; } this.huList.Add(locationLotDetailList[0].Hu); this.GV_HuList.DataSource = this.huList; this.GV_HuList.DataBind(); this.lTitle.Visible = true; this.fdHuList.Visible = true; InitialHuScan(); }
protected void btnRepack_Click(object sender, EventArgs e) { try { if (this.RepackType == BusinessConstants.CODE_MASTER_REPACK_TYPE_VALUE_REPACK) { if (this.IsQty) { if (this.tbLocation.Text.Trim() == string.Empty) { ShowErrorMessage("MasterData.Inventory.Repack.Location.Empty"); return; } if (this.OutTransformerDetailList == null || this.OutTransformerDetailList.Count == 0) { ShowErrorMessage("MasterData.Inventory.Repack.Error.RepackDetailEmpty"); return; } IList <RepackDetail> repackDetailList = new List <RepackDetail>(); IDictionary <string, decimal> ItemDic = new Dictionary <string, decimal>(); foreach (TransformerDetail transformerDetail in OutTransformerDetailList) { RepackDetail outRepackDetail = new RepackDetail(); outRepackDetail.IOType = BusinessConstants.IO_TYPE_OUT; outRepackDetail.Hu = TheHuMgr.LoadHu(transformerDetail.HuId); outRepackDetail.Qty = outRepackDetail.Hu.Qty * outRepackDetail.Hu.UnitQty; if (ItemDic.ContainsKey(outRepackDetail.Hu.Item.Code)) { ItemDic[outRepackDetail.Hu.Item.Code] += outRepackDetail.Qty; } else { ItemDic.Add(outRepackDetail.Hu.Item.Code, outRepackDetail.Qty); } repackDetailList.Add(outRepackDetail); } if (repackDetailList.Count > 0) { foreach (string item in ItemDic.Keys) { IList <LocationLotDetail> locationLotDetailList = TheLocationLotDetailMgr.GetLocationLotDetail(this.tbLocation.Text.Trim(), item, false, false, BusinessConstants.PLUS_INVENTORY, null, false); if (locationLotDetailList == null || locationLotDetailList.Count == 0) { ShowErrorMessage("MasterData.Inventory.Repack.LocationLotDetail.Empty"); return; } decimal locQty = (from l in locationLotDetailList select l.Qty).Sum(); decimal outQty = ItemDic[item]; if (outQty > locQty) { ShowErrorMessage("MasterData.Inventory.LocationLotDetail.LessThanHuQty", item, locQty.ToString("0.########"), outQty.ToString("0.########")); return; } foreach (LocationLotDetail locationLotDetail in locationLotDetailList) { RepackDetail inRepackDetail = new RepackDetail(); inRepackDetail.LocationLotDetail = locationLotDetail; inRepackDetail.IOType = BusinessConstants.IO_TYPE_IN; repackDetailList.Add(inRepackDetail); if (locationLotDetail.Qty < outQty) { inRepackDetail.Qty = locationLotDetail.Qty; outQty -= inRepackDetail.Qty; } else { inRepackDetail.Qty = outQty; break; } } } } Repack repack = TheRepackMgr.CreateRepack(repackDetailList, this.CurrentUser); if (this.IsQty) { RepackEvent(repack.RepackNo, e); } } else { ExecuteSubmit(); Repack repack = TheRepackMgr.LoadRepack(this.CacheResolver.Code, true); IList <Hu> huList = new List <Hu>(); foreach (RepackDetail repackDet in repack.RepackDetails) { if (repackDet.IOType == BusinessConstants.IO_TYPE_OUT && repackDet.LocationLotDetail.Hu != null && repackDet.LocationLotDetail.Hu.PrintCount == 0) { huList.Add(repackDet.LocationLotDetail.Hu); } } if (huList.Count > 0) { IList <object> huDetailObj = new List <object>(); huDetailObj.Add(huList); huDetailObj.Add(CurrentUser.Code); string huTemplate = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_HU_TEMPLATE).Value; if (huTemplate != null && huTemplate.Length > 0) { string barCodeUrl = TheReportMgr.WriteToFile(huTemplate, huDetailObj, "BarCode.xls"); Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + barCodeUrl + "'); </script>"); } } } } else if (this.RepackType == BusinessConstants.CODE_MASTER_REPACK_TYPE_VALUE_DEVANNING) { UpdateOutTransformer(); ExecuteSubmit(); } if (RepackEvent != null && !this.IsQty) { RepackEvent(this.CacheResolver.Code, e); } } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } }
private void HuScan(Hu hu) { bool isMatch = false; #region Hu拣货 if (this.PickBy == BusinessConstants.CODE_MASTER_PICKBY_HU) { foreach (GridViewRow row in GV_List.Rows) { Label lblOrderQty = (Label)row.FindControl("lblOrderQty"); TextBox tbShipQty = (TextBox)row.FindControl("tbShipQty"); Label lblHuId = (Label)row.FindControl("lblHuId"); Label lblLoc = (Label)row.FindControl("lblLoc"); Label lblStorageBin = (Label)row.FindControl("lblStorageBin"); HiddenField hfId = (HiddenField)row.FindControl("hfId"); Hu_HuInput ucHuInput = (Hu_HuInput)row.FindControl("ucHuInput"); if (ucHuInput.CheckExist(hu.HuId)) { this.lblMessage.Text = Resources.Language.MasterDataHuExist; break; } if (hu.HuId == lblHuId.Text.Trim()) { IList <LocationLotDetail> locationLotDetList = TheLocationLotDetailMgr.GetHuLocationLotDetail(hu.HuId); if (locationLotDetList != null && locationLotDetList.Count > 0) { LocationLotDetail locLotDet = locationLotDetList[0]; if (locLotDet.Location.Code == lblLoc.Text.Trim() && (locLotDet.StorageBin == null || locLotDet.StorageBin.Code.ToUpper() == lblStorageBin.Text.Trim().ToUpper())) { decimal orderQty = lblOrderQty.Text.Trim() == string.Empty ? 0 : decimal.Parse(lblOrderQty.Text.Trim()); decimal shipQty = tbShipQty.Text.Trim() == string.Empty ? 0 : decimal.Parse(tbShipQty.Text.Trim()); if (orderQty >= shipQty + hu.Qty) { ucHuInput.HuInput(hu); tbShipQty.Text = ucHuInput.SumQty().ToString("F2"); PickListResult pickListResult = new PickListResult(); pickListResult.LocationLotDetail = locLotDet; pickListResult.PickListDetail = ThePickListDetailMgr.LoadPickListDetail(int.Parse(hfId.Value)); pickListResult.Qty = hu.Qty; isMatch = true; InitialHuScan(); break; } } } } } } #endregion #region LotNo拣货 else if (this.PickBy == BusinessConstants.CODE_MASTER_PICKBY_LOTNO) { foreach (GridViewRow row in GV_List.Rows) { Label lblOrderQty = (Label)row.FindControl("lblOrderQty"); TextBox tbShipQty = (TextBox)row.FindControl("tbShipQty"); Label lblLotNo = (Label)row.FindControl("lblLotNo"); Label lblItemCode = (Label)row.FindControl("lblItemCode"); Label lblUnitCount = (Label)row.FindControl("lblUnitCount"); Label lblUom = (Label)row.FindControl("lblUom"); Label lblLoc = (Label)row.FindControl("lblLoc"); Label lblStorageBin = (Label)row.FindControl("lblStorageBin"); Hu_HuInput ucHuInput = (Hu_HuInput)row.FindControl("ucHuInput"); HiddenField hfId = (HiddenField)row.FindControl("hfId"); if (ucHuInput.CheckExist(hu.HuId)) { this.lblMessage.Text = Resources.Language.MasterDataHuExist; break; } if (lblLotNo.Text.Trim().ToUpper() == hu.LotNo.ToUpper() && lblItemCode.Text.Trim().ToUpper() == hu.Item.Code.ToUpper() && decimal.Parse(lblUnitCount.Text.Trim()) == hu.UnitCount && lblUom.Text.Trim().ToUpper() == hu.Uom.Code.ToUpper()) { IList <LocationLotDetail> locationLotDetList = TheLocationLotDetailMgr.GetHuLocationLotDetail(hu.HuId); if (locationLotDetList != null && locationLotDetList.Count > 0) { LocationLotDetail locLotDet = locationLotDetList[0]; if (locLotDet.Location.Code == lblLoc.Text.Trim() && (locLotDet.StorageBin == null || locLotDet.StorageBin.Code == lblStorageBin.Text.Trim())) { decimal orderQty = lblOrderQty.Text.Trim() == string.Empty ? 0 : decimal.Parse(lblOrderQty.Text.Trim()); decimal shipQty = tbShipQty.Text.Trim() == string.Empty ? 0 : decimal.Parse(tbShipQty.Text.Trim()); if (orderQty >= shipQty + hu.Qty) { ucHuInput.HuInput(hu); tbShipQty.Text = ucHuInput.SumQty().ToString("F2"); PickListResult pickListResult = new PickListResult(); pickListResult.LocationLotDetail = locLotDet; pickListResult.PickListDetail = ThePickListDetailMgr.LoadPickListDetail(int.Parse(hfId.Value)); pickListResult.Qty = hu.Qty; isMatch = true; InitialHuScan(); break; } } } } } } #endregion if (!isMatch) { this.lblMessage.Text = Resources.Language.MasterDataPickListNotExistHu; this.tbHuScan.Text = string.Empty; this.tbHuScan.Focus(); } }
private void ReceiveRender(object sender, EventArgs e) { bool isOddCreateHu = (bool)sender; IList <ReceiptDetail> receiptDetailList = this.ucDetailList.PopulateReceiptDetailList(); bool isReceiptOneItem = bool.Parse(TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_IS_RECEIPT_ONE_ITEM).Value); if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION && this.ModuleSubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_ADJ && isReceiptOneItem && receiptDetailList.Count > 1) { ShowErrorMessage("MasterData.Receipt.One.Item"); return; } IList <OrderLocationTransaction> inLocTransList = new List <OrderLocationTransaction>(); foreach (ReceiptDetail receiptDetail in receiptDetailList) { OrderLocationTransaction ol = receiptDetail.OrderLocationTransaction; ol.CurrentReceiveQty = ol.UnitQty * (receiptDetail.ReceivedQty.HasValue ? (decimal)receiptDetail.ReceivedQty : 0); ol.CurrentRejectQty = ol.UnitQty * (receiptDetail.RejectedQty.HasValue ? (decimal)receiptDetail.RejectedQty : 0); ol.CurrentScrapQty = ol.UnitQty * (receiptDetail.ScrapQty.HasValue ? (decimal)receiptDetail.ScrapQty : 0); inLocTransList.Add(ol); } IList <OrderLocationTransaction> orderLocTransList = this.ucInLocTransList.InLocTransList; //投入原材料List IList <OrderLocationTransaction> outLocTransList = new List <OrderLocationTransaction>(); //非零原材料List IList <OrderLocationTransaction> rwoLocTransList = new List <OrderLocationTransaction>(); //返工成品List foreach (OrderLocationTransaction inLocTrans in this.ucInLocTransList.InLocTransList) { if (inLocTrans.BomDetail == null) { rwoLocTransList.Add(inLocTrans); } else if (inLocTrans.CurrentReceiveQty != 0) { outLocTransList.Add(inLocTrans); } } try { #region 正常生产收货 if (outLocTransList.Count > 0) { foreach (ReceiptDetail receiptDetail in receiptDetailList) { foreach (OrderLocationTransaction orderLocationTransaction in outLocTransList) { MaterialFlushBack materialFlushBack = new MaterialFlushBack(); materialFlushBack.RawMaterial = orderLocationTransaction.Item; materialFlushBack.Uom = orderLocationTransaction.OrderDetail.Uom; materialFlushBack.Operation = orderLocationTransaction.Operation; materialFlushBack.Qty = orderLocationTransaction.CurrentReceiveQty; IList <MaterialFlushBack> materialFlushBackList = TheMaterialFlushBackMgr.AssignMaterialFlushBack(materialFlushBack, inLocTransList); foreach (MaterialFlushBack m in materialFlushBackList) { if (m.OrderLocationTransaction.OrderDetail.Id == receiptDetail.OrderLocationTransaction.OrderDetail.Id) { if (m.OrderLocationTransaction.UnitQty != 0) { m.Qty = m.Qty / m.OrderLocationTransaction.UnitQty; } materialFlushBack = m; receiptDetail.AddMaterialFlushBack(materialFlushBack); break; } } } } } #endregion #region 新品收货 if (this.IsNewItem) { IList <TransformerDetail> transformerDetailList = this.ucNewItemInLocTransList.NewItemInLocTransList; //新品原材料List if (transformerDetailList.Count > 0) { foreach (ReceiptDetail receiptDetail in receiptDetailList) { foreach (TransformerDetail transformerDetail in transformerDetailList) { MaterialFlushBack materialFlushBack = new MaterialFlushBack(); LocationLotDetail newItemLocationLotDetail = TheLocationLotDetailMgr.LoadLocationLotDetail(transformerDetail.LocationLotDetId); materialFlushBack.RawMaterial = newItemLocationLotDetail.Item; materialFlushBack.Uom = newItemLocationLotDetail.Hu.Uom; materialFlushBack.Qty = newItemLocationLotDetail.Qty; materialFlushBack.HuId = newItemLocationLotDetail.Hu.HuId; IList <MaterialFlushBack> materialFlushBackList = TheMaterialFlushBackMgr.AssignMaterialFlushBack(materialFlushBack, inLocTransList); foreach (MaterialFlushBack m in materialFlushBackList) { if (m.OrderLocationTransaction.OrderDetail.Id == receiptDetail.OrderLocationTransaction.OrderDetail.Id) { if (m.OrderLocationTransaction.UnitQty != 0) { m.Qty = m.Qty / m.OrderLocationTransaction.UnitQty; } materialFlushBack = m; receiptDetail.AddMaterialFlushBack(materialFlushBack); break; } } } } } } #endregion #region 返工收货 if (rwoLocTransList.Count > 0) { foreach (OrderLocationTransaction rwoOrderLocTran in rwoLocTransList) { foreach (ReceiptDetail receiptDetail in receiptDetailList) { if (receiptDetail.OrderLocationTransaction.Item.Code == rwoOrderLocTran.Item.Code) { MaterialFlushBack materialFlushBack = new MaterialFlushBack(); materialFlushBack.RawMaterial = rwoOrderLocTran.Item; materialFlushBack.Uom = rwoOrderLocTran.OrderDetail.Uom; materialFlushBack.Operation = rwoOrderLocTran.Operation; materialFlushBack.Qty = rwoOrderLocTran.CurrentReceiveQty; IList <MaterialFlushBack> materialFlushBackList = TheMaterialFlushBackMgr.AssignMaterialFlushBack(materialFlushBack, inLocTransList); foreach (MaterialFlushBack m in materialFlushBackList) { if (m.OrderLocationTransaction.OrderDetail.Id == receiptDetail.OrderLocationTransaction.OrderDetail.Id) { if (m.OrderLocationTransaction.UnitQty != 0) { m.Qty = m.Qty / m.OrderLocationTransaction.UnitQty; } materialFlushBack = m; receiptDetail.AddMaterialFlushBack(materialFlushBack); break; } } } } } } #endregion Receipt receipt = TheOrderMgr.ReceiveOrder(receiptDetailList, this.CurrentUser, null, null, null, true, isOddCreateHu); OrderHead orderHead = TheOrderHeadMgr.LoadOrderHead(this.OrderNo); if (RefreshListEvent != null) { this.RefreshListEvent(new object[] { receipt.ReceiptNo, orderHead.NeedPrintReceipt }, e); } } catch (BusinessErrorException ex) { this.ShowErrorMessage(ex); } }