/// <summary> DBから取得したデータを入力項目に設定 </summary> /// <param name="section"> DBから取得したデータのModel</param> private async Task SetSectionData(Section section) { if (section != null) { txtSection.Text = section.Code; lblPaymentName.Text = section.Name; SectionId = section.Id; ClearStatusMessage(); SetSectionDisable(); if (txtSection.Text != "" || txtSection.Enabled == false) { OriginSectionWithDepList = await LoadGridListAsync(); ModifySectionWithDepList = new List <SectionWithDepartment>(OriginSectionWithDepList); grdDepartmentModify.DataSource = new BindingSource(OriginSectionWithDepList, null); grdDepartmentOrigin.DataSource = new BindingSource(ModifySectionWithDepList, null); if (!OriginSectionWithDepList.Any()) { DispStatusMessage(MsgInfSaveNewData, "入金部門"); } txtDepartmentFrom.Select(); btnAdd.Enabled = true; btnDelete.Enabled = true; btnDeleteAll.Enabled = true; } } }
/// <summary> 請求部門コントロールにあるコードでデータを取得</summary> /// <param name="code">請求部門コントロールにあるコード</param> /// <param name="name">請求部門コントロールにあるコードの名前</param> /// <param name="id">請求部門コントロールにあるコードのId</param> private void GetDataFromValidate(VOneTextControl code, VOneDispLabelControl name, ref int?id) { var depResult = new List <Department>(); SectionWithDepartment sectionWithDepValue = null; var task = ServiceProxyFactory.LifeTime(async factory => { var service = factory.Create <DepartmentMasterClient>(); var result = await service.GetByCodeAsync(SessionKey, CompanyId, new string[] { code.Text }); if (result.ProcessResult.Result && result.Departments.Any()) { depResult = result.Departments; sectionWithDepValue = await GetDepartmentIdInSWD(depResult[0].Id); } }); ProgressDialog.Start(ParentForm, task, false, SessionKey); if (depResult.Any()) { ///項目にあるコードはGridにあるかどうかをチェックする var isExists = OriginSectionWithDepList.Exists( x => x.DepartmentId == sectionWithDepValue?.DepartmentId); if (sectionWithDepValue != null && isExists == false) { ShowWarningDialog(MsgWngAlreadyRegSection, code.Text); SetDepartmentData(null, code, name, ref id); code.Focus(); return; } SetDepartmentData(depResult[0], code, name, ref id); ClearStatusMessage(); } else { ShowWarningDialog(MsgWngMasterNotExist, "請求部門", code.Text); SetDepartmentData(null, code, name, ref id); code.Focus(); return; } }