Beispiel #1
0
        private void btnDeleteAll_Click(object sender, EventArgs e)
        {
            try
            {
                this.ButtonClicked(btnDeleteAll);
                ClearStatusMessage();

                if (!ModifySection.Any())
                {
                    ShowWarningDialog(MsgWngNoData, "削除");
                    return;
                }

                bool result = ShowConfirmDialog(MsgQstConfirmDeleteAll);

                if (result)
                {
                    ModifySection.Clear();
                    grdLoginUserModify.DataSource = new BindingSource(ModifySection, null);
                    Task <List <SectionWithLoginUser> > getTask = GetByLoginUser();
                    ProgressDialog.Start(ParentForm, getTask, false, SessionKey);
                    OriginSection = getTask.Result;
                    grdLoginUserOrigin.DataSource = new BindingSource(OriginSection, null);
                    Modified = true;
                }

                ClearFromTo();
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
            }
        }
Beispiel #2
0
        private void SaveSectionWithLoginUser()
        {
            CloseFlg = true;

            if (!string.IsNullOrWhiteSpace(txtSectionFrom.Text) ||
                !string.IsNullOrWhiteSpace(txtSectionTo.Text))
            {
                Task <int> containsNew = AddLoginUserWithSectionAsync();
                ProgressDialog.Start(ParentForm, containsNew, false, SessionKey);

                if (containsNew.Result == 0)
                {
                    CloseFlg = false;
                    return;
                }
            }

            bool success = false;
            List <SectionWithLoginUser> list = null;

            var task = ServiceProxyFactory.LifeTime(async factory =>
            {
                var deleteList = GetPrepareSaveData();
                var service    = factory.Create <SectionWithLoginUserMasterClient>();
                SectionWithLoginUserResult result = await service.SaveAsync(SessionKey, ModifySection.ToArray(), deleteList.ToArray());

                success = result?.ProcessResult.Result ?? false;

                if (success)
                {
                    list = await GetByLoginUser();
                }
            });

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

            if (success)
            {
                DispStatusMessage(MsgInfSaveSuccess);
                ModifySection.Clear();

                OriginSection = list;
                ModifySection = OriginSection;
                grdLoginUserModify.DataSource = new BindingSource(OriginSection, null);
                grdLoginUserOrigin.DataSource = new BindingSource(ModifySection, null);
                txtSectionFrom.Focus();
                ClearFromTo();
                Modified = false;
            }
            else
            {
                ShowWarningDialog(MsgErrSaveError);
            }
        }