private IList getItems() { IList items = new ArrayList(); for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { if (itemsDataGrid[invoiceNoColumn.Index, i].Value == null) { continue; } if (itemsDataGrid[invoiceNoColumn.Index, i].Value.ToString() == "") { continue; } CustomerOutStandingInvoiceItem st = (CustomerOutStandingInvoiceItem)itemsDataGrid.Rows[i].Tag; if (st == null) { st = new CustomerOutStandingInvoiceItem(); } itemsDataGrid.Rows[i].Tag = st; st.EVENT_JOURNAL = m_prn; st.AMOUNT = Convert.ToDouble(itemsDataGrid[amountColumn.Index, i].Value); st.INVOICE_NO = itemsDataGrid[invoiceNoColumn.Index, i].Value.ToString(); st.INVOICE_DATE = Convert.ToDateTime(itemsDataGrid[invoiceDateColumn.Index, i].Value); st.TOP = (TermOfPayment)Utils.FindEntityInList(itemsDataGrid[topColumn.Index, i].Value.ToString(), m_tops); st.DUE_DATE = Convert.ToDateTime(itemsDataGrid[dueDateColumn.Index, i].Value); st.EMPLOYEE = (Employee)Utils.FindEntityInList(itemsDataGrid[invoicerColumn.Index, i].Value.ToString(), m_employee); st.VENDOR = m_prn.VENDOR; st.CURRENCY = m_prn.CURRENCY; items.Add(st); } return(items); }
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((Customer)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 (ReceiptItem item in m_prn.EVENT_JOURNAL_ITEMS) { int i = itemsDataGrid.Rows.Add(); if (item.CUSTOMER_INVOICE_JOURNAL_ITEM is CustomerInvoiceJournalItem) { CustomerInvoiceJournalItem siji = (CustomerInvoiceJournalItem)item.CUSTOMER_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.CUSTOMER_INVOICE_JOURNAL_ITEM is CustomerOutStandingInvoiceItem) { CustomerOutStandingInvoiceItem siji = (CustomerOutStandingInvoiceItem)item.CUSTOMER_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 == ReceiptType.Bank ? item.BANK.ToString() : ""; if (item.PAYMENT_TYPE == ReceiptType.ARCreditNote) { itemsDataGrid[docnoColumn.Index, i].Tag = item.AR_CREDIT_NOTE; itemsDataGrid[docnoColumn.Index, i].Value = item.AR_CREDIT_NOTE.CODE; itemsDataGrid[paymentAmountColumn.Index, i].Value = item.AR_CREDIT_NOTE.NET_AMOUNT; itemsDataGrid[docdateColumn.Index, i].Value = item.AR_CREDIT_NOTE.TRANSACTION_DATE; } } }
private void toolStripButtonOutstandingInvoice_Click(object sender, EventArgs e) { Customer sp = (Customer)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 CustomerOutStandingInvoiceItem) { CustomerOutStandingInvoiceItem pi = (CustomerOutStandingInvoiceItem)itemsDataGrid[invoiceNoColumn.Index, i].Tag; if (pi == null) { continue; } addedPI.Add(pi.ID); } } using (SearchOstCussInvForReceiptForm frm = new SearchOstCussInvForReceiptForm(ccy, sp, addedPI, m_mainForm.CurrentUser, dateKryptonDateTimePicker.Value)) { frm.ShowDialog(); IList result = frm.RESULT; foreach (CustomerOutStandingInvoiceItem 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[dueDateColumn.Index, i].Value = item.DUE_DATE; itemsDataGrid[invoicerColumn.Index, i].Value = item.EMPLOYEE.ToString(); itemsDataGrid[amountColumn.Index, i].Value = item.AMOUNT; itemsDataGrid[OutstandingAmountColumn.Index, i].Value = item.OUTSTANDING_AMOUNT; itemsDataGrid[paidAmountColumn.Index, i].Value = item.RECEIPT_AMOUNT; //Init--- itemsDataGrid[paymentTypeColumn.Index, i].Value = ReceiptType.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; } CustomerOutStandingInvoiceItem pi = (CustomerOutStandingInvoiceItem)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 CustomerInvoiceJournalItem) { CustomerInvoiceJournalItem si = (CustomerInvoiceJournalItem)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 = "Receipt exceed outstanding amount"; return; } } if (itemsDataGrid[invoiceNoColumn.Index, e.RowIndex].Tag is CustomerOutStandingInvoiceItem) { CustomerOutStandingInvoiceItem si = (CustomerOutStandingInvoiceItem)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 = "Receipt exceed outstanding amount"; return; } } } if (docnoColumn.Index == e.ColumnIndex) { ReceiptType type = (ReceiptType)Enum.Parse(typeof(ReceiptType), itemsDataGrid[paymentTypeColumn.Index, e.RowIndex].Value.ToString()); if (type == ReceiptType.ARCreditNote) { 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; } ARCreditNote ap = (ARCreditNote)itemsDataGrid[docnoColumn.Index, i].Tag; if (ap == null) { continue; } notin.Add(ap.ID); } IList result = r_apdn.FindARCRForReceipt(((Customer)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 = ((ARCreditNote)result[0]).CODE; itemsDataGrid[paymentAmountColumn.Index, e.RowIndex].Value = ((ARCreditNote)result[0]).NET_AMOUNT; itemsDataGrid[docdateColumn.Index, e.RowIndex].Value = ((ARCreditNote)result[0]).TRANSACTION_DATE; itemsDataGrid[noteColumn.Index, e.RowIndex].Value = ((ARCreditNote)result[0]).NOTES; } else { using (SearchARCRForReceiptForm ap = new SearchARCRForReceiptForm(e.FormattedValue.ToString(), (Customer)supplierkryptonComboBox.SelectedItem, result, m_mainForm.CurrentUser, dateKryptonDateTimePicker.Value, notin)) { ap.ShowDialog(); ARCreditNote res = ap.ARCREDIT_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; ReceiptType type = (ReceiptType)Enum.Parse(typeof(ReceiptType), e.FormattedValue.ToString()); if (type == ReceiptType.ARCreditNote) { itemsDataGrid[paymentAmountColumn.Index, e.RowIndex].ReadOnly = true; itemsDataGrid[docdateColumn.Index, e.RowIndex].ReadOnly = true; } } }