Exemple #1
0
        private void LoadData()
        {
            String                  query       = "select ORDERID,CATEGORYNAME, QUANTITY, PRICE from Orders";
            SqlDataReader           reader      = DataAccess.GetData(query);
            List <BillingOperation> BillingList = new List <BillingOperation>();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    BillingOperation bl = new BillingOperation();
                    bl.OrderId      = reader.GetString(0);
                    bl.CategoryName = reader.GetString(1);
                    bl.OrderPrice   = reader.GetDouble(3);
                    bl.Quantity     = reader.GetInt32(2);
                    BillingList.Add(bl);
                }
            }
            billingDataGrid.ItemsSource = BillingList;
            String        Query = "Select SUM(PRICE) from Orders";
            SqlDataReader read  = DataAccess.GetData(Query);

            read.Read();
            subTotal.Text = read.IsDBNull(0) ? null : read.GetDouble(0).ToString();
        }
Exemple #2
0
        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            BillingOperation b      = new BillingOperation(Convert.ToDouble(priceTextBox.Text), Convert.ToInt32(quantityTextBox.Text), menuComboBox.Text);
            BillingService   bs     = new BillingService();
            String           query  = "select ORDERID,CATEGORYNAME, QUANTITY, PRICE from Orders where CATEGORYNAME = '" + menuComboBox.Text + "'";
            SqlDataReader    reader = DataAccess.GetData(query);

            if (reader.HasRows)
            {
                reader.Read();
                if (reader.GetString(1).Equals(menuComboBox.Text))
                {
                    MessageBox.Show(reader.GetString(0));
                    b.Quantity   = b.Quantity + reader.GetInt32(2);
                    b.OrderPrice = Convert.ToDouble(priceTextBox.Text) * b.Quantity;
                    bs.Edit(b, reader.GetString(0));
                }
            }

            else
            {
                //MessageBox.Show(reader.GetString(0));
                bs.AddOrder(b);
            }

            LoadData();
        }
        private void printButton_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog  printDlg = new PrintDialog();
            FlowDocument doc      = CreateFlowDocument();

            doc.Name = "FlowDoc";
            IDocumentPaginatorSource idpSource = doc;

            printDlg.PrintDocument(idpSource.DocumentPaginator, "Booking");
            BillingOperation Bo = new BillingOperation(bookingIdBlock.Text, customerNameBlock.Text, Convert.ToDateTime(bookingDateBlock.Text), tableNoBlock.Text, contactBlock.Text,
                                                       Convert.ToDouble(subTotal.Text), Convert.ToDouble(serviceTax.Text), Convert.ToDouble(vat.Text), Convert.ToDouble(discount.Text), Total);
            BillingService bs = new BillingService();

            bs.AddBilling(Bo);
            String Query = "truncate Table Orders";

            DataAccess.ExecuteQuery(Query);
            BookingService bookingService = new BookingService();

            bookingService.DeleteBooking(bookingIdBlock.Text);
            using (BookingReport BR = new BookingReport())
            {
                this.Close();
                BR.ShowDialog();
            }
        }
        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            BillingOperation b  = new BillingOperation(Convert.ToDouble(priceTextBox.Text), Convert.ToInt32(quantityTextBox.Text), categoryComboBox.Text);
            BillingService   bs = new BillingService();

            bs.AddOrder(b);
            LoadData();
        }
Exemple #5
0
        private void orderDeleteButton_Click(object sender, RoutedEventArgs e)
        {
            BillingOperation order = (BillingOperation)billingDataGrid.SelectedItem;

            if (order != null)
            {
                BillingService billingService = new BillingService();

                if (MessageBox.Show("Are you want to Delete ?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    billingService.DeleteOrder(order.OrderId);
                }

                LoadData();
            }
        }
Exemple #6
0
        private void printButton_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog  printDlg = new PrintDialog();
            FlowDocument doc      = CreateFlowDocument();

            doc.Name = "FlowDoc";
            IDocumentPaginatorSource idpSource = doc;

            printDlg.PrintDocument(idpSource.DocumentPaginator, "Billing");
            BillingOperation Bo = new BillingOperation(billingNo.Text, customerName.Text, Convert.ToDateTime(billingDate.Text), tableNo.Text, contact.Text,
                                                       Convert.ToDouble(subTotal.Text), Convert.ToDouble(serviceTax.Text), Convert.ToDouble(vat.Text), Convert.ToDouble(discount.Text), Total);
            BillingService bs = new BillingService();

            bs.AddBilling(Bo);
            bs.TruncateOrder();
            this.Close();
        }
Exemple #7
0
        public Billing()
        {
            InitializeComponent();
            getCategoryId();
            billingDate.SelectedDate = DateTime.Now.Date;
            String        query  = "Select COUNT(BILLINGNO) from Billing";
            SqlDataReader reader = DataAccess.GetData(query);

            reader.Read();
            BillingOperation bl = new BillingOperation(reader.GetInt32(0));

            billingNo.Text = bl.BillingNo;
            if (this.IsLoaded == false)
            {
                BillingService bs = new BillingService();
                bs.TruncateOrder();
            }
            priceTextBox.IsEnabled    = false;
            menuComboBox.IsEnabled    = false;
            NextButton1.IsEnabled     = false;
            quantityTextBox.IsEnabled = false;
            AddButton.IsEnabled       = false;
        }
        public void LoadExpense()
        {
            if (fromDate.SelectedDate != null && toDate.SelectedDate != null)
            {
                Double                  Profit       = 0;
                Double                  Loss         = 0;
                Double                  TotalEarn    = 0;
                Double                  TotalExpense = 0;
                List <Expense>          expenseList  = new List <Expense>();
                List <BillingOperation> earningList  = new List <BillingOperation>();
                List <Entity.Payment>   paymentList  = new List <Entity.Payment>();
                String                  Query        = "Select CATEGORY,DESCRIPTION,AMOUNT,DATE from Expense where DATE between '" + fromDate.SelectedDate.Value + "'AND '" + toDate.SelectedDate.Value + "'";
                SqlDataReader           reader       = DataAccess.GetData(Query);
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Expense ex = new Expense();
                        ex.ExpenseCategory    = reader.GetString(0);
                        ex.ExpenseDescription = reader.GetString(1);
                        ex.ExpenseAmount      = reader.GetDouble(2);
                        ex.ExpenseDate        = reader.GetDateTime(3);
                        expenseList.Add(ex);

                        TotalExpense = TotalExpense + reader.GetDouble(2);
                        //MessageBox.Show(TotalExpense.ToString());
                    }
                }
                expenseDataGrid.ItemsSource = expenseList;

                String        Query1  = "Select BILLINGNO, BILLINGDATE, TOTAL from Billing where BILLINGDATE between '" + fromDate.SelectedDate.Value + "'AND '" + toDate.SelectedDate.Value + "'";
                SqlDataReader reader1 = DataAccess.GetData(Query1);
                if (reader1.HasRows)
                {
                    while (reader1.Read())
                    {
                        BillingOperation bl = new BillingOperation();
                        bl.BillingNo   = reader1.GetString(0);
                        bl.BillingDate = reader1.GetDateTime(1);
                        bl.Total       = reader1.GetDouble(2);
                        earningList.Add(bl);

                        TotalEarn = TotalEarn + reader1.GetDouble(2);
                        //MessageBox.Show(TotalExpense.ToString());
                    }
                }
                earningDataGrid.ItemsSource = earningList;
                String        Query2  = "Select OPERATORNAME, PAYMENTDATE, PAYMENTSTATUS, SALARY from Payment where PAYMENTDATE between '" + fromDate.SelectedDate.Value + "'AND '" + toDate.SelectedDate.Value + "'";
                SqlDataReader reader2 = DataAccess.GetData(Query2);
                if (reader2.HasRows)
                {
                    while (reader2.Read())
                    {
                        Entity.Payment payment = new Entity.Payment();
                        payment.OperatorName   = reader2.GetString(0);
                        payment.PaymentDate    = reader2.GetDateTime(1);
                        payment.PaymentStatus  = reader2.GetString(2);
                        payment.OperatorSalary = reader2.GetDouble(3);
                        paymentList.Add(payment);
                        TotalExpense = TotalExpense + reader2.GetDouble(3);
                        //MessageBox.Show(TotalExpense.ToString());
                    }
                }
                paymentDataGrid.ItemsSource = paymentList;
                totalEarnTextBlock.Text     = TotalEarn.ToString();
                totalExTexBlock.Text        = TotalExpense.ToString();
                Profit = TotalEarn - TotalExpense;
                MessageBox.Show(Profit.ToString());
                if (Profit > 0)
                {
                    profitTextBlock.Text = Profit.ToString();
                }
                else if (Profit == 0)
                {
                    lossTextBlock.Text   = "No Loss";
                    profitTextBlock.Text = "No Profit";
                }
                else
                {
                    Loss = TotalExpense - TotalEarn;
                    lossTextBlock.Text = Loss.ToString();
                }
            }
        }