/// <summary> /// Validate Register repair request instrument detail /// </summary> /// <param name="Con">Register condition object</param> /// <returns></returns> public ActionResult IVS130_cmdConfirm(IVS130ConfirmCond Con) { ObjectResultData res = new ObjectResultData(); try { IVS130_ScreenParameter prm = GetScreenObject <IVS130_ScreenParameter>(); if (prm.ElemInstrument == null) { prm.ElemInstrument = new List <IVS130INST>(); } prm.ElemInstrument = Con.StockInInstrument; //4.1 ICommonHandler ComH = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; if (ComH.IsSystemSuspending()) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049); res.ResultData = true; return(Json(res)); } if (!CheckUserPermission(ScreenID.C_INV_SCREEN_ID_REPAIR_RETURN_RECEIVE, FunctionID.C_FUNC_ID_OPERATE)) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); res.ResultData = true; return(Json(res)); } IInventoryHandler InvH = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler; //4.2.1 List <tbt_InventorySlip> lstInventorySlip = InvH.GetTbt_InventorySlip(prm.SlipNo); //4.2.2 if (lstInventorySlip.Count > 0 && lstInventorySlip[0].SlipStatus == InventorySlipStatus.C_INV_SLIP_STATUS_COMPLETE) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4012, new string[] { prm.SlipNo }); res.ResultData = true; return(Json(res)); } //4.2.3 foreach (IVS130INST i in prm.ElemInstrument) { doCheckTransferQty chk = new doCheckTransferQty(); chk.OfficeCode = prm.office.OfficeCode; chk.LocationCode = InstrumentLocation.C_INV_LOC_REPAIR_RETURN; chk.AreaCode = i.DestinationAreaCode; chk.ShelfNo = i.DestinationShelfNo; chk.InstrumentCode = i.InstrumentCode; chk.TransferQty = i.TransferQty == null ? 0 : Convert.ToInt32(i.TransferQty); doCheckTransferQtyResult TransferQtyResult = InvH.CheckTransferQty(chk); //4.2.3 if (TransferQtyResult.OverQtyFlag == null) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4009, new string[] { i.InstrumentCode }); res.ResultData = i.row_id; i.IsError = true; return(Json(res)); } else if (TransferQtyResult.OverQtyFlag == true) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4008, new string[] { i.InstrumentCode }); res.ResultData = i.row_id; i.IsError = true; return(Json(res)); } } return(Json(res)); } catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); } }
/// <summary> /// Validate Register transfer stock-out repairing instrument data /// </summary> /// <param name="Cond">Register condition object</param> /// <returns></returns> public ActionResult IVS100_cmdReg(IVS100RegisterCond Cond) { ObjectResultData res = new ObjectResultData(); try { IVS100_ScreenParameter prm = GetScreenObject <IVS100_ScreenParameter>(); if (prm.ElemInstrument == null) { prm.ElemInstrument = new List <IVS100INST>(); } IInventoryHandler InvH = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler; ICommonHandler ComH = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; if (ComH.IsSystemSuspending()) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049); return(Json(res)); } if (!CheckUserPermission(ScreenID.C_INV_SCREEN_ID_REPAIR_REQUEST, FunctionID.C_FUNC_ID_OPERATE)) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); return(Json(res)); } //Valid Cond //6.1.1 if (prm.ElemInstrument.Count <= 0) { res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4006); return(Json(res)); } prm.ElemInstrument = Cond.StockInInstrument; prm.Memo = Cond.Memo; prm.Location = Cond.SourceLoc; prm.ApproveNo = Cond.ApproveNo; prm.RepairSubContractor = Cond.RepairSubContractor; //6.1.2 foreach (IVS100INST i in prm.ElemInstrument) { if (i.StockOutQty <= 0) { res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4030, new string[] { i.InstrumentCode }, new string[] { i.StockOutQty_id }); } } //6.1.3 if (!string.IsNullOrEmpty(prm.Memo) && prm.Memo.Replace(" ", "").Contains("\n\n\n\n")) { res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4022, null, new string[] { "memo" }); return(Json(res)); } //6.1.4 bool isError = false; foreach (IVS100INST i in prm.ElemInstrument) { doCheckTransferQty doCheck = new doCheckTransferQty(); doCheck.OfficeCode = prm.office.OfficeCode; doCheck.LocationCode = prm.Location; doCheck.AreaCode = i.AreaCode; doCheck.ShelfNo = i.ShelfNo; doCheck.InstrumentCode = i.InstrumentCode; doCheck.TransferQty = i.StockOutQty; doCheckTransferQtyResult doCheckResult = InvH.CheckTransferQty(doCheck); i.InstrumentQty = doCheckResult.CurrentyQty; if (doCheckResult.OverQtyFlag == null) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4009, new string[] { i.InstrumentCode }, new string[] { i.StockOutQty_id }); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; isError = true; } else if (doCheckResult.OverQtyFlag == true) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4008, new string[] { i.InstrumentCode }, new string[] { i.StockOutQty_id }); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; isError = true; } } res.ResultData = prm.ElemInstrument; return(Json(res)); } catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); } }
/// <summary> /// Register transfer stock-out repairing instrument data /// </summary> /// <param name="Con">Register condition object</param> /// <returns></returns> public ActionResult IVS100_cmdConfirm(IVS100RegisterCond Con) { ObjectResultData res = new ObjectResultData(); try { //Check Suspend IVS100_ScreenParameter prm = GetScreenObject <IVS100_ScreenParameter>(); if (prm.ElemInstrument == null) { prm.ElemInstrument = new List <IVS100INST>(); } ICommonHandler ComH = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; if (ComH.IsSystemSuspending()) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049); return(Json(res)); } if (!CheckUserPermission(ScreenID.C_INV_SCREEN_ID_REPAIR_REQUEST, FunctionID.C_FUNC_ID_OPERATE)) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); return(Json(res)); } IInventoryHandler InvH = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler; //prm.ElemInstrument = (from x in prm.ElemInstrument // orderby x.InstrumentCode, x.AreaCode // select x).ToList(); foreach (IVS100INST i in prm.ElemInstrument) { doCheckTransferQty Cond = new doCheckTransferQty(); Cond.OfficeCode = prm.office.OfficeCode; Cond.LocationCode = prm.Location; Cond.AreaCode = i.AreaCode; Cond.ShelfNo = i.ShelfNo; Cond.InstrumentCode = i.InstrumentCode; Cond.TransferQty = i.StockOutQty; doCheckTransferQtyResult TransferQtyResult = InvH.CheckTransferQty(Cond); i.InstrumentQty = TransferQtyResult.CurrentyQty; //8.2.1 if (TransferQtyResult.OverQtyFlag == null) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4009, new string[] { i.InstrumentCode }, new string[] { i.StockOutQty_id }); res.ResultData = prm.ElemInstrument; i.IsError = true; return(Json(res)); } else if (TransferQtyResult.OverQtyFlag == true) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4008, new string[] { i.InstrumentCode }, new string[] { i.StockOutQty_id }); res.ResultData = prm.ElemInstrument; i.IsError = true; return(Json(res)); } } string strInventorySlipNo = string.Empty; using (TransactionScope scope = new TransactionScope()) { //8.3 doRegisterTransferInstrumentData data = new doRegisterTransferInstrumentData(); data.SlipId = SlipID.C_INV_SLIPID_REPAIR_REQUEST; tbt_InventorySlip InvSlip = new tbt_InventorySlip(); InvSlip.SlipNo = null; InvSlip.SlipStatus = InventorySlipStatus.C_INV_SLIP_STATUS_TRANSFER; InvSlip.TransferTypeCode = TransferType.C_INV_TRANSFERTYPE_REPAIR_REQUEST; InvSlip.InstallationSlipNo = null; InvSlip.ProjectCode = null; InvSlip.PurchaseOrderNo = null; InvSlip.ContractCode = null; InvSlip.SlipIssueDate = DateTime.Now; InvSlip.StockInDate = null; InvSlip.StockOutDate = DateTime.Now; InvSlip.SourceLocationCode = prm.Location; InvSlip.DestinationLocationCode = InstrumentLocation.C_INV_LOC_REPAIRING; InvSlip.SourceOfficeCode = prm.office.OfficeCode; InvSlip.DestinationOfficeCode = prm.office.OfficeCode; InvSlip.ApproveNo = prm.ApproveNo; InvSlip.Memo = prm.Memo; InvSlip.StockInFlag = null; InvSlip.DeliveryOrderNo = null; InvSlip.ShelfType = ShelfType.C_INV_SHELF_TYPE_NORMAL; InvSlip.RepairSubcontractor = prm.RepairSubContractor; InvSlip.InstallationCompleteFlag = null; InvSlip.ContractStartServiceFlag = null; InvSlip.CustomerAcceptanceFlag = null; // doSlip.ProjectCompleteFlag=null; InvSlip.PickingListNo = null; InvSlip.CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo; InvSlip.CreateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; InvSlip.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; InvSlip.UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo; data.InventorySlip = InvSlip; data.lstTbt_InventorySlipDetail = new List <tbt_InventorySlipDetail>(); int iRunNo = 1; foreach (IVS100INST i in prm.ElemInstrument) { tbt_InventorySlipDetail SlipDetail = new tbt_InventorySlipDetail(); SlipDetail.SlipNo = null; SlipDetail.RunningNo = iRunNo; SlipDetail.InstrumentCode = i.InstrumentCode; SlipDetail.SourceAreaCode = i.AreaCode; SlipDetail.DestinationAreaCode = i.AreaCode; SlipDetail.SourceShelfNo = i.ShelfNo; SlipDetail.DestinationShelfNo = ShelfNo.C_INV_SHELF_NO_OTHER_LOCATION; SlipDetail.TransferQty = i.StockOutQty; SlipDetail.NotInstalledQty = null; SlipDetail.RemovedQty = null; SlipDetail.UnremovableQty = null; SlipDetail.InstrumentAmount = null; data.lstTbt_InventorySlipDetail.Add(SlipDetail); iRunNo++; } //8.4 strInventorySlipNo = InvH.RegisterTransferInstrument(data); //8.5 if (InvH.CheckNewInstrument(strInventorySlipNo) == 1) { //8.5.1 List <doGroupNewInstrument> groupNewInstrument = InvH.GetGroupNewInstrument(strInventorySlipNo); foreach (doGroupNewInstrument i in groupNewInstrument) { //8.5.2 i.DestinationLocationCode = InstrumentLocation.C_INV_LOC_REPAIR_REQUEST; //8.5.3 #region Monthly Price @ 2015 decimal decMovingAveragePrice = InvH.GetMonthlyAveragePrice(i.Instrumentcode, InvSlip.SlipIssueDate, InventoryAccountCode.C_INV_ACCOUNT_CODE_INSTOCK, SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_LOCAL, SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US); #endregion InvH.UpdateAccountTransferNewInstrument(i, Convert.ToDecimal(decMovingAveragePrice)); } } //8.6 int blnCheckSecondhandInstrument = InvH.CheckSecondhandInstrument(strInventorySlipNo); if (blnCheckSecondhandInstrument == 1) { //8.6.1 List <doGroupSecondhandInstrument> GroupSecondHandInstrument = InvH.GetGroupSecondhandInstrument(strInventorySlipNo); foreach (doGroupSecondhandInstrument i in GroupSecondHandInstrument) { //8.6.2 i.DestinationLocationCode = InstrumentLocation.C_INV_LOC_REPAIR_REQUEST; InvH.UpdateAccountTransferSecondhandInstrument(i); } } //8.7 int blnCheckSampleInstrument = InvH.CheckSampleInstrument(strInventorySlipNo); if (blnCheckSampleInstrument == 1) { //8.7.1 List <doGroupSampleInstrument> GroupSampleInstrument = InvH.GetGroupSampleInstrument(strInventorySlipNo); foreach (doGroupSampleInstrument i in GroupSampleInstrument) { //8.7.2 i.DestinationLocationCode = InstrumentLocation.C_INV_LOC_REPAIR_REQUEST; InvH.UpdateAccountTransferSampleInstrument(i, null); } } scope.Complete(); } //8.8.1 IInventoryDocumentHandler handlerInventoryDocument = ServiceContainer.GetService <IInventoryDocumentHandler>() as IInventoryDocumentHandler; string strReportPath = handlerInventoryDocument.GenerateIVR070FilePath(strInventorySlipNo, prm.office.OfficeCode, CommonUtil.dsTransData.dtUserData.EmpNo, CommonUtil.dsTransData.dtOperationData.ProcessDateTime); prm.slipNoReportPath = strReportPath; prm.slipNo = strInventorySlipNo; res.ResultData = strInventorySlipNo; return(Json(res)); } catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); } }
/// <summary> /// Calculate price.<br /> /// - Check is empty.<br /> /// - Check quantity.<br /> /// - If second hand get price by FIFO lot.<br /> /// - If sample use default.<br /> /// - If new get average price. /// </summary> /// <param name="Cond"></param> /// <param name="SourceLoc"></param> /// <param name="RegisterPress"></param> /// <returns></returns> public ActionResult IVS040_Calculate(List <IVS040INST> Cond, string SourceLoc, bool RegisterPress) { ObjectResultData res = new ObjectResultData(); try { if (Cond == null || Cond.Count <= 0) { if (RegisterPress) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4006); } else { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4068); } res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; return(Json(res)); } IVS040_ScreenParameter prm = GetScreenObject <IVS040_ScreenParameter>(); if (prm.ElemInstrument == null) { prm.ElemInstrument = new List <IVS040INST>(); } IInventoryHandler InvH = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler; //int previousQty = 0; Hashtable preTransQty = new Hashtable(); bool isError = false; // Check transfer empty instrument //List<IVS040INST> zeroList = ( // from row in Cond // where row.TransferInstrumentQty <= 0 // select row //).ToList<IVS040INST>(); //foreach (var i in zeroList) { // res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4030, new string[] { i.InstrumentCode }, new string[] { i.TransQtyID }); // isError = true; //} //if (isError) { // res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; // res.ResultData = prm.ElemInstrument; // return Json(res); //} //isError = false; for (int i = 0; i < Cond.Count; i++) { if (Cond[i].TransferInstrumentQty <= 0) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4030, new string[] { Cond[i].InstrumentCode }, new string[] { Cond[i].TransQtyID }); isError = true; continue; } foreach (IVS040INST k in prm.ElemInstrument) { if (Cond[i].InstrumentCode == k.InstrumentCode && Cond[i].AreaCode == k.AreaCode) { doCheckTransferQty checkCon = new doCheckTransferQty(); checkCon.OfficeCode = prm.office.OfficeCode; checkCon.LocationCode = SourceLoc; checkCon.AreaCode = k.AreaCode; checkCon.ShelfNo = k.ShelfNo; checkCon.InstrumentCode = k.InstrumentCode; checkCon.TransferQty = Cond[i].TransferInstrumentQty; doCheckTransferQtyResult checkResult = InvH.CheckTransferQty(checkCon); k.InstrumentQty = checkResult.CurrentyQty; if (checkResult.OverQtyFlag == null) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4009, new string[] { k.InstrumentCode }, new string[] { Cond[i].TransQtyID }); isError = true; break; } else if (checkResult.OverQtyFlag == true) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4008, new string[] { k.InstrumentCode }, new string[] { Cond[i].TransQtyID }); isError = true; break; } break; } } } if (isError) { res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.ResultData = prm.ElemInstrument; return(Json(res)); } for (int i = 0; i < Cond.Count; i++) { foreach (IVS040INST k in prm.ElemInstrument) { if (Cond[i].InstrumentCode == k.InstrumentCode && Cond[i].AreaCode == k.AreaCode) { k.TransQtyID = Cond[i].TransQtyID; k.TransferInstrumentQty = Cond[i].TransferInstrumentQty; if (k.AreaCode == InstrumentArea.C_INV_AREA_SE_RENTAL || k.AreaCode == InstrumentArea.C_INV_AREA_SE_HANDLING_DEMO) { int previousQty = 0; if (preTransQty.ContainsKey(k.InstrumentCode)) { previousQty = ((int)preTransQty[k.InstrumentCode]); preTransQty[k.InstrumentCode] = previousQty + k.TransferInstrumentQty; } else { preTransQty[k.InstrumentCode] = k.TransferInstrumentQty; } doFIFOInstrumentPrice instrumentPrice = InvH.GetFIFOInstrumentPrice(k.TransferInstrumentQty, prm.office.OfficeCode, SourceLoc, k.InstrumentCode, previousQty); if (instrumentPrice.decTransferAmount == null) { k.TransferAmount = 0; } else { k.TransferAmount = instrumentPrice.decTransferAmount.Value; k.TransferAmountCurrencyType = instrumentPrice.decTransferAmountCurrencyType; } //k.TransferAmount = Convert.ToDecimal(InvH.GetFIFOInstrumentPrice(k.TransferInstrumentQty, prm.office.OfficeCode, SourceLoc, k.InstrumentCode, previousQty)); } else if (k.AreaCode == InstrumentArea.C_INV_AREA_NEW_SAMPLE) { k.TransferAmount = InventoryConfig.C_INV_DEFAULT_SAMPLE_AMOUNT; k.TransferAmountCurrencyType = SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_LOCAL; } else { doCalPriceCondition CalPrice = InvH.GetMovingAveragePriceCondition(prm.office.OfficeCode, null, null, k.InstrumentCode, new string[] { SourceLoc }, null); k.TransferAmount = Convert.ToDecimal(CalPrice.MovingAveragePrice * k.TransferInstrumentQty); if (CalPrice.MovingAveragePriceCurrencyType != null) { k.TransferAmountCurrencyType = CalPrice.MovingAveragePriceCurrencyType; } } break; } } } res.ResultData = prm.ElemInstrument; return(Json(res)); } catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); } }
/// <summary> /// Validate before register.<br /> /// - Check system suspending.<br /> /// - Check user permission for screen IVS070.<br /> /// - Check slip status.<br /> /// - Check quantity. /// </summary> /// <param name="Cond"></param> /// <returns></returns> public ActionResult IVS070_cmdConfirm(IVS070RegisterCond Cond) { ObjectResultData res = new ObjectResultData(); try { IVS070_ScreenParameter prm = GetScreenObject <IVS070_ScreenParameter>(); string SlipNo = prm.SlipNo; string SourceOffice = prm.SourceOffice; string DestinationOffice = prm.DestinationOffice; ICommonHandler ComH = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; if (ComH.IsSystemSuspending()) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049); res.ResultData = MessageUtil.MessageList.MSG0049; return(Json(res)); } if (!CheckUserPermission(ScreenID.C_INV_SCREEN_ID_TRANSFER_OFFICE_RECEIVE, FunctionID.C_FUNC_ID_OPERATE)) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); res.ResultData = MessageUtil.MessageList.MSG0053; return(Json(res)); } IInventoryHandler InvH = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler; List <tbt_InventorySlip> dtTbt_InventorySlip = InvH.GetTbt_InventorySlip(SlipNo); tbt_InventorySlip InvenSlip = dtTbt_InventorySlip[0]; //4.2.2 if (InvenSlip.SlipStatus == InventorySlipStatus.C_INV_SLIP_STATUS_COMPLETE) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4012, new string[] { SlipNo }); res.ResultData = MessageUtil.MessageList.MSG4012; return(Json(res)); } //4.2.3 foreach (IVS070INST i in Cond.StockInInstrument) { doCheckTransferQty checkQty = new doCheckTransferQty(); checkQty.OfficeCode = DestinationOffice; checkQty.LocationCode = InstrumentLocation.C_INV_LOC_TRANSFER; checkQty.AreaCode = i.DestinationAreaCode; checkQty.ShelfNo = ShelfNo.C_INV_SHELF_NO_OTHER_LOCATION; checkQty.InstrumentCode = i.InstrumentCode; checkQty.TransferQty = Convert.ToInt32(i.TransferQty); doCheckTransferQtyResult qtyResult = InvH.CheckTransferQty(checkQty); if (qtyResult.OverQtyFlag == null) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4009, new string[] { i.InstrumentCode }); res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.ResultData = i.row_id; return(Json(res)); } else if (qtyResult.OverQtyFlag == true) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4008, new string[] { i.InstrumentCode }); res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.ResultData = i.row_id; return(Json(res)); } } //4.3 Return to screen and show message //res.ResultData = prm.SlipNo; return(Json(res)); } catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); } }
/// <summary> /// Validate before confirm screen.<br /> /// - Check require field.<br /> /// - Check instrument list not empty.<br /> /// - Check memo. /// - Check quantity. /// </summary> /// <param name="transfer"></param> /// <returns></returns> public ActionResult IVS060_cmdReg(IVS060TransferDO transfer) { ObjectResultData res = new ObjectResultData(); try { IVS060_ScreenParameter prm = GetScreenObject <IVS060_ScreenParameter>(); if (prm.lstTransferInstrument == null) { prm.lstTransferInstrument = new List <IVS060INST>(); } if (prm.lstTransferInstrument.Count <= 0) { res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4006); return(Json(res)); } if (transfer.memo != null) { if (transfer.memo.Replace(" ", "").Contains("\n\n\n\n")) { res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4022, null, new string[] { "memo" }); return(Json(res)); } } prm.Memo = transfer.memo; bool isError = false; List <string> controls = new List <string>(); bool hasTransfer = true; foreach (var i in transfer.transferQTYList) { if (!i.transferQTY.HasValue || i.transferQTY.Value == 0) { controls.Add(i.controlID); hasTransfer = false; } if (hasTransfer) { foreach (var instrument in prm.lstTransferInstrument) { if (instrument.InstrumentCode == i.instrumentCode && instrument.AreaCode == i.areaCode) { instrument.TransferInstrumentQty = i.transferQTY.Value; instrument.TransQtyID = i.controlID; continue; } } } } if (controls.Count > 0) { res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.AddErrorMessage( MessageUtil.MODULE_INVENTORY, ScreenID.C_INV_SCREEN_ID_TRANSFER_OFFICE, MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4029, new string[] { "headerTransferInstrumentQuantity" }, controls.ToArray()); isError = true; //return Json(res); } foreach (IVS060INST i in prm.lstTransferInstrument) { doCheckTransferQty checkQty = new doCheckTransferQty(); checkQty.OfficeCode = prm.SourceOffice; checkQty.LocationCode = InstrumentLocation.C_INV_LOC_INSTOCK; checkQty.AreaCode = i.AreaCode; checkQty.ShelfNo = i.ShelfNo; checkQty.InstrumentCode = i.InstrumentCode; checkQty.TransferQty = i.TransferInstrumentQty; IInventoryHandler InvH = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler; doCheckTransferQtyResult resCheckQty = InvH.CheckTransferQty(checkQty); i.InstrumentQty = resCheckQty.CurrentyQty; if (resCheckQty.OverQtyFlag == null) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4009, new string[] { i.InstrumentCode }, new string[] { i.TransQtyID }); isError = true; } else if (resCheckQty.OverQtyFlag == true) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4008, new string[] { i.InstrumentCode }, new string[] { i.TransQtyID }); isError = true; } } if (isError) { UpdateScreenObject(prm); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.ResultData = prm.lstTransferInstrument; return(Json(res)); } UpdateScreenObject(prm); res.ResultData = prm.lstTransferInstrument; return(Json(res)); } catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); } }
/// <summary> /// Register pre-elimination.<br /> /// - Check system suspending.<br /> /// - Check permission.<br /> /// - Check quantity.<br /> /// - Insert inventory slip.<br /> /// - Update account transfer new/second hand/sample instrument.<br /> /// - Generate report. /// </summary> /// <returns></returns> public ActionResult IVS040_cmdConfirm() { ObjectResultData res = new ObjectResultData(); try { //Check Suspend IVS040_ScreenParameter prm = GetScreenObject <IVS040_ScreenParameter>(); if (prm.ElemInstrument == null) { prm.ElemInstrument = new List <IVS040INST>(); } ICommonHandler ComH = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; if (ComH.IsSystemSuspending()) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049); return(Json(res)); } if (!CheckUserPermission(ScreenID.C_INV_SCREEN_ID_PRE_ELIMINATION, FunctionID.C_FUNC_ID_OPERATE)) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); return(Json(res)); } IInventoryHandler InvH = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler; bool isError = false; foreach (IVS040INST i in prm.ElemInstrument) { doCheckTransferQty Cond = new doCheckTransferQty(); Cond.OfficeCode = prm.office.OfficeCode; Cond.LocationCode = prm.Location; Cond.AreaCode = i.AreaCode; Cond.ShelfNo = i.ShelfNo; Cond.InstrumentCode = i.InstrumentCode; Cond.TransferQty = i.TransferInstrumentQty; doCheckTransferQtyResult TransferQtyResult = InvH.CheckTransferQty(Cond); i.InstrumentQty = TransferQtyResult.CurrentyQty; //8.2.1 if (TransferQtyResult.OverQtyFlag == null) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4009, new string[] { i.InstrumentCode }, new string[] { i.TransQtyID }); //res.ResultData = i.InstrumentCode + "," + i.row_id; isError = true; } else if (TransferQtyResult.OverQtyFlag == true) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4008, new string[] { i.InstrumentCode }, new string[] { i.TransQtyID }); //res.ResultData = i.InstrumentCode + "," + i.row_id; isError = true; } } if (isError) { //res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.ResultData = prm.ElemInstrument; return(Json(res)); } string strInventorySlipNo = null; using (TransactionScope scope = new TransactionScope()) { //8.3 doRegisterTransferInstrumentData data = new doRegisterTransferInstrumentData(); data.SlipId = SlipID.C_INV_SLIPID_PRE_ELIMINATE; data.InventorySlip = new tbt_InventorySlip(); data.lstTbt_InventorySlipDetail = new List <tbt_InventorySlipDetail>(); tbt_InventorySlip InvSlip = new tbt_InventorySlip(); InvSlip.SlipStatus = InventorySlipStatus.C_INV_SLIP_STATUS_COMPLETE; InvSlip.TransferTypeCode = TransferType.C_INV_TRANSFERTYPE_PRE_ELIMINATION; InvSlip.SlipIssueDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; InvSlip.StockInDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; InvSlip.StockOutDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; InvSlip.SourceLocationCode = prm.Location; //InvSlip.DestinationLocationCode = InstrumentLocation.C_INV_LOC_PRE_ELIMINATION; InvSlip.DestinationLocationCode = prm.DestinationLocation; InvSlip.SourceOfficeCode = prm.office.OfficeCode; InvSlip.DestinationOfficeCode = prm.office.OfficeCode; InvSlip.ApproveNo = prm.ApproveNo; InvSlip.Memo = prm.Memo; InvSlip.ShelfType = ShelfType.C_INV_SHELF_TYPE_NORMAL; InvSlip.CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo; InvSlip.CreateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; InvSlip.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; InvSlip.UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo; data.InventorySlip = InvSlip; data.lstTbt_InventorySlipDetail = new List <tbt_InventorySlipDetail>(); int iRunNo = 1; List <IVS040INST> sortedList = ( from row in prm.ElemInstrument orderby row.InstrumentCode, row.AreaCode select row ).ToList <IVS040INST>(); foreach (IVS040INST i in sortedList) { tbt_InventorySlipDetail SlipDetail = new tbt_InventorySlipDetail(); SlipDetail.RunningNo = iRunNo; SlipDetail.InstrumentCode = i.InstrumentCode; SlipDetail.SourceAreaCode = i.AreaCode; SlipDetail.DestinationAreaCode = i.AreaCode; SlipDetail.SourceShelfNo = i.ShelfNo; if (InstrumentLocation.C_INV_LOC_INSTOCK == prm.DestinationLocation) { SlipDetail.DestinationShelfNo = ShelfNo.C_INV_SHELF_NO_NOT_MOVE_SHELF; } else { SlipDetail.DestinationShelfNo = ShelfNo.C_INV_SHELF_NO_OTHER_LOCATION; } //SlipDetail.DestinationShelfNo = ShelfNo.C_INV_SHELF_NO_OTHER_LOCATION; SlipDetail.TransferQty = i.TransferInstrumentQty; data.lstTbt_InventorySlipDetail.Add(SlipDetail); iRunNo++; } strInventorySlipNo = InvH.RegisterTransferInstrument(data); if (InvH.CheckNewInstrument(strInventorySlipNo) == 1) { //8.5.1 List <doGroupNewInstrument> groupNewInstrument = InvH.GetGroupNewInstrument(strInventorySlipNo); foreach (doGroupNewInstrument i in groupNewInstrument) { //i.DestinationLocationCode = InstrumentLocation.C_INV_LOC_PRE_ELIMINATION; #region Monthly Price @ 2015 //decimal decMovingAveragePrice = InvH.CalculateMovingAveragePrice(i); var decMovingAveragePrice = InvH.GetMonthlyAveragePrice(i.Instrumentcode, InvSlip.SlipIssueDate, InventoryAccountCode.C_INV_ACCOUNT_CODE_INSTOCK, SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_LOCAL, SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US); #endregion InvH.UpdateAccountTransferNewInstrument(i, Convert.ToDecimal(decMovingAveragePrice)); } } //8.6 int blnCheckSecondhandInstrument = InvH.CheckSecondhandInstrument(strInventorySlipNo); if (blnCheckSecondhandInstrument == 1) { List <doGroupSecondhandInstrument> GroupSecondHandInstrument = InvH.GetGroupSecondhandInstrument(strInventorySlipNo); foreach (doGroupSecondhandInstrument i in GroupSecondHandInstrument) { //i.DestinationLocationCode = InstrumentLocation.C_INV_LOC_PRE_ELIMINATION; InvH.UpdateAccountTransferSecondhandInstrument(i); } } //8.7 int blnCheckSampleInstrument = InvH.CheckSampleInstrument(strInventorySlipNo); if (blnCheckSampleInstrument == 1) { List <doGroupSampleInstrument> GroupSampleInstrument = InvH.GetGroupSampleInstrument(strInventorySlipNo); foreach (doGroupSampleInstrument i in GroupSampleInstrument) { //i.DestinationLocationCode = InstrumentLocation.C_INV_LOC_PRE_ELIMINATION; InvH.UpdateAccountTransferSampleInstrument(i, null); } } scope.Complete(); } //end transaction scope //8.8 IInventoryDocumentHandler handlerInventoryDocument = ServiceContainer.GetService <IInventoryDocumentHandler>() as IInventoryDocumentHandler; string reportPath = handlerInventoryDocument.GenerateIVR020FilePath(strInventorySlipNo, prm.office.OfficeCode, CommonUtil.dsTransData.dtUserData.EmpNo, CommonUtil.dsTransData.dtOperationData.ProcessDateTime); prm.slipNo = strInventorySlipNo; prm.reportFilePath = reportPath; UpdateScreenObject(prm); res.ResultData = strInventorySlipNo; return(Json(res)); } catch (Exception ex) { res.ResultData = "toregister"; res.AddErrorMessage(ex); return(Json(res)); } }
/// <summary> /// Register Elimination.<br /> /// - Check system suspending.<br /> /// - Check quantity.<br /> /// - Insert inventory slip.<br /> /// - Update account transfer new/second hand/sample instrument.<br /> /// - Insert account stock moving.<br /> /// - Generate report. /// </summary> /// <returns></returns> public ActionResult IVS050_cmdConfirm() { ObjectResultData res = new ObjectResultData(); try { //Check Suspend IVS050_ScreenParameter prm = GetScreenObject <IVS050_ScreenParameter>(); if (prm.ElemInstrument == null) { prm.ElemInstrument = new List <IVS040INST>(); } ICommonHandler ComH = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; if (ComH.IsSystemSuspending()) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049); return(Json(res)); } if (!CheckUserPermission(ScreenID.C_INV_SCREEN_ID_ELIMINATION, FunctionID.C_FUNC_ID_OPERATE)) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); return(Json(res)); } IInventoryHandler InvH = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler; //8.4.1 bool isError = false; foreach (IVS040INST i in prm.ElemInstrument) { doCheckTransferQty Cond = new doCheckTransferQty(); Cond.OfficeCode = prm.office.OfficeCode; Cond.LocationCode = InstrumentLocation.C_INV_LOC_PRE_ELIMINATION; Cond.AreaCode = i.AreaCode; Cond.ShelfNo = i.ShelfNo; Cond.InstrumentCode = i.InstrumentCode; Cond.TransferQty = i.TransferInstrumentQty; doCheckTransferQtyResult TransferQtyResult = InvH.CheckTransferQty(Cond); i.InstrumentQty = TransferQtyResult.CurrentyQty; if (TransferQtyResult.OverQtyFlag == null) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4009, new string[] { i.InstrumentCode }, new string[] { i.TransQtyID }); //res.ResultData = i.InstrumentCode + "," + i.row_id; isError = true; } else if (TransferQtyResult.OverQtyFlag == true) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4008, new string[] { i.InstrumentCode }, new string[] { i.TransQtyID }); //res.ResultData = i.InstrumentCode + "," + i.row_id; isError = true; } } if (isError) { //res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.ResultData = prm.ElemInstrument; return(Json(res)); } string strInventorySlipNo = null; using (TransactionScope scope = new TransactionScope()) { //8.5 doRegisterTransferInstrumentData data = new doRegisterTransferInstrumentData(); data.SlipId = SlipID.C_INV_SLIPID_ELIMINATE; data.InventorySlip = new tbt_InventorySlip(); data.lstTbt_InventorySlipDetail = new List <tbt_InventorySlipDetail>(); tbt_InventorySlip InvSlip = new tbt_InventorySlip(); InvSlip.SlipStatus = InventorySlipStatus.C_INV_SLIP_STATUS_COMPLETE; InvSlip.TransferTypeCode = TransferType.C_INV_TRANSFERTYPE_ELIMINATION; InvSlip.SlipIssueDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; InvSlip.StockInDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; InvSlip.StockOutDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; InvSlip.SourceLocationCode = InstrumentLocation.C_INV_LOC_PRE_ELIMINATION; InvSlip.DestinationLocationCode = InstrumentLocation.C_INV_LOC_ELIMINATION; InvSlip.SourceOfficeCode = prm.office.OfficeCode; InvSlip.DestinationOfficeCode = prm.office.OfficeCode; InvSlip.ApproveNo = prm.ApproveNo; InvSlip.Memo = prm.Memo; InvSlip.ShelfType = ShelfType.C_INV_SHELF_TYPE_NORMAL; InvSlip.CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo; InvSlip.CreateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; InvSlip.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; InvSlip.UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo; data.InventorySlip = InvSlip; data.lstTbt_InventorySlipDetail = new List <tbt_InventorySlipDetail>(); int iRunNo = 1; foreach (IVS040INST i in prm.ElemInstrument) { tbt_InventorySlipDetail SlipDetail = new tbt_InventorySlipDetail(); SlipDetail.SlipNo = null; SlipDetail.RunningNo = iRunNo; SlipDetail.InstrumentCode = i.InstrumentCode; SlipDetail.SourceAreaCode = i.AreaCode; SlipDetail.DestinationAreaCode = i.AreaCode; SlipDetail.SourceShelfNo = i.ShelfNo; SlipDetail.DestinationShelfNo = i.ShelfNo; SlipDetail.TransferQty = i.TransferInstrumentQty; SlipDetail.InstrumentAmount = i.TransferAmount; data.lstTbt_InventorySlipDetail.Add(SlipDetail); iRunNo++; } strInventorySlipNo = InvH.RegisterTransferInstrument(data); List <tbt_AccountStockMoving> listInsertAccStockMoving = new List <tbt_AccountStockMoving>(); if (InvH.CheckNewInstrument(strInventorySlipNo) == 1) { //8.7.1 List <doGroupNewInstrument> groupNewInstrument = InvH.GetGroupNewInstrument(strInventorySlipNo); foreach (doGroupNewInstrument i in groupNewInstrument) { i.DestinationLocationCode = InstrumentLocation.C_INV_LOC_ELIMINATION; #region Monthly Price @ 2015 //decimal decMovingAveragePrice = InvH.CalculateMovingAveragePrice(i); decimal decMovingAveragePrice = InvH.GetMonthlyAveragePrice(i.Instrumentcode, InvSlip.SlipIssueDate, InventoryAccountCode.C_INV_ACCOUNT_CODE_INSTOCK, SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_LOCAL, SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US); #endregion bool canUpdate = InvH.UpdateAccountTransferNewInstrument(i, Convert.ToDecimal(decMovingAveragePrice)); if (!canUpdate) { scope.Dispose(); return(Json(res)); } List <tbt_AccountInstock> listInstock = InvH.GetTbt_AccountInStock(i.Instrumentcode, InstrumentLocation.C_INV_LOC_PRE_ELIMINATION, prm.office.OfficeCode); if (listInstock.Count <= 0) { scope.Dispose(); return(Json(res)); } tbt_AccountStockMoving accountStockMoving = new tbt_AccountStockMoving(); accountStockMoving.SlipNo = strInventorySlipNo; accountStockMoving.TransferTypeCode = TransferType.C_INV_TRANSFERTYPE_ELIMINATION; accountStockMoving.SourceAccountStockCode = InventoryAccountCode.C_INV_ACCOUNT_CODE_INSTOCK; accountStockMoving.DestinationAccountStockCode = InventoryAccountCode.C_INV_ACCOUNT_CODE_ELIMINATE; accountStockMoving.SourceLocationCode = InstrumentLocation.C_INV_LOC_PRE_ELIMINATION; accountStockMoving.DestinationLocationCode = InstrumentLocation.C_INV_LOC_ELIMINATION; accountStockMoving.InstrumentCode = i.Instrumentcode; accountStockMoving.InstrumentQty = i.TransferQty; accountStockMoving.InstrumentPrice = listInstock[0].MovingAveragePrice; accountStockMoving.CreateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; accountStockMoving.CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo; accountStockMoving.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; accountStockMoving.UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo; listInsertAccStockMoving.Add(accountStockMoving); } } //8.8 int blnCheckSecondhandInstrument = InvH.CheckSecondhandInstrument(strInventorySlipNo); if (blnCheckSecondhandInstrument == 1) { List <doGroupSecondhandInstrument> GroupSecondHandInstrument = InvH.GetGroupSecondhandInstrument(strInventorySlipNo); foreach (doGroupSecondhandInstrument i in GroupSecondHandInstrument) { i.DestinationLocationCode = InstrumentLocation.C_INV_LOC_ELIMINATION; bool canUpdate = InvH.UpdateAccountTransferSecondhandInstrument(i); if (!canUpdate) { scope.Dispose(); return(Json(res)); } decimal sumTransferAmount = 0; foreach (IVS040INST j in prm.ElemInstrument) { if (i.Instrumentcode == j.InstrumentCode && (j.AreaCode == InstrumentArea.C_INV_AREA_SE_RENTAL || j.AreaCode == InstrumentArea.C_INV_AREA_SE_HANDLING_DEMO)) { sumTransferAmount += j.TransferAmount; } } tbt_AccountStockMoving accountStockMoving = new tbt_AccountStockMoving(); accountStockMoving.SlipNo = strInventorySlipNo; accountStockMoving.TransferTypeCode = TransferType.C_INV_TRANSFERTYPE_ELIMINATION; accountStockMoving.SourceAccountStockCode = InventoryAccountCode.C_INV_ACCOUNT_CODE_INSTALLED; accountStockMoving.DestinationAccountStockCode = InventoryAccountCode.C_INV_ACCOUNT_CODE_ELIMINATE; accountStockMoving.SourceLocationCode = InstrumentLocation.C_INV_LOC_PRE_ELIMINATION; accountStockMoving.DestinationLocationCode = InstrumentLocation.C_INV_LOC_ELIMINATION; accountStockMoving.InstrumentCode = i.Instrumentcode; accountStockMoving.InstrumentQty = i.TransferQty; if (sumTransferAmount != 0) { accountStockMoving.InstrumentPrice = sumTransferAmount / i.TransferQty; } else { accountStockMoving.InstrumentPrice = 0; } accountStockMoving.CreateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; accountStockMoving.CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo; accountStockMoving.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; accountStockMoving.UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo; listInsertAccStockMoving.Add(accountStockMoving); } } //8.9 int blnCheckSampleInstrument = InvH.CheckSampleInstrument(strInventorySlipNo); if (blnCheckSampleInstrument == 1) { List <doGroupSampleInstrument> GroupSampleInstrument = InvH.GetGroupSampleInstrument(strInventorySlipNo); foreach (doGroupSampleInstrument i in GroupSampleInstrument) { i.DestinationLocationCode = InstrumentLocation.C_INV_LOC_ELIMINATION; bool canUpdate = InvH.UpdateAccountTransferSampleInstrument(i, null); if (!canUpdate) { scope.Dispose(); return(Json(res)); } tbt_AccountStockMoving accountStockMoving = new tbt_AccountStockMoving(); accountStockMoving.SlipNo = strInventorySlipNo; accountStockMoving.TransferTypeCode = TransferType.C_INV_TRANSFERTYPE_ELIMINATION; accountStockMoving.SourceAccountStockCode = InventoryAccountCode.C_INV_ACCOUNT_CODE_INSTOCK; accountStockMoving.DestinationAccountStockCode = InventoryAccountCode.C_INV_ACCOUNT_CODE_ELIMINATE; accountStockMoving.SourceLocationCode = InstrumentLocation.C_INV_LOC_PRE_ELIMINATION; accountStockMoving.DestinationLocationCode = InstrumentLocation.C_INV_LOC_ELIMINATION; accountStockMoving.InstrumentCode = i.Instrumentcode; accountStockMoving.InstrumentQty = i.TransferQty; accountStockMoving.InstrumentPrice = InventoryConfig.C_INV_DEFAULT_SAMPLE_AMOUNT; accountStockMoving.CreateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; accountStockMoving.CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo; accountStockMoving.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; accountStockMoving.UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo; listInsertAccStockMoving.Add(accountStockMoving); } } //8.10 List <tbt_AccountStockMoving> resultInsert = InvH.InsertAccountStockMoving(listInsertAccStockMoving); if (resultInsert.Count <= 0) { scope.Dispose(); return(Json(res)); } scope.Complete(); } //end transaction scope IInventoryDocumentHandler handlerInventoryDocument = ServiceContainer.GetService <IInventoryDocumentHandler>() as IInventoryDocumentHandler; string reportPath = handlerInventoryDocument.GenerateIVR030FilePath(strInventorySlipNo, prm.office.OfficeCode, CommonUtil.dsTransData.dtUserData.EmpNo, CommonUtil.dsTransData.dtOperationData.ProcessDateTime); prm.slipNo = strInventorySlipNo; prm.reportFilePath = reportPath; UpdateScreenObject(prm); res.ResultData = strInventorySlipNo; return(Json(res)); } catch (Exception ex) { res.ResultData = "toregister"; res.AddErrorMessage(ex); return(Json(res)); } }
/// <summary> /// Register transfer instrument data /// </summary> /// <param name="Con">Register condition object</param> /// <returns></returns> public ActionResult IVS210_cmdConfirm(IVS210RegisterCond Con) { ObjectResultData res = new ObjectResultData(); try { IVS210_ScreenParameter prm = GetScreenObject <IVS210_ScreenParameter>(); if (prm.ElemInstrument == null) { prm.ElemInstrument = new List <IVS210INST>(); } //8.1 ICommonHandler ComH = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; if (ComH.IsSystemSuspending()) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049); return(Json(res)); } if (!CheckUserPermission(ScreenID.C_INV_SCREEN_ID_MOVE_SHELF, FunctionID.C_FUNC_ID_OPERATE)) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); return(Json(res)); } IInventoryHandler InvH = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler; IShelfMasterHandler ShelfH = ServiceContainer.GetService <IShelfMasterHandler>() as IShelfMasterHandler; if (InvH.CheckStartedStockChecking() == 0) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4003); return(Json(res)); } foreach (IVS210INST i in prm.ElemInstrument) { //8.2.1 if (i.DestinationShelfNo == ShelfNo.C_INV_SHELF_NO_NOT_PRICE || i.DestinationShelfNo == ShelfNo.C_INV_SHELF_NO_NOT_MOVE_SHELF || i.DestinationShelfNo == ShelfNo.C_INV_SHELF_NO_OTHER_LOCATION) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4050, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.DestShelfNo_id }); res.ResultData = i.InstrumentCode + "," + i.row_id; i.IsError = true; return(Json(res)); } //8.2.2 if (i.DestinationShelfNo == i.SourceShelfNo) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4053, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.DestShelfNo_id }); res.ResultData = i.InstrumentCode + "," + i.row_id; i.IsError = true; return(Json(res)); } //8.2.3 doCheckTransferQty doCheck = new doCheckTransferQty(); doCheck.OfficeCode = prm.Office.OfficeCode; doCheck.LocationCode = prm.Location; doCheck.AreaCode = i.AreaCode; doCheck.ShelfNo = i.SourceShelfNo; doCheck.InstrumentCode = i.InstrumentCode; doCheck.TransferQty = i.TransferQty; doCheckTransferQtyResult doCheckResult = InvH.CheckTransferQty(doCheck); i.InstrumentQty = doCheckResult.CurrentyQty; if (doCheckResult.OverQtyFlag == null) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4009, new string[] { i.InstrumentCode }, new string[] { i.StockOutQty_id }); res.ResultData = prm.ElemInstrument; i.IsError = true; return(Json(res)); } else if (doCheckResult.OverQtyFlag == true) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4008, new string[] { i.InstrumentCode }, new string[] { i.StockOutQty_id }); res.ResultData = prm.ElemInstrument; i.IsError = true; return(Json(res)); } //8.2.4 List <tbm_Shelf> GetTbm_Shelf = ShelfH.GetTbm_Shelf(i.DestinationShelfNo); // 8.2.5 if (GetTbm_Shelf.Count > 0 && GetTbm_Shelf[0].ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_PROJECT) { continue; } // 8.2.6 doGetShelfOfArea SourceShelf = InvH.GetShelfOfArea(i.AreaCode, i.InstrumentCode); // 8.2.7 if ((SourceShelf != null && SourceShelf.InstrumentQty > 0) && SourceShelf.ShelfNo != i.DestinationShelfNo && SourceShelf.ShelfNo != i.SourceShelfNo) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4054, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.DestShelfNo_id }); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; i.IsError = true; continue; } // 8.2.8 if ((SourceShelf == null || SourceShelf.InstrumentQty == 0)) { List <tbt_InventoryCurrent> doTbt_InventoryCurrent = InvH.GetTbt_InventoryCurrent( prm.Office.OfficeCode, InstrumentLocation.C_INV_LOC_INSTOCK, GetTbm_Shelf[0].AreaCode, GetTbm_Shelf[0].ShelfNo, GetTbm_Shelf[0].InstrumentCode); if (doTbt_InventoryCurrent != null && doTbt_InventoryCurrent.Count != 0 && doTbt_InventoryCurrent[0] != null && doTbt_InventoryCurrent[0].InstrumentQty > 0) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4054, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.DestShelfNo_id }); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; i.IsError = true; continue; } if ((i.ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_NORMAL) && i.SourceShelfNo != ShelfNo.C_INV_SHELF_NO_NOT_MOVE_SHELF && i.InstrumentQty != i.TransferQty) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4056, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.StockOutQty_id }); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; i.IsError = true; continue; } } #region OLD CODE //8.2.5 //if (GetTbm_Shelf.Count > 0 && GetTbm_Shelf[0].ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_NORMAL) //{ // //8.2.5.1 // List<tbt_InventoryCurrent> doTbt_InventoryCurrent = InvH.GetTbt_InventoryCurrent(prm.Office.OfficeCode, InstrumentLocation.C_INV_LOC_INSTOCK, i.AreaCode, GetTbm_Shelf[0].ShelfNo, i.InstrumentCode); // if ((i.AreaCode != GetTbm_Shelf[0].AreaCode || string.Compare(i.InstrumentCode, GetTbm_Shelf[0].InstrumentCode, true) != 0) // //&& i.ShelfTypeCode != ShelfType.C_INV_SHELF_TYPE_NORMAL // && (doTbt_InventoryCurrent.Count > 0 && doTbt_InventoryCurrent[0].InstrumentQty > 0) // ) { // //8.2.5.2 // res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4054, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.DestShelfNo_id }); // res.ResultData = i.InstrumentCode + "," + i.row_id; // i.IsError = true; // return Json(res); // } // else if ( // //(i.AreaCode != GetTbm_Shelf[0].AreaCode || string.Compare(i.InstrumentCode, GetTbm_Shelf[0].InstrumentCode, true) != 0) // //&& (doTbt_InventoryCurrent.Count > 0 && doTbt_InventoryCurrent[0].InstrumentQty > 0) // //&& i.ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_NORMAL // (doTbt_InventoryCurrent.Count == 0 || (doTbt_InventoryCurrent.Count > 0 && doTbt_InventoryCurrent[0].InstrumentQty == 0)) // && i.ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_NORMAL // && i.InstrumentQty != i.TransferQty // ) { // //8.2.5.3 // res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4056, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.StockOutQty_id }); // res.ResultData = i.InstrumentCode + "," + i.row_id; // i.IsError = true; // return Json(res); // } //} //dtTbm_Shelf.ShelfTypeCode = C_INV_SHELF_TYPE_NORMAL ////8.2.6 //if (GetTbm_Shelf.Count > 0 && GetTbm_Shelf[0].ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_EMPTY) //{ // //8.2.6.1 // if (i.ShelfTypeCode != ShelfType.C_INV_SHELF_TYPE_NORMAL) // { // doGetShelfOfArea SourceShelf = InvH.GetShelfOfArea(i.AreaCode, i.InstrumentCode); // if (SourceShelf != null && !string.IsNullOrEmpty(SourceShelf.ShelfNo) && SourceShelf.ShelfNo != i.DestinationShelfNo) // { // res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4055, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.DestShelfNo_id }); // res.ResultData = i.InstrumentCode + "," + i.row_id; // i.IsError = true; // return Json(res); // } // } // //8.2.6.2 // if (i.ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_NORMAL) // { // if (i.InstrumentQty != i.TransferQty) // { // res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4056, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.StockOutQty_id }); // res.ResultData = i.InstrumentCode + "," + i.row_id; // i.IsError = true; // return Json(res); // } // } //} #endregion } using (TransactionScope scope = new TransactionScope()) //Add by Jutarat A. on 18022013 { //8.3 foreach (IVS210INST i in prm.ElemInstrument) { //8.3.1 List <tbt_InventoryCurrent> lstSourceCurr = InvH.GetTbt_InventoryCurrent(prm.Office.OfficeCode, prm.Location, i.AreaCode, i.SourceShelfNo, i.InstrumentCode); if (lstSourceCurr.Count > 0) { lstSourceCurr[0].InstrumentQty = lstSourceCurr[0].InstrumentQty - i.TransferQty; lstSourceCurr[0].UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; lstSourceCurr[0].UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo; } InvH.UpdateTbt_InventoryCurrent(lstSourceCurr); //8.3.2 List <tbt_InventoryCurrent> lstDestCurr = InvH.GetTbt_InventoryCurrent(prm.Office.OfficeCode, prm.Location, i.AreaCode, i.DestinationShelfNo, i.InstrumentCode); if (lstDestCurr.Count <= 0) { doNormalShelfExistCurrent destShelf = InvH.GetNormalShelfExistCurrent(i.DestinationShelfNo); if (destShelf != null) { InvH.DeleteTbt_InventoryCurrent( prm.Office.OfficeCode, InstrumentLocation.C_INV_LOC_INSTOCK, destShelf.AreaCode, i.DestinationShelfNo, destShelf.InstrumentCode); } tbt_InventoryCurrent newCurr = new tbt_InventoryCurrent(); newCurr.OfficeCode = prm.Office.OfficeCode; newCurr.LocationCode = prm.Location; newCurr.AreaCode = i.AreaCode; newCurr.ShelfNo = i.DestinationShelfNo; newCurr.InstrumentCode = i.InstrumentCode; newCurr.InstrumentQty = i.TransferQty; newCurr.CreateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; newCurr.CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo; List <tbt_InventoryCurrent> CurrentForInsert = new List <tbt_InventoryCurrent>(); CurrentForInsert.Add(newCurr); InvH.InsertTbt_InventoryCurrent(CurrentForInsert); } else { lstDestCurr[0].InstrumentQty = lstDestCurr[0].InstrumentQty + i.TransferQty; lstDestCurr[0].UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; lstDestCurr[0].UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo; InvH.UpdateTbt_InventoryCurrent(lstDestCurr); } //8.3.3 List <doShelf> dtTbm_DestShelf = ShelfH.GetShelf(i.DestinationShelfNo, null, null, null); //8.3.4 if (dtTbm_DestShelf[0].ShelfTypeCode != ShelfType.C_INV_SHELF_TYPE_PROJECT) { //8.3.5 doGetShelfOfArea SourceShelf = InvH.GetShelfOfArea(i.AreaCode, i.InstrumentCode); //8.3.6 //if (dtTbm_DestShelf.Count > 0 && i.ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_NORMAL // && (dtTbm_DestShelf[0].ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_EMPTY || dtTbm_DestShelf[0].ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_NORMAL)) if (SourceShelf != null && SourceShelf.ShelfNo != i.DestinationShelfNo) { //Update Source Shelf No //List<tbm_Shelf> Tbm_SourceShelf = ShelfH.GetTbm_Shelf(i.SourceShelfNo); List <tbm_Shelf> Tbm_SourceShelf = ShelfH.GetTbm_Shelf(SourceShelf.ShelfNo); if (Tbm_SourceShelf.Count > 0) { Tbm_SourceShelf[0].ShelfTypeCode = ShelfType.C_INV_SHELF_TYPE_EMPTY; Tbm_SourceShelf[0].AreaCode = null; Tbm_SourceShelf[0].InstrumentCode = null; Tbm_SourceShelf[0].UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo; Tbm_SourceShelf[0].UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; ShelfH.UpdateShelf(Tbm_SourceShelf[0]); } //InvH.DeleteTbt_InventoryCurrent(prm.Office.OfficeCode, InstrumentLocation.C_INV_LOC_INSTOCK, i.AreaCode, i.SourceShelfNo, i.InstrumentCode); InvH.DeleteTbt_InventoryCurrent(prm.Office.OfficeCode, InstrumentLocation.C_INV_LOC_INSTOCK, i.AreaCode, SourceShelf.ShelfNo, i.InstrumentCode); //Update Destination Shelf No List <tbm_Shelf> Tbm_DestShelf = ShelfH.GetTbm_Shelf(i.DestinationShelfNo); if (Tbm_DestShelf.Count > 0) { Tbm_DestShelf[0].ShelfTypeCode = ShelfType.C_INV_SHELF_TYPE_NORMAL; Tbm_DestShelf[0].AreaCode = i.AreaCode; Tbm_DestShelf[0].InstrumentCode = i.InstrumentCode; Tbm_DestShelf[0].UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo; Tbm_DestShelf[0].UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; ShelfH.UpdateShelf(Tbm_DestShelf[0]); } } //8.3.7 //if (dtTbm_DestShelf.Count > 0 && dtTbm_DestShelf[0].ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_EMPTY) else if (SourceShelf == null) { List <tbm_Shelf> Tbm_DestShelf = ShelfH.GetTbm_Shelf(i.DestinationShelfNo); if (Tbm_DestShelf.Count > 0) { Tbm_DestShelf[0].ShelfTypeCode = ShelfType.C_INV_SHELF_TYPE_NORMAL; Tbm_DestShelf[0].AreaCode = i.AreaCode; Tbm_DestShelf[0].InstrumentCode = i.InstrumentCode; Tbm_DestShelf[0].UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo; Tbm_DestShelf[0].UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; ShelfH.UpdateShelf(Tbm_DestShelf[0]); } } } } scope.Complete(); //Add by Jutarat A. on 18022013 } //8.4 res.ResultData = MessageUtil.GetMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4019); return(Json(res)); } catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); } }
/// <summary> /// Validate register transfer instrument data /// </summary> /// <param name="Cond">Register condition object</param> /// <returns></returns> public ActionResult IVS210_cmdReg(IVS210RegisterCond Cond) { ObjectResultData res = new ObjectResultData(); try { IVS210_ScreenParameter prm = GetScreenObject <IVS210_ScreenParameter>(); if (prm.ElemInstrument == null) { prm.ElemInstrument = new List <IVS210INST>(); } IInventoryHandler InvH = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler; IShelfMasterHandler ShelfH = ServiceContainer.GetService <IShelfMasterHandler>() as IShelfMasterHandler; ICommonHandler ComH = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; if (ComH.IsSystemSuspending()) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049); return(Json(res)); } if (!CheckUserPermission(ScreenID.C_INV_SCREEN_ID_MOVE_SHELF, FunctionID.C_FUNC_ID_OPERATE)) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); return(Json(res)); } if (InvH.CheckStartedStockChecking() == 0) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4003); return(Json(res)); } //6.1.1 if (prm.ElemInstrument.Count <= 0) { res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4006); return(Json(res)); } prm.ElemInstrument = Cond.StockInInstrument; prm.Location = Cond.Location; List <IVS210INST> arrayEmptyShelf = new List <IVS210INST>(); bool isError = false; foreach (IVS210INST i in prm.ElemInstrument) { //6.1.2 if (i.TransferQty <= 0) { res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4047, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.StockOutQty_id }); isError = true; continue; } //6.1.3 if (string.IsNullOrEmpty(i.DestinationShelfNo)) { res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4049, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.DestShelfNo_id }); isError = true; continue; } //6.1.4 if (i.DestinationShelfNo == ShelfNo.C_INV_SHELF_NO_NOT_PRICE || i.DestinationShelfNo == ShelfNo.C_INV_SHELF_NO_NOT_MOVE_SHELF || i.DestinationShelfNo == ShelfNo.C_INV_SHELF_NO_OTHER_LOCATION) { res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4050, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.DestShelfNo_id }); isError = true; continue; } //6.1.5 if (i.DestinationShelfNo == i.SourceShelfNo) { res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4053, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.DestShelfNo_id }); isError = true; continue; } //6.1.6 doCheckTransferQty doCheck = new doCheckTransferQty(); doCheck.OfficeCode = prm.Office.OfficeCode; doCheck.LocationCode = prm.Location; doCheck.AreaCode = i.AreaCode; doCheck.ShelfNo = i.SourceShelfNo; doCheck.InstrumentCode = i.InstrumentCode; doCheck.TransferQty = i.TransferQty; doCheckTransferQtyResult doCheckResult = InvH.CheckTransferQty(doCheck); i.InstrumentQty = doCheckResult.CurrentyQty; if (doCheckResult.OverQtyFlag == null) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4009, new string[] { i.InstrumentCode }, new string[] { i.StockOutQty_id }); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; isError = true; continue; } else if (doCheckResult.OverQtyFlag == true) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4008, new string[] { i.InstrumentCode }, new string[] { i.StockOutQty_id }); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; isError = true; continue; } if (!string.IsNullOrEmpty(i.DestinationShelfNo)) { //6.1.7 List <tbm_Shelf> GetTbm_Shelf = ShelfH.GetTbm_Shelf(i.DestinationShelfNo); //6.1.8 if (GetTbm_Shelf.Count <= 0) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4048, new string[] { i.DestinationShelfNo }, new string[] { i.DestShelfNo_id }); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; isError = true; continue; } else { i.DestinationShelfNo = GetTbm_Shelf[0].ShelfNo; } //6.1.9 if (GetTbm_Shelf.Count > 0 && GetTbm_Shelf[0].ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_PROJECT) { continue; } // 6.1.10 doGetShelfOfArea SourceShelf = InvH.GetShelfOfArea(i.AreaCode, i.InstrumentCode); // 6.1.11 if ((SourceShelf != null && SourceShelf.InstrumentQty > 0) && SourceShelf.ShelfNo != i.DestinationShelfNo && SourceShelf.ShelfNo != i.SourceShelfNo) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4054, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.DestShelfNo_id }); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; isError = true; continue; } // 6.1.12 if ((SourceShelf == null || SourceShelf.InstrumentQty == 0) || ((SourceShelf != null || SourceShelf.InstrumentQty > 0) && i.SourceShelfNo == SourceShelf.ShelfNo)) { List <tbt_InventoryCurrent> doTbt_InventoryCurrent = InvH.GetTbt_InventoryCurrent( prm.Office.OfficeCode, InstrumentLocation.C_INV_LOC_INSTOCK, GetTbm_Shelf[0].AreaCode, GetTbm_Shelf[0].ShelfNo, GetTbm_Shelf[0].InstrumentCode); if (doTbt_InventoryCurrent != null && doTbt_InventoryCurrent.Count != 0 && doTbt_InventoryCurrent[0] != null && doTbt_InventoryCurrent[0].InstrumentQty > 0) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4054, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.DestShelfNo_id }); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; isError = true; continue; } if ((i.ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_NORMAL) && i.SourceShelfNo != ShelfNo.C_INV_SHELF_NO_NOT_MOVE_SHELF && i.InstrumentQty != i.TransferQty) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4056, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.StockOutQty_id }); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; isError = true; continue; } // 6.1.14.3 bool blnDuplicateEmptyShelf = false; foreach (IVS210INST item in arrayEmptyShelf) { //if (item.DestinationShelfNo.ToUpper() == i.DestinationShelfNo.ToUpper() && item.AreaCode != i.AreaCode) if (item.DestinationShelfNo.ToUpper() == i.DestinationShelfNo.ToUpper() && item.InstrumentCode != i.InstrumentCode) //Modify by Jutarat A. on 21062013 { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4128, new string[] { i.DestinationShelfNo, i.InstrumentCode }, new string[] { i.DestShelfNo_id }); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; isError = true; blnDuplicateEmptyShelf = true; break; } } if (blnDuplicateEmptyShelf == false) { arrayEmptyShelf.Add(i); } } #region OLD CODE ////6.1.9 //if (GetTbm_Shelf.Count > 0 && GetTbm_Shelf[0].ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_NORMAL) //{ // //6.1.9.1 // List<tbt_InventoryCurrent> doTbt_InventoryCurrent = InvH.GetTbt_InventoryCurrent(prm.Office.OfficeCode, InstrumentLocation.C_INV_LOC_INSTOCK, GetTbm_Shelf[0].AreaCode, GetTbm_Shelf[0].ShelfNo, GetTbm_Shelf[0].InstrumentCode); // if ((i.AreaCode != GetTbm_Shelf[0].AreaCode || string.Compare(i.InstrumentCode, GetTbm_Shelf[0].InstrumentCode, true) != 0) // //&& i.ShelfTypeCode != ShelfType.C_INV_SHELF_TYPE_NORMAL // && (doTbt_InventoryCurrent.Count > 0 && doTbt_InventoryCurrent[0].InstrumentQty > 0) // ) // { // //6.1.9.2 // res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4054, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.DestShelfNo_id }); // res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; // isError = true; // continue; // } // else if ( // //(i.AreaCode != GetTbm_Shelf[0].AreaCode || string.Compare(i.InstrumentCode, GetTbm_Shelf[0].InstrumentCode, true) != 0) // //&& (doTbt_InventoryCurrent.Count > 0 && doTbt_InventoryCurrent[0].InstrumentQty > 0) // //&& i.ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_NORMAL // (doTbt_InventoryCurrent.Count == 0 || (doTbt_InventoryCurrent.Count > 0 && doTbt_InventoryCurrent[0].InstrumentQty == 0)) // && i.ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_NORMAL // && i.InstrumentQty != i.TransferQty // ) // { // //6.1.9.3 // res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4056, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.StockOutQty_id }); // res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; // isError = true; // continue; // } //} //dtTbm_Shelf.ShelfTypeCode = C_INV_SHELF_TYPE_NORMAL ////6.1.10 //if (GetTbm_Shelf.Count > 0 && GetTbm_Shelf[0].ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_EMPTY) //{ // //6.1.10.1 // // if (i.ShelfTypeCode != ShelfType.C_INV_SHELF_TYPE_NORMAL) // // { // doGetShelfOfArea SourceShelf = InvH.GetShelfOfArea(i.AreaCode, i.InstrumentCode); // if (SourceShelf != null && !string.IsNullOrEmpty(SourceShelf.ShelfNo) && SourceShelf.ShelfNo != i.DestinationShelfNo) // { // res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4055, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.DestShelfNo_id }); // res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; // isError = true; // continue; // } // // } // //6.1.10.2 // if (i.ShelfTypeCode == ShelfType.C_INV_SHELF_TYPE_NORMAL && i.ShelfNo != ShelfNo.C_INV_SHELF_NO_NOT_MOVE_SHELF) // { // if (i.InstrumentQty != i.TransferQty) // { // res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4056, new string[] { i.SourceShelfNo, i.InstrumentCode }, new string[] { i.StockOutQty_id }); // res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; // isError = true; // continue; // } // } // //6.1.10.3 // bool blnDuplicateEmptyShelf = false; // foreach (IVS210INST item in arrayEmptyShelf) // { // if (item.DestinationShelfNo.ToUpper() == i.DestinationShelfNo.ToUpper() && item.AreaCode != i.AreaCode) // { // res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4128, new string[] { i.DestinationShelfNo, i.InstrumentCode }, new string[] { i.DestShelfNo_id }); // res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; // isError = true; // blnDuplicateEmptyShelf = true; // break; // } // } // if (blnDuplicateEmptyShelf == false) // { // arrayEmptyShelf.Add(i); // } //} #endregion } } res.ResultData = prm.ElemInstrument; return(Json(res)); } catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); } }
/// <summary> /// Register checking returned instrument.<br /> /// - Check system suspending.<br /> /// - Check quantity.<br /> /// - Register transfer instrument.<br /> /// - Update account transfer new/second hand/sample instrument.<br /> /// - Generate report. /// </summary> /// <returns></returns> public ActionResult IVS140_Confirm() { string slipNo = string.Empty; string slipNoReportPath = string.Empty; IVS140_ScreenParameter param = GetScreenObject <IVS140_ScreenParameter>(); IVS140_RegisterData data = new IVS140_RegisterData(); if (param != null) { data = param.RegisterData; } ObjectResultData res = new ObjectResultData(); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; try { IInventoryHandler handlerInventory = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler; ICommonHandler handlerCommon = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; // Is suspend ? if (handlerCommon.IsSystemSuspending()) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049); return(Json(res)); } //Business validate //int countBusinessWaringing = 0; foreach (var item in data.Detail) { doCheckTransferQty doCheck = new doCheckTransferQty() { OfficeCode = param.HeaderOffice[0].OfficeCode, LocationCode = InstrumentLocation.C_INV_LOC_RETURNED, AreaCode = item.AreaCode, ShelfNo = item.ShelfNo, InstrumentCode = item.Instrumentcode, TransferQty = item.FixedReturnQty.HasValue ? item.FixedReturnQty.Value : 0 }; doCheckTransferQtyResult result = handlerInventory.CheckTransferQty(doCheck); item.InstrumentQty = result.CurrentyQty; if (result.OverQtyFlag == null) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4009 , new string[] { item.Instrumentcode } , new string[] { item.txtFixedReturnQtyID }); res.ResultData = new { IsSuccess = false, Data = data }; return(Json(res)); //countBusinessWaringing++; } else if (result.OverQtyFlag == true) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4008 , new string[] { item.Instrumentcode } , new string[] { item.txtFixedReturnQtyID }); res.ResultData = new { IsSuccess = false, Data = data }; return(Json(res)); //countBusinessWaringing++; } } //if (countBusinessWaringing > 0) //{ // return Json(res); //} // Prepare data for Register doRegisterTransferInstrumentData dsRegisterData = new doRegisterTransferInstrumentData(); dsRegisterData.SlipId = SlipID.C_INV_SLIPID_CHECKING_RETURNED; dsRegisterData.InventorySlip = new tbt_InventorySlip() { SlipStatus = InventorySlipStatus.C_INV_SLIP_STATUS_COMPLETE, TransferTypeCode = TransferType.C_INV_TRANSFERTYPE_CHECKING_RETURNED, SlipIssueDate = DateTime.Now, StockInDate = DateTime.Now, StockOutDate = DateTime.Now, SourceLocationCode = InstrumentLocation.C_INV_LOC_RETURNED, DestinationLocationCode = InstrumentLocation.C_INV_LOC_INSTOCK, SourceOfficeCode = param.HeaderOffice[0].OfficeCode, DestinationOfficeCode = param.HeaderOffice[0].OfficeCode, ApproveNo = data.Header.ApproveNo, Memo = data.Header.Memo, ShelfType = ShelfType.C_INV_SHELF_TYPE_NORMAL, CreateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime, CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo, UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime, UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo }; dsRegisterData.lstTbt_InventorySlipDetail = new List <tbt_InventorySlipDetail>(); tbt_InventorySlipDetail detail; for (int i = 0; i < data.Detail.Count; i++) { detail = new tbt_InventorySlipDetail() { RunningNo = (i + 1), InstrumentCode = data.Detail[i].Instrumentcode, SourceAreaCode = data.Detail[i].AreaCode, DestinationAreaCode = data.Detail[i].AreaCode, SourceShelfNo = data.Detail[i].ShelfNo, DestinationShelfNo = ShelfNo.C_INV_SHELF_NO_NOT_MOVE_SHELF, TransferQty = data.Detail[i].FixedReturnQty }; dsRegisterData.lstTbt_InventorySlipDetail.Add(detail); } // TODO: (Narupon) Uncomment for use TransactionScope // Save data to database.. using (TransactionScope scope = new TransactionScope()) { try { // Register Inventory Tranfer data string slipNo_result = handlerInventory.RegisterTransferInstrument(dsRegisterData); slipNo = slipNo_result; param.SlipNo = slipNo_result; // Check New instrument -- 8.5 int bCheckingNewInstrument = handlerInventory.CheckNewInstrument(slipNo_result); if (bCheckingNewInstrument == 1) { List <doGroupNewInstrument> dtGroupNewInstrument = handlerInventory.GetGroupNewInstrument(slipNo_result); foreach (var item in dtGroupNewInstrument) { #region Monthly Price @ 2015 //decimal decMovingAveragePrice = handlerInventory.CalculateMovingAveragePrice(item); decimal decMovingAveragePrice = handlerInventory.GetMonthlyAveragePrice(item.Instrumentcode, dsRegisterData.InventorySlip.SlipIssueDate, InventoryAccountCode.C_INV_ACCOUNT_CODE_INSTOCK, SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_LOCAL, SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US); #endregion handlerInventory.UpdateAccountTransferNewInstrument(item, decMovingAveragePrice); } } // Check secondhand instrument -- 8.6 int bCheckSeconhandInstrument = handlerInventory.CheckSecondhandInstrument(slipNo_result); if (bCheckSeconhandInstrument == 1) { List <doGroupSecondhandInstrument> dtGroupSecondhandInstrument = handlerInventory.GetGroupSecondhandInstrument(slipNo_result); foreach (var item in dtGroupSecondhandInstrument) { handlerInventory.UpdateAccountTransferSecondhandInstrument(item); } } // Check sample instrument -- 8.6 int bCheckSampleInstrument = handlerInventory.CheckSampleInstrument(slipNo_result); if (bCheckSampleInstrument == 1) { List <doGroupSampleInstrument> dtGroupSampleInstrument = handlerInventory.GetGroupSampleInstrument(slipNo_result); foreach (var item in dtGroupSampleInstrument) { handlerInventory.UpdateAccountTransferSampleInstrument(item, null); } } // Generate inventory slip report // ReportID.C_INV_REPORT_ID_CHECKING_RETURNED = IVR090 IInventoryDocumentHandler handlerInventoryDocument = ServiceContainer.GetService <IInventoryDocumentHandler>() as IInventoryDocumentHandler; slipNoReportPath = handlerInventoryDocument.GenerateIVR090FilePath(slipNo_result, param.HeaderOffice[0].OfficeCode, CommonUtil.dsTransData.dtUserData.EmpNo, CommonUtil.dsTransData.dtOperationData.ProcessDateTime); scope.Complete(); // Commit transtion. } catch (Exception ex) { scope.Dispose(); throw ex; } } // TODO: (Narupon) Uncomment for use TransactionScope param.SlipNoReportPath = slipNoReportPath; res.ResultData = new { IsSuccess = true, Data = data, SlipNo = slipNo }; } catch (Exception ex) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(ex); } return(Json(res)); }
// Register click //[PermissionOperationAttibute("","")] /// <summary> /// Validate before register.<br /> /// - Check system suspending.<br /> /// - Check user permission.<br /> /// - Check detail not empty.<br /> /// - Check memo.<br /> /// - Check quantity. /// </summary> /// <param name="data"></param> /// <returns></returns> public ActionResult IVS140_Register(IVS140_RegisterData data) { IVS140_ScreenParameter param = GetScreenObject <IVS140_ScreenParameter>(); ObjectResultData res = new ObjectResultData(); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; try { // Is suspend ? ICommonHandler handlerCommon = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; if (handlerCommon.IsSystemSuspending()) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049); return(Json(res)); } // Check permission if (CheckUserPermission(ScreenID.C_INV_SCREEN_ID_CHECKING_RETURN, FunctionID.C_FUNC_ID_OPERATE) == false) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); return(Json(res)); } //Validate #1 if (data.Detail == null || data.Detail.Count == 0) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4006); return(Json(res)); } //Validate #2 data.Header.Memo = data.Header.Memo == null ? "" : data.Header.Memo; if (data.Header.Memo.Replace(" ", "").Contains("\n\n\n\n")) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4022, null, new string[] { "Memo" }); return(Json(res)); } //Validate #3 List <string> lstWarningAtControls = new List <string>(); foreach (var item in data.Detail) { if (item.FixedReturnQty.GetValueOrDefault(0) <= 0) { lstWarningAtControls.Add(item.txtFixedReturnQtyID); } } if (lstWarningAtControls.Count > 0) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4071, null, lstWarningAtControls.ToArray()); return(Json(res)); } List <dtSearchInstrumentListResult> lstUpdatedCurrent = new List <dtSearchInstrumentListResult>(); //Business validate int countBusinessWaringing = 0; IInventoryHandler handlerInventory = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler; foreach (var item in data.Detail) { doCheckTransferQty doCheck = new doCheckTransferQty() { OfficeCode = param.HeaderOffice[0].OfficeCode, LocationCode = InstrumentLocation.C_INV_LOC_RETURNED, AreaCode = item.AreaCode, ShelfNo = item.ShelfNo, InstrumentCode = item.Instrumentcode, TransferQty = item.FixedReturnQty.HasValue ? item.FixedReturnQty.Value : 0 }; doCheckTransferQtyResult result = handlerInventory.CheckTransferQty(doCheck); item.InstrumentQty = result.CurrentyQty; if (result.OverQtyFlag == null) { item.InstrumentQty = 0; res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4009 , new string[] { item.Instrumentcode } , new string[] { item.txtFixedReturnQtyID }); countBusinessWaringing++; } else if (result.OverQtyFlag == true) { res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4008 , new string[] { item.Instrumentcode } , new string[] { item.txtFixedReturnQtyID }); countBusinessWaringing++; } } if (countBusinessWaringing > 0) { res.ResultData = new { IsSuccess = false, Data = data }; return(Json(res)); } // Save RegisterData in session if (param != null) { param.RegisterData = data; } } catch (Exception ex) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(ex); } res.ResultData = new { IsSuccess = true, Data = data }; return(Json(res)); }