Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Food a = new Food();

            a.nhom = "Tinh bột";
            var x = new EditDetail(a).ShowDialog();

            if (x == DialogResult.OK)
            {
                foods.Add(a);
                SaveJson();


                loadIntoListView();
                listView1.SelectedItems.Clear();

                MessageBox.Show("Thêm thức ăn thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count == 0)
            {
                MessageBox.Show("Hãy chọn thức ăn cần sửa ở bảng!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            Food a = new Food();
            Food b = GetFoodFromListView();

            a.setvaluefromFood(b);
            var x = new EditDetail(a).ShowDialog();

            if (x == DialogResult.OK)
            {
                b.setvaluefromFood(a);
                SaveJson();

                loadIntoListView();
                listView1.SelectedItems.Clear();

                MessageBox.Show("Cập nhật thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }