/// <summary>
		/// Select ticket for bill adjustment
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
        private void button_Click(object sender, RoutedEventArgs e)
        {
			List<Cart> totalCart = new List<Cart>();
			decimal running_total = 0m;
			ticketNumber.Text = "N/A";
			authBy.Text = "Employee";
			foreach (client c in clientList)
			{
				if (c.name == Discounted_Tickets_List.SelectedValue.ToString())
				{
					try
					{
						string SQLConnectionString = "Server=tcp:omsdb.database.windows.net,1433;Database=OMSDB;User ID=csce4444@omsdb;Password=Pineapple!;";
						// Create an SqlConnection from the provided connection string.
						using (SqlConnection connection = new SqlConnection(SQLConnectionString))
						{
							// Formulate the command.
							SqlCommand command = new SqlCommand(@"SELECT * FROM dbo.Orders WHERE Client=@cli", connection);

							command.Parameters.AddWithValue("@cli", c.ip.ToString());
							connection.Open();
							SqlDataReader reader = command.ExecuteReader();

							// while not done reading the stuff returned from the query
							while (reader.Read())
							{
								Cart tempCart = new Cart();
								tempCart = (Cart)commHelper.ByteToObject((byte[])reader[1]);
								tempCart.Order_num = (int)reader[0];
								totalCart.Add(tempCart);
							}
						}
					}
					catch (Exception) { }

					foreach (Cart item in totalCart)
					{
						foreach (cartItem food in item.Items)
						{
							running_total += food.price;
						}
					}
					running_total = Math.Round(running_total, 2);
					originalAmt.Text = running_total.ToString();
					discountAmt.Text = c.adjustment.ToString();
				}
			}
			reason.Text = "N/A";
			
        }
        /// <summary>
        /// Update the database to make it work nicer, and change the 
        /// </summary>
        public void createOrders()
		{
			Dispatcher.Invoke(() =>
			{
				orderList.Items.Clear();
			});
			myOrders.Clear();
			try
			{
				string SQLConnectionString = "Server=tcp:omsdb.database.windows.net,1433;Database=OMSDB;User ID=csce4444@omsdb;Password=Pineapple!;";
				// Create an SqlConnection from the provided connection string.
				using (C.SqlConnection connection = new C.SqlConnection(SQLConnectionString))
				{
					// Formulate the command.
					C.SqlCommand command = new C.SqlCommand();
					command.Connection = connection;

					// Specify the query to be executed.
					command.CommandType = D.CommandType.Text;
					command.CommandText = @"
                    SELECT * FROM dbo.Orders
                    WHERE Finished=0
                    ";
					// Open a connection to database.
					connection.Open();
					// Read data returned for the query.
					C.SqlDataReader reader = command.ExecuteReader();

					// while not done reading the stuff returned from the query
					while (reader.Read())
					{
                        Cart tempCart = new Cart();
                        tempCart = (Cart)ByteToObject((byte[])reader[1]);
                        tempCart.Order_num = (int)reader[0];
                        myOrders.Add(tempCart);
					}

					connection.Close();

					foreach (Cart item in myOrders)
					{
						foreach (cartItem food in item.Items)
						{
							order += (food.name + ", ");
						}
						Dispatcher.Invoke(() =>
						{
							orderList.Items.Add(item.Order_num + " " + order);
						});

                        order = "";
					}
				}
			}
			catch (Exception) { }
        }
        private void tick_done_Click(object sender, RoutedEventArgs e)
        {
			List<Cart> temp = new List<Cart>();
			string ip = "";
			foreach (ClientInfo thing in TableList)
			{
				if (thing.Name == currentTableName.Content.ToString())
				{
					ip = thing.IP.ToString();
				}
			}
			try
			{
				string SQLConnectionString = "Server=tcp:omsdb.database.windows.net,1433;Database=OMSDB;User ID=csce4444@omsdb;Password=Pineapple!;";
				// Create an SqlConnection from the provided connection string.
				using (SqlConnection connection = new SqlConnection(SQLConnectionString))
				{
					// Formulate the command.
					SqlCommand command = new SqlCommand();
					command.Connection = connection;

					// Specify the query to be executed.
					command.CommandType = CommandType.Text;
					command.CommandText = @"
                    SELECT * FROM dbo.Orders
					WHERE Client=@cli
                    ";
					command.Parameters.AddWithValue("@cli", ip);
					// Open a connection to database.
					connection.Open();
					// Read data returned for the query.
					SqlDataReader reader = command.ExecuteReader();

					// while not done reading the stuff returned from the query
					while (reader.Read())
					{
						Cart tempCart = new Cart();
						tempCart = (Cart)ByteToObject((byte[])reader[1]);
						tempCart.Order_num = (int)reader[0];
						temp.Add(tempCart);
					}
				}
			}
			catch (Exception) { }
			decimal running_total = 0m;

			foreach (Cart item in temp)
			{
				foreach (cartItem food in item.Items)
				{
					running_total += food.price;
				}
			}

			if (Convert.ToDecimal(comp.Text) > running_total)
			{
				MessageBox.Show("NO FREE FOOD");
			}
			else
			{
				commHelper.functionSend("ticketAdjusted");
				commHelper.functionSend(comp.Text);
				commHelper.functionSend(ip);
				tick_ad.Visibility = Visibility.Hidden;
			}
        }