Пример #1
0
        private void SaveChanges()
        {
            paymentpayment_detailViewSource.View.Refresh();
            payment payment = paymentViewSource.View.CurrentItem as payment;

            PaymentDB.payment_detail.RemoveRange(payment.payment_detail.Where(x => x.IsSelected == false));
            PaymentDB.SaveChanges();
            foreach (payment_detail payment_detail in payment.payment_detail.Where(x => x.IsSelected))
            {
                if (Mode == Modes.Recievable)
                {
                    PaymentDB.Approve(payment_detail.id_payment_schedual, true);
                }
                else
                {
                    PaymentDB.Approve(payment_detail.id_payment_schedual, false);
                }
            }
            lblCancel_MouseDown(null, null);
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            sales_invoice sales_invoice = (sales_invoice)sales_invoiceViewSource.View.CurrentItem as sales_invoice;
            payment       payment       = paymentViewSource.View.CurrentItem as payment;

            /// VALIDATIONS...
            ///
            /// Validates if Contact is not assigned, then it will take user to the Contact Tab.
            if (sales_invoice.contact == null)
            {
                tabContact.Focus();
                return;
            }

            /// Validates if Sales Detail has 0 rows, then take you to Sales Tab.
            if (sales_invoice.sales_invoice_detail.Count == 0)
            {
                tabSales.Focus();
                return;
            }

            /// Validate Payment <= Sales.GrandTotal
            //if (payment.GrandTotal >= payment.GrandTotal_Detail)
            //{
            if (payment.GrandTotalDetail < sales_invoice.GrandTotal)
            {
                tabPayment.Focus();
                return;
            }

            /// If all validation is met, then we can start Sales Process.
            if (sales_invoice.contact != null && sales_invoice.sales_invoice_detail.Count > 0)
            {
                ///Approve Sales Invoice.
                ///Note> Approve includes Save Logic. No need to seperately Save.
                ///Plus we are passing True as default because in Point of Sale, we will always discount Stock.
                SalesInvoiceDB.Approve(true);

                payment_schedual payment_schedual = SalesInvoiceDB.payment_schedual.Where(x => x.id_sales_invoice == sales_invoice.id_sales_invoice && x.debit > 0).FirstOrDefault();
                PaymentDB.Approve(payment_schedual.id_payment_schedual, (bool)chkreceipt.IsChecked);

                //Start New Sale
                New_Sale_Payment();
            }
        }