Exemplo n.º 1
0
        private void dataGridViewQLDiemDanh_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridViewQLDiemDanh.CurrentCell is DataGridViewCheckBoxCell)
            {
                // Save the changes by passing checkBoxState and keyValue accordingly
                string sql;
                int    keyValue;

                if (Convert.ToBoolean(dataGridViewQLDiemDanh.CurrentCell.Value) == true)
                {
                    keyValue = 0;
                }
                else
                {
                    keyValue = 1;
                }
                List <CustomParameter> lstPara = new List <CustomParameter>();

                sql = "UpdateDD";
                lstPara.Add(new CustomParameter()
                {
                    key   = "@MaBH",
                    value = dataGridViewQLDiemDanh.CurrentRow.Cells["MaBH"].Value.ToString()
                });


                lstPara.Add(new CustomParameter()
                {
                    key   = "@MaHV",
                    value = dataGridViewQLDiemDanh.CurrentRow.Cells["MaHV"].Value.ToString()
                });


                lstPara.Add(new CustomParameter()
                {
                    key   = "@CoTrenLop",
                    value = keyValue.ToString()
                });

                Console.WriteLine(lstPara);

                var rs = new CSDL().ExeCute(sql, lstPara);
                if (rs == 1)
                {
                    MessageBox.Show("Cập nhật thành công");
                    this.buttonLoad.PerformClick();
                }
                else
                {
                    MessageBox.Show("Thao tác không thành công");
                }
            }
        }
Exemplo n.º 2
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            var db = new CSDL();

            if (MessageBox.Show("Bạn muốn xóa lớp học " + dataGridViewDanhSachLop.CurrentRow.Cells["TenLH"].Value.ToString() + " ?", "Warning!!!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                var tenLH = dataGridViewDanhSachLop.CurrentRow.Cells["TenLH"].Value.ToString();
                var idLH  = dataGridViewDanhSachLop.CurrentRow.Cells["MaLH"].Value.ToString();
                db.deleteLH(idLH);
                MessageBox.Show("Đã xóa lớp học : " + tenLH);
            }
            reload();
        }
Exemplo n.º 3
0
        private void FormQLDD_Load(object sender, EventArgs e)
        {
            CSDL      csdl       = new CSDL();
            string    getAllMaLH = "SELECT MaLH FROM LOPHOC";
            DataTable maLHTable  = csdl.SelectData(getAllMaLH);

            comboBoxChonLop.DataSource    = maLHTable.Copy();
            comboBoxChonLop.DisplayMember = "MaLH";
            comboBoxChonLop.ValueMember   = "MaLH";

            comboBoxChonLop.SelectedIndex   = 7;
            comboBoxChonThang.SelectedIndex = 8;
        }
Exemplo n.º 4
0
        private void FormThemLopHoc_Load(object sender, EventArgs e)
        {
            CSDL csdl = new CSDL();
            // ma MHP
            string    getAllMaMHP = "SELECT MaMHP FROM MUCHOCPHI";
            DataTable maMHPTable  = csdl.SelectData(getAllMaMHP);

            comboBoxMaMHP.DataSource    = maMHPTable.Copy();
            comboBoxMaMHP.DisplayMember = "MaMHP";
            comboBoxMaMHP.ValueMember   = "MaMHP";
            //ma mon học
            string    getAllMaMH = "SELECT MaMH FROM MONHOC";
            DataTable maMHTable  = csdl.SelectData(getAllMaMH);

            comboBoxMaMonHoc.DataSource    = maMHTable.Copy();
            comboBoxMaMonHoc.DisplayMember = "MaMH";
            comboBoxMaMonHoc.ValueMember   = "MaMH";
            // mã giáo viên
            string    getAllMaGV = "SELECT MaGV FROM GIAOVIEN";
            DataTable maGVTable  = csdl.SelectData(getAllMaGV);

            comboBoxMaGiaoVien.DataSource    = maGVTable.Copy();
            comboBoxMaGiaoVien.DisplayMember = "MaGV";
            comboBoxMaGiaoVien.ValueMember   = "MaGV";
            if (string.IsNullOrEmpty(malh))
            {
                this.Text = "Thêm mới lớp học";
            }
            else
            {
                this.Text = "Cập nhật thông tin lớp học";

                var r = new CSDL().Select(string.Format("searchMaLop '" + malh + "'"));

                textBoxMaLop.Text     = r["MaLH"].ToString();
                textBoxMaLop.ReadOnly = true;
                textBoxTenLop.Text    = r["TenLH"].ToString();

                string maMucHocPhi = r["MaMHP"].ToString();
                Console.WriteLine(maMucHocPhi);
                comboBoxMaMHP.SelectedValue = maMucHocPhi;
                string maMonHoc = r["MaMH"].ToString();
                comboBoxMaMHP.SelectedValue = maMonHoc;
                string maGiaoVien = r["MaGV"].ToString();
                comboBoxMaMHP.SelectedValue = maGiaoVien;
            }
        }
