public Task <ReminderLevelSetting> SaveAsync(ReminderLevelSetting ReminderLevelSetting, CancellationToken token = default(CancellationToken))
        {
            #region merge query
            var query = @"
MERGE INTO ReminderLevelSetting target
USING (
    SELECT @CompanyId       [CompanyId]
         , @ReminderLevel   [ReminderLevel]
) source
ON    (
        target.CompanyId        = source.CompanyId
    AND target.ReminderLevel    = source.ReminderLevel
)
WHEN MATCHED THEN
    UPDATE SET 
         ReminderTemplateId = @ReminderTemplateId
        ,ArrearDays         = @ArrearDays
        ,UpdateBy           = @UpdateBy
        ,UpdateAt           = GETDATE()
WHEN NOT MATCHED THEN 
    INSERT (CompanyId, ReminderLevel, ReminderTemplateId, ArrearDays, CreateBy, CreateAt, UpdateBy, UpdateAt) 
    VALUES (@CompanyId, @ReminderLevel, @ReminderTemplateId, @ArrearDays, @UpdateBy, GETDATE(), @UpdateBy, GETDATE()) 
OUTPUT inserted.*; ";
            #endregion

            return(dbHelper.ExecuteAsync <ReminderLevelSetting>(query, ReminderLevelSetting, token));
        }
Пример #2
0
        private ReminderLevelSetting PrepareLevelSetting()
        {
            int level = 0;

            if (cbxAddReminderLevel.Checked)
            {
                Task <int> task = GetMaxLevelAsync();
                ProgressDialog.Start(ParentForm, task, false, SessionKey);
                level = task.Result;
            }
            else
            {
                level = Convert.ToInt32(cmbReminderLevel.SelectedItem.Text);
            }

            decimal arrearDays   = nmbArrearDays.Value ?? 0M;
            var     levelSetting = new ReminderLevelSetting();

            levelSetting.CompanyId          = CompanyId;
            levelSetting.ReminderLevel      = level;
            levelSetting.ReminderTemplateId = TemplateId;
            levelSetting.ArrearDays         = Decimal.ToInt32(arrearDays);
            levelSetting.CreateBy           = Login.UserId;
            levelSetting.UpdateBy           = Login.UserId;
            return(levelSetting);
        }
Пример #3
0
        private void SaveReminderLevelSettings()
        {
            if (!RequireFieldsChecking())
            {
                return;
            }

            ZeroLeftPaddingWithoutValidated();

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

            var  result           = false;
            var  isTemplateExist  = false;
            var  isRegistTemplate = false;
            Task task             = ExistTemplateSettingAsync(TemplateId)
                                    .ContinueWith(async t =>
            {
                isTemplateExist = t.Result;
                if (isTemplateExist)
                {
                    if (cbxAddReminderLevel.Checked)
                    {
                        isRegistTemplate = await ExistTemplateAtLevelAsync(TemplateId);
                    }

                    if (!isRegistTemplate)
                    {
                        ReminderLevelSetting levelSetting = PrepareLevelSetting();
                        var levelResult = await SaveLevelSettingAsync(levelSetting);
                        result          = levelResult.ProcessResult.Result;
                        await GetLevelSettingsAsync();
                        SetLevelCombo();
                    }
                }
            }, TaskScheduler.FromCurrentSynchronizationContext())
                                    .Unwrap();

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

            if (isRegistTemplate)
            {
                ShowWarningDialog(MsgWngRegistedOtherLevelPatternNo);
                return;
            }

            if (!isTemplateExist)
            {
                ShowWarningDialog(MsgWngNotRegistPatternNo, txtLevelPatternNo.Text);
                return;
            }

            if (result)
            {
                ClearTabs(tbcReminderSetting.TabPages.IndexOf(tbpLevelSetting));
                DispStatusMessage(MsgInfSaveSuccess);
            }
            else
            {
                ShowWarningDialog(MsgErrSaveError);
            }
        }
Пример #4
0
 private async Task <ReminderLevelSettingResult> SaveLevelSettingAsync(ReminderLevelSetting levelSetting)
 => await ServiceProxyFactory.DoAsync(async (ReminderSettingServiceClient client) =>
 {
     var result = await client.SaveReminderLevelSettingAsync(SessionKey, levelSetting);
     return(result);
 });
Пример #5
0
 public async Task <ActionResult <int> > DeleteReminderLevelSetting(ReminderLevelSetting setting, CancellationToken token)
 => await reminderLevelSettingProcessor.DeleteAsync(setting.CompanyId, setting.ReminderLevel, token);
Пример #6
0
 public async Task <ActionResult <ReminderLevelSetting> > SaveReminderLevelSetting(ReminderLevelSetting ReminderLevelSetting, CancellationToken token)
 => await reminderLevelSettingProcessor.SaveAsync(ReminderLevelSetting, token);
Пример #7
0
 public async Task <ActionResult <ReminderLevelSetting> > GetReminderLevelSettingByLevel(ReminderLevelSetting setting, CancellationToken token)
 => await reminderLevelSettingProcessor.GetItemByLevelAsync(setting.CompanyId, setting.ReminderLevel, token);
 public async Task <ReminderLevelSetting> SaveAsync(ReminderLevelSetting ReminderLevelSetting, CancellationToken token = default(CancellationToken))
 => await addReminderLevelSettingQueryProcessor.SaveAsync(ReminderLevelSetting, token);
Пример #9
0
 public async Task <ReminderLevelSettingResult> SaveReminderLevelSettingAsync(string SessionKey, ReminderLevelSetting ReminderLevelSetting)
 {
     return(await authorizationProcess.DoAuthorizeAsync(SessionKey, async token =>
     {
         var result = await reminderLevelSettingProcessor.SaveAsync(ReminderLevelSetting, token);
         return new ReminderLevelSettingResult
         {
             ProcessResult = new ProcessResult {
                 Result = true
             },
             ReminderLevelSetting = result,
         };
     }, logger));
 }