예제 #1
0
		public MenuItem(MenuType type, int id, int keyID, string keyIDTxt, string name, string desc, double price)
		{
			this.TypeID = type.ID;
			this.ID = id;
			this.KeyID = keyID;
			this.KeyIDText = keyIDTxt;
			this.Name = name;
			this.Description = desc;
			this.Price = price;
			this.MenuDefaults = null;
		}
		public MenuType[] GetMenus(string AppName)
		{
			string str3;
			MenuType[] typeArray2;
			string str = ConfigurationSettings.AppSettings["LANG"];
			string str2 = ConfigurationSettings.AppSettings[AppName];
			if (str2 != "")
			{
				str3 = "Menu" + ConfigurationSettings.AppSettings[AppName] + "Name";
			}
			else
			{
				str3 = "MenuName" + str;
			}
			new PrintSlip("KIT");
			SqlConnection connection = null;
			try
			{
				int num;
				int num2;
				DataRow row;
				connection = ConnectDB.GetConnection();
				SqlCommand selectCommand = new SqlCommand("GetMenus", connection);
				selectCommand.CommandType = CommandType.StoredProcedure;
				SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);
				DataSet dataSet = new DataSet();
				adapter.Fill(dataSet);
				DataTable table = dataSet.Tables[0];
				MenuType[] typeArray = new MenuType[table.Rows.Count];
				for (num = 0; num < table.Rows.Count; num++)
				{
					row = table.Rows[num];
					int id = (int) row["MenuTypeID"];
					string name = (row["MenuTypeName"] is DBNull) ? null : ((string) row["MenuTypeName"]);
					string desc = (row["MenuTypeDescription"] is DBNull) ? null : ((string) row["MenuTypeDescription"]);
					double num5 = double.Parse(row["Tax1"].ToString());
					double num6 = double.Parse(row["Tax2"].ToString());
					int num7 = (int) row["ItemCount"];
					typeArray[num] = new MenuType(id, name, desc);
					typeArray[num].Tax1 = num5 / 100.0;
					typeArray[num].Tax2 = num6 / 100.0;
					if (num7 > 0)
					{
						typeArray[num].MenuItems = new MenuItem[num7];
					}
				}
				table = dataSet.Tables[1];
				int index = 0;
				int num9 = 0;
				int num10 = 0;
				for (num = 0; num < table.Rows.Count; num++)
				{
					row = table.Rows[num];
					int num11 = (int) row["MenuID"];
					int keyID = (int) row["MenuKeyID"];
					int num13 = (int) row["MenuTypeID"];
					string keyIDTxt = (row["MenuKeyIDText"] is DBNull) ? keyID.ToString() : row["MenuKeyIDText"].ToString();
					string str7 = row[str3].ToString();
					string str8 = (row["MenuDescription"] is DBNull) ? null : ((string) row["MenuDescription"]);
					double price = double.Parse(row["Price"].ToString());
					int num15 = (int) row["ItemCount"];
					switch (keyIDTxt)
					{
						case null:
						case "":
							keyIDTxt = keyID.ToString();
							break;
					}
					if (num10 != num13)
					{
						num2 = 0;
						while (num2 < typeArray.Length)
						{
							if (typeArray[num2].ID == num13)
							{
								index = num2;
								break;
							}
							num2++;
						}
						num9 = -1;
						if (typeArray[index].MenuItems != null)
						{
							num2 = 0;
							while (num2 < typeArray[index].MenuItems.Length)
							{
								if (typeArray[index].MenuItems[num2] == null)
								{
									num9 = num2;
									break;
								}
								num2++;
							}
						}
						num10 = num13;
					}
					if (num9 >= 0)
					{
						typeArray[index].MenuItems[num9] = new MenuItem(typeArray[index], num11, keyID, keyIDTxt, str7, str8, price);
						if (num15 > 0)
						{
							typeArray[index].MenuItems[num9].MenuDefaults = new MenuDefault[num15];
						}
						num9++;
					}
				}
				table = dataSet.Tables[2];
				index = 0;
				num9 = 0;
				int num16 = 0;
				int num17 = 0;
				for (num = 0; num < table.Rows.Count; num++)
				{
					row = table.Rows[num];
					int num18 = (int) row["MenuID"];
					int optionID = (int) row["OptionID"];
					int choiceID = (int) row["DefaultChoiceID"];
					if (num17 != num18)
					{
						index = -1;
						num9 = -1;
						num2 = 0;
						while (num2 < typeArray.Length)
						{
							if (typeArray[num2].MenuItems != null)
							{
								for (int i = 0; i < typeArray[num2].MenuItems.Length; i++)
								{
									if (typeArray[num2].MenuItems[i].ID == num18)
									{
										index = num2;
										num9 = i;
										break;
									}
								}
								if (index >= 0)
								{
									break;
								}
							}
							num2++;
						}
						num16 = -1;
						if (typeArray[index].MenuItems[num9].MenuDefaults != null)
						{
							for (num2 = 0; num2 < typeArray[index].MenuItems[num9].MenuDefaults.Length; num2++)
							{
								if (typeArray[index].MenuItems[num9].MenuDefaults[num2] == null)
								{
									num16 = num2;
									break;
								}
							}
						}
						num17 = num18;
					}
					if (num16 >= 0)
					{
						typeArray[index].MenuItems[num9].MenuDefaults[num16] = new MenuDefault(typeArray[index].MenuItems[num9], optionID, choiceID);
						num16++;
					}
				}
				typeArray2 = typeArray;
			}
			catch (Exception)
			{
				typeArray2 = null;
			}
			finally
			{
				if (connection != null)
				{
					connection.Close();
				}
			}
			return typeArray2;
		}