Example #1
0
        async private void CreateMyListView()
        {
            // Create a new ListView control.

            listView1.Bounds = new Rectangle(new Point(10, 40), new Size(1085, 445));

            // Set the view to show details.
            listView1.View = View.Details;
            // Allow the user to edit item text.
            listView1.LabelEdit = false;
            // Allow the user to rearrange columns.
            listView1.AllowColumnReorder = true;
            // Display check boxes.
            listView1.CheckBoxes = false;
            // Select the item and subitems when selection is made.
            listView1.FullRowSelect = true;
            // Display grid lines.
            listView1.GridLines = true;
            // Sort the items in the list in ascending order.
            listView1.Sorting     = SortOrder.Ascending;
            listView1.MultiSelect = true;

            listView1.Font = new Font("Consolas", 12f);
            ListViewItem food;

            try
            {
                foods = await db.ListFoods(linRestaurant.RestaurantID);

                if (foods != null)
                {
                    for (int i = 0; i < foods.Count; ++i)
                    {
                        food = new ListViewItem(foods[i].Name, i);
                        food.SubItems.Add(foods[i].Price.ToString() + " Ft");
                        food.SubItems.Add(foods[i].Description);
                        food.SubItems.Add(foods[i].Allergens);
                        listView1.Items.Add(food);
                    }
                    //listView1.Columns.Add("UP", -2, HorizontalAlignment.Left);
                    //listView1.Columns.Clear();
                    listView1.Columns.Add("Név", 40, HorizontalAlignment.Center);
                    listView1.Columns.Add("Ár", 40, HorizontalAlignment.Center);
                    listView1.Columns.Add("Leírás", 40, HorizontalAlignment.Center);
                    listView1.Columns.Add("Allergének", 40, HorizontalAlignment.Center);
                    listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                    // Add the ListView to the control collection.
                    this.Controls.Add(listView1);
                    refreshList();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Example #2
0
        async void listFoods(Restaurant clickedRestaurant)
        {
            this.selectedRestaurant = clickedRestaurant;
            try
            {
                listView1.Items.Clear();
                listView1.Columns.Clear();
                foods = await db.ListFoods(clickedRestaurant.RestaurantID);

                ListViewItem etel;
                for (int i = 0; i < foods.Count; ++i)
                {
                    if ((foods[i].StartPeriod == null && foods[i].EndPeriod == null) ||
                        ((0 >= DateTime.Compare(DateTime.Parse(foods[i].StartPeriod), DateTime.Now)) && (0 < DateTime.Compare(DateTime.Parse(foods[i].EndPeriod), DateTime.Now))))
                    {
                        etel = new ListViewItem(foods[i].Name, i);
                        etel.SubItems.Add(foods[i].Category);
                        etel.SubItems.Add(foods[i].Allergens);
                        int discountPrice = (int)(foods[i].Price * (double)(1 - (double)((double)foods[i].Discount / 100)));
                        Debug.WriteLine(1 - (foods[i].Discount / 100));
                        etel.SubItems.Add(discountPrice.ToString());
                        etel.SubItems.Add(foods[i].Description);
                        listView1.Items.Add(etel);
                    }
                }
                listView1.Columns.Add("Név", -1, HorizontalAlignment.Center);
                listView1.Columns.Add("Kategória", -1, HorizontalAlignment.Center);     listView1.Columns[1].Width = listView1.Columns[1].Text.Length * 15;
                listView1.Columns.Add("Allergének", -1, HorizontalAlignment.Center);    listView1.Columns[2].Width = -1;
                listView1.Columns.Add("Ár(Ft)", -1, HorizontalAlignment.Center);        listView1.Columns[3].Width = 100;
                listView1.Columns.Add("Leírás", -1, HorizontalAlignment.Center);        listView1.Columns[4].Width = -1;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Example #3
0
        /*
         * private String GenerateFoodID()
         * {
         *  if (foods != null)
         *  {
         *      if (foods.Count != 0)
         *      {
         *          Boolean found = false;
         *          int i = -1;
         *          while (!found)
         *          {
         *              i++;
         *              found = true;
         *              for (int j = 0; j < foods.Count; j++)
         *              {
         *                  MessageBox.Show("food id: " + foods[j].FoodID + "; i: " + i, "id");
         *                  if (Convert.ToInt32(foods[j].FoodID) == i)
         *                  {
         *                      found = false;
         *                  }
         *              }
         *          }
         *          return Convert.ToString(i);
         *      }
         *      MessageBox.Show("elso nulla", "hiba");
         *      return "0";
         *  } else
         *  {
         *      MessageBox.Show("masodik nulla", "hiba");
         *      return "0";
         *  }
         * }*/

        async private void GetFoods()
        {
            foods = await db.ListFoods(linRestaurant.RestaurantID);
        }