/// <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; } } }
private void Save() { try { if (!ValidateChildren()) { return; } ZeroLeftPaddingWithoutValidated(); if (!CheckRequired()) { return; } if (!CheckPayerCode()) { return; } if (!ShowConfirmDialog(MsgQstConfirmSave)) { DispStatusMessage(MsgInfProcessCanceled); return; } Section sectionInsert = SectionDataInfo(); SectionResults saveResult = null; List <Section> newList = null; var success = false; var task = ServiceProxyFactory.LifeTime(async factory => { var service = factory.Create <SectionMasterClient>(); saveResult = saveResult = await service.SaveAsync(SessionKey, sectionInsert); success = saveResult?.ProcessResult.Result ?? false; if (success) { newList = await LoadGridAsync(); } }); ProgressDialog.Start(ParentForm, task, false, SessionKey); if (!success) { ShowWarningDialog(MsgErrSaveError); return; } SectionList = newList; grdSectionMaster.DataSource = new BindingSource(SectionList, null); Clears(); DispStatusMessage(MsgInfSaveSuccess); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); } }
private void txtSectionCode_Validated(object sender, EventArgs e) { try { ClearStatusMessage(); var sectionCode = txtSectionCode.Text; if (string.IsNullOrEmpty(sectionCode) || string.IsNullOrWhiteSpace(sectionCode)) { lblSectionName.Clear(); SectionId = null; return; } Section section = null; var task = ServiceProxyFactory.LifeTime(async factory => { var service = factory.Create <SectionMasterClient>(); SectionsResult result = await service.GetByCodeAsync( Login.SessionKey, Login.CompanyId, new string[] { sectionCode }); if (result.ProcessResult.Result && result.Sections.Any()) { section = result.Sections[0]; } }); ProgressDialog.Start(ParentForm, task, false, SessionKey); if (section != null) { txtSectionCode.Text = section.Code; lblSectionName.Text = section.Name; SectionId = section.Id; } else { txtSectionCode.Clear(); lblSectionName.Clear(); SectionId = null; ShowWarningDialog(MsgWngMasterNotExist, "入金部門", sectionCode); txtSectionCode.Focus(); } } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); } }
private void SetSectionData(Section section, VOneTextControl code, VOneDispLabelControl name, ref int?sectionId) { if (section == null) { code.Clear(); name.Clear(); sectionId = 0; return; } code.Text = section.Code; name.Text = section.Name; sectionId = section.Id; }
private Section SectionDataInfo() { var userInsert = new Section(); userInsert.CompanyId = CompanyId; userInsert.Id = SectionId; userInsert.Code = txtSectionCode.Text; userInsert.Name = txtSectionName.Text.Trim(); userInsert.Note = txtNote.Text.Trim(); userInsert.PayerCodeLeft = txtLeftPayerCode.Text; userInsert.PayerCodeRight = txtRightPayerCode.Text; userInsert.UpdateBy = Login.UserId; userInsert.CreateBy = Login.UserId; return(userInsert); }
private void GetItemsByCode() { var section = new Section(); var task = ServiceProxyFactory.LifeTime(async factory => { var service = factory.Create <SectionMasterClient>(); var result = await service.GetByCodeAsync(SessionKey, CompanyId, new string[] { txtSectionCode.Text }); if (result.ProcessResult.Result && result.Sections.Any()) { section = result.Sections[0]; } }); ProgressDialog.Start(ParentForm, task, false, SessionKey); if (section?.Code == null) { DispStatusMessage(MsgInfSaveNewData, "入金部門"); return; } txtSectionCode.Text = section.Code; txtSectionName.Text = section.Name; txtNote.Text = section.Note; SectionId = section.Id; if (!string.IsNullOrWhiteSpace(section.PayerCode)) { txtLeftPayerCode.Text = section.PayerCode.Substring(0, 3); txtRightPayerCode.Text = section.PayerCode.Substring(3, 7); } txtSectionCode.Enabled = false; BaseContext.SetFunction03Enabled(true); Modified = false; }