Exemplo n.º 5
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBox1.Text))
     {
         MessageBox.Show("Bạn chưa nhập thông tin tìm kiếm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         if (comboBoxSearch.SelectedIndex != -1)
         {
             String valueSearch = textBox1.Text;
             var    db          = new CSDL();
             String sqlSearch   = "";
             if (comboBoxSearch.SelectedIndex == 0)
             {
                 sqlSearch = "exec searchMaLop '" + valueSearch + "'";
                 if (db.SelectData(sqlSearch).Rows.Count != 0)
                 {
                     new SearchOutLH(sqlSearch).Show();
                 }
                 else
                 {
                     MessageBox.Show("Không tìm thấy thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
             else if (comboBoxSearch.SelectedIndex == 1)
             {
                 sqlSearch = "exec searchTenLop N'" + valueSearch + "'";
                 if (db.SelectData(sqlSearch).Rows.Count != 0)
                 {
                     new SearchOutLH(sqlSearch).Show();
                 }
                 else
                 {
                     MessageBox.Show("Không tìm thấy thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
         resetValue();
     }
 }
Exemplo n.º 6
0
        private void buttonLuu_Click(object sender, EventArgs e)
        {
            string sql;
            string MaLH  = textBoxMaLop.Text;
            string TenLH = textBoxTenLop.Text;
            string MaMHP = comboBoxMaMHP.Text;
            string MaMH  = comboBoxMaMonHoc.Text;
            string MaGV  = comboBoxMaGiaoVien.Text;

            List <CustomParameter> lstPara = new List <CustomParameter>();

            if (textBoxMaLop.ReadOnly != true)
            {
                sql = "ThemMoiLH";
                lstPara.Add(new CustomParameter()
                {
                    key   = "@MaLH",
                    value = MaLH
                });
            }
            else
            {
                sql = "UpdateLH";
                lstPara.Add(new CustomParameter()
                {
                    key   = "@MaLH",
                    value = malh
                });
            }

            lstPara.Add(new CustomParameter()
            {
                key   = "@TenLH",
                value = TenLH
            });

            lstPara.Add(new CustomParameter()
            {
                key   = "@MaMHP",
                value = MaMHP
            });

            lstPara.Add(new CustomParameter()
            {
                key   = "@MaMH",
                value = MaMH
            });

            lstPara.Add(new CustomParameter()
            {
                key   = "@MaGV",
                value = MaGV
            });


            var rs = new CSDL().ExeCute(sql, lstPara);

            if (rs == 1)
            {
                if (textBoxMaLop.ReadOnly != true)
                {
                    MessageBox.Show("Thêm mới thành công");
                }
                else
                {
                    MessageBox.Show("Cập nhật thành công");
                }
                this.Dispose();
            }
            else
            {
                MessageBox.Show("Thao tác không thành công");
            }
        }