private void loadData() { textBoxCode.Text = m_prn.CODE; dateKryptonDateTimePicker.Value = m_prn.TRANSACTION_DATE; employeeKryptonComboBox.Text = r_employee.GetById(m_prn.EMPLOYEE).ToString(); notesKryptonTextBox.Text = m_prn.NOTES; supplierkryptonComboBox.Text = r_sup.GetById((Supplier)m_prn.VENDOR).ToString(); currencyKryptonComboBox.Text = r_ccy.GetById(m_prn.CURRENCY).ToString(); netAmountkryptonNumericUpDown.Value = Convert.ToDecimal(m_prn.NET_AMOUNT); itemsDataGrid.Rows.Clear(); foreach (PaymentItem item in m_prn.EVENT_JOURNAL_ITEMS) { int i = itemsDataGrid.Rows.Add(); if (item.SUPPLIER_INVOICE_JOURNAL_ITEM is SupplierInvoiceJournalItem) { SupplierInvoiceJournalItem siji = (SupplierInvoiceJournalItem)item.SUPPLIER_INVOICE_JOURNAL_ITEM; itemsDataGrid[invoiceNoColumn.Index, i].Tag = siji; itemsDataGrid[invoiceNoColumn.Index, i].Value = siji.EVENT_JOURNAL.CODE; itemsDataGrid[invoiceDateColumn.Index, i].Value = siji.EVENT_JOURNAL.TRANSACTION_DATE; itemsDataGrid[topColumn.Index, i].Value = siji.TOP.ToString(); itemsDataGrid[dueDateColumn.Index, i].Value = siji.DUE_DATE; itemsDataGrid[invoicerColumn.Index, i].Value = siji.EMPLOYEE.ToString(); itemsDataGrid[amountColumn.Index, i].Value = siji.AMOUNT; itemsDataGrid[OutstandingAmountColumn.Index, i].Value = r_sij.GetOutstanding(siji.ID); itemsDataGrid[paidAmountColumn.Index, i].Value = r_sij.GetPaid(siji.ID); } if (item.SUPPLIER_INVOICE_JOURNAL_ITEM is SupplierOutStandingInvoiceItem) { SupplierOutStandingInvoiceItem siji = (SupplierOutStandingInvoiceItem)item.SUPPLIER_INVOICE_JOURNAL_ITEM; itemsDataGrid[invoiceNoColumn.Index, i].Tag = siji; itemsDataGrid[invoiceNoColumn.Index, i].Value = siji.EVENT_JOURNAL.CODE; itemsDataGrid[invoiceDateColumn.Index, i].Value = siji.EVENT_JOURNAL.TRANSACTION_DATE; itemsDataGrid[topColumn.Index, i].Value = siji.TOP.ToString(); itemsDataGrid[dueDateColumn.Index, i].Value = siji.DUE_DATE; itemsDataGrid[invoicerColumn.Index, i].Value = siji.EMPLOYEE.ToString(); itemsDataGrid[amountColumn.Index, i].Value = siji.AMOUNT; itemsDataGrid[OutstandingAmountColumn.Index, i].Value = r_soij.GetOutstanding(siji.ID); itemsDataGrid[paidAmountColumn.Index, i].Value = r_soij.GetPaid(siji.ID); } itemsDataGrid.Rows[i].Tag = item; itemsDataGrid[paymentAmountColumn.Index, i].Value = item.AMOUNT; itemsDataGrid[paymentTypeColumn.Index, i].Value = item.PAYMENT_TYPE.ToString(); itemsDataGrid[docnoColumn.Index, i].Value = item.INVOICE_NO; itemsDataGrid[docdateColumn.Index, i].Value = item.INVOICE_DATE; itemsDataGrid[noteColumn.Index, i].Value = item.NOTES; itemsDataGrid[bankColumn.Index, i].Value = item.PAYMENT_TYPE == PaymentType.Bank ? item.BANK.ToString() : ""; if (item.PAYMENT_TYPE == PaymentType.APDebitNote) { itemsDataGrid[docnoColumn.Index, i].Tag = item.AP_DEBIT_NOTE; itemsDataGrid[docnoColumn.Index, i].Value = item.AP_DEBIT_NOTE.CODE; itemsDataGrid[paymentAmountColumn.Index, i].Value = item.AP_DEBIT_NOTE.NET_AMOUNT; itemsDataGrid[docdateColumn.Index, i].Value = item.AP_DEBIT_NOTE.TRANSACTION_DATE; } } }
private void toolStripButtonSearchSI_Click(object sender, EventArgs e) { Supplier sp = (Supplier)supplierkryptonComboBox.SelectedItem; Currency ccy = (Currency)currencyKryptonComboBox.SelectedItem; if (sp == null) { return; } if (ccy == null) { return; } IList addedPI = new ArrayList(); for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { if (itemsDataGrid[invoiceNoColumn.Index, i].Tag is SupplierInvoiceJournalItem) { SupplierInvoiceJournalItem pi = (SupplierInvoiceJournalItem)itemsDataGrid[invoiceNoColumn.Index, i].Tag; if (pi == null) { continue; } addedPI.Add(pi.ID); } } using (SearchSuppInvJForPaymentForm frm = new SearchSuppInvJForPaymentForm(ccy, sp, addedPI, m_mainForm.CurrentUser, dateKryptonDateTimePicker.Value)) { frm.ShowDialog(); IList result = frm.RESULT; foreach (SupplierInvoiceJournalItem item in result) { int i = itemsDataGrid.Rows.Add(); itemsDataGrid[invoiceNoColumn.Index, i].Tag = item; itemsDataGrid[invoiceNoColumn.Index, i].Value = item.EVENT_JOURNAL.CODE; itemsDataGrid[invoiceDateColumn.Index, i].Value = item.EVENT_JOURNAL.TRANSACTION_DATE; itemsDataGrid[topColumn.Index, i].Value = item.TOP.ToString(); itemsDataGrid[amountColumn.Index, i].Value = item.AMOUNT; itemsDataGrid[dueDateColumn.Index, i].Value = item.DUE_DATE; itemsDataGrid[invoicerColumn.Index, i].Value = item.EMPLOYEE.ToString(); itemsDataGrid[OutstandingAmountColumn.Index, i].Value = item.OUTSTANDING_AMOUNT; itemsDataGrid[paidAmountColumn.Index, i].Value = item.PAID_AMOUNT; //Init--- itemsDataGrid[paymentTypeColumn.Index, i].Value = PaymentType.Bank; itemsDataGrid[docdateColumn.Index, i].Value = DateTime.Today; //--- } } }
private void AddResult() { for (int i = 0; i < gridData.Rows.Count; i++) { bool check = Convert.ToBoolean(gridData[checkColumn.Index, i].Value); if (!check) { continue; } SupplierInvoiceJournalItem pi = (SupplierInvoiceJournalItem)gridData.Rows[i].Tag; RESULT.Add(pi); } }
void dataItemskryptonDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (m_editMode == EditMode.View) { return; } itemsDataGrid.Rows[e.RowIndex].ErrorText = ""; if (!itemsDataGrid[e.ColumnIndex, e.RowIndex].IsInEditMode) { return; } if (e.ColumnIndex == paymentAmountColumn.Index) { double py = Convert.ToDouble(e.FormattedValue); if (itemsDataGrid[invoiceNoColumn.Index, e.RowIndex].Tag == null) { return; } if (itemsDataGrid[invoiceNoColumn.Index, e.RowIndex].Tag is SupplierInvoiceJournalItem) { SupplierInvoiceJournalItem si = (SupplierInvoiceJournalItem)itemsDataGrid[invoiceNoColumn.Index, e.RowIndex].Tag; si.OUTSTANDING_AMOUNT = r_sij.GetOutstanding(si.ID); if (si == null) { e.Cancel = true; itemsDataGrid.Rows[e.RowIndex].ErrorText = "Please Fill Invoice"; return; } if (py > si.OUTSTANDING_AMOUNT) { e.Cancel = true; itemsDataGrid.Rows[e.RowIndex].ErrorText = "Payment exceed outstanding amount"; return; } } if (itemsDataGrid[invoiceNoColumn.Index, e.RowIndex].Tag is SupplierOutStandingInvoiceItem) { SupplierOutStandingInvoiceItem si = (SupplierOutStandingInvoiceItem)itemsDataGrid[invoiceNoColumn.Index, e.RowIndex].Tag; si.OUTSTANDING_AMOUNT = r_soij.GetOutstanding(si.ID); if (si == null) { e.Cancel = true; itemsDataGrid.Rows[e.RowIndex].ErrorText = "Please Fill Invoice"; return; } if (py > si.OUTSTANDING_AMOUNT) { e.Cancel = true; itemsDataGrid.Rows[e.RowIndex].ErrorText = "Payment exceed outstanding amount"; return; } } } if (docnoColumn.Index == e.ColumnIndex) { PaymentType type = (PaymentType)Enum.Parse(typeof(PaymentType), itemsDataGrid[paymentTypeColumn.Index, e.RowIndex].Value.ToString()); if (type == PaymentType.APDebitNote) { itemsDataGrid[docnoColumn.Index, e.RowIndex].Tag = null; IList notin = new ArrayList(); for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { if (i == e.RowIndex) { continue; } if (itemsDataGrid[docnoColumn.Index, i].Tag == null) { continue; } APDebitNote ap = (APDebitNote)itemsDataGrid[docnoColumn.Index, i].Tag; if (ap == null) { continue; } notin.Add(ap.ID); } IList result = r_apdn.FindAPDNForPayment(((Supplier)supplierkryptonComboBox.SelectedItem).ID, dateKryptonDateTimePicker.Value, e.FormattedValue.ToString(), notin); if (result.Count == 1) { itemsDataGrid[docnoColumn.Index, e.RowIndex].Tag = result[0]; itemsDataGrid[docnoColumn.Index, e.RowIndex].Value = ((APDebitNote)result[0]).CODE; itemsDataGrid[paymentAmountColumn.Index, e.RowIndex].Value = ((APDebitNote)result[0]).NET_AMOUNT; itemsDataGrid[docdateColumn.Index, e.RowIndex].Value = ((APDebitNote)result[0]).TRANSACTION_DATE; itemsDataGrid[noteColumn.Index, e.RowIndex].Value = ((APDebitNote)result[0]).NOTES; } else { using (SearchAPDNForPaymentForm ap = new SearchAPDNForPaymentForm(e.FormattedValue.ToString(), (Supplier)supplierkryptonComboBox.SelectedItem, result, m_mainForm.CurrentUser, dateKryptonDateTimePicker.Value, notin)) { ap.ShowDialog(); APDebitNote res = ap.APDEBIT_NOTE; if (res == null) { return; } itemsDataGrid[docnoColumn.Index, e.RowIndex].Tag = res; itemsDataGrid[docnoColumn.Index, e.RowIndex].Value = res.CODE; itemsDataGrid[paymentAmountColumn.Index, e.RowIndex].Value = res.NET_AMOUNT; itemsDataGrid[docdateColumn.Index, e.RowIndex].Value = res.TRANSACTION_DATE; itemsDataGrid[noteColumn.Index, e.RowIndex].Value = res.NOTES; } } } } if (paymentTypeColumn.Index == e.ColumnIndex) { itemsDataGrid[paymentAmountColumn.Index, e.RowIndex].Value = 0; itemsDataGrid[paymentAmountColumn.Index, e.RowIndex].ReadOnly = false; itemsDataGrid[docdateColumn.Index, e.RowIndex].ReadOnly = false; PaymentType type = (PaymentType)Enum.Parse(typeof(PaymentType), e.FormattedValue.ToString()); if (type == PaymentType.APDebitNote) { itemsDataGrid[paymentAmountColumn.Index, e.RowIndex].ReadOnly = true; itemsDataGrid[docdateColumn.Index, e.RowIndex].ReadOnly = true; } } }