/// <summary> DepartmentIdでSectionWithDepartmetからデータを取得 </summary>
        /// <param name="departmentId"> 入力項目にある請求部門コードのId </param>
        /// <returns> SectionWithDepartmentデータ </returns>
        private async Task <SectionWithDepartment> GetDepartmentIdInSWD(int departmentId)
        {
            SectionWithDepartment depValue = null;

            if (departmentId != 0)
            {
                await ServiceProxyFactory.LifeTime(async factory =>
                {
                    var service = factory.Create <SectionWithDepartmentMasterClient>();
                    SectionWithDepartmentResult result = await service.GetByDepartmentAsync(SessionKey, CompanyId, departmentId);

                    if (result.ProcessResult.Result)
                    {
                        depValue = result.SectionDepartment;
                    }
                });
            }
            return(depValue);
        }
        /// <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;
            }
        }
示例#3
0
        public Task <SectionWithDepartment> SaveAsync(SectionWithDepartment SectionWithDepartment, CancellationToken token = default(CancellationToken))
        {
            var query = @"
MERGE INTO SectionWithDepartment AS target 
USING (SELECT
              @SectionId    As SectionId
            , @DepartmentId As DepartmentId
   ) As source
ON ( 
            target.SectionId    = source.SectionId
        AND target.DepartmentId = source.DepartmentId
) 
WHEN MATCHED THEN 
    UPDATE SET 
     UpdateBy = @UpdateBy
    ,UpdateAt = GETDATE()
WHEN NOT MATCHED THEN 
 INSERT (SectionId, DepartmentId, CreateBy, CreateAt, UpdateBy, UpdateAt)
 VALUES (SectionId, DepartmentId, @UpdateBy, GETDATE(),@UpdateBy, GETDATE())
 OUTPUT inserted.*; ";

            return(dbHelper.ExecuteAsync <SectionWithDepartment>(query, SectionWithDepartment, token));
        }
 public async Task <SectionWithDepartment> SaveAsync(SectionWithDepartment SectionWithDepartment, CancellationToken token = default(CancellationToken))
 => await addSectionWithDepartmentQueryProcessor.SaveAsync(SectionWithDepartment, token);