Пример #1
0
        //public ActionResult ISR110_GetRptDeliveryConfirmData(string strSlipNo)
        //{
        //    strSlipNo = "401029201112043";
        //    IReportHandler reportHandler = ServiceContainer.GetService<IReportHandler>() as IReportHandler;
        //    List<RPTDeliveryConfirmDo> rptList = reportHandler.GetRptDeliveryConfirmData(strSlipNo);

        //    IDocumentHandler dochandler = ServiceContainer.GetService<IDocumentHandler>() as IDocumentHandler;
        //    List<tbm_DocumentTemplate> dLst = dochandler.GetDocumentTemplateByDocumentCode(DocumentCode.C_DOCUMENT_CODE_DELIVERY_CONFIRMATION_AND_WARRANTY);

        //    ReportDocument rptH = new ReportDocument();

        //    string path = ReportUtil.GetReportPath("Reports/ISR110_DeliveryConfirmData.rpt", Server.MapPath("/"));

        //    rptH.Load(path);

        //    List<RPTDeliveryConfirmDo> lst = new List<RPTDeliveryConfirmDo>();
        //    int i = 0;
        //    foreach (RPTDeliveryConfirmDo rptDataRow in rptList)
        //    {
        //        lst.Add(rptDataRow);
        //        if (dLst.Count > 0)
        //        {
        //            lst[i].DocumentNameEN = dLst[0].DocumentNameEN;
        //            lst[i].DocumentVersion = dLst[0].DocumentVersion;
        //        }
        //        i++;
        //    }
        //    rptH.SetDataSource(lst);
        //    rptH.Subreports["Page1"].SetDataSource(lst);
        //    rptH.Subreports["Page2"].SetDataSource(lst);
        //    Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        //    rptH.Close();

        //    return File(stream, "application/pdf");
        //}
        #endregion

        public ActionResult GenerateInstallationSlipDocBySlipNo()
        {
            ObjectResultData             res         = new ObjectResultData();
            ICommonHandler               comHandler  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            IInstallationDocumentHandler docHand     = ServiceContainer.GetService <IInstallationDocumentHandler>() as IInstallationDocumentHandler;
            IInstallationHandler         installHand = ServiceContainer.GetService <IInstallationHandler>() as IInstallationHandler;

            try
            {
                //using (TransactionScope scope = new TransactionScope())
                //{
                List <tbt_InstallationSlip> installList  = installHand.GetTbt_InstallationSlip(null);
                List <tbt_DocumentList>     documentList = comHandler.GetTbt_DocumentList(null, null, null);

                installList = (from t in installList
                               where //(
                                     //t.SlipStatus == "01"
                                     //|| t.SlipStatus == "02"
                                     //|| t.SlipStatus == "03"
                                     //|| t.SlipStatus == "04"
                                     //|| t.SlipStatus == "06")
                                     //&& t.SlipIssueFlag == true
                                     //&& t.CreateDate >= new DateTime(2013,7,24,12,20,0)
                               t.CreateBy == "INITIAL" &&
                               documentList.Any(d => (d.DocumentNo == t.SlipNo))
                               select t).ToList <tbt_InstallationSlip>();

                foreach (tbt_InstallationSlip data in installList)
                {
                    tbt_InstallationSlip dataSlip = installHand.GetTbt_InstallationSlipData(data.SlipNo);

                    //if (dataSlip != null
                    //        && dataSlip.SlipStatus != SlipStatus.C_SLIP_STATUS_NO_NEED_TO_STOCK_OUT
                    //        && dataSlip.SlipStatus != SlipStatus.C_SLIP_STATUS_NOT_STOCK_OUT //Modify by Jutarat A. on 07022013
                    //        && dataSlip.SlipStatus != SlipStatus.C_SLIP_STATUS_PARTIAL_STOCK_OUT //Add by Jutarat A. on 17062013
                    //        && dataSlip.SlipStatus != SlipStatus.C_SLIP_STATUS_STOCK_OUT) //Add by Jutarat A. on 24062013
                    //{
                    //    return Json(res);
                    //}

                    if (dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_NEW || dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_CHANGEPLAN_NEW)
                    {
                        //6.1.1.	Call		InstallationDocumentHandler.CreateISR010
                        //Parameter	doTbt_InstallationSlip.SlipNo
                        //Return		fsPDFFileISR010
                        docHand.CreateInstallationReport(dataSlip.SlipNo, DocumentCode.C_DOCUMENT_CODE_NEW_INSTALL_SLIP_RENTAL);
                    }

                    if (dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_CHANGE_WIRING ||
                        dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_CHANGEPLAN_AFTER_NEW ||
                        dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_MAINTENANCE_EXCHANGE ||
                        dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_MOVE ||
                        dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_PERIODICAL_MAINTENANCE ||
                        dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_REMOVE_DURING_STOP_PARTIAL ||
                        dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_REMOVE_DURING_STOP_REMOVE_ALL ||
                        dataSlip.InstallationType == SaleInstallationType.C_SALE_INSTALL_TYPE_CHANGE_WIRING ||
                        dataSlip.InstallationType == SaleInstallationType.C_SALE_INSTALL_TYPE_MAINTENANCE_EXCHANGE ||
                        dataSlip.InstallationType == SaleInstallationType.C_SALE_INSTALL_TYPE_MOVE ||
                        dataSlip.InstallationType == SaleInstallationType.C_SALE_INSTALL_TYPE_PARTIAL_REMOVE
                        )
                    {
                        //6.2.1.	Call		InstallationDocumentHandler.CreateISR020
                        //Parameter	doTbt_InstallationSlip.SlipNo
                        //Return		fsPDFFileISR020
                        docHand.CreateInstallationReport(dataSlip.SlipNo, DocumentCode.C_DOCUMENT_CODE_CHANGE_INSTALL_SLIP);
                    }
                    if (dataSlip.InstallationType == RentalInstallationType.C_RENTAL_INSTALL_TYPE_REMOVE_ALL ||
                        dataSlip.InstallationType == SaleInstallationType.C_SALE_INSTALL_TYPE_REMOVE_ALL)
                    {
                        //6.3.1.	Call		InstallationDocumentHandler.CreateISR030
                        //Parameter	doTbt_InstallationSlip.SlipNo
                        //Return		fsPDFFileISR030
                        docHand.CreateInstallationReport(dataSlip.SlipNo, DocumentCode.C_DOCUMENT_CODE_REMOVAL_INSTALL_SLIP);
                    }
                    if (dataSlip.InstallationType == SaleInstallationType.C_SALE_INSTALL_TYPE_NEW ||
                        dataSlip.InstallationType == SaleInstallationType.C_SALE_INSTALL_TYPE_ADD)
                    {
                        //6.4.1.	Call		InstallationDocumentHandler.CreateISR040
                        //Parameter	doTbt_InstallationSlip.SlipNo
                        //Return		fsPDFFileISR040
                        docHand.CreateInstallationReport(dataSlip.SlipNo, DocumentCode.C_DOCUMENT_CODE_NEW_INSTALL_SLIP_SALE);
                    }

                    if (dataSlip != null && dataSlip.SlipIssueFlag != FlagType.C_FLAG_ON)
                    {
                        dataSlip.SlipIssueFlag = FlagType.C_FLAG_ON;
                        int updatedRpw = installHand.UpdateTbt_InstallationSlip(dataSlip);
                    }
                }

                //    scope.Complete();
                //    res.ResultData = "Process Complete.";
                //}

                res.ResultData = "Process Complete.";
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Пример #2
0
        /// <summary>
        /// Validate register receiving returned instrument
        /// </summary>
        /// <param name="Con">Register condition object</param>
        /// <returns></returns>
        public ActionResult IVS030_cmdConfirm(IVS030ConfirmCond Con)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                IVS030_ScreenParameter prm = GetScreenObject <IVS030_ScreenParameter>();
                if (prm.ElemInstrument == null)
                {
                    prm.ElemInstrument = new List <IVS030INST>();
                }

                IInventoryHandler    InvH     = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler;
                ICommonHandler       ComH     = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                IInstallationHandler InstallH = ServiceContainer.GetService <IInstallationHandler>() as IInstallationHandler;

                //4.1
                if (ComH.IsSystemSuspending())
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049);
                    return(Json(res));
                }
                if (!CheckUserPermission(ScreenID.C_INV_SCREEN_ID_RECEIVE_RETURN, FunctionID.C_FUNC_ID_OPERATE))
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                    return(Json(res));
                }

                //4.2
                if (InvH.CheckStartedStockChecking() == 0)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4003);
                    return(Json(res));
                }

                prm.ApproveNo = Con.ApproveNo;
                prm.Memo      = Con.Memo;

                //Check Memo
                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[] { "Detmemo" });
                    return(Json(res));
                }

                //4.3
                //foreach (IVS030INST i in prm.ElemInstrument)
                //{
                //    //4.3.1
                //    if ((i.RemoveQty == null || i.RemoveQty <= 0) && (i.NotInstalledQty == null || i.NotInstalledQty <= 0))
                //    {
                //        res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4127, null, null);
                //        res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                //        return Json(res);
                //    }
                //}
                // 4.3.1
                if (prm.ElemInstrument.Sum(q => q.RemoveQty) <= 0 && prm.ElemInstrument.Sum(q => q.NotInstalledQty) <= 0)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4127, null, null);
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    return(Json(res));
                }


                //4.3.2
                if (prm.SlipSelectType == IVS030_ScreenParameter.SlipType.InstallationSlip)
                {
                    tbt_InstallationSlip doTbt_InstallationSlip = InstallH.GetTbt_InstallationSlipData(prm.SlipNo);

                    if (doTbt_InstallationSlip.SlipStatus == SlipStatus.C_SLIP_STATUS_RETURNED)
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4097, null, null);
                        res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                        return(Json(res));
                    }
                }
                else
                {
                    List <tbt_InventorySlip> doTbt_InventorySlip = InvH.GetTbt_InventorySlip(prm.SlipNo);

                    if (doTbt_InventorySlip.Count > 0 && doTbt_InventorySlip[0].SlipStatus == InventorySlipStatus.C_INV_SLIP_STATUS_COMPLETE)
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4097, null, null);
                        res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                        return(Json(res));
                    }
                }

                res.ResultData = prm.ElemInstrument;

                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex); return(Json(res));
            }
        }