Exemplo n.º 1
0
 private void buttonSpecAny1_Click(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         gridData.Rows.Clear();
         IList records = r_soinv.FindAPDNForPayment(m_sup.ID, m_date, searchText.Text.Trim(), m_notIn);
         loadResult(records);
         this.Cursor = Cursors.Default;
     }
     catch (Exception x)
     {
         KryptonMessageBox.Show(x.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Exemplo n.º 2
0
 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;
         }
     }
 }