/// <summary> /// Update shelf data /// </summary> /// <param name="data"></param> /// <returns></returns> public ActionResult MAS120_UpdateShelf(MAS120_ShelfData data) { ObjectResultData res = new ObjectResultData(); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; try { ICommonHandler commonHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; if (commonHandler.IsSystemSuspending()) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049); return(Json(res)); } if (!(CheckUserPermission(ScreenID.C_SCREEN_ID_MAINTAIN_SHELF_INFO, FunctionID.C_FUNC_ID_VIEW) == true || CheckUserPermission(ScreenID.C_SCREEN_ID_MAINTAIN_SHELF_INFO, FunctionID.C_FUNC_ID_ADD) == true || CheckUserPermission(ScreenID.C_SCREEN_ID_MAINTAIN_SHELF_INFO, FunctionID.C_FUNC_ID_EDIT) == true || CheckUserPermission(ScreenID.C_SCREEN_ID_MAINTAIN_SHELF_INFO, FunctionID.C_FUNC_ID_DEL) == true )) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); return(Json(res)); } IShelfMasterHandler hand = ServiceContainer.GetService <IShelfMasterHandler>() as IShelfMasterHandler; IInventoryHandler invenHand = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler; tbm_Shelf result = new tbm_Shelf(); if ((bool)data.DeleteFlag) { if (invenHand.IsEmptyShelf(data.ShelfNo) == false) { res.AddErrorMessage(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1049, null, new string[] { "" }); return(Json(res)); } } else { if (data.ShelfTypeCode != ShelfType.C_INV_SHELF_TYPE_NORMAL) { data.InstrumentCode = null; data.AreaCode = null; } } // Check required field. if (ModelState.IsValid == false) { ValidatorUtil.BuildErrorMessage(res, this); if (res.IsError) { return(Json(res)); } } data.ShelfNo = String.IsNullOrEmpty(data.ShelfNo) == false?data.ShelfNo.ToUpper() : data.ShelfNo; //Add by Jutarat A. on 28022013 List <tbm_Shelf> list = hand.UpdateShelf(data); if (list.Count > 0) { result = list[0]; } res.ResultData = result; return(Json(res)); } catch (Exception ex) { res.AddErrorMessage(ex); return(null); } }
/// <summary> /// Delete shelf data /// </summary> /// <param name="ShelfNo"></param> /// <returns></returns> public ActionResult MAS120_DeleteShelf(string ShelfNo) { ObjectResultData res = new ObjectResultData(); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; try { ICommonHandler commonHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; if (commonHandler.IsSystemSuspending()) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049); return(Json(res)); } if (!(CheckUserPermission(ScreenID.C_SCREEN_ID_MAINTAIN_SHELF_INFO, FunctionID.C_FUNC_ID_VIEW) == true || CheckUserPermission(ScreenID.C_SCREEN_ID_MAINTAIN_SHELF_INFO, FunctionID.C_FUNC_ID_ADD) == true || CheckUserPermission(ScreenID.C_SCREEN_ID_MAINTAIN_SHELF_INFO, FunctionID.C_FUNC_ID_EDIT) == true || CheckUserPermission(ScreenID.C_SCREEN_ID_MAINTAIN_SHELF_INFO, FunctionID.C_FUNC_ID_DEL) == true )) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); return(Json(res)); } tbm_Shelf data = new tbm_Shelf(); data.ShelfNo = ShelfNo; data.DeleteFlag = true; IShelfMasterHandler hand = ServiceContainer.GetService <IShelfMasterHandler>() as IShelfMasterHandler; // Check required field. if (ModelState.IsValid == false) { ValidatorUtil.BuildErrorMessage(res, this); if (res.IsError) { return(Json(res)); } } List <tbm_Shelf> list = hand.UpdateShelf(data); string result = string.Empty; if (list.Count == 0) { result = "0"; } else { result = "1"; } res.ResultData = result; return(Json(res)); } catch (Exception ex) { res.AddErrorMessage(ex); return(null); } }
/// <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)); } }