/// <summary> /// Reverse all tagged rows /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ReverseAllTagged(object sender, EventArgs e) { // This will throw an exception if insufficient permissions TSecurityChecks.CheckUserModulePermissions("FINANCE-2", "ReverseAllTagged [raised by Client Proxy for ModuleAccessManager]"); string MsgTitle = Catalog.GetString("Document Reversal"); // I can only reverse invoices that are POSTED. // This method is only enabled when the grid shows rows for paying // This will include rows that are PARTPAID - we need to test for those List <int> ReverseTheseDocs = new List <int>(); int taggedCount = 0; foreach (DataRowView rv in grdInvoices.PagedDataTable.DefaultView) { if (rv.Row["Selected"].Equals(true)) { taggedCount++; if (MFinanceConstants.AP_DOCUMENT_POSTED == rv.Row["DocumentStatus"].ToString()) { ReverseTheseDocs.Add(Convert.ToInt32(rv.Row["ApDocumentId"])); } } } if (ReverseTheseDocs.Count < taggedCount) { string msg = Catalog.GetString("A document cannot be reversed if it has been part-paid."); if (ReverseTheseDocs.Count == 0) { MessageBox.Show(msg, MsgTitle); } else { msg += Environment.NewLine + Environment.NewLine; msg += Catalog.GetString("Do you want to continue and reverse the 'Posted' documents?"); if (MessageBox.Show(msg, MsgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } } } if (ReverseTheseDocs.Count > 0) { TVerificationResultCollection Verifications; TDlgGLEnterDateEffective dateEffectiveDialog = new TDlgGLEnterDateEffective( FMainForm.LedgerNumber, Catalog.GetString("Select reversal date"), Catalog.GetString("The date effective for this reversal") + ":"); if (dateEffectiveDialog.ShowDialog(FMainForm) != DialogResult.OK) { MessageBox.Show(Catalog.GetString("Reversal was cancelled."), MsgTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DateTime PostingDate = dateEffectiveDialog.SelectedDate; this.Cursor = Cursors.WaitCursor; Int32 glBatchNumber; if (TRemote.MFinance.AP.WebConnectors.PostAPDocuments( FMainForm.LedgerNumber, ReverseTheseDocs, PostingDate, true, out glBatchNumber, out Verifications)) { if (glBatchNumber >= 0) { TFrmBatchPostingRegister ReportGui = new TFrmBatchPostingRegister(null); ReportGui.PrintReportNoUi(FMainForm.LedgerNumber, glBatchNumber); } this.Cursor = Cursors.Default; MessageBox.Show(Catalog.GetString("The tagged invoices have been reversed to 'Approved' status."), MsgTitle); FMainForm.IsInvoiceDataChanged = true; LoadInvoices(); return; } else { this.Cursor = Cursors.Default; string ErrorMessages = Verifications.BuildVerificationResultString(); MessageBox.Show(ErrorMessages, MsgTitle); } } else { MessageBox.Show(Catalog.GetString("There are no tagged invoices to be reversed."), MsgTitle); } }
/// <summary> /// Reverse all tagged rows /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ReverseAllTagged(object sender, EventArgs e) { string MsgTitle = Catalog.GetString("Document Reversal"); // I can only reverse invoices that are POSTED. // This method is only enabled when the grid shows rows for paying // This will include rows that are PARTPAID - we need to test for those List <int> ReverseTheseDocs = new List <int>(); int taggedCount = 0; foreach (DataRowView rv in grdInvoices.PagedDataTable.DefaultView) { if (rv.Row["Selected"].Equals(true)) { taggedCount++; if ("POSTED" == rv.Row["DocumentStatus"].ToString()) { ReverseTheseDocs.Add((int)rv.Row["ApDocumentId"]); } } } if (ReverseTheseDocs.Count < taggedCount) { string msg = Catalog.GetString("A document cannot be reversed if it has been part-paid."); if (ReverseTheseDocs.Count == 0) { MessageBox.Show(msg, MsgTitle); } else { msg += Environment.NewLine + Environment.NewLine; msg += Catalog.GetString("Do you want to continue and reverse the 'Posted' documents?"); if (MessageBox.Show(msg, MsgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } } } if (ReverseTheseDocs.Count > 0) { TVerificationResultCollection Verifications; TDlgGLEnterDateEffective dateEffectiveDialog = new TDlgGLEnterDateEffective( FMainForm.LedgerNumber, Catalog.GetString("Select reversal date"), Catalog.GetString("The date effective for this reversal") + ":"); if (dateEffectiveDialog.ShowDialog(FMainForm) != DialogResult.OK) { MessageBox.Show(Catalog.GetString("Reversal was cancelled."), MsgTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DateTime PostingDate = dateEffectiveDialog.SelectedDate; this.Cursor = Cursors.WaitCursor; if (TRemote.MFinance.AP.WebConnectors.PostAPDocuments( FMainForm.LedgerNumber, ReverseTheseDocs, PostingDate, true, out Verifications)) { this.Cursor = Cursors.Default; MessageBox.Show(Catalog.GetString("The tagged invoices have been reversed to 'Approved' status."), MsgTitle); FMainForm.IsInvoiceDataChanged = true; LoadInvoices(); return; } else { this.Cursor = Cursors.Default; string ErrorMessages = Verifications.BuildVerificationResultString(); MessageBox.Show(ErrorMessages, MsgTitle); } } else { MessageBox.Show(Catalog.GetString("There are no tagged invoices to be reversed."), MsgTitle); } }