Ejemplo n.º 1
0
        private void ViewStudents_Click(object sender, EventArgs e)
        {
            NotiLabel.Text     = "";
            Classes.Enabled    = true;
            Subjects.Enabled   = true;
            EditButton.Enabled = false;
            listViewInfo       = ListViewInfo.Students;

            _Id.Text     = "Student ID";
            _Id.Width    = 150;
            _Name.Text   = "Student name";
            _Name.Width  = 175;
            _Info1.Text  = "Class";
            _Info1.Width = 125;
            _Info2.Text  = "Date of Birth";
            _Info2.Width = 155;
            _Info3.Text  = "Gender";
            _Info3.Width = 125;
            _Info4.Text  = "Identify Card No.";
            _Info4.Width = 150;

            listView.Items.Clear();
            listView.Columns.Clear();
            listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[]
                                      { _No, _Id, _Name, _Info1, _Info2, _Info3, _Info4 });

            try
            {
                StudentServices service = new StudentServices();
                var             Data    = service.GetStudentsFromDB(Classes.SelectedItem.ToString(), Subjects.SelectedItem.ToString());
                BindDataToListView(Data);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (listView.Items.Count == 0)
            {
                NotiLabel.Text = "Nothing is found...";
            }
            listView.View = View.Details;
        }