private doGenerateDocumentResult GenerateACC009_Sheet1(DocumentContext context, SLDocument doc, string sheetname) { #region Prepare doGenerateDocumentResult result = new doGenerateDocumentResult() { ErrorFlag = false, Total = 0, Complete = 0, Failed = 0, ResultDocumentNoList = string.Empty }; #endregion #region Constants const int ROW_HEADER = 1; const int COL_HEADER_TITLE = 1; const int ROW_TBLHDR = 3; int columncount = 0; int COL_ROWNUMBER = ++columncount; int COL_BILLINGTARGETNAMEEN = ++columncount; int COL_SITENAMEEN = ++columncount; int COL_CONTRACTCODE = ++columncount; int COL_BILLINGTARGETCODE = ++columncount; int COL_PLANCODE = ++columncount; int COL_ORDERDEPOSITFEECURRENCY = ++columncount; int COL_ORDERDEPOSITFEE = ++columncount; int COL_ORDERINSTALLFEECURRENCY = ++columncount; int COL_ORDERINSTALLFEE = ++columncount; int COL_INSTALLFEEAMOUNTCURRENCY = ++columncount; int COL_INSTALLFEEAMOUNT = ++columncount; int COL_INSTALLFEEINVOICENO = ++columncount; int COL_ORDERCONTRACTFEECURRENCY = ++columncount; int COL_ORDERCONTRACTFEE = ++columncount; int COL_CONTRACTFEEAMOUNTCURRENCY = ++columncount; int COL_CONTRACTFEEAMOUNT = ++columncount; int COL_INVOICENO = ++columncount; int COL_BILLINGCYCLE = ++columncount; int COL_OFFICENAMEEN = ++columncount; int COL_FIRSTSECURITYSTARTDATE = ++columncount; int COL_PRODUCTNAMEEN = ++columncount; int COL_SALESMANNAME = ++columncount; #endregion if (doc.GetSheetNames().Contains(sheetname)) { doc.DeleteWorksheet(sheetname); } doc.AddWorksheet(sheetname); doc.SelectWorksheet(sheetname); doc.SetCellStyle(ROW_HEADER, COL_HEADER_TITLE, new SLStyle() { Font = new SLFont() { FontName = "Tahoma", FontSize = 12, Bold = true } }); doc.SetCellValue(ROW_HEADER, COL_HEADER_TITLE, "New operation rental report"); doc.SetCellStyle(ROW_TBLHDR, COL_HEADER_TITLE, ROW_TBLHDR, columncount, new SLStyle() { Font = new SLFont() { FontName = "Tahoma", FontSize = 10, Bold = true } }); doc.SetCellValue(ROW_TBLHDR, COL_ROWNUMBER, "NO."); doc.SetCellValue(ROW_TBLHDR, COL_BILLINGTARGETNAMEEN, "BILLINGCUSTOMERNAME"); doc.SetCellValue(ROW_TBLHDR, COL_SITENAMEEN, "PREMISE'SNAME"); doc.SetCellValue(ROW_TBLHDR, COL_CONTRACTCODE, "CONTRACTNO."); doc.SetCellValue(ROW_TBLHDR, COL_BILLINGTARGETCODE, "BILLINGCUSTOMERCODE"); doc.SetCellValue(ROW_TBLHDR, COL_PLANCODE, "PLANCODE"); doc.SetCellValue(ROW_TBLHDR, COL_ORDERDEPOSITFEECURRENCY, "ORDERDEPOSITFEECURRENCY"); doc.SetCellValue(ROW_TBLHDR, COL_ORDERDEPOSITFEE, "ORDERDEPOSITFEE"); doc.SetCellValue(ROW_TBLHDR, COL_ORDERINSTALLFEECURRENCY, "ORDERINSTALLFEECURRENCY"); doc.SetCellValue(ROW_TBLHDR, COL_ORDERINSTALLFEE, "ORDERINSTALLFEE"); doc.SetCellValue(ROW_TBLHDR, COL_INSTALLFEEAMOUNTCURRENCY, "INSTALLFEEAMOUNTCURRENCY"); doc.SetCellValue(ROW_TBLHDR, COL_INSTALLFEEAMOUNT, "INSTALLFEEAMOUNT"); doc.SetCellValue(ROW_TBLHDR, COL_INSTALLFEEINVOICENO, "INSTALLFEEINVOICENO"); doc.SetCellValue(ROW_TBLHDR, COL_ORDERCONTRACTFEECURRENCY, "ORDERCONTRACTFEECURRENCY"); doc.SetCellValue(ROW_TBLHDR, COL_ORDERCONTRACTFEE, "ORDERCONTRACTFEE"); doc.SetCellValue(ROW_TBLHDR, COL_CONTRACTFEEAMOUNTCURRENCY, "CONTRACTFEEAMOUNTCURRENCY"); doc.SetCellValue(ROW_TBLHDR, COL_CONTRACTFEEAMOUNT, "CONTRACTFEEAMOUNT"); doc.SetCellValue(ROW_TBLHDR, COL_INVOICENO, "INVOICENO"); doc.SetCellValue(ROW_TBLHDR, COL_BILLINGCYCLE, "BILLINGCYCLE"); doc.SetCellValue(ROW_TBLHDR, COL_OFFICENAMEEN, "OFFICENAMEEN"); doc.SetCellValue(ROW_TBLHDR, COL_FIRSTSECURITYSTARTDATE, "FIRSTSECURITYSTARTDATE"); doc.SetCellValue(ROW_TBLHDR, COL_PRODUCTNAMEEN, "PRODUCTNAMEEN"); doc.SetCellValue(ROW_TBLHDR, COL_SALESMANNAME, "SALESMANNAME"); List <dtACC009> accountData = this.GetAccountDataOfACC009(context.TargetPeriodFrom, context.TargetPeriodTo, context.UserHQCode); if (accountData.Count == 0) { result.ErrorFlag = true; result.ErrorCode = MessageUtil.MessageList.MSG8005; return(result); } result.Complete = accountData.Count; result.Total = accountData.Count; int rowindex = ROW_TBLHDR + 1; doc.SetCellStyle(rowindex, COL_HEADER_TITLE, rowindex + accountData.Count - 1, columncount, new SLStyle() { Font = new SLFont() { FontName = "Tahoma", FontSize = 10, Bold = false } }); foreach (var rowdata in accountData) { if (rowdata.No != null) { doc.SetCellValue(rowindex, COL_ROWNUMBER, rowdata.No.Value); } doc.SetCellValue(rowindex, COL_BILLINGTARGETNAMEEN, rowdata.BillingTargetNameEN); doc.SetCellValue(rowindex, COL_SITENAMEEN, rowdata.SiteNameEN); doc.SetCellValue(rowindex, COL_CONTRACTCODE, rowdata.ContractCode); doc.SetCellValue(rowindex, COL_BILLINGTARGETCODE, rowdata.BillingTargetCode); doc.SetCellValue(rowindex, COL_PLANCODE, rowdata.PlanCode); if (rowdata.OrderDepositFeeCurrencyType != null) { doc.SetCellValue(rowindex, COL_ORDERCONTRACTFEECURRENCY, this.CurrencyName(rowdata.OrderContractFeeCurrencyType)); } if (rowdata.OrderDepositFee != null) { doc.SetCellValue(rowindex, COL_ORDERDEPOSITFEE, rowdata.OrderDepositFee.Value); } if (rowdata.OrderInstallFeeCurrencyType != null) { doc.SetCellValue(rowindex, COL_ORDERINSTALLFEECURRENCY, this.CurrencyName(rowdata.OrderInstallFeeCurrencyType)); } if (rowdata.OrderInstallFee != null) { doc.SetCellValue(rowindex, COL_ORDERINSTALLFEE, rowdata.OrderInstallFee.Value); } if (rowdata.InstallFeeAmountCurrencyType != null) { doc.SetCellValue(rowindex, COL_INSTALLFEEAMOUNTCURRENCY, this.CurrencyName(rowdata.InstallFeeAmountCurrencyType)); } if (rowdata.InstallFeeAmount != null) { doc.SetCellValue(rowindex, COL_INSTALLFEEAMOUNT, rowdata.InstallFeeAmount.Value); } doc.SetCellValue(rowindex, COL_INSTALLFEEINVOICENO, rowdata.InstallFeeInvoiceNo); if (rowdata.OrderContractFeeCurrencyType != null) { doc.SetCellValue(rowindex, COL_ORDERCONTRACTFEECURRENCY, this.CurrencyName(rowdata.OrderContractFeeCurrencyType)); } if (rowdata.OrderContractFee != null) { doc.SetCellValue(rowindex, COL_ORDERCONTRACTFEE, rowdata.OrderContractFee.Value); } if (rowdata.ContractFeeAmountCurrencyType != null) { doc.SetCellValue(rowindex, COL_CONTRACTFEEAMOUNTCURRENCY, this.CurrencyName(rowdata.ContractFeeAmountCurrencyType)); } if (rowdata.ContractFeeAmount != null) { doc.SetCellValue(rowindex, COL_CONTRACTFEEAMOUNT, rowdata.ContractFeeAmount.Value); } doc.SetCellValue(rowindex, COL_INVOICENO, rowdata.InvoiceNo); if (rowdata.BillingCycle != null) { doc.SetCellValue(rowindex, COL_BILLINGCYCLE, rowdata.BillingCycle.Value); } doc.SetCellValue(rowindex, COL_OFFICENAMEEN, rowdata.OfficeNameEN); if (rowdata.FirstSecurityStartDate != null) { doc.SetCellValue(rowindex, COL_FIRSTSECURITYSTARTDATE, rowdata.FirstSecurityStartDate.Value); } doc.SetCellValue(rowindex, COL_PRODUCTNAMEEN, rowdata.ProductNameEN); doc.SetCellValue(rowindex, COL_SALESMANNAME, rowdata.SalesmanName); rowindex++; } result.Total += accountData.Count; return(result); }
public doGenerateDocumentResult ACC009_NewOperationRentalReport(DocumentContext context) { doGenerateDocumentResult result = new doGenerateDocumentResult() { ErrorFlag = false, Total = 0, Complete = 0, Failed = 0, ResultDocumentNoList = string.Empty }; using (TransactionScope scope = new TransactionScope()) { try { #region Write text report dtAccountingConfig folder = this.getAccountingConfig(AccountingConfig.C_ACC_CONFIG_GROUP_CSV, AccountingConfig.C_ACC_CONFIG_NAME_FOLDER); string documentNo = string.Format(@"{0}{1}{2}{3}", context.DocumentCode, context.TargetPeriodFrom.Value.ToString("yyyyMMdd"), context.TargetPeriodTo.Value.ToString("yyyyMMdd"), context.UserHQCode); string outputfilepath = string.Format(@"{0}\{1}\{2}.xlsx", context.TargetPeriodTo.Value.ToString("yyyyMM"), folder.ConfigValue, documentNo); string fullOutputFilePath = PathUtil.GetPathValue(PathUtil.PathName.GeneratedReportPath, outputfilepath); ICommonHandler comHand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>() { new doMiscTypeCode() { FieldName = MiscType.C_CURRENCT, ValueCode = "%" } }).ToList(); Currencies = new List <doMiscTypeCode>(tmpCurrencies); using (SLDocument doc = new SLDocument()) { //Sheet1 { result = this.GenerateACC009_Sheet1(context, doc, "Sheet1"); if (result.ErrorFlag == true) { return(result); } } WriteCSVFile egWriteCSV = new WriteCSVFile(); egWriteCSV.IfExitDeleteFile(fullOutputFilePath); doc.SaveAs(fullOutputFilePath); } #endregion #region Keep daily genereated document List <tbt_AccountingDocumentList> genComplete = new List <tbt_AccountingDocumentList>(); genComplete.Add(new tbt_AccountingDocumentList() { DocumentNo = documentNo, DocumentCode = context.DocumentCode, TargetPeriodFrom = context.TargetPeriodFrom.Value, TargetPeriodTo = context.TargetPeriodTo.Value, GenerateHQCode = context.UserHQCode, ReportMonth = Convert.ToInt32(context.TargetPeriodTo.Value.ToString("MM")), ReportYear = Convert.ToInt32(context.TargetPeriodTo.Value.ToString("yyyy")), FilePath = outputfilepath, CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo, CreateDate = DateTime.Now, UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo, UpdateDate = DateTime.Now }); this.Insert_tbt_AccountingDocumentList(CommonUtil.ConvertToXml_Store <tbt_AccountingDocumentList>(genComplete)); #endregion scope.Complete(); //Record info result.Complete = result.Total; result.ResultDocumentNoList = documentNo; return(result); } catch (Exception ex) { scope.Dispose(); throw; } } }
private doGenerateDocumentResult GenerateACC012_Sheet6(DocumentContext context, SLDocument doc, string sheetname) { #region Prepare doGenerateDocumentResult result = new doGenerateDocumentResult() { ErrorFlag = false, Total = 0, Complete = 0, Failed = 0, ResultDocumentNoList = string.Empty }; #endregion #region Constants const int ROW_HEADER = 1; const int COL_HEADER_TITLE = 1; const int ROW_TBLHDR = 3; int columncount = 0; int COL_ROWNUMBER = ++columncount; int COL_FULLNAMEEN = ++columncount; int COL_BILLINGTARGETCODE = ++columncount; int COL_CONTRACTCODE = ++columncount; int COL_BILLINGTYPE = ++columncount; int COL_INVOICENO = ++columncount; int COL_ISSUEINVDATE = ++columncount; int COL_BILLINGSTARTDATE = ++columncount; int COL_BILLINGENDDATE = ++columncount; int COL_BILLINGAMOUNTCURRENCY = ++columncount; int COL_BILLINGAMOUNT = ++columncount; int COL_VAT = ++columncount; int COL_TAXINVOICENO = ++columncount; int COL_TAXINVOICEDATE = ++columncount; int COL_FIRSTSECURITYSTARTDATE = ++columncount; #endregion if (doc.GetSheetNames().Contains(sheetname)) { doc.DeleteWorksheet(sheetname); } doc.AddWorksheet(sheetname); doc.SelectWorksheet(sheetname); doc.SetCellStyle(ROW_HEADER, COL_HEADER_TITLE, new SLStyle() { Font = new SLFont() { FontName = "Tahoma", FontSize = 12, Bold = true } }); doc.SetCellValue(ROW_HEADER, COL_HEADER_TITLE, "Not Payment List (BillingTypeCode 99)"); doc.SetCellStyle(ROW_TBLHDR, COL_HEADER_TITLE, ROW_TBLHDR, columncount, new SLStyle() { Font = new SLFont() { FontName = "Tahoma", FontSize = 10, Bold = true } }); doc.SetCellValue(ROW_TBLHDR, COL_ROWNUMBER, "#"); doc.SetCellValue(ROW_TBLHDR, COL_FULLNAMEEN, "FULLNAMEEN"); doc.SetCellValue(ROW_TBLHDR, COL_BILLINGTARGETCODE, "BILLINGTARGETCODE"); doc.SetCellValue(ROW_TBLHDR, COL_CONTRACTCODE, "CONTRACTCODE"); doc.SetCellValue(ROW_TBLHDR, COL_BILLINGTYPE, "BILLINGTYPE"); doc.SetCellValue(ROW_TBLHDR, COL_INVOICENO, "INVOICENO"); doc.SetCellValue(ROW_TBLHDR, COL_ISSUEINVDATE, "ISSUEINVDATE"); doc.SetCellValue(ROW_TBLHDR, COL_BILLINGAMOUNTCURRENCY, "BILLINGAMOUNTCURRENCY"); doc.SetCellValue(ROW_TBLHDR, COL_BILLINGAMOUNT, "BILLINGAMOUNT"); doc.SetCellValue(ROW_TBLHDR, COL_VAT, "VAT"); doc.SetCellValue(ROW_TBLHDR, COL_TAXINVOICENO, "TAXINVOICENO"); doc.SetCellValue(ROW_TBLHDR, COL_TAXINVOICEDATE, "TAXINVOICEDATE"); doc.SetCellValue(ROW_TBLHDR, COL_FIRSTSECURITYSTARTDATE, "FIRSTSECURITYSTARTDATE"); var reportdata = this.GetAccountDataOfACC012_Sheet6(context.UserHQCode); if (reportdata.Count == 0) { result.ErrorFlag = true; result.ErrorCode = MessageUtil.MessageList.MSG8005; return(result); } result.Complete = reportdata.Count; result.Total = reportdata.Count; int rowindex = ROW_TBLHDR + 1; doc.SetCellStyle(rowindex, COL_HEADER_TITLE, rowindex + reportdata.Count - 1, columncount, new SLStyle() { Font = new SLFont() { FontName = "Tahoma", FontSize = 10, Bold = false } }); foreach (var rowdata in reportdata) { if (rowdata.RowNumber != null) { doc.SetCellValue(rowindex, COL_ROWNUMBER, rowdata.RowNumber.Value); } doc.SetCellValue(rowindex, COL_FULLNAMEEN, rowdata.FullNameEN); doc.SetCellValue(rowindex, COL_BILLINGTARGETCODE, rowdata.BillingTargetCode); doc.SetCellValue(rowindex, COL_CONTRACTCODE, rowdata.ContractCode); doc.SetCellValue(rowindex, COL_BILLINGTYPE, rowdata.BillingType); doc.SetCellValue(rowindex, COL_INVOICENO, rowdata.InvoiceNo); if (rowdata.IssueInvDate != null) { doc.SetCellValue(rowindex, COL_ISSUEINVDATE, rowdata.IssueInvDate.Value.ToString("dd-MMM-yyyy")); } if (rowdata.BillingAmountCurrencyType != null) { doc.SetCellValue(rowindex, COL_BILLINGAMOUNTCURRENCY, rowdata.BillingAmountCurrencyType); } if (rowdata.BillingAmount != null) { doc.SetCellValue(rowindex, COL_BILLINGAMOUNT, rowdata.BillingAmount.Value); } if (rowdata.Vat != null) { doc.SetCellValue(rowindex, COL_VAT, rowdata.Vat.Value); } doc.SetCellValue(rowindex, COL_TAXINVOICENO, rowdata.TaxInvoiceNo); if (rowdata.TaxInvoiceDate != null) { doc.SetCellValue(rowindex, COL_TAXINVOICEDATE, rowdata.TaxInvoiceDate.Value.ToString("dd-MMM-yyyy")); } if (rowdata.FirstSecurityStartDate != null) { doc.SetCellValue(rowindex, COL_FIRSTSECURITYSTARTDATE, rowdata.FirstSecurityStartDate.Value.ToString("dd-MMM-yyyy")); } rowindex++; } return(result); }
public doGenerateDocumentResult ACC012_NotPaymentListReport(DocumentContext context) { doGenerateDocumentResult result = new doGenerateDocumentResult() { ErrorFlag = false, Total = 0, Complete = 0, Failed = 0, ResultDocumentNoList = string.Empty }; using (TransactionScope scope = new TransactionScope()) { try { #region Write text report dtAccountingConfig folder = this.getAccountingConfig(AccountingConfig.C_ACC_CONFIG_GROUP_CSV, AccountingConfig.C_ACC_CONFIG_NAME_FOLDER); string documentNo = string.Format(@"{0}{1}{2}", context.DocumentCode, context.TargetPeriodTo.Value.ToString("yyyyMMdd"), context.UserHQCode); string outputfilepath = string.Format(@"{0}\{1}\{2}.xlsx", context.TargetPeriodTo.Value.ToString("yyyyMM"), folder.ConfigValue, documentNo); string fullOutputFilePath = PathUtil.GetPathValue(PathUtil.PathName.GeneratedReportPath, outputfilepath); int dataNotFoundCount = 0; using (SLDocument doc = new SLDocument()) { //Sheet1 { result = this.GenerateACC012_Sheet1(context, doc, "Sheet1"); if (result.ErrorFlag == true) { if (result.ErrorCode == MessageUtil.MessageList.MSG8005) { dataNotFoundCount++; } else { return(result); } } else { result.Complete += 1; } } //Sheet2 { result = this.GenerateACC012_Sheet2(context, doc, "Sheet2"); if (result.ErrorFlag == true) { if (result.ErrorCode == MessageUtil.MessageList.MSG8005) { dataNotFoundCount++; } else { return(result); } } else { result.Complete += 1; } } //Sheet3 { result = this.GenerateACC012_Sheet3(context, doc, "Sheet3"); if (result.ErrorFlag == true) { if (result.ErrorCode == MessageUtil.MessageList.MSG8005) { dataNotFoundCount++; } else { return(result); } } else { result.Complete += 1; } } //Sheet4 { result = this.GenerateACC012_Sheet4(context, doc, "Sheet4"); if (result.ErrorFlag == true) { if (result.ErrorCode == MessageUtil.MessageList.MSG8005) { dataNotFoundCount++; } else { return(result); } } else { result.Complete += 1; } } //Sheet5 { result = this.GenerateACC012_Sheet5(context, doc, "Sheet5"); if (result.ErrorFlag == true) { if (result.ErrorCode == MessageUtil.MessageList.MSG8005) { dataNotFoundCount++; } else { return(result); } } else { result.Complete += 1; } } //Sheet6 { result = this.GenerateACC012_Sheet6(context, doc, "Sheet6"); if (result.ErrorFlag == true) { if (result.ErrorCode == MessageUtil.MessageList.MSG8005) { dataNotFoundCount++; } else { return(result); } } else { result.Complete += 1; } } if (dataNotFoundCount >= 6) { return(result); } else { result.ErrorFlag = false; } WriteCSVFile egWriteCSV = new WriteCSVFile(); egWriteCSV.IfExitDeleteFile(fullOutputFilePath); doc.SaveAs(fullOutputFilePath); } #endregion #region Keep daily genereated document List <tbt_AccountingDocumentList> genComplete = new List <tbt_AccountingDocumentList>(); genComplete.Add(new tbt_AccountingDocumentList() { DocumentNo = documentNo, DocumentCode = context.DocumentCode, TargetPeriodFrom = context.TargetPeriodTo.Value, TargetPeriodTo = context.TargetPeriodTo.Value, GenerateHQCode = context.UserHQCode, ReportMonth = Convert.ToInt32(context.TargetPeriodTo.Value.ToString("MM")), ReportYear = Convert.ToInt32(context.TargetPeriodTo.Value.ToString("yyyy")), FilePath = outputfilepath, CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo, CreateDate = DateTime.Now, UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo, UpdateDate = DateTime.Now }); this.Insert_tbt_AccountingDocumentList(CommonUtil.ConvertToXml_Store <tbt_AccountingDocumentList>(genComplete)); #endregion scope.Complete(); //Record info result.Complete = result.Total; result.ResultDocumentNoList = documentNo; return(result); } catch (Exception ex) { scope.Dispose(); throw; } } }
public ActionResult ACS010_GenerateReport(ACS010_Generate generateCondition) { ObjectResultData res = new ObjectResultData(); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; List <dtAccountingDocumentList> documentList = new List <dtAccountingDocumentList>(); try { List <tbm_Office> list = new List <tbm_Office>(); AccountingHandler handler = new AccountingHandler(); IOfficeMasterHandler officehandler = ServiceContainer.GetService <IOfficeMasterHandler>() as IOfficeMasterHandler; var officeItem = officehandler.GetTbm_Office(CommonUtil.dsTransData.dtUserData.MainOfficeCode); List <dtAccountingDocument> documents = handler.GetAccountingDocument(generateCondition.documentCode); //Generate DocumentContext context = new DocumentContext(); context.DocumentCode = documents[0].DocumentCode; context.DocumentGeneratorName = documents[0].DocumentGeneratorName; context.UserID = CommonUtil.dsTransData.dtUserData.EmpNo; context.DocumentTimingTypeDesc = documents[0].DocumentTimingTypeDesc; context.GenerateDate = DateTime.Now; context.TargetPeriodFrom = generateCondition.generateTargetFrom; context.TargetPeriodTo = generateCondition.generateTargetTo; context.UserHQCode = officeItem[0].HQCode; doGenerateDocumentResult result = DocumentGenerator.Generate(context); //Success if (result.ErrorFlag == false) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION_OK; res.AddErrorMessage(MessageUtil.MODULE_ACCOUNTING, ScreenID.C_SCREEN_ID_OTHER_ACCOUNTING_REPORT, MessageUtil.MODULE_ACCOUNTING, MessageUtil.MessageList.MSG8004, null, new string[] { "AccountingGenerateDocument" }); //Result list ACS010_Search searchCondition = new ACS010_Search(); searchCondition.SearchDocumentCode = result.DocumentContext.DocumentCode; searchCondition.SearchDocumentNo = result.ResultDocumentNoList; documentList = handler.GetAccountingDocumentList(searchCondition, result.DocumentContext.UserHQCode); } //Fail else { res.AddErrorMessage(MessageUtil.MODULE_ACCOUNTING, ScreenID.C_SCREEN_ID_OTHER_ACCOUNTING_REPORT, MessageUtil.MODULE_ACCOUNTING, result.ErrorCode, null, new string[] { "AccountingGenerateDocument" }); } } catch (Exception ex) { documentList = new List <dtAccountingDocumentList>(); res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(ex); } res.ResultData = CommonUtil.ConvertToXml <dtAccountingDocumentList>(documentList, "Accounting\\ACS010", CommonUtil.GRID_EMPTY_TYPE.SEARCH); return(Json(res)); }
public doGenerateDocumentResult ACC002_AgingReport(DocumentContext context) { #region Prepare doGenerateDocumentResult result = new doGenerateDocumentResult() { ErrorFlag = false, Total = 0, Complete = 0, Failed = 0, ResultDocumentNoList = string.Empty }; #endregion using (TransactionScope scope = new TransactionScope()) { try { ICommonHandler comHand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>() { new doMiscTypeCode() { FieldName = MiscType.C_CURRENCT, ValueCode = "%" } }).ToList(); #region Do process //Get business date parameter dtAccountingBusinessDateOfAgingReport businessDate = this.GetAccountingBusinessDateOfAgingReport(context.TargetPeriodTo).FirstOrDefault(); dtAccountingConfig folder = this.getAccountingConfig(AccountingConfig.C_ACC_CONFIG_GROUP_CSV, AccountingConfig.C_ACC_CONFIG_NAME_FOLDER); #region Generate report //Get account data List <dtAccountDataOfAgingReport> accountData = this.GetAccountDataOfAgingReport(businessDate.TargetPeriod.Value, businessDate.LastEndDate.Value, context.UserHQCode); if (accountData.Count == 0) { result.ErrorFlag = true; result.ErrorCode = MessageUtil.MessageList.MSG8005; return(result); } for (int i = 0; i < accountData.Count(); i++) { accountData[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies); } #region Write text report //Format: ..\YYYYMM\[CSV.Folder]\ACC002YYYYMMDDHQCD.csv string textContent = CSVReportUtil.GenerateAccountingCSVData <dtAccountDataOfAgingReport>(accountData, true, true, "No."); string documentNo = string.Format(@"{0}{1}{2}", context.DocumentCode, businessDate.TargetPeriod.Value.ToString("yyyyMMdd"), context.UserHQCode); string outputfilepath = string.Format(@"{0}{1}\{2}\{3}.csv", businessDate.ReportYear, businessDate.ReportMonth, folder.ConfigValue, documentNo); string fullOutputFilePath = PathUtil.GetPathValue(PathUtil.PathName.GeneratedReportPath, outputfilepath); WriteCSVFile egWriteCSV = new WriteCSVFile(); egWriteCSV.IfExitDeleteFile(fullOutputFilePath); using (StreamWriter sw = new StreamWriter(fullOutputFilePath, false, Encoding.GetEncoding("TIS-620"))) { sw.WriteLine(textContent); sw.Close(); } #endregion #region Keep daily genereated document List <tbt_AccountingDocumentList> genComplete = new List <tbt_AccountingDocumentList>(); genComplete.Add(new tbt_AccountingDocumentList() { DocumentNo = documentNo, DocumentCode = context.DocumentCode, TargetPeriodFrom = businessDate.TargetPeriod.Value, TargetPeriodTo = businessDate.TargetPeriod.Value, GenerateHQCode = context.UserHQCode, ReportMonth = Convert.ToInt32(businessDate.ReportMonth), ReportYear = Convert.ToInt32(businessDate.ReportYear), FilePath = outputfilepath, CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo, CreateDate = DateTime.Now, UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo, UpdateDate = DateTime.Now }); this.Insert_tbt_AccountingDocumentList(CommonUtil.ConvertToXml_Store <tbt_AccountingDocumentList>(genComplete)); #endregion scope.Complete(); //Record info result.Total += accountData.Count; result.Complete = result.Total; result.ResultDocumentNoList = documentNo; return(result); } catch (Exception ex) { scope.Dispose(); throw; } #endregion #endregion } }
private doGenerateDocumentResult GenerateACC010_Sheet1(DocumentContext context, SLDocument doc, string sheetname) { #region Prepare doGenerateDocumentResult result = new doGenerateDocumentResult() { ErrorFlag = false, Total = 0, Complete = 0, Failed = 0, ResultDocumentNoList = string.Empty }; #endregion #region Constants const int ROW_HEADER = 1; const int COL_HEADER_TITLE = 1; const int ROW_TBLHDR = 3; int columncount = 0; int COL_ROWNUMBER = ++columncount; int COL_CUSTFULLNAMEEN = ++columncount; int COL_CONTRACTCODE = ++columncount; int COL_SITENAMEEN = ++columncount; int COL_PLANCODE = ++columncount; int COL_OFFICENAMEEN = ++columncount; int COL_CUSTACCEPTANCEDATE = ++columncount; int COL_PRODUCTNAMEEN = ++columncount; int COL_SALESMANNAME = ++columncount; int COL_ORDERPRODUCTPRICECURRENCY = ++columncount; int COL_ORDERPRODUCTPRICE = ++columncount; int COL_INSTRUMENTCOSTCURRENCY = ++columncount; int COL_INSTRUMENTCOST = ++columncount; int COL_ORDERINSTALLFEECURRENCY = ++columncount; int COL_ORDERINSTALLFEE = ++columncount; int COL_PAYTOSUBCONTRACTORCURRENCY = ++columncount; int COL_PAYTOSUBCONTRACTOR = ++columncount; #endregion if (doc.GetSheetNames().Contains(sheetname)) { doc.DeleteWorksheet(sheetname); } doc.AddWorksheet(sheetname); doc.SelectWorksheet(sheetname); doc.SetCellStyle(ROW_HEADER, COL_HEADER_TITLE, new SLStyle() { Font = new SLFont() { FontName = "Tahoma", FontSize = 12, Bold = true } }); doc.SetCellValue(ROW_HEADER, COL_HEADER_TITLE, "New operation sales report"); doc.SetCellStyle(ROW_TBLHDR, COL_HEADER_TITLE, ROW_TBLHDR, columncount, new SLStyle() { Font = new SLFont() { FontName = "Tahoma", FontSize = 10, Bold = true } }); doc.SetCellValue(ROW_TBLHDR, COL_ROWNUMBER, "NO."); doc.SetCellValue(ROW_TBLHDR, COL_CUSTFULLNAMEEN, "CUSTFULLNAMEEN"); doc.SetCellValue(ROW_TBLHDR, COL_CONTRACTCODE, "CONTRACTNO."); doc.SetCellValue(ROW_TBLHDR, COL_SITENAMEEN, "PREMISE'SNAMEEN"); doc.SetCellValue(ROW_TBLHDR, COL_PLANCODE, "PLANCODE"); doc.SetCellValue(ROW_TBLHDR, COL_OFFICENAMEEN, "OFFICENAMEEN"); doc.SetCellValue(ROW_TBLHDR, COL_CUSTACCEPTANCEDATE, "CUSTACCEPTANCEDATE"); doc.SetCellValue(ROW_TBLHDR, COL_PRODUCTNAMEEN, "PRODUCTNAMEEN"); doc.SetCellValue(ROW_TBLHDR, COL_SALESMANNAME, "SALESMANNAME"); doc.SetCellValue(ROW_TBLHDR, COL_ORDERPRODUCTPRICECURRENCY, "ORDERPRODUCTPRICECURRENCY"); doc.SetCellValue(ROW_TBLHDR, COL_ORDERPRODUCTPRICE, "ORDERPRODUCTPRICE"); doc.SetCellValue(ROW_TBLHDR, COL_INSTRUMENTCOSTCURRENCY, "INSTRUMENTCOSTCURRENCY"); doc.SetCellValue(ROW_TBLHDR, COL_INSTRUMENTCOST, "INSTRUMENTCOST"); doc.SetCellValue(ROW_TBLHDR, COL_ORDERINSTALLFEECURRENCY, "ORDERINSTALLFEECURRENCY"); doc.SetCellValue(ROW_TBLHDR, COL_ORDERINSTALLFEE, "ORDERINSTALLFEE"); doc.SetCellValue(ROW_TBLHDR, COL_PAYTOSUBCONTRACTORCURRENCY, "PAYTOSUBCONTRACTORCURRENCY"); doc.SetCellValue(ROW_TBLHDR, COL_PAYTOSUBCONTRACTOR, "PAYTOSUBCONTRACTOR"); var accountData = this.GetAccountDataOfACC010(context.TargetPeriodFrom, context.TargetPeriodTo, context.UserHQCode); if (accountData.Count == 0) { result.ErrorFlag = true; result.ErrorCode = MessageUtil.MessageList.MSG8005; return(result); } result.Complete = accountData.Count; result.Total = accountData.Count; int rowindex = ROW_TBLHDR + 1; doc.SetCellStyle(rowindex, COL_HEADER_TITLE, rowindex + accountData.Count - 1, columncount, new SLStyle() { Font = new SLFont() { FontName = "Tahoma", FontSize = 10, Bold = false } }); foreach (var rowdata in accountData) { if (rowdata.RowNumber != null) { doc.SetCellValue(rowindex, COL_ROWNUMBER, rowdata.RowNumber.Value); } doc.SetCellValue(rowindex, COL_CUSTFULLNAMEEN, rowdata.CustFullNameEN); doc.SetCellValue(rowindex, COL_CONTRACTCODE, rowdata.ContractCode); doc.SetCellValue(rowindex, COL_SITENAMEEN, rowdata.SiteNameEN); doc.SetCellValue(rowindex, COL_PLANCODE, rowdata.PlanCode); doc.SetCellValue(rowindex, COL_OFFICENAMEEN, rowdata.OfficeNameEN); if (rowdata.CustAcceptanceDate != null) { doc.SetCellValue(rowindex, COL_CUSTACCEPTANCEDATE, rowdata.CustAcceptanceDate.Value.ToString("dd-MMM-yyyy")); } doc.SetCellValue(rowindex, COL_PRODUCTNAMEEN, rowdata.ProductNameEN); doc.SetCellValue(rowindex, COL_SALESMANNAME, rowdata.SalesmanName); if (rowdata.OrderProductPriceCurrencyType != null) { doc.SetCellValue(rowindex, COL_ORDERPRODUCTPRICECURRENCY, rowdata.OrderProductPriceCurrencyType); } if (rowdata.OrderProductPrice != null) { doc.SetCellValue(rowindex, COL_ORDERPRODUCTPRICE, rowdata.OrderProductPrice.Value); } if (rowdata.InstrumentCostCurrencyType != null) { doc.SetCellValue(rowindex, COL_INSTRUMENTCOSTCURRENCY, rowdata.InstrumentCostCurrencyType); } if (rowdata.InstrumentCost != null) { doc.SetCellValue(rowindex, COL_INSTRUMENTCOST, rowdata.InstrumentCost.Value); } if (rowdata.OrderInstallFee != null) { doc.SetCellValue(rowindex, COL_ORDERINSTALLFEE, rowdata.OrderInstallFee.Value); } if (rowdata.OrderInstallFeeCurrencyType != null) { doc.SetCellValue(rowindex, COL_ORDERINSTALLFEECURRENCY, rowdata.OrderInstallFeeCurrencyType); } if (rowdata.PayToSubcontractor != null) { doc.SetCellValue(rowindex, COL_PAYTOSUBCONTRACTOR, rowdata.PayToSubcontractor.Value); } rowindex++; } doc.Filter(ROW_TBLHDR, COL_ROWNUMBER, rowindex - 1, COL_PAYTOSUBCONTRACTOR); doc.SetCellValue(SLConvert.ToCellReference(rowindex, COL_ORDERPRODUCTPRICE), string.Format("=SUBTOTAL({0})", SLConvert.ToCellRange(ROW_TBLHDR + 1, COL_ORDERPRODUCTPRICE, rowindex - 1, COL_ORDERPRODUCTPRICE))); return(result); }