Beispiel #1
0
        /// <summary>
        /// Get shelf detail data
        /// </summary>
        /// <param name="ShelfNo"></param>
        /// <returns></returns>
        public ActionResult MAS120_GetShelfDetail(string ShelfNo)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                IShelfMasterHandler hand       = ServiceContainer.GetService <IShelfMasterHandler>() as IShelfMasterHandler;
                ICommonHandler      comHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                doShelf             detail     = null;
                List <doShelf>      list       = hand.GetShelf(ShelfNo, null, null, null);
                if (list.Count > 0)
                {
                    detail = list[0];

                    MAS120_ScreenParameter MAS120Param = GetScreenObject <MAS120_ScreenParameter>();
                    if (detail.UpdateDate.HasValue)
                    {
                        MAS120Param.updateDate = detail.UpdateDate.Value;
                    }

                    detail.AreaCodeName = comHandler.GetMiscDisplayValue(MiscType.C_INV_AREA, detail.AreaCode);
                }

                res.ResultData = detail;
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Search shelf data
        /// </summary>
        /// <param name="txtShelfNo"></param>
        /// <param name="txtShelfName"></param>
        /// <param name="txtShelfType"></param>
        /// <param name="txtAreaCode"></param>
        /// <returns></returns>
        public ActionResult MAS120_Search(string txtShelfNo, string txtShelfName, string txtShelfType, string txtAreaCode)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                txtShelfNo   = (txtShelfNo == "" ? null : txtShelfNo);
                txtShelfName = (txtShelfName == "" ? null : txtShelfName);
                txtShelfType = (txtShelfType == "" ? null : txtShelfType);
                txtAreaCode  = (txtAreaCode == "" ? null : txtAreaCode);

                if (txtShelfNo == null && txtShelfName == null && txtShelfType == null && txtAreaCode == null)
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0006);
                }

                if (res.IsError)
                {
                    return(Json(res));
                }

                IShelfMasterHandler hand = ServiceContainer.GetService <IShelfMasterHandler>() as IShelfMasterHandler;
                List <doShelf>      list = hand.GetShelf(txtShelfNo, txtShelfName, txtShelfType, txtAreaCode);

                List <doShelf> tmpList = (from t in list
                                          where t.DeleteFlag != true
                                          select t).ToList <doShelf>();
                foreach (doShelf tmp in tmpList)
                {
                    ICommonHandler comHandler           = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                    string         strShelfTypeCodeName = comHandler.GetMiscDisplayValue(MiscType.C_INV_SHELF_TYPE, tmp.ShelfTypeCode);
                    tmp.ShelfTypeCodeName = strShelfTypeCodeName;
                    string strAreaCodeName = comHandler.GetMiscDisplayValue(MiscType.C_INV_AREA, tmp.AreaCode);
                    tmp.AreaCodeName = strAreaCodeName;
                }

                string xml = CommonUtil.ConvertToXml <doShelf>(tmpList, "Master\\MAS120", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                res.ResultData = xml;
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(null);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Insert shelf data
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public ActionResult MAS120_InsertShelf(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;
                tbm_Shelf           result    = new tbm_Shelf();
                ValidatorUtil       validator = new ValidatorUtil();
                // Check required field.
                //if (ModelState.IsValid == false)
                //{
                //    ValidatorUtil.BuildErrorMessage(res, this);
                //    if (res.IsError)
                //        res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                //    return Json(res);
                //}
                if (CommonUtil.IsNullOrEmpty(data.ShelfNo))
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_MASTER,
                                              "MAS120",
                                              MessageUtil.MODULE_COMMON,
                                              MessageUtil.MessageList.MSG0007,
                                              "ShelfNo",
                                              "lblShelfNo",
                                              "ShelfNo");
                }

                if (CommonUtil.IsNullOrEmpty(data.ShelfName))
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_MASTER,
                                              "MAS120",
                                              MessageUtil.MODULE_COMMON,
                                              MessageUtil.MessageList.MSG0007,
                                              "ShelfName",
                                              "lblShelfName",
                                              "ShelfName");
                }

                if (CommonUtil.IsNullOrEmpty(data.ShelfTypeCode))
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_MASTER,
                                              "MAS120",
                                              MessageUtil.MODULE_COMMON,
                                              MessageUtil.MessageList.MSG0007,
                                              "ShelfTypeCode",
                                              "lblShelfType",
                                              "ShelfTypeCode");
                }

                ValidatorUtil.BuildErrorMessage(res, validator, null);

                if (res.IsError)
                {
                    return(Json(res));
                }

                if (hand.CheckDuplicateShelf(data.ShelfNo))
                {
                    List <doShelf> doViewShelf = hand.GetShelf(data.ShelfNo, null, null, null);
                    if (doViewShelf.Count > 0)
                    {
                        if (doViewShelf[0].DeleteFlag == true)
                        {
                            res.ResultData = "ConfirmUpdate";
                            return(Json(res));
                            //res.AddErrorMessage(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1055);
                            //return Json(res);
                        }
                    }
                    res.AddErrorMessage(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1048);
                    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.InsertShelf(data);
                if (list.Count > 0)
                {
                    result = list[0];
                }

                res.ResultData = result;
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(null);
            }
        }
Beispiel #4
0
        /// <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));
            }
        }