Beispiel #1
0
        private PdfOutputSetting GetInputedValues()
        {
            var setting = new PdfOutputSetting {
                CompanyId = Login.CompanyId,
                CreateBy  = Login.UserId,
                UpdateBy  = Login.UserId,
            };

            if (ReturnScreen is PC1501)
            {
                setting.ReportType = (int)PdfOutputSettingReportType.Invoice;
            }
            else if (ReturnScreen is PI0401)
            {
                setting.ReportType = (int)PdfOutputSettingReportType.Reminder;
            }

            if (rdoAllInOne.Checked)
            {
                setting.OutputUnit = (int)PdfOutputSettingOutputUnit.AllInOne;
                return(setting);
            }
            setting.OutputUnit     = (int)PdfOutputSettingOutputUnit.ByReport;
            setting.FileName       = txtFileName.Text.Trim();
            setting.UseCompression = cbxUseCompression.Checked ? 1 : 0;
            setting.MaximumSize    = nmbMaxSize.Value;
            return(setting);
        }
Beispiel #2
0
        private void Print()
        {
            ClearStatusMessage();
            if (!ValidateInputValueForPrint())
            {
                return;
            }

            try
            {
                var path = string.Empty;
                PdfSetting = GetPdfOutputSetting();
                if (!PdfSetting.IsAllInOne)
                {
                    var serverPath      = GetServerPath();
                    var selectedPath    = string.Empty;
                    var rootBrowserPath = new List <string>();
                    if (!LimitAccessFolder ?
                        !ShowFolderBrowserDialog(serverPath, out selectedPath) :
                        !ShowRootFolderBrowserDialog(ApplicationControl.RootPath, out rootBrowserPath, FolderBrowserType.SelectFolder))
                    {
                        DispStatusMessage(MsgInfProcessCanceled);
                        return;
                    }
                    path = (!LimitAccessFolder ? selectedPath : rootBrowserPath.First());
                }

                if (!PdfSetting.IsAllInOne && !ShowConfirmDialog(MsgQstConfirmOutput))
                {
                    DispStatusMessage(MsgInfProcessCanceled);
                    return;
                }

                if (!ReminderSummary.Any())
                {
                    ShowWarningDialog(MsgWngPrintDataNotExist, "出力");
                    return;
                }

                grdReminder.CommitEdit();
                Task task = null;
                if (!UseDestinationSummarized)
                {
                    task = PrintSummarized(path);
                }
                else
                {
                    task = PrintDestinationSummarized(path);
                }
                ProgressDialog.Start(ParentForm, task, false, SessionKey);
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                ShowWarningDialog(MsgErrExportError);
            }
        }
Beispiel #3
0
 private async Task <PdfOutputSetting> SavePdfOutputSetting(PdfOutputSetting setting) =>
 await ServiceProxyFactory.DoAsync(async (PdfOutputSettingMasterClient client) =>
 {
     var result = await client.SaveAsync(SessionKey, setting);
     if (result == null || result.ProcessResult == null || !result.ProcessResult.Result)
     {
         return(null);
     }
     return(result.PdfOutputSetting);
 });
Beispiel #4
0
        public Task <PdfOutputSetting> SaveAsync(PdfOutputSetting setting, CancellationToken token = default(CancellationToken))
        {
            var query = @"
MERGE INTO PdfOutputSetting AS target
USING ( 
    SELECT 
     @CompanyId  AS CompanyId
    ,@ReportType AS ReportType
) AS source 
ON ( 
        target.CompanyId  = source.CompanyId
    AND target.ReportType = source.ReportType
) 
WHEN MATCHED THEN 
    UPDATE SET
         OutputUnit     = @OutputUnit
        ,FileName       = @FileName
        ,UseCompression = @UseCompression
        ,MaximumSize    = @MaximumSize
        ,UpdateBy       = @UpdateBy
        ,UpdateAt       = GETDATE()
WHEN NOT MATCHED THEN
    INSERT (
         CompanyId
        ,ReportType
        ,OutputUnit
        ,FileName
        ,UseCompression
        ,MaximumSize
        ,CreateBy
        ,CreateAt
        ,UpdateBy
        ,UpdateAt
    ) VALUES (
         @CompanyId
        ,@ReportType
        ,@OutputUnit
        ,@FileName
        ,@UseCompression
        ,@MaximumSize
        ,@CreateBy
        ,GETDATE()
        ,@UpdateBy
        ,GETDATE()
        )
OUTPUT inserted.*; ";

            return(dbHelper.ExecuteAsync <PdfOutputSetting>(query, setting, token));
        }
        public async Task <PdfOutputSettingResult> SaveAsync(string SessionKey, PdfOutputSetting Setting)
        {
            return(await authorizationProcessor.DoAuthorizeAsync(SessionKey, async token =>
            {
                var result = await pdfOutputSettingProcessor.SaveAsync(Setting, token);

                return new PdfOutputSettingResult
                {
                    ProcessResult = new ProcessResult {
                        Result = true
                    },
                    PdfOutputSetting = result,
                };
            }, logger));
        }
Beispiel #6
0
        private void SetOdfOutputSetting(PdfOutputSetting setting)
        {
            if (setting.IsAllInOne)
            {
                SetAllInOne();
                Modified = false;
                rdoAllInOne.Select();
                return;
            }

            rdoByReport.Checked       = true;
            txtFileName.Text          = setting.FileName;
            cbxUseCompression.Checked = setting.UseZip;
            nmbMaxSize.Value          = setting.MaximumSize;
            Modified = false;
            rdoByReport.Select();
        }
        public async Task <PdfOutputSetting> GetAsync(int CompanyId, int ReportType, int UserId, CancellationToken token = default(CancellationToken))
        {
            var setting = await pdfOutputSettingQueryProcessor.GetAsync(CompanyId, ReportType, token);

            if (setting != null)
            {
                return(setting);
            }

            var defaultSetting = new PdfOutputSetting {
                CompanyId  = CompanyId,
                ReportType = ReportType,
                OutputUnit = (int)PdfOutputSettingOutputUnit.AllInOne,
                CreateBy   = UserId,
                UpdateBy   = UserId
            };

            return(await addPdfOutputSettingQueryProcessor.SaveAsync(defaultSetting, token));
        }
Beispiel #8
0
        public static ReminderReport CreateReminderReport(IEnumerable <ReminderBilling> source,
                                                          ReminderCommonSetting ReminderCommonSetting,
                                                          List <ReminderSummarySetting> ReminderSummarySetting,
                                                          ReminderTemplateSetting template,
                                                          Company Company,
                                                          List <ColumnNameSetting> ColumnNameSetting,
                                                          DateTime outputAt,
                                                          PdfOutputSetting pdfSetting)
        {
            var reminderReport = new ReminderReport();

            reminderReport.Template = template;
            reminderReport.txtOutputAtHeader.Text = outputAt.ToString("yyyy年MM月dd日");
            reminderReport.txtOutputAtDetail.Text = outputAt.ToString("yyyy年MM月dd日");

            var rd            = source.FirstOrDefault();
            var isDestination = rd.DestinationId.HasValue && rd.DestinationId != 0;

            reminderReport.txtCustomerPostalCode.Text = isDestination ? rd.DestinationPostalCode : rd.CustomerPostalCode;
            reminderReport.txtCustomerAddress1.Text   = isDestination ? rd.DestinationAddress1 : rd.CustomerAddress1;
            reminderReport.txtCustomerAddress2.Text   = isDestination ? rd.DestinationAddress2 : rd.CustomerAddress2;
            reminderReport.txtCustomerName.Text       = !string.IsNullOrEmpty(rd.DestinationName) ? rd.DestinationName : rd.CustomerName;

            if (isDestination)
            {
                var isNullDepartment = string.IsNullOrEmpty(rd.DestinationDepartmentName);
                var isNullAddressee  = string.IsNullOrEmpty(rd.DestinationAddressee);
                if (isNullDepartment && isNullAddressee)
                {
                    reminderReport.txtCustomerName.Text += rd.DestinationHonorific;
                }
                else if (!isNullDepartment && isNullAddressee)
                {
                    reminderReport.txtDestinationDepartmentName.Text = rd.DestinationDepartmentName + " " + rd.DestinationHonorific;
                    reminderReport.txtDestinationAddressee.Text      = "";
                }
                else if (isNullDepartment && !isNullAddressee)
                {
                    reminderReport.txtDestinationDepartmentName.Text = rd.DestinationAddressee + " " + rd.DestinationHonorific;
                    reminderReport.txtDestinationAddressee.Text      = "";
                }
                else
                {
                    reminderReport.txtDestinationDepartmentName.Text = rd.DestinationDepartmentName;
                    reminderReport.txtDestinationAddressee.Text      = rd.DestinationAddressee + " " + rd.DestinationHonorific;
                }
            }
            else
            {
                var isNullDepartment     = string.IsNullOrEmpty(rd.DestinationDepartmentName);
                var isNullAddressee      = string.IsNullOrEmpty(rd.DestinationAddressee);
                var destinationHonorific = rd.DestinationHonorific;
                if (isNullDepartment && isNullAddressee)
                {
                    reminderReport.txtCustomerName.Text += destinationHonorific;
                    reminderReport.txtDestinationDepartmentName.Text = "";
                    reminderReport.txtDestinationAddressee.Text      = "";
                }
                else if (!isNullDepartment && isNullAddressee)
                {
                    reminderReport.txtDestinationDepartmentName.Text = rd.DestinationDepartmentName + destinationHonorific;
                    reminderReport.txtDestinationAddressee.Text      = "";
                }
                else if (isNullDepartment && !isNullAddressee)
                {
                    reminderReport.txtDestinationDepartmentName.Text = rd.DestinationAddressee + destinationHonorific;
                    reminderReport.txtDestinationAddressee.Text      = "";
                }
                else
                {
                    reminderReport.txtDestinationDepartmentName.Text = rd.DestinationDepartmentName;
                    reminderReport.txtDestinationAddressee.Text      = rd.DestinationAddressee + destinationHonorific;
                }
            }

            reminderReport.DataSource = new BindingSource(source, null);

            reminderReport.txtCompanyPostalCode.Text = "〒" + Company.PostalCode;
            reminderReport.txtCompanyAddress1.Text   = Company.Address1;
            reminderReport.txtCompanyAddress2.Text   = Company.Address2;
            reminderReport.txtCompanyName.Text       = Company.Name;

            reminderReport.txtOwnDepartmentName.Text   = ReminderCommonSetting.OwnDepartmentName;
            reminderReport.txtAccountingStaffName.Text = ReminderCommonSetting.AccountingStaffName;

            if (ReminderCommonSetting.OutputDetail == 1)
            {
                reminderReport.lblNote.Text      = ColumnNameSetting.First(x => x.ColumnName == ReminderCommonSetting.OutputDetailItem).DisplayColumnName;
                reminderReport.txtNote.DataField = ReminderCommonSetting.OutputDetailItem;
            }

            if (!ReminderSummarySetting.Any(x => x.ColumnName == "Staff" && x.Available == 1))
            {
                reminderReport.txtStaffName.Visible = false;
                reminderReport.lblTel.Visible       = false;
                reminderReport.txtStaffTel.Visible  = false;
                reminderReport.lblFax.Visible       = false;
                reminderReport.txtStaffFax.Visible  = false;
            }

            reminderReport.txtAccountName.Text = Company.BankAccountName;
            var rb = source.First();

            if (pdfSetting.IsAllInOne)
            {
                reminderReport.Name = $"督促状{outputAt.ToString("yyyyMMdd")}";
            }
            else
            {
                var name = pdfSetting.FileName.Replace("[CODE]", rb.CustomerCode);
                name = name.Replace("[NAME]", rb.CustomerName);
                name = name.Replace("[NO]", rb.OutputNo.ToString("000000"));
                name = name.Replace("[DATE]", outputAt.ToString("yyyyMMdd"));
                reminderReport.Name = name;
            }
            reminderReport.CustomerReceiveAccount1 = rb.CustomerReceiveAccount1 == 1;
            reminderReport.CustomerReceiveAccount2 = rb.CustomerReceiveAccount2 == 1;
            reminderReport.CustomerReceiveAccount3 = rb.CustomerReceiveAccount3 == 1;

            reminderReport.CompanyBankAccount1 = $"{Company.BankName1} {Company.BranchName1} {Company.AccountType1} {Company.AccountNumber1}";
            reminderReport.CompanyBankAccount2 = $"{Company.BankName2} {Company.BranchName2} {Company.AccountType2} {Company.AccountNumber2}";
            reminderReport.CompanyBankAccount3 = $"{Company.BankName3} {Company.BranchName3} {Company.AccountType3} {Company.AccountNumber3}";

            reminderReport.TotalAmountPrintHandler += (customerId) =>
            {
                reminderReport.txtTotalAmount.Text = source.Where(x => x.CustomerId == customerId)
                                                     .Sum(x => x.RemainAmount).ToString("#,##0");
            };

            if (ReminderCommonSetting.OutputDetail == 0)
            {
                reminderReport.HideDetail();
            }

            if (!source.Any(x => x.OutputNo > 0))
            {
                reminderReport.HideOutputNo();
            }

            reminderReport.Run(false);

            return(reminderReport);
        }
Beispiel #9
0
        private void grdReminder_CellClick(object sender, CellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            if (e.CellName != CellName("Preview"))
            {
                return;
            }

            grdReminder.CommitEdit();

            try
            {
                string serverPath = GetServerPath();
                var    summary    = grdReminder.Rows[e.RowIndex].DataBoundItem as ReminderSummary;

                if (UseDestinationSummarized)
                {
                    var option = new DestinationSearch();
                    option.CompanyId  = CompanyId;
                    option.CustomerId = summary.CustomerId;

                    var taskDestination = GetDestinationsAsync(option);
                    ProgressDialog.Start(ParentForm, taskDestination, false, SessionKey);
                    var destinations = taskDestination.Result;

                    var destinationIds = new List <ReminderSummary>();
                    var inputCode      = string.Empty;

                    var cell = grdReminder.Rows[e.RowIndex].Cells[CellName(nameof(Web.Models.ReminderSummary.DestinationCode))];
                    if (IsCellEmpty(cell))
                    {
                        summary.DestinationIdInput = null;
                    }
                    else
                    {
                        inputCode = cell.Value.ToString().PadLeft(2, '0');
                        if (!destinations.Any(x => x.Code == inputCode))
                        {
                            ShowWarningDialog(MsgWngMasterNotExist, "送付先", inputCode);
                            return;
                        }
                        summary.DestinationIdInput = destinations.FirstOrDefault(x => x.Code == inputCode).Id;
                    }

                    var qry = from row in grdReminder.Rows where (string)(row.Cells[CellName(nameof(Web.Models.ReminderSummary.CustomerCode))].Value) == summary.CustomerCode select row;
                    foreach (var row in qry)
                    {
                        var bsd  = row.DataBoundItem as ReminderSummary;
                        var code = Convert.ToString(row.Cells[CellName(nameof(Web.Models.ReminderSummary.DestinationCode))].Value);
                        if (code == inputCode)
                        {
                            if (bsd.DestinationId.HasValue)
                            {
                                destinationIds.Add(bsd);
                            }
                            else
                            {
                                summary.NoDestination = true;
                            }
                        }
                    }

                    summary.CompanyId      = CompanyId;
                    summary.CustomerIds    = new int[] { summary.CustomerId };
                    summary.DestinationIds = destinationIds.Select(x => x.DestinationId.Value).Distinct().ToArray();
                }

                var summaryList = new List <ReminderSummary>();
                summaryList.Add(summary);

                var task = UseDestinationSummarized ?
                           GetReminderBillingForSummaryPrintByDestinationCodeAsync(summaryList) :
                           GetReminderBillingForSummaryPrintAsync(ReminderSummary.Select(x => x.CustomerId).ToArray());
                ProgressDialog.Start(ParentForm, task, false, SessionKey);

                if (!task.Result.ProcessResult.Result)
                {
                    ShowWarningDialog(MsgErrCreateReportError);
                    return;
                }

                var reminderBillings = task.Result.ReminderBilling;

                var template = ReminderTemplateSetting.First(x => x.Id == summary.TemplateId);

                PdfSetting = GetPdfOutputSetting();
                var report = UtilReminder.CreateReminderReport(reminderBillings,
                                                               ReminderCommonSetting,
                                                               ReminderSummarySetting,
                                                               template,
                                                               Company,
                                                               ColumnNameSettingInfo,
                                                               DateTime.Now,
                                                               PdfSetting);

                ShowDialogPreview(ParentForm, report, serverPath);
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                ShowWarningDialog(MsgErrCreateReportError);
            }
        }
 public async Task <ActionResult <PdfOutputSetting> > Save(PdfOutputSetting setting, CancellationToken token)
 => await pdfOutputSettingProcessor.SaveAsync(setting, token);
 public async Task <ActionResult <PdfOutputSetting> > Get(PdfOutputSetting setting, CancellationToken token)
 => await pdfOutputSettingProcessor.GetAsync(setting.CompanyId, setting.ReportType, setting.UpdateBy, token);
 public async Task <PdfOutputSetting> SaveAsync(PdfOutputSetting setting, CancellationToken token = default(CancellationToken))
 => await addPdfOutputSettingQueryProcessor.SaveAsync(setting, token);