Beispiel #1
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);
                }
            }
        }
Beispiel #2
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)
            {
            }
        }