Example #1
0
        /// <summary>
        /// Register repair return instrument data
        /// </summary>
        /// <param name="Con">Register condition object</param>
        /// <returns></returns>
        public ActionResult IVS120_cmdConfirm(IVS120RegisterCond Con)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {       //Check Suspend
                IVS120_ScreenParameter prm = GetScreenObject <IVS120_ScreenParameter>();
                if (prm.ElemInstrument == null)
                {
                    prm.ElemInstrument = new List <IVS120INST>();
                }

                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_RETURN, FunctionID.C_FUNC_ID_OPERATE))
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                    return(Json(res));
                }
                IInventoryHandler InvH = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler;

                foreach (IVS120INST 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 });
                        i.IsError      = true;
                        res.ResultData = prm.ElemInstrument;
                        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 });
                        i.IsError      = true;
                        res.ResultData = prm.ElemInstrument;
                        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_RETURN;

                    tbt_InventorySlip InvSlip = new tbt_InventorySlip();
                    InvSlip.SlipNo                  = null;
                    InvSlip.SlipStatus              = InventorySlipStatus.C_INV_SLIP_STATUS_TRANSFER;
                    InvSlip.TransferTypeCode        = TransferType.C_INV_TRANSFERTYPE_REPAIR_RETURN;
                    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      = InstrumentLocation.C_INV_LOC_REPAIRING;
                    InvSlip.DestinationLocationCode = InstrumentLocation.C_INV_LOC_RETURNED;
                    InvSlip.SourceOfficeCode        = prm.office.OfficeCode;
                    InvSlip.DestinationOfficeCode   = prm.office.OfficeCode;
                    InvSlip.ApproveNo               = null;
                    InvSlip.Memo                     = prm.Memo;
                    InvSlip.StockInFlag              = null;
                    InvSlip.DeliveryOrderNo          = null;
                    InvSlip.ShelfType                = ShelfType.C_INV_SHELF_TYPE_NORMAL;
                    InvSlip.RepairSubcontractor      = null;
                    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 (IVS120INST 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_RETURN;
                            //8.5.3
                            InvH.UpdateAccountTransferNewInstrument(i, null);
                        }
                    }
                    //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_RETURN;
                            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_RETURN;
                            InvH.UpdateAccountTransferSampleInstrument(i, null);
                        }
                    }

                    scope.Complete();
                }

                //8.8.1

                // Generate report
                IInventoryDocumentHandler handlerInventoryDocument = ServiceContainer.GetService <IInventoryDocumentHandler>() as IInventoryDocumentHandler;
                string strReportPath = handlerInventoryDocument.GenerateIVR080FilePath(strInventorySlipNo, 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));
            }
        }
Example #2
0
        /// <summary>
        /// Validate Register repair return instrument data
        /// </summary>
        /// <param name="Cond">Register condition object</param>
        /// <returns></returns>
        public ActionResult IVS120_cmdReg(IVS120RegisterCond Cond)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                IVS120_ScreenParameter prm = GetScreenObject <IVS120_ScreenParameter>();
                if (prm.ElemInstrument == null)
                {
                    prm.ElemInstrument = new List <IVS120INST>();
                }
                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_RETURN, 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;

                //6.1.2
                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.3
                foreach (IVS120INST i in prm.ElemInstrument)
                {
                    if (i.StockOutQty <= 0)
                    {
                        res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                        res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4031, new string[] { i.InstrumentCode }, new string[] { i.StockOutQty_id });
                        i.IsError = true;
                    }
                }

                bool isError = false;
                foreach (IVS120INST 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));
            }
        }