Esempio n. 1
0
		public void AddItem(OrderBillItem item)
		{
			OrderBillItem[] items = this.Items;
			if (items != null)
			{
				this.Items = new OrderBillItem[items.Length + 1];
				for (int i = 0; i < items.Length; i++)
				{
					this.Items[i] = items[i];
				}
			}
			else
			{
				this.Items = new OrderBillItem[1];
			}
			this.Items[this.Items.Length - 1] = item;
		}
		public OrderInformation GetOrder(int tableID)
		{
			SqlConnection connection = null;
			OrderInformation information2;
			try
			{
				int num;
				int num2;
				int num3;
				connection = ConnectDB.GetConnection();
				SqlCommand selectCommand = new SqlCommand("getOrderInformation", connection);
				selectCommand.CommandType = CommandType.StoredProcedure;
				selectCommand.Parameters.Add("@tableID", SqlDbType.Int).Value = tableID;
				SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);
				DataSet dataSet = new DataSet();
				adapter.Fill(dataSet);
				DataTable table = dataSet.Tables[0];
				if (table.Rows.Count <= 0)
				{
					return null;
				}
				OrderInformation information = new OrderInformation();
				DataRow row = table.Rows[0];
				information.OrderID = (int) row["OrderID"];
				information.OrderTime = (DateTime) row["OrderTime"];
				information.TableID = (int) row["TableID"];
				information.EmployeeID = (int) row["EmployeeID"];
				information.NumberOfGuest = (int) row["NumberOfGuest"];
				information.CloseOrderDate = (row["CloseOrderDate"] is DBNull) ? AppParameter.MinDateTime : ((DateTime) row["CloseOrderDate"]);
				information.CreateDate = (DateTime) row["CreateDate"];
				table = dataSet.Tables[1];
				if (table.Rows.Count <= 0)
				{
					information.Bills = null;
					return information;
				}
				information.Bills = new OrderBill[table.Rows.Count];
				for (num = 0; num < table.Rows.Count; num++)
				{
					information.Bills[num] = new OrderBill();
					row = table.Rows[num];
					information.Bills[num].OrderBillID = (int) row["OrderBillID"];
					information.Bills[num].BillID = (int) row["BillID"];
					information.Bills[num].EmployeeID = (int) row["EmployeeID"];
					information.Bills[num].Items = null;
					information.Bills[num].CloseBillDate = (row["CloseBillDate"] is DBNull) ? AppParameter.MinDateTime : ((DateTime) row["CloseBillDate"]);
				}
				table = dataSet.Tables[2];
				if (table.Rows.Count <= 0)
				{
					return information;
				}
				for (num = 0; num < table.Rows.Count; num++)
				{
					row = table.Rows[num];
					int num5 = (int) row["OrderBillID"];
					num2 = 0;
					while (num2 < information.Bills.Length)
					{
						if (information.Bills[num2].OrderBillID == num5)
						{
							OrderBill bill = information.Bills[num2];
							if (bill.Items == null)
							{
								bill.Items = new OrderBillItem[1];
							}
							else
							{
								OrderBillItem[] items = bill.Items;
								bill.Items = new OrderBillItem[bill.Items.Length + 1];
								num3 = 0;
								while (num3 < items.Length)
								{
									bill.Items[num3] = items[num3];
									num3++;
								}
							}
							OrderBillItem item = new OrderBillItem();
							item.BillDetailID = (int) row["BillDetailID"];
							item.MenuID = (int) row["MenuID"];
							item.Unit = (int) row["Unit"];
							item.Status = (byte) row["Status"];
							item.Message = (row["Message"] is DBNull) ? null : ((string) row["Message"]);
							item.ServeTime = (row["ServeTime"] is DBNull) ? AppParameter.MinDateTime : ((DateTime) row["ServeTime"]);
							item.CancelReasonID = (int) row["CancelReasonID"];
							item.EmployeeID = (int) row["EmployeeID"];
							item.ChangeFlag = false;
							item.ItemChoices = null;
							bill.Items[bill.Items.Length - 1] = item;
							break;
						}
						num2++;
					}
				}
				table = dataSet.Tables[3];
				if (table.Rows.Count <= 0)
				{
					return information;
				}
				for (num = 0; num < table.Rows.Count; num++)
				{
					row = table.Rows[num];
					int num6 = (int) row["BillDetailID"];
					for (num2 = 0; num2 < information.Bills.Length; num2++)
					{
						if ((information.Bills[num2] != null) && (information.Bills[num2].Items != null))
						{
							for (num3 = 0; num3 < information.Bills[num2].Items.Length; num3++)
							{
								if (information.Bills[num2].Items[num3].BillDetailID == num6)
								{
									OrderBillItem item2 = information.Bills[num2].Items[num3];
									if (item2.ItemChoices == null)
									{
										item2.ItemChoices = new OrderItemChoice[1];
										item2.DefaultOption = false;
									}
									else
									{
										OrderItemChoice[] itemChoices = item2.ItemChoices;
										item2.ItemChoices = new OrderItemChoice[item2.ItemChoices.Length + 1];
										for (int i = 0; i < itemChoices.Length; i++)
										{
											item2.ItemChoices[i] = itemChoices[i];
										}
									}
									OrderItemChoice choice = new OrderItemChoice();
									choice.OptionID = (int) row["OptionID"];
									choice.ChoiceID = (int) row["ChoiceID"];
									item2.ItemChoices[item2.ItemChoices.Length - 1] = choice;
									break;
								}
							}
						}
					}
				}
				information2 = information;
			}
			catch (Exception)
			{
				information2 = null;
			}
			finally
			{
				if (connection != null)
				{
					connection.Close();
				}
			}
			return information2;
		}
		private int PrintKitchen(string[] BillDetailID)
		{
			string billDetailID = string.Join(",", BillDetailID);
			Printer.PrintKitchen.Print(billDetailID);
			byte status = 2;
			OrderBillItem item = new OrderBillItem();
			return item.OrderBillItemStatus(billDetailID, status);
		}