Esempio n. 1
0
        public double catculateCreditSale(String date)
        {
            InvoiceModel inv      = new InvoiceModel();
            dynamic      invoices = inv.where (inv, "is_credit = '1' and date ='" + date + "'");
            double       total    = 0.0;

            if (invoices.Count > 0)
            {
                foreach (var invoice in invoices)
                {
                    PaymentModel pay      = new PaymentModel();
                    dynamic      payments = pay.where (pay, "invoice_id ='" + invoice.id + "'");
                    if (payments.Count > 0)
                    {
                        double paymentAmount = 0.0;
                        foreach (var payment in payments)
                        {
                            paymentAmount += payment.amount;
                        }
                        total += (invoice.net_total - paymentAmount);
                    }
                    else
                    {
                        total += invoice.net_total;
                    }
                }
            }
            return(total);
        }
Esempio n. 2
0
        private void dateTimePickerSearchInvoice_ValueChanged(object sender, EventArgs e)
        {
            String       searchValue = dateTimePickerSearchInvoice.Value.ToString("yyyy-MM-dd");
            InvoiceModel inv         = new InvoiceModel();
            dynamic      invoices    = inv.where (inv, " date ='" + searchValue + "'");

            loadInvoiceData(invoices);
        }
Esempio n. 3
0
        public void loadSales(string date)
        {
            clear_amount();
            paymentList.Rows.Clear();
            InvoiceModel inv      = new InvoiceModel();
            dynamic      invoices = inv.where (inv, "till_id = '" + DepartmentSettings.TillId + "' and date ='" + date + "'");

            if (invoices.Count > 0)
            {
                string invoiceIds = null;
                foreach (var invoice in invoices)
                {
                    invoiceIds += "," + invoice.id;
                }
                string       Ids      = invoiceIds.Substring(1);
                PaymentModel pay      = new PaymentModel();
                dynamic      payments = pay.where (pay, "invoice_id in(" + Ids + ")");

                if (payments.Count > 0)
                {
                    foreach (var payment in payments)
                    {
                        totalPayment += payment.amount;
                        String type = payment.payment_method;
                        switch (type)
                        {
                        case "Cash":
                            totalCashPayment += payment.amount;
                            break;

                        case "Mobile":
                            mobilePayment += payment.amount;
                            break;

                        case "Card":
                            totalCardPayment += payment.amount;
                            break;

                        case "Debit":
                            debitPayment += payment.amount;
                            break;

                        default:
                            break;
                        }
                        paymentList.Rows.Add(payment.id, payment.payment_method, payment.invoice_id, Math.Round(payment.amount, 2), payment.transaction_token, payment.date);
                    }
                }
                double total = totalPayment + catculateCreditSale(date);
                totalLabel.Text      = "" + Math.Round(total, 2);
                cardLabel.Text       = "" + Math.Round(totalCardPayment, 2);
                mobileLabel.Text     = "" + Math.Round(mobilePayment, 2);
                debitLabel.Text      = "" + Math.Round(debitPayment, 2);
                cashSaleLabel.Text   = "" + Math.Round(totalCashPayment, 2);
                labelCreditSale.Text = "" + catculateCreditSale(date);
            }
        }
Esempio n. 4
0
 private void textBoxSearchInvoice_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Return)
     {
         string       number   = textBoxSearchInvoice.Text;
         InvoiceModel inv      = new InvoiceModel();
         dynamic      invoices = inv.where (inv, "lower(number) like '%" + number.ToLower() + "%'");
         loadInvoiceData(invoices);
     }
 }
Esempio n. 5
0
        public void loadSales()
        {
            string date = DateTime.Now.ToString("yyyy-MM-dd");

            InvoiceModel inv      = new InvoiceModel();
            dynamic      invoices = inv.where (inv, "till_id = '" + DepartmentSettings.TillId + "' and date ='" + date + "'");

            if (invoices.Count > 0)
            {
                string invoiceIds = null;
                foreach (var invoice in invoices)
                {
                    invoiceIds += "," + invoice.id;
                }
                string       Ids      = invoiceIds.Substring(1);
                PaymentModel pay      = new PaymentModel();
                dynamic      payments = pay.where (pay, "invoice_id in(" + Ids + ")");

                if (payments.Count > 0)
                {
                    foreach (var payment in payments)
                    {
                        totalPayment += payment.amount;
                        String type = payment.payment_method;
                        switch (type)
                        {
                        case "Cash":
                            totalCashPayment += payment.amount;
                            break;

                        case "Mobile":
                            mobilePayment += payment.amount;
                            break;

                        case "Card":
                            totalCardPayment += payment.amount;
                            break;

                        case "Debit":
                            debitPayment += payment.amount;
                            break;

                        default:
                            break;
                        }
                    }
                }
                totalLabel.Text    = "" + Math.Round(totalPayment, 2);
                cardLabel.Text     = "" + Math.Round(totalCardPayment, 2);
                mobileLabel.Text   = "" + Math.Round(mobilePayment, 2);
                debitLabel.Text    = "" + Math.Round(debitPayment, 2);
                cashSaleLabel.Text = "" + Math.Round(totalCashPayment, 2);
                cashSale.Text      = "" + Math.Round(totalCashPayment, 2);
            }
        }
Esempio n. 6
0
 private void search_invoice_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Return)
     {
         string       number   = search_invoice.Text;
         InvoiceModel inv      = new InvoiceModel();
         dynamic      invoices = inv.where (inv, "lower(number) like '%" + number.ToLower() + "%'");
         if (invoices.Count > 0)
         {
             foreach (dynamic invoice in invoices)
             {
                 invoiceList.Rows.Add(invoice.id, invoice.number, invoice.customer_id, invoice.date, invoice.net_total);
             }
             invoiceList.Rows[0].Selected = true;
             invoiceList.Focus();
         }
         else
         {
             MessageDialog.ShowAlert("Invoice not found");
         }
     }
 }