/// <summary>Delete Netting Items</summary> private void DeleteNettingItems() { var nettingId = new List <long>(); Func <Row, bool> isExistDeleteId = (row) => row.Cells[1].Value != null && Convert.ToInt32(row.Cells[1].Value) == 1; foreach (var row in grdNettingDisplay.Rows.Where(x => isExistDeleteId(x))) { nettingId.Add(Convert.ToInt64(row.Cells["celId"].Value.ToString())); } NettingResult resultData = null; var task = ServiceProxyFactory.LifeTime(async factory => { var service = factory.Create <NettingServiceClient>(); resultData = await service.DeleteAsync(SessionKey, nettingId.ToArray()); if (resultData.ProcessResult.Result) { await SearchNettingItems(); } }); ProgressDialog.Start(ParentForm, task, false, SessionKey); if (resultData.ProcessResult.Result) { DispStatusMessage(MsgInfDeleteSuccess); datPaymentDate.Focus(); } else { ShowWarningDialog(MsgErrDeleteError); } }
/// <summary>Save Netting Items</summary> private void SaveNettingItems() { Func <Row, bool> isCategoryCode = (row) => row["celCategoryCode"].Value != null && row["celCategoryCode"].Value is string && row["celCategoryCode"].Value.ToString() != ""; var nettingSearch = new List <Netting>(); foreach (var row in grdNettingInput.Rows.Where(x => isCategoryCode(x))) { var netting = new Netting(); netting.CompanyId = CompanyId; netting.CustomerId = CustomerId; netting.ReceiptCategoryId = Convert.ToInt32(row.Cells["celId"].Value); netting.Note = row.Cells["celNote"].Value.ToString(); if (row.Cells["celDueAt"].Value != null) { netting.DueAt = Convert.ToDateTime(row.Cells["celDueAt"].Value.ToString()); } netting.Amount = Convert.ToDecimal(row.Cells["celAmount"].Value); netting.ReceiptMemo = row.Cells["celMemoData"].Value.ToString(); netting.RecordedAt = datPaymentDate.Value.Value; netting.CurrencyId = CurrencyId; if (ApplicationControl.UseReceiptSection == 1) { netting.SectionId = SectionId; } else { netting.SectionId = null; } nettingSearch.Add(netting); } NettingResult resultData = null; var success = false; var task = ServiceProxyFactory.LifeTime(async factory => { var service = factory.Create <NettingServiceClient>(); resultData = await service.SaveAsync(SessionKey, nettingSearch.ToArray()); success = resultData?.ProcessResult.Result ?? false; if (success) { await SearchNettingItems(); } }); ProgressDialog.Start(ParentForm, task, false, SessionKey); if (resultData.ProcessResult.Result) { DispStatusMessage(MsgInfSaveSuccess); grdNettingInput.DataSource = null; InitializeInputGridSetting(); datPaymentDate.Focus(); datPaymentDate.Text = DateTime.Today.ToShortDateString(); txtSectionCode.Clear(); lblSectionName.Clear(); nmbTotalFee.Value = 0M; } else { ShowWarningDialog(MsgErrSaveError); } }