Пример #1
0
        public CategoryListBoxControl(Medicine medicine)
        {
            InitializeComponent();
            List <Category> categories = MedicineHelper.GetCategoryOfTheMedicine(medicine.ID_Medicine);

            foreach (var item in categories)
            {
                if (item != null)
                {
                    checkListBox.Items.Add(item.NameCategory, CheckState.Checked);
                }
            }
            foreach (var item in MedicineHelper.GetAllCategory())
            {
                int check = 1;
                if (item != null)
                {
                    foreach (var x in categories)
                    {
                        if (x.CategoryID.CompareTo(item.CategoryID) == 0)
                        {
                            check = 0;
                            break;
                        }
                    }
                    if (check == 1)
                    {
                        checkListBox.Items.Add(item.NameCategory, CheckState.Unchecked);
                    }
                }
            }
        }
Пример #2
0
        private void ButtonSuaThongTinHang_Click(object sender, EventArgs e)
        {
            int Id;

            try
            {
                Id = int.Parse(ListShow.SelectedItems[0].SubItems[1].Text);
            }
            catch (Exception ex)
            {
                return;
            }
            BoolClass boolClass = new BoolClass();

            boolClass.isChanged = false;
            Medicine medicine1 = null;

            foreach (var medicine in MedicineHelper.GetMedicines())
            {
                if (medicine.ID_Medicine == Id)
                {
                    medicine1               = medicine;
                    medicine1.ID_Category   = new List <int?>();
                    medicine1.Name_Category = new List <string>();
                    foreach (var category in MedicineHelper.GetCategoryOfTheMedicine(medicine.ID_Medicine))
                    {
                        medicine1.ID_Category.Add(category.CategoryID);
                        medicine1.Name_Category.Add(category.NameCategory);
                    }
                    break;
                }
            }
            ChangeInformationMedicine changeInformationMedicine = new ChangeInformationMedicine(medicine1, boolClass);

            changeInformationMedicine.ShowDialog();

            if (boolClass.isChanged == false)
            {
                return;
            }
            else
            {
                MedicineHelper.UpdateMedicine(medicine1, Id);
                MedicineHelper.UpdateCategoryWithMedicine(medicine1);
            }
            ListShow.Items.Clear();
            //button1_Click(PictureBoxDanhMucSanPham, null);
            Init();
            //ComboBoxChonLoai_SelectedValueChanged(ComboBoxChonLoai, null);
            SelectShowList(ListShow, new EventArgsForMedicine {
                Id = Id
            });
        }