Beispiel #1
0
        public List <SupplierInvoice> searchById(int id)
        {
            if (id != 0)
            {
                List <SupplierInvoice> supplierInvoiceList = BLSupplierInvoice.GetSupplierInvoiceListById(APCContext, id);

                if (supplierInvoiceList != null)
                {
                    tbId.Text = supplierInvoiceList[0].Id.ToString();
                    tbSupplierOriInvoiceNo.Text = supplierInvoiceList[0].SupplierOriNo;
                    tbPaymentDue.Text           = supplierInvoiceList[0].PaymentDue.ToString();
                    calDueDate.Value            = DateTime.Parse(supplierInvoiceList[0].DueDate.ToString());
                    ddlPO.SelectedValue         = int.Parse(supplierInvoiceList[0].PO.Id.ToString());
                    return(supplierInvoiceList);
                }
                else
                {
                    MessageBox.Show("SupplierInvoice Id not found");
                }
            }
            else
            {
                MessageBox.Show("SupplierInvoice Id not found");
            }
            return(null);
        }
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     SupplierInvoice supplierInvoice = BLSupplierInvoice.GetSupplierInvoiceListById(APCContext,int.Parse(tbSupplierInvoiceId.Text)).First();
     BLPaymentToSupplier.insertPaymentToSupplier(APCContext, supplierInvoice, decimal.Parse(tbPaymentAmount.Text), calPaidDate.Value);
     
     //check if payment has been made full - if yes then can mark as paid.
     if (supplierInvoice.PaymentDue <= TotalPaid(supplierInvoice.Id))
     {
         supplierInvoice.Paid = true;
         supplierInvoice.PaidDate = DateTime.Now;
         APCContext.SaveChanges();
     }
     
     MessageBox.Show("Payment has been recorded");
 }