Beispiel #1
0
        internal void EnableForm(TableOrder tableOrder)
        {
            thisTableOrder = tableOrder;

            TextBlock_TableNum.Text = "TABLE " + tableOrder.GetTableNumber();

            TableTableOrder.ConvertTableOrderToTableRow(tableOrder);
            UpdateSumTaxTotal(thisTableOrder.GetSumTaxTotal());

            if (thisTableOrder.GetTableStatus() == TableOrder.PRESETTLEMENT_BILL)
            {
                DisableTableTableOrder();
            }
            else
            {
                EnableTableTableOrder();
            }

            BrushConverter brush = new BrushConverter();

            Rectangle1.Fill = (Brush)brush.ConvertFrom("#363636");
            Rectangle2.Fill = (Brush)brush.ConvertFrom("#363636");
            Rectangle3.Fill = (Brush)brush.ConvertFrom("#363636");

            TextBlock_TableNum.Foreground          = (Brush)brush.ConvertFrom("#363636");
            TextBlock_ItemOrderedHeader.Foreground = (Brush)brush.ConvertFrom("#363636");

            TextBlock_SumHeader.Foreground   = (Brush)brush.ConvertFrom("#363636");
            TextBlock_SumNum.Foreground      = (Brush)brush.ConvertFrom("#363636");
            TextBlock_TaxHeader.Foreground   = (Brush)brush.ConvertFrom("#363636");
            TextBlock_TaxNum.Foreground      = (Brush)brush.ConvertFrom("#363636");
            TextBlock_TotalHeader.Foreground = (Brush)brush.ConvertFrom("#363636");
            TextBlock_TotalNum.Foreground    = (Brush)brush.ConvertFrom("#363636");
            TextBlock_PrintHeader.Foreground = (Brush)brush.ConvertFrom("#363636");
        }
        internal void EnableForm(TableOrder tableOrder)
        {
            thisTableOrder = tableOrder;

            TextBlock_TableNum.Text = "TABLE " + tableOrder.GetTableNumber();

            TableTableOrder.ConvertTableOrderToTableRow(tableOrder);
            UpdateSumTaxTotal(thisTableOrder.GetSumTaxTotal());

            if (thisTableOrder.GetTableStatus() == TableOrder.PRESETTLEMENT_BILL)
            {
                DisableTableTableOrder();

            }
            else
            {
                EnableTableTableOrder();

            }

            BrushConverter brush = new BrushConverter();

            Rectangle1.Fill = (Brush)brush.ConvertFrom("#363636");
            Rectangle2.Fill = (Brush)brush.ConvertFrom("#363636");
            Rectangle3.Fill = (Brush)brush.ConvertFrom("#363636");

            TextBlock_TableNum.Foreground = (Brush)brush.ConvertFrom("#363636");
            TextBlock_ItemOrderedHeader.Foreground = (Brush)brush.ConvertFrom("#363636");

            TextBlock_SumHeader.Foreground = (Brush)brush.ConvertFrom("#363636");
            TextBlock_SumNum.Foreground = (Brush)brush.ConvertFrom("#363636");
            TextBlock_TaxHeader.Foreground = (Brush)brush.ConvertFrom("#363636");
            TextBlock_TaxNum.Foreground = (Brush)brush.ConvertFrom("#363636");
            TextBlock_TotalHeader.Foreground = (Brush)brush.ConvertFrom("#363636");
            TextBlock_TotalNum.Foreground = (Brush)brush.ConvertFrom("#363636");
            TextBlock_PrintHeader.Foreground = (Brush)brush.ConvertFrom("#363636");

        }
        private void SaveTransactionToDatabase()
        {
            TableOrder tableOrder = fTableOrder.GetTableOrder();

            String path = Assembly.GetExecutingAssembly().Location;

            path = path.Replace("bin\\Debug\\ICTProjectPOS.exe", "RestaurantDB.accdb");

            String connectionString = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}", path);

            OleDbConnection connection = new OleDbConnection(connectionString);

            //OPEN CONNECTION
            connection.Open();

            String employeeID = "EMP001";

            DateTime dateTime = new DateTime();

            dateTime = DateTime.Now;

            OleDbCommand cmd = new OleDbCommand();

            cmd.CommandText = "SELECT COUNT(*) FROM Invoice";
            cmd.Connection  = connection;

            int invoiceNumber = (int)cmd.ExecuteScalar() + 1;

            cmd.CommandText = "INSERT INTO Invoice([InvoiceNum],[TableNum],[EmployeeID], [DineDate], [DineTime], [TotalOrder], [PayMethod]) VALUES (?, ?, ?, ?, ?, ?, ?)";

            cmd.Parameters.AddWithValue("InvoiceNum", invoiceNumber);
            cmd.Parameters.AddWithValue("TableNum", tableOrder.GetTableNumber());
            cmd.Parameters.AddWithValue("EmployeeId", employeeID);
            cmd.Parameters.AddWithValue("DineDate", dateTime.Date);
            cmd.Parameters.AddWithValue("DineTime", dateTime.TimeOfDay);
            cmd.Parameters.AddWithValue("TotalOrder", tableOrder.GetAmountDue());
            cmd.Parameters.AddWithValue("PayMethod", tableOrder.GetPaymentMethod());

            cmd.ExecuteNonQuery();

            connection.Close();

            connection.Open();

            foreach (Item item in tableOrder.GetItemsOrdered())
            {
                OleDbCommand cmd2 = new OleDbCommand();
                cmd2.Connection = connection;

                cmd2.CommandText = "SELECT * FROM Item WHERE ItemName LIKE ?";

                cmd2.Parameters.AddWithValue("ItemName", "%" + item.GetName() + "%");

                string itemID = "";

                OleDbDataReader dr = cmd2.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        itemID = dr[0].ToString();
                    }
                }


                OleDbCommand cmd3 = new OleDbCommand();
                cmd3.Connection = connection;

                cmd3.CommandText = "INSERT INTO InvoiceItem ([InvoiceNum], [ItemID], [Quantity]) Values (?, ?, ?)";

                cmd3.Parameters.AddWithValue("@InvoiceNum", invoiceNumber);
                cmd3.Parameters.AddWithValue("@ItemID", itemID);
                cmd3.Parameters.AddWithValue("@Quantity", item.GetQuantity());

                cmd3.ExecuteNonQuery();
            }


            //CLOSE CONNECTION
            connection.Close();
        }