public Task <CollationOrder> SaveCollationOrderAsync(CollationOrder CollationOrder, CancellationToken token = default(CancellationToken)) { var query = @" INSERT INTO CollationOrder (CompanyId, CollationTypeId, ExecutionOrder, Available, CreateBy, CreateAt, UpdateBy, UpdateAt) OUTPUT inserted.* VALUES (@CompanyId, @CollationTypeId, @ExecutionOrder, @Available, @CreateBy, GETDATE(), @UpdateBy, GETDATE())"; return(dbHelper.ExecuteAsync <CollationOrder>(query, CollationOrder, token)); }
private void SaveCollationSetting() { ClearStatusMessage(); try { if (!ValidateInputValues()) { return; } if (!ShowConfirmDialog(MsgQstConfirmSave)) { DispStatusMessage(MsgInfProcessCanceled); return; } var collationOrder = new List <CollationOrder>(); var billingOrder = new List <MatchingOrder>(); var receiptOrder = new List <MatchingOrder>(); var setting = new CollationSetting(); setting.CompanyId = CompanyId; setting.ReloadCollationData = cbxReloadCollationData.Checked ? 1 : 0; setting.AutoMatching = cbxAutoMatching.Checked ? 1 : 0; setting.AutoSortMatchingEnabledData = cbxAutoSortMatchingEnabledData.Checked ? 1 : 0; setting.UseFromToNarrowing = (cbxUseFromToNarrowing.Checked) ? 1 : 0; setting.SetSystemDateToCreateAtFilter = cbxSetSystemDateToCreateAtFilter.Checked ? 1 : 0; setting.PrioritizeMatchingIndividuallyMultipleReceipts = cbxPrioritizeMatchingIndividuallyMultipleReceipts.Checked ? 1 : 0; setting.ForceShareTransferFee = cbxForceShareTransferFee.Checked ? 1 : 0; setting.PrioritizeMatchingIndividuallyTaxTolerance = cbxPrioritizeMatchingIndividuallyTaxTolerance.Checked ? 1 : 0; setting.UseApportionMenu = cbxUseApportionMenu.Checked ? 1 : 0; setting.RequiredCustomer = cbxRequiredCustomer.Checked ? 1 : 0; setting.AutoAssignCustomer = cbxAutoAssignCustomer.Checked ? 1 : 0; setting.LearnKanaHistory = cbxLearnKanaHistory.Checked ? 1 : 0; setting.LearnSpecifiedCustomerKana = cbxLearnSpecifiedCustomerKana.Checked ? 1 : 0; setting.UseAdvanceReceived = cbxUseAdvanceReceived.Checked ? 1 : 0; setting.MatchingSilentSortedData = rdoDisplayOrder.Checked ? 0 : 1; setting.AdvanceReceivedRecordedDateType = Convert.ToInt32(cmbAdvanceReceivedRecordedDateType.SelectedItem.SubItems[1].Value); setting.BillingReceiptDisplayOrder = rdoBillingReceiptOrder.Checked ? 0 : 1; setting.RemoveSpaceFromPayerName = cbxRemoveSpaceFromPayerName.Checked ? 1 : 0; setting.JournalizingPattern = rdoStandard.Checked ? 0 : 1; setting.CalculateTaxByInputId = cbxCalculateTaxByInputId.Checked ? 1 : 0; setting.SortOrderColumn = Convert.ToInt32(cmbSortOrderColumn.SelectedItem.SubItems[1].Value); setting.SortOrder = Convert.ToInt32(cmbSortOrder.SelectedItem.SubItems[1].Value); foreach (var row in grdCollationOrder.Rows) { var collation = new CollationOrder(); collation.ExecutionOrder = int.Parse(row.Cells[CellName("Order")].Value.ToString()); collation.Available = int.Parse(row.Cells[CellName(nameof(CollationOrder.Available))].Value.ToString()); var collationTypeName = row.Cells[CellName("CollationTypeName")].Value.ToString(); collation.CollationTypeId = CollationOrderName.FirstOrDefault(x => x.Value == collationTypeName).Key; collation.CompanyId = CompanyId; collation.CreateBy = Login.UserId; collation.UpdateBy = Login.UserId; collationOrder.Add(collation); } foreach (var row in grdMatchingBillingOrder.Rows) { var matchingBillingOrder = new MatchingOrder(); matchingBillingOrder.ExecutionOrder = int.Parse(row.Cells[CellName("Order")].Value.ToString()); matchingBillingOrder.Available = int.Parse(row.Cells[CellName(nameof(MatchingOrder.Available))].Value.ToString()); matchingBillingOrder.ItemName = row.Cells[CellName("BillingItemName")].Value.ToString(); matchingBillingOrder.TransactionCategory = 1; matchingBillingOrder.SortOrder = int.Parse(row.Cells[CellName(nameof(MatchingOrder.SortOrder))].Value.ToString()); matchingBillingOrder.CompanyId = CompanyId; matchingBillingOrder.CreateBy = Login.UserId; matchingBillingOrder.UpdateBy = Login.UserId; billingOrder.Add(matchingBillingOrder); } foreach (var row in grdMatchingReceiptOrder.Rows) { var matchingReceiptOrder = new MatchingOrder(); matchingReceiptOrder.ExecutionOrder = int.Parse(row.Cells[CellName("Order")].Value.ToString()); matchingReceiptOrder.Available = int.Parse(row.Cells[CellName(nameof(MatchingOrder.Available))].Value.ToString()); matchingReceiptOrder.ItemName = row.Cells[CellName("ReceiptItemName")].Value.ToString(); matchingReceiptOrder.SortOrder = int.Parse(row.Cells[CellName(nameof(MatchingOrder.SortOrder))].Value.ToString()); matchingReceiptOrder.TransactionCategory = 2; matchingReceiptOrder.CompanyId = CompanyId; matchingReceiptOrder.CreateBy = Login.UserId; matchingReceiptOrder.UpdateBy = Login.UserId; receiptOrder.Add(matchingReceiptOrder); } var task = ServiceProxyFactory.DoAsync(async(CollationSettingMasterClient client) => await client.SaveAsync(SessionKey, setting, collationOrder.ToArray(), billingOrder.ToArray(), receiptOrder.ToArray())); ProgressDialog.Start(ParentForm, task, false, SessionKey); var result = task.Result; if (result != null && result.ProcessResult.Result) { DispStatusMessage(MsgInfSaveSuccess); } else { ShowWarningDialog(MsgErrSaveError); } Modified = false; } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); } }