Ejemplo n.º 1
0
        private void dtgvSinhVien_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
            {
                tx_Name.Text  = dtgvSinhVien.CurrentRow.Cells["HoVaTen"].Value.ToString();
                tx_Email.Text = dtgvSinhVien.CurrentRow.Cells["Email"].Value.ToString();
                tx_MSV.Text   = dtgvSinhVien.CurrentRow.Cells["MaSV"].Value.ToString();
                tx_SĐT.Text   = Convert.ToString(dtgvSinhVien.CurrentRow.Cells["SDT"].Value);
                if (dtgvSinhVien.CurrentRow.Cells["GioiTinh"].Value.ToString() == "Nam")
                {
                    rdb_Nam.Checked = true;
                }
                else
                {
                    rdb_Nu.Checked = true;
                }
                cb_lop.Text       = LopDAO.LoadTenLop((int)dtgvSinhVien.CurrentRow.Cells["MaLop"].Value);
                dtp_NgaySinh.Text = dtgvSinhVien.CurrentRow.Cells["NgaySinh"].Value.ToString();

                if (bt_Edit.Enabled == false)
                {
                    bt_Edit.Enabled = true;
                }
                if (bt_delete.Enabled == false)
                {
                    bt_delete.Enabled = true;
                }
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            List <SinhVien> list_SV = new List <SinhVien>();

            list_SV = SinhVienDAO.TimKiem_MSV(txb_MaSV.Text);
            if (list_SV == null)
            {
                MessageBox.Show("Không có sinh viên nào ");
            }
            else
            {
                btn_TrangSau.Enabled   = false;
                btn_TrangTruoc.Enabled = false;
                pl_cha.Controls.Clear();
                Label Name1 = new Label()
                {
                    Text = "Mã Sinh Viên", Location = new Point(15, 0), AutoSize = true
                };
                Label lbLop1 = new Label()
                {
                    Text = "Họ Và Tên", Location = new Point(150, 0), AutoSize = true
                };
                Label lbMASV1 = new Label()
                {
                    Text = "Tên Lớp", Location = new Point(350, 0), AutoSize = true
                };
                pl_cha.Controls.Add(Name1);
                pl_cha.Controls.Add(lbLop1);
                pl_cha.Controls.Add(lbMASV1);

                int i = 0;
                foreach (SinhVien item in list_SV)
                {
                    CheckBox ckb = new CheckBox()
                    {
                        Text = list_SV[i].MaSV, Location = new Point(10, (i + 1) * 30)
                    };
                    Label Name = new Label()
                    {
                        Text = list_SV[i].HoVaTen, Location = new Point(150, (i + 1) * 30)
                    };
                    Label lbLop = new Label()
                    {
                        Text = LopDAO.LoadTenLop(list_SV[i].MaLop), Location = new Point(350, (i + 1) * 30)
                    };
                    if (check_ListCB(ckb) == true)
                    {
                        listCheckBox.Add(ckb);
                    }
                    pl_cha.Controls.Add(ckb);
                    pl_cha.Controls.Add(Name);
                    pl_cha.Controls.Add(lbLop);
                }
            }
        }
Ejemplo n.º 3
0
        private void UC_SinhVien_Load(object sender, EventArgs e)
        {
            LoadForm();
            DataGridViewColumn clTenLop = new DataGridViewColumn();
            DataGridViewCell   cell     = new DataGridViewTextBoxCell();

            clTenLop.CellTemplate = cell;
            clTenLop.Name         = "TenLop";
            clTenLop.Width        = 200;
            clTenLop.HeaderText   = "Tên Lớp";
            dtgvSinhVien.Columns.Add(clTenLop);
            for (int i = 0; i < SinhVienDAO.LoadDSSinhVien().Count; i++)
            {
                dtgvSinhVien.Rows[i].Cells["TenLop"].Value = LopDAO.LoadTenLop((int)dtgvSinhVien.Rows[i].Cells["MaLop"].Value);
            }
        }
Ejemplo n.º 4
0
        public void LoadForm()
        {
            ListSV = SinhVienDAO.LoadDSSinhVien();
            dtgvSinhVien.DataSource = ListSV;

            dtgvSinhVien.Columns["HoVaTen"].HeaderText  = "Họ và Tên";
            dtgvSinhVien.Columns["NgaySinh"].HeaderText = "Ngày Sinh";
            dtgvSinhVien.Columns["GioiTinh"].HeaderText = "Giới Tính";
            dtgvSinhVien.Columns["SDT"].HeaderText      = "Số điện thoại";
            dtgvSinhVien.Columns["MaLop"].HeaderText    = "Mã Lớp";
            dtgvSinhVien.Columns["HoVaTen"].Width       = 150;
            dtgvSinhVien.Columns["NgaySinh"].Width      = 100;
            dtgvSinhVien.Columns["GioiTinh"].Width      = 100;
            dtgvSinhVien.Columns["SDT"].Width           = 100;
            dtgvSinhVien.Columns["Email"].Width         = 150;
            dtgvSinhVien.Columns["MaLop"].Width         = 50;
            DataGridViewColumn clTenLop = new DataGridViewColumn();
            DataGridViewCell   cell     = new DataGridViewTextBoxCell();

            clTenLop.CellTemplate = cell;
            clTenLop.Name         = "TenLop";

            clTenLop.HeaderText = "Tên Lớp";
            dtgvSinhVien.Columns.Add(clTenLop);
            for (int i = 0; i < dtgvSinhVien.RowCount; i++)
            {
                dtgvSinhVien.Rows[i].Cells["TenLop"].Value = LopDAO.LoadTenLop((int)dtgvSinhVien.Rows[i].Cells["MaLop"].Value);
            }



            // hiển thị cb khoa
            String querry_Khoa = "select * From Khoa";

            cbKhoa.DataSource    = DataProvider.instanse.Executequerry(querry_Khoa);
            cbKhoa.DisplayMember = "TenKhoa";
            cbKhoa.ValueMember   = "MaKhoa";
            cb_lop.DataSource    = LopDAO.LoadDSLop();
            cb_lop.DisplayMember = "TenLop";
            cb_lop.ValueMember   = "MaLop";
            // ẩn các lab thông báo
            lb_ThongBao6.Hide(); lb_ThongBao1.Hide();
            lb_ThongBao2.Hide(); lb_ThongBao4.Hide();
            lb_ThongBao3.Hide(); lb_ThongBao5.Hide();
        }
Ejemplo n.º 5
0
 public void LoadDS()
 {
     if (list.Count <= 10)
     {
         Label Name1 = new Label()
         {
             Text = "Mã Sinh Viên", Location = new Point(15, 0), AutoSize = true
         };
         Label lbLop1 = new Label()
         {
             Text = "Họ Và Tên", Location = new Point(150, 0), AutoSize = true
         };
         Label lbMASV1 = new Label()
         {
             Text = "Tên Lớp", Location = new Point(350, 0), AutoSize = true
         };
         pl_cha.Controls.Add(Name1);
         pl_cha.Controls.Add(lbLop1);
         pl_cha.Controls.Add(lbMASV1);
         for (i = 0; i < list.Count; i++)
         {
             CheckBox ckb = new CheckBox()
             {
                 Name = "ckb" + i.ToString(), Text = list[i].MaSV, Location = new Point(10, (i + 1) * 30), AutoSize = true
             };
             Label Name = new Label()
             {
                 Text = list[i].HoVaTen, Location = new Point(150, (i + 1) * 30), AutoSize = true
             };
             Label lbLop = new Label()
             {
                 Text = LopDAO.LoadTenLop(list[i].MaLop), Location = new Point(350, (i + 1) * 30), AutoSize = true
             };
             listCheckBox.Add(ckb);
             pl_cha.Controls.Add(ckb);
             pl_cha.Controls.Add(Name);
             pl_cha.Controls.Add(lbLop);
         }
     }
     else
     {
         Label Name1 = new Label()
         {
             Text = "Mã Sinh Viên", Location = new Point(15, 0), AutoSize = true
         };
         Label lbLop1 = new Label()
         {
             Text = "Họ Và Tên", Location = new Point(150, 0), AutoSize = true
         };
         Label lbMASV1 = new Label()
         {
             Text = "Tên Lớp", Location = new Point(350, 0), AutoSize = true
         };
         pl_cha.Controls.Add(Name1);
         pl_cha.Controls.Add(lbLop1);
         pl_cha.Controls.Add(lbMASV1);
         for (i = 0; i < 10; i++)
         {
             CheckBox ckb = new CheckBox()
             {
                 Name = "ckb" + i.ToString(), Text = list[i].MaSV, Location = new Point(10, (i + 1) * 30), AutoSize = true
             };
             Label Name = new Label()
             {
                 Text = list[i].HoVaTen, Location = new Point(150, (i + 1) * 30), AutoSize = true
             };
             Label lbLop = new Label()
             {
                 Text = LopDAO.LoadTenLop(list[i].MaLop), Location = new Point(350, (i + 1) * 30), AutoSize = true
             };
             listCheckBox.Add(ckb);
             pl_cha.Controls.Add(ckb);
             pl_cha.Controls.Add(Name);
             pl_cha.Controls.Add(lbLop);
         }
     }
 }
Ejemplo n.º 6
0
        private void btn_TrangSau_Click(object sender, EventArgs e)
        {
            int stt = 0;

            if (list.Count / 10 == 0)
            {
                MessageBox.Show("Bạn đang ở trang cuối", "Thông báo");
            }
            else
            {
                if (trang == (list.Count / 10) + 1 && trang != 1)
                {
                    MessageBox.Show("Bạn đang ở trang cuối", "Thông báo");
                }
                else
                {
                    pl_cha.Controls.Clear();
                    trang++;
                    lb_Trang.Text = "Trang" + trang;
                    Label Name1 = new Label()
                    {
                        Text = "Mã Sinh Viên", Location = new Point(15, 0), AutoSize = true
                    };
                    Label lbLop1 = new Label()
                    {
                        Text = "Họ Và Tên", Location = new Point(150, 0), AutoSize = true
                    };
                    Label lbMASV1 = new Label()
                    {
                        Text = "Tên Lớp", Location = new Point(350, 0), AutoSize = true
                    };
                    pl_cha.Controls.Add(Name1);
                    pl_cha.Controls.Add(lbLop1);
                    pl_cha.Controls.Add(lbMASV1);
                    if (i + 10 > list.Count)
                    {
                        int j = i;
                        for (j = i; j < list.Count; j++)
                        {
                            CheckBox ckb = new CheckBox()
                            {
                                Name = "ckb" + j.ToString(), Text = list[j].MaSV, Location = new Point(10, (stt + 1) * 30), AutoSize = true
                            };
                            Label Name = new Label()
                            {
                                Text = list[j].HoVaTen, Location = new Point(150, (stt + 1) * 30), AutoSize = true
                            };
                            Label lbLop = new Label()
                            {
                                Text = LopDAO.LoadTenLop(list[j].MaLop), Location = new Point(350, (stt + 1) * 30), AutoSize = true
                            };
                            if (check_ListCB(ckb) == true)
                            {
                                listCheckBox.Add(ckb);
                            }
                            pl_cha.Controls.Add(ckb);
                            pl_cha.Controls.Add(Name);
                            pl_cha.Controls.Add(lbLop);
                            stt++;
                        }
                        i = j;
                    }
                    else
                    {
                        int j = i;
                        for (j = i; j < i + 10; j++)
                        {
                            CheckBox ckb = new CheckBox()
                            {
                                Name = "ckb" + j.ToString(), Text = list[j].MaSV, Location = new Point(10, (stt + 1) * 30)
                            };
                            Label Name = new Label()
                            {
                                Text = list[j].HoVaTen, Location = new Point(150, (stt + 1) * 30)
                            };
                            Label lbLop = new Label()
                            {
                                Text = LopDAO.LoadTenLop(list[j].MaLop), Location = new Point(350, (stt + 1) * 30)
                            };
                            if (check_ListCB(ckb) == true)
                            {
                                listCheckBox.Add(ckb);
                            }
                            pl_cha.Controls.Add(ckb);
                            pl_cha.Controls.Add(Name);
                            pl_cha.Controls.Add(lbLop);
                            stt++;
                        }
                        i = j;
                    }
                }
            }
        }