Пример #1
0
        public void addFoodToGrid(DataRow dr)
        {
            string[] gridViewRow = { "", "", "" };

            DataRow foodTypeRow = TablesUtilities.getFoodTypeFromId(dr.ItemArray[3].ToString(), db.Ds);

            if (foodTypeRow == null)
            {
                return;
            }

            string foodID   = dr.ItemArray[0].ToString().TrimEnd();
            string foodName = dr.ItemArray[1].ToString().TrimEnd();
            string foodType = foodTypeRow.ItemArray[1].ToString().TrimEnd();

            gridViewRow[0] = foodID;
            gridViewRow[1] = foodName;
            gridViewRow[2] = foodType;

            dataGridView1.Rows.Add(gridViewRow);
        }
Пример #2
0
        private void deleteTypeButton_Click(object sender, EventArgs e)
        {
            string id = dataGridView2.SelectedRows[0].Cells[0].Value.ToString();

            if (TablesUtilities.getFoodTypeFromFood(TablesUtilities.getFoodTypeFromId(id, db.Ds), db.Ds).Count != 0)
            {
                DialogResult stopBox = MessageBox.Show("Des produits sont de ce type. Veuillez supprimer ces produits avant de supprimer ce type !", "Opération impossible", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            DialogResult deleteBox = MessageBox.Show("Etes vous sûre de vouloir supprimer le type sélectionnée ? Cela peut entrainer des pertes de données !", "Confirmation de suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (deleteBox == DialogResult.Yes)
            {
                string[] table = { "foodTypes" };

                TablesUtilities.removeFoodTypeByID(id, db.Ds);

                db.Ds.updateDatabase(table);
            }
        }
Пример #3
0
        public void populateDispList()
        {
            objectListView1.Items.Clear();

            List <Food> f = new List <Food>();

            foreach (DataRow food in db.Ds.Dataset.Tables["food"].Rows)
            {
                f.Add(new Food((int)food.ItemArray[0], (string)food.ItemArray[1], (string)(TablesUtilities.getFoodTypeFromId(food.ItemArray[3].ToString(), db.Ds).ItemArray[1]), (int)food.ItemArray[2]));
            }

            objectListView1.AddObjects(f);

            objectListView1.Sort(2);
        }