예제 #1
0
        private void SaveReminderCommonSettings()
        {
            if (cbxDisplayArrearsInterest.Checked)
            {
                if (!nmbArrearsInterestRate.Value.HasValue || nmbArrearsInterestRate.Value == 0)
                {
                    DispStatusMessage(MsgWngInputRequired, lblArrearsInterestRate.Text);
                    nmbArrearsInterestRate.Focus();
                    return;
                }
            }

            if (!ShowConfirmDialog(MsgQstConfirmSave))
            {
                DispStatusMessage(MsgInfProcessCanceled);
                return;
            }

            ReminderCommonSetting commonSetting     = PrepareCommonSetting();
            Task <ReminderCommonSettingResult> task = SaveCommonSettingAsync(commonSetting);

            ProgressDialog.Start(ParentForm, task, false, SessionKey);

            if (task.Result.ProcessResult.Result)
            {
                DispStatusMessage(MsgInfSaveSuccess);
                CommonChangeFlg = false;
            }
            else
            {
                ShowWarningDialog(MsgErrSaveError);
            }
        }
        public Task <ReminderCommonSetting> SaveAsync(ReminderCommonSetting ReminderCommonSetting, CancellationToken token = default(CancellationToken))
        {
            #region merge query
            var query = @"
MERGE INTO ReminderCommonSetting target
USING (
    SELECT @CompanyId   [CompanyId]
) source
ON    (
        target.CompanyId    = source.CompanyId
)
WHEN MATCHED THEN
    UPDATE SET 
         OwnDepartmentName      = @OwnDepartmentName
        ,AccountingStaffName    = @AccountingStaffName
        ,OutputDetail           = @OutputDetail
        ,OutputDetailItem       = @OutputDetailItem
        ,ReminderManagementMode = @ReminderManagementMode
        ,DepartmentSummaryMode  = @DepartmentSummaryMode
        ,CalculateBaseDate      = @CalculateBaseDate
        ,IncludeOnTheDay        = @IncludeOnTheDay
        ,DisplayArrearsInterest = @DisplayArrearsInterest
        ,ArrearsInterestRate    = @ArrearsInterestRate
        ,UpdateBy = @UpdateBy
        ,UpdateAt = GETDATE()
WHEN NOT MATCHED THEN 
    INSERT (CompanyId, OwnDepartmentName, AccountingStaffName, ReminderManagementMode, DepartmentSummaryMode, OutputDetail, OutputDetailItem, CalculateBaseDate, IncludeOnTheDay, DisplayArrearsInterest, ArrearsInterestRate, CreateBy, CreateAt, UpdateBy, UpdateAt) 
    VALUES (@CompanyId, @OwnDepartmentName, @AccountingStaffName, @ReminderManagementMode, @DepartmentSummaryMode, @OutputDetail, @OutputDetailItem, @CalculateBaseDate, @IncludeOnTheDay, @DisplayArrearsInterest, @ArrearsInterestRate, @UpdateBy, GETDATE(), @UpdateBy, GETDATE()) 
OUTPUT inserted.*; ";
            #endregion

            return(dbHelper.ExecuteAsync <ReminderCommonSetting>(query, ReminderCommonSetting, token));
        }
예제 #3
0
 private async Task LoadReminderCommonSetting()
 {
     ReminderCommonSetting setting = null;
     await ServiceProxyFactory.DoAsync <ReminderSettingServiceClient>(async client =>
     {
         var result = await client.GetReminderCommonSettingAsync(SessionKey, CompanyId);
         if (result.ProcessResult.Result)
         {
             setting = result.ReminderCommonSetting;
         }
         ReminderCommonSetting = setting;
     });
 }
예제 #4
0
        private ReminderCommonSetting PrepareCommonSetting()
        {
            var commonSetting = new ReminderCommonSetting();

            commonSetting.CompanyId              = CompanyId;
            commonSetting.OwnDepartmentName      = txtOwnDepartmentName.Text.Trim();
            commonSetting.AccountingStaffName    = txtAccountingStaffName.Text.Trim();
            commonSetting.OutputDetail           = cbxOutputDetail.Checked ? 1 : 0;
            commonSetting.OutputDetailItem       = cbxOutputDetail.Checked ? (string)cmbOutputDetailItem.SelectedValue : "";
            commonSetting.ReminderManagementMode = rdoReminder.Checked ? (int)ReminderManagementMode.ByReminder : (int)ReminderManagementMode.ByCustomer;
            commonSetting.DepartmentSummaryMode  = Convert.ToInt32(cmbDepartmentSummaryMode.SelectedItem.SubItems[1].Value);
            commonSetting.CalculateBaseDate      = Convert.ToInt32(cmbCalculateBaseDate.SelectedItem.SubItems[1].Value);
            commonSetting.IncludeOnTheDay        = Convert.ToInt32(cmbIncludeOnTheDay.SelectedItem.SubItems[1].Value);
            commonSetting.DisplayArrearsInterest = cbxDisplayArrearsInterest.Checked ? 1 : 0;
            commonSetting.ArrearsInterestRate    = nmbArrearsInterestRate.Value;
            commonSetting.CreateBy = Login.UserId;
            commonSetting.UpdateBy = Login.UserId;
            return(commonSetting);
        }
예제 #5
0
 private async Task <ReminderCommonSettingResult> SaveCommonSettingAsync(ReminderCommonSetting commonSetting)
 => await ServiceProxyFactory.DoAsync(async (ReminderSettingServiceClient client) =>
 {
     var result = await client.SaveReminderCommonSettingAsync(SessionKey, commonSetting);
     return(result);
 });
예제 #6
0
 public Task <ReminderCommonSetting> SaveAsync(ReminderCommonSetting ReminderCommonSetting, CancellationToken token = default(CancellationToken))
 => addReminderCommonSettingQueryProcessor.SaveAsync(ReminderCommonSetting, token);
예제 #7
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);
        }
예제 #8
0
 public async Task <ActionResult <ReminderCommonSetting> > SaveReminderCommonSetting(ReminderCommonSetting ReminderCommonSetting, CancellationToken token)
 => await reminderCommonSettingProcessor.SaveAsync(ReminderCommonSetting, token);
예제 #9
0
        public async Task <IEnumerable <Reminder> > CreateAsync(int companyId, int loginUserId, int useForeignCurrency, Reminder[] Reminder, ReminderCommonSetting setting, ReminderSummarySetting[] summary, CancellationToken token = default(CancellationToken))
        {
            using (var scope = transactionScopeBuilder.Create())
            {
                //var commonSetting = getReminderCommonSettingQueryProcessor.GetItems(companyId);
                //if (commonSetting == null || !commonSetting.First().Equals(setting))
                //    return null;

                //var summarySetting = reminderSummarySettingQueryProcessor.GetItems(companyId, useForeignCurrency);
                //if (summarySetting == null || !summarySetting.ToArray().Equals(summary))
                //    return null;

                var defaultStatusId = (await statusQueryProcessor.GetAsync(new StatusSearch {
                    CompanyId = companyId, StatusType = 1, Codes = new[] { "00" }
                }, token)).First().Id;

                var result = new List <Reminder>();
                foreach (var r in Reminder)
                {
                    r.StatusId = defaultStatusId;
                    var reminderEntity = await addReminderQueryProcessor.AddAsync(r, token);

                    r.Id = reminderEntity.Id;

                    var reminderSummary = new ReminderSummary()
                    {
                        CustomerId = r.CustomerId,
                        CurrencyId = r.CurrencyId,
                        Memo       = "",
                    };
                    await addReminderQueryProcessor.AddSummaryAsync(reminderSummary, token);

                    var billingUpdateResult = (await updateBillingReminderQueryProcessor.UpdateAsync(r, setting, summary)).ToArray();

                    if (r.DetailCount != billingUpdateResult.Length || r.RemainAmount != billingUpdateResult.Sum(x => x.RemainAmount))
                    {
                        return(null);
                    }

                    result.Add(reminderEntity);
                }
                scope.Complete();

                return(result.ToArray());
            }
        }
예제 #10
0
 public async Task <IEnumerable <Reminder> > GetItemsAsync(ReminderSearch search, ReminderCommonSetting setting, ReminderSummarySetting[] summary, CancellationToken token = default(CancellationToken))
 => await reminderQueryProcessor.GetItemsAsync(search, setting, summary, token);
예제 #11
0
 public async Task <IEnumerable <ReminderHistory> > GetReminderListAsync(ReminderSearch search, ReminderCommonSetting setting, CancellationToken token = default(CancellationToken))
 => await reminderQueryProcessor.GetReminderListAsync(search, setting, token);
예제 #12
0
        public async Task <ReminderSummaryResult> GetSummaryItemsAsync(string SessionKey, ReminderSearch condition, ReminderCommonSetting setting)
        {
            return(await authorizationProcessor.DoAuthorizeAsync(SessionKey, async token =>
            {
                var result = (await reminderProcessor.GetSummaryItemsAsync(condition, setting, token)).ToList();

                return new ReminderSummaryResult()
                {
                    ProcessResult = new ProcessResult {
                        Result = true
                    },
                    ReminderSummary = result,
                };
            }, logger));
        }
예제 #13
0
        public async Task <ReminderResult> GetCancelDecisionItemsAsync(string SessionKey, ReminderSearch condition, ReminderCommonSetting setting, IEnumerable <ReminderSummarySetting> summary)
        {
            return(await authorizationProcessor.DoAuthorizeAsync(SessionKey, async token =>
            {
                var result = (await reminderProcessor.GetCancelDecisionItemsAsync(condition, setting, summary, token)).ToList();

                return new ReminderResult
                {
                    ProcessResult = new ProcessResult {
                        Result = true
                    },
                    Reminder = result,
                };
            }, logger));
        }
예제 #14
0
        public async Task <ReminderHistoriesResult> GetReminderListAsync(string SessionKey, ReminderSearch search, ReminderCommonSetting setting)
        {
            return(await authorizationProcessor.DoAuthorizeAsync(SessionKey, async token =>
            {
                var result = (await reminderProcessor.GetReminderListAsync(search, setting, token)).ToList();

                return new ReminderHistoriesResult
                {
                    ProcessResult = new ProcessResult()
                    {
                        Result = true
                    },
                    ReminderHistories = result,
                };
            }, logger));
        }
예제 #15
0
        public async Task <ReminderResult> CreateAsync(string SessionKey, int companyId, int loginUserId, int useForeignCurrency, Reminder[] Reminder, ReminderCommonSetting setting, ReminderSummarySetting[] summary)
        {
            return(await authorizationProcessor.DoAuthorizeAsync(SessionKey, async token =>
            {
                var processResult = new ProcessResult();
                var result = (await reminderProcessor.CreateAsync(companyId, loginUserId, useForeignCurrency, Reminder, setting, summary, token)).ToList();

                if (result != null)
                {
                    processResult.Result = true;
                }

                return new ReminderResult
                {
                    ProcessResult = processResult,
                    Reminder = result,
                };
            }, logger));
        }
예제 #16
0
 public async Task <IEnumerable <ReminderSummary> > GetSummaryItemsByDestinationAsync(ReminderSearch search, ReminderCommonSetting setting, CancellationToken token = default(CancellationToken))
 => await reminderQueryProcessor.GetSummaryItemsByDestinationAsync(search, setting, token);
예제 #17
0
 public async Task <ReminderCommonSettingResult> SaveReminderCommonSettingAsync(string SessionKey, ReminderCommonSetting ReminderCommonSetting)
 {
     return(await authorizationProcess.DoAuthorizeAsync(SessionKey, async token =>
     {
         var result = await reminderCommonSettingProcessor.SaveAsync(ReminderCommonSetting, token);
         return new ReminderCommonSettingResult
         {
             ProcessResult = new ProcessResult {
                 Result = true
             },
             ReminderCommonSetting = result,
         };
     }, logger));
 }