Пример #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));
        }