Exemplo n.º 1
0
        public void Init()
        {
            foreach (ColumnHeader column in ListShow.Columns)
            {
                column.Width = -2;
            }
            ListShow.Items.Clear();
            List <Medicine> medicines = MedicineHelper.GetMedicines();
            int             i         = 0;

            foreach (var item in medicines)
            {
                i++;
                ListViewItem listViewItem = new ListViewItem(new string[] { i.ToString(), item.ID_Medicine.ToString(),
                                                                            item.Name_Medicine,
                                                                            item.Remain_Amount.ToString(),
                                                                            item.Min_Expiry.Value.ToShortDateString() + " - " + item.Max_Expiry.Value.ToShortDateString() });
                ListShow.Items.Add(listViewItem);
            }
            ContextMenuStrip  contextMenuStripListShow = new ContextMenuStrip();
            ToolStripMenuItem itemXoa = new ToolStripMenuItem();

            itemXoa.Name   = "XoaSanPham";
            itemXoa.Text   = "Xóa Sản Phẩm";
            itemXoa.Click += ItemXoa_Click;
            contextMenuStripListShow.Items.Add(itemXoa);
            ListShow.ContextMenuStrip = contextMenuStripListShow;
            InitComboBoxCategory(ComboBoxChonLoai);
        }
Exemplo n.º 2
0
        //0, 2
        private void button1_Click(object sender, EventArgs e)
        {
            GUI_Admin.listIsShow          = true;
            panelDanhSachNhanVien.Visible = false;
            PanelSanPham.Visible          = true;
            PanelSanPham.BringToFront();
            ListShow.Items.Clear();
            List <Medicine> medicines = MedicineHelper.GetMedicines();
            int             i         = 0;

            foreach (var item in medicines)
            {
                ListViewItem listViewItem = new ListViewItem(new string[] { i.ToString(), item.ID_Medicine.ToString(),
                                                                            item.Name_Medicine,
                                                                            item.Remain_Amount.ToString(),
                                                                            item.Expiry_Date.ToString() });
                ListShow.Items.Add(listViewItem);
                i++;
            }
            ContextMenuStrip  contextMenuStripListShow = new ContextMenuStrip();
            ToolStripMenuItem itemXoa = new ToolStripMenuItem();

            itemXoa.Name   = "XoaSanPham";
            itemXoa.Text   = "Xóa Sản Phẩm";
            itemXoa.Click += ItemXoa_Click;
            contextMenuStripListShow.Items.Add(itemXoa);
            ListShow.ContextMenuStrip = contextMenuStripListShow;
        }
Exemplo n.º 3
0
        private void ButtonThemVaoDanhSach_Click(object sender, EventArgs e)
        {
            Medicine  medicine;
            BoolClass boolClass = new BoolClass()
            {
                isChanged = false
            };
            ThemSanPhamForm themSanPhamForm = new ThemSanPhamForm(boolClass);

            themSanPhamForm.ShowDialog();
            if (boolClass.isChanged == true)
            {
                ListShow.Items.Clear();
                List <Medicine> medicines = MedicineHelper.GetMedicines();
                int             i         = 0;
                foreach (var item in medicines)
                {
                    ListViewItem listViewItem = new ListViewItem(new string[] { i.ToString(), item.ID_Medicine.ToString(),
                                                                                item.Name_Medicine,
                                                                                item.Remain_Amount.ToString(),
                                                                                item.Expiry_Date.ToString() });
                    ListShow.Items.Add(listViewItem);
                    i++;
                }
            }
            ShowMedicines.InitComboBoxCategory(ComboBoxChonLoai);
        }
Exemplo n.º 4
0
        public NhapHang()
        {
            InitializeComponent();
            InitilizeManufaturerComboBox();
            ShowMedicines.InitComboBoxCategory(ComboBoxChonLoai);
            ListNhapHang.Columns[ListNhapHang.Columns.Count - 1].Width = 0;
            ListShow.Items.Clear();
            List <Medicine> medicines = MedicineHelper.GetMedicines();
            int             i         = 0;

            foreach (var item in medicines)
            {
                ListViewItem listViewItem = new ListViewItem(new string[] { i.ToString(), item.ID_Medicine.ToString(),
                                                                            item.Name_Medicine,
                                                                            item.Remain_Amount.ToString(),
                                                                            item.Expiry_Date.ToString() });
                ListShow.Items.Add(listViewItem);
                i++;
            }
            ContextMenuStrip  contextMenuStripListShow = new ContextMenuStrip();
            ToolStripMenuItem itemXoa = new ToolStripMenuItem();

            itemXoa.Name   = "XoaSanPham";
            itemXoa.Text   = "Xóa Sản Phẩm";
            itemXoa.Click += ItemXoa_Click;
            contextMenuStripListShow.Items.Add(itemXoa);
            ListNhapHang.ContextMenuStrip = contextMenuStripListShow;
        }
Exemplo n.º 5
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
            });
        }
Exemplo n.º 6
0
        private void ComboBoxChonLoai_SelectedValueChanged(object sender, EventArgs e)
        {
            if (GUI_Admin.listIsShow)
            {
                try
                {
                    int idCategory = 0;
                    idCategory = (ComboBoxChonLoai.SelectedItem as DataRowView).Row.Field <int>("ID_Category");
                    ListShow.Items.Clear();

                    using (SqlConnection sqlConnection = new SqlConnection(Form1.connect))
                    {
                        if (idCategory > 0)
                        {
                            int             i         = 0;
                            List <Medicine> medicines = MedicineHelper.GetMedicinesWithCategory(idCategory);
                            foreach (var item in medicines)
                            {
                                ListViewItem listViewItem = new ListViewItem(new string[] { i.ToString(), item.ID_Medicine.ToString(),
                                                                                            item.Name_Medicine,
                                                                                            item.Remain_Amount.ToString(),
                                                                                            item.Expiry_Date.ToString() });
                                ListShow.Items.Add(listViewItem);
                                i++;
                            }
                        }
                        else
                        {
                            List <Medicine> medicines = MedicineHelper.GetMedicines();
                            int             i         = 0;
                            foreach (var item in medicines)
                            {
                                ListViewItem listViewItem = new ListViewItem(new string[] { i.ToString(), item.ID_Medicine.ToString(),
                                                                                            item.Name_Medicine,
                                                                                            item.Remain_Amount.ToString(),
                                                                                            item.Expiry_Date.ToString() });
                                ListShow.Items.Add(listViewItem);
                                i++;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.ToString());
                    Debug.WriteLine(ex.StackTrace);
                }
            }
        }
Exemplo n.º 7
0
        private void ComboBoxChonLoai_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                int idCategory = 0;
                idCategory = (ComboBoxChonLoai.SelectedItem as ComboBoxItem).Value;
                ListShow.Items.Clear();

                using (SqlConnection sqlConnection = new SqlConnection(Form1.connect))
                {
                    if (idCategory > 0)
                    {
                        int             i         = 0;
                        List <Medicine> medicines = MedicineHelper.GetMedicinesWithCategory(idCategory);
                        foreach (var item in medicines)
                        {
                            ListViewItem listViewItem = new ListViewItem(new string[] { i.ToString(), item.ID_Medicine.ToString(),
                                                                                        item.Name_Medicine,
                                                                                        item.Remain_Amount.ToString(),
                                                                                        item.Min_Expiry.Value.ToShortDateString() + " - " + item.Max_Expiry.Value.ToShortDateString() });
                            ListShow.Items.Add(listViewItem);
                            i++;
                        }
                    }
                    else
                    {
                        List <Medicine> medicines = MedicineHelper.GetMedicines();
                        int             i         = 0;
                        foreach (var item in medicines)
                        {
                            ListViewItem listViewItem = new ListViewItem(new string[] { i.ToString(), item.ID_Medicine.ToString(),
                                                                                        item.Name_Medicine,
                                                                                        item.Remain_Amount.ToString(),
                                                                                        item.Min_Expiry.Value.ToShortDateString() + " - " + item.Max_Expiry.Value.ToShortDateString() });
                            ListShow.Items.Add(listViewItem);
                            i++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 8
0
        private void ListShow_SelectedIndexChanged(object sender, EventArgs e)
        {
            int Id;

            try
            {
                if (ListShow.SelectedItems.Count > 0)
                {
                    Id = int.Parse(ListShow.SelectedItems[0].SubItems[1].Text);
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                if (e is EventArgsForMedicine)
                {
                    Id = ((EventArgsForMedicine)e).Id;
                }
                else
                {
                    return;
                }
            }
            Medicine medicine1 = new Medicine();

            foreach (var medicine in MedicineHelper.GetMedicines())
            {
                if (medicine.ID_Medicine == Id)
                {
                    medicine1 = medicine;
                    break;
                }
            }

            if (medicine1.Remain_Amount != null)
            {
                TextBoxSoLuongCon.Text = medicine1.Remain_Amount.Value.ToString();
            }
            TextBoxXuatXu.Text   = medicine1.Source;
            textBoxTienNhap.Text = medicine1.Cost.ToString();
        }
Exemplo n.º 9
0
        private void TextBoxTimKiem_TextChanged(object sender, EventArgs e)
        {
            ListShow.Items.Clear();
            List <Medicine> medicines = MedicineHelper.GetMedicines();
            int             i         = 0;

            foreach (var item in medicines)
            {
                ListViewItem listViewItem = new ListViewItem(new string[] { i.ToString(), item.ID_Medicine.ToString(),
                                                                            item.Name_Medicine,
                                                                            item.Remain_Amount.ToString(),
                                                                            item.Min_Expiry.Value.ToShortDateString() + " - " + item.Max_Expiry.Value.ToShortDateString() });
                ListShow.Items.Add(listViewItem);
            }
            foreach (ListViewItem item in ListShow.Items)
            {
                if (!item.SubItems[2].Text.ToLower().Contains(TextBoxTimKiem.Text.ToLower()))
                {
                    ListShow.Items.Remove(item);
                }
            }
        }