Exemple #1
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (MyPublic.tonTaiKhoaChinh("MaLop", txtMalop.Text, "TheoDoiBaiThi"))
     {
         MessageBox.Show("Phải xóa dữ liệu bài thi của lớp trước !");
     }
     else
     {
         DialogResult dongY;
         dongY = MessageBox.Show("Bạn thật sự muốn xóa ?", "Xác Nhận", MessageBoxButtons.YesNo);
         if (dongY == DialogResult.Yes)
         {
             string delete = "Delete LopHoc Where MaLop = @MaLop";
             if (MyPublic.connection.State == ConnectionState.Closed)
             {
                 MyPublic.connection.Open();
             }
             SqlCommand cmdCommand = new SqlCommand(delete, MyPublic.connection);
             cmdCommand.Parameters.AddWithValue("@MaLop", txtMalop.Text);
             cmdCommand.ExecuteNonQuery();
             MyPublic.connection.Close();
             int curRow = dgvLophoc.CurrentRow.Index;
             lop.Tables["LopHoc"].Rows.RemoveAt(curRow);
             GanDuLieu();
         }
     }
     DieuKhienKhiBinhThuong();
 }
Exemple #2
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (MyPublic.tonTaiKhoaChinh("MaMon", cbMonhoc.SelectedValue.ToString(), "MonHoc"))
     {
         MessageBox.Show("Phải xóa dữ liệu môn học này trước !");
     }
     else
     {
         DialogResult dongY;
         dongY = MessageBox.Show("Bạn thật sự muốn xóa ?", "Xác Nhận", MessageBoxButtons.YesNo);
         if (dongY == DialogResult.Yes)
         {
             string delete = "Delete TheoDoiBaiThi Where MaMon = @MaMon And MaLop = @MaLop";
             if (MyPublic.connection.State == ConnectionState.Closed)
             {
                 MyPublic.connection.Open();
             }
             SqlCommand command = new SqlCommand(delete, MyPublic.connection);
             command.Parameters.AddWithValue("@MaMon", cbMonhoc.SelectedValue);
             command.Parameters.AddWithValue("@MaLop", cbLophoc.SelectedValue);
             command.ExecuteNonQuery();
             MyPublic.connection.Close();
             int curRow = dgvBaithitheolop.CurrentRow.Index;
             dsbaithi.Tables["TheoDoiBaiThi"].Rows.RemoveAt(curRow);
             GanDuLieu();
         }
     }
     DieuKhienKhiBinhThuong();
 }
Exemple #3
0
        private void xoaBtn_Click(object sender, EventArgs e)
        {
            int currentRow = dsMHGridView.CurrentRow.Index;

            DialogResult dialog = MessageBox.Show("Bạn có thực sự muốn xóa môn học này không?", "Thông báo", MessageBoxButtons.YesNo);

            if (dialog == DialogResult.No)
            {
                return;
            }

            if (MyPublic.connection.State == ConnectionState.Closed)
            {
                MyPublic.connection.Open();
            }
            if (MyPublic.tonTaiKhoaChinh("MaMon", mamonTextBox.Text, "TheoDoiBaiThi"))
            {
                MessageBox.Show("Bạn phải xóa các bài thi có liên quan tới môn học này trước!", "Thông báo", MessageBoxButtons.OK);
                return;
            }

            string     query   = "DELETE FROM MonHoc WHERE MaMon=@MAMON";
            SqlCommand command = new SqlCommand(query, MyPublic.connection);

            command.Parameters.AddWithValue("@MAMON", dsMonHoc.Rows[currentRow]["MaMon"]);
            command.ExecuteNonQuery();

            dsMonHoc.Rows.RemoveAt(currentRow);
        }
Exemple #4
0
        private void luuBtn_Click(object sender, EventArgs e)
        {
            if (mamonTextBox.Text == "" || tenmonTextBox.Text == "" || tinchiTextBox.Text == "")
            {
                MessageBox.Show("Không được để trống thông tin!", "Thông báo", MessageBoxButtons.OK);
                return;
            }

            int sotinchi;

            if (!int.TryParse(tinchiTextBox.Text, out sotinchi))
            {
                MessageBox.Show("Thông tin không hợp lệ!", "Thông báo", MessageBoxButtons.OK);
                return;
            }

            if (MyPublic.connection.State == ConnectionState.Closed)
            {
                MyPublic.connection.Open();
            }

            string     query;
            SqlCommand command;
            int        currentRow = dsMHGridView.CurrentRow.Index;


            if (MyPublic.tonTaiKhoaChinh("MaMon", mamonTextBox.Text, "MonHoc") && action == "them")
            {
                MessageBox.Show("Môn học đã tồn tại!", "Thông báo", MessageBoxButtons.OK);
                return;
            }

            if (action == "them")
            {
                query   = "INSERT INTO MonHoc VALUES(@MAMON, @TENMON, @SOTINCHI)";
                command = new SqlCommand(query, MyPublic.connection);
                command.Parameters.AddWithValue("@MAMON", mamonTextBox.Text);
                command.Parameters.AddWithValue("@TENMON", tenmonTextBox.Text);
                command.Parameters.AddWithValue("@SOTINCHI", sotinchi);

                dsMonHoc.Rows.Add(mamonTextBox.Text, tenmonTextBox.Text, sotinchi);
            }
            else
            {
                query   = "UPDATE MonHoc SET TenMon=@TENMON, SoTinChi=@SOTINCHI WHERE MaMon=@MAMON";
                command = new SqlCommand(query, MyPublic.connection);
                command.Parameters.AddWithValue("@TENMON", tenmonTextBox.Text);
                command.Parameters.AddWithValue("@SOTINCHI", sotinchi);
                command.Parameters.AddWithValue("@MAMON", mamonTextBox.Text);

                dsMonHoc.Rows[currentRow]["MaMon"]    = mamonTextBox.Text;
                dsMonHoc.Rows[currentRow]["TenMon"]   = tenmonTextBox.Text;
                dsMonHoc.Rows[currentRow]["SoTinChi"] = sotinchi;
            }

            command.ExecuteNonQuery();

            toggleEdit(false);
        }
Exemple #5
0
        private void luuBtn_Click(object sender, EventArgs e)
        {
            if (tenTKTextBox.Text == "" || quyenSDCBBox.SelectedIndex == -1 || maTTCBBox.SelectedIndex == -1)
            {
                MessageBox.Show("Không được để trống thông tin!", "Thông báo", MessageBoxButtons.OK);
                return;
            }

            if (MyPublic.connection.State == ConnectionState.Closed)
            {
                MyPublic.connection.Open();
            }

            string     query;
            SqlCommand command;
            int        currentRow = dsTKGridView.CurrentRow.Index;


            if (MyPublic.tonTaiKhoaChinh("TenTaiKhoan", tenTKTextBox.Text, "NguoiSuDung") && action == "them")
            {
                MessageBox.Show("Tài khoản đã tồn tại!", "Thông báo", MessageBoxButtons.OK);
                return;
            }

            if (action == "them")
            {
                query   = "INSERT INTO NguoiSuDung VALUES(@TAIKHOAN, @MATKHAU, @QUYENSD, @MATT)";
                command = new SqlCommand(query, MyPublic.connection);
                command.Parameters.AddWithValue("@TAIKHOAN", tenTKTextBox.Text);
                command.Parameters.AddWithValue("@QUYENSD", quyenSDCBBox.SelectedValue);
                command.Parameters.AddWithValue("@MATT", maTTCBBox.SelectedValue);
                command.Parameters.AddWithValue("@MATKHAU", showRequirePasswordPrompt());;

                dsNguoiSD.Rows.Add(tenTKTextBox.Text, quyenSDCBBox.SelectedValue, maTTCBBox.SelectedValue);
            }
            else
            {
                query   = "UPDATE NguoiSuDung SET QuyenSD=@QUYENSD, MaTT=@MATT WHERE TenTaiKhoan=@TAIKHOAN";
                command = new SqlCommand(query, MyPublic.connection);
                command.Parameters.AddWithValue("@QUYENSD", quyenSDCBBox.SelectedValue);
                command.Parameters.AddWithValue("@MATT", maTTCBBox.SelectedValue);
                command.Parameters.AddWithValue("@TAIKHOAN", tenTKTextBox.Text);

                dsNguoiSD.Rows[currentRow]["TenTaiKhoan"] = tenTKTextBox.Text;
                dsNguoiSD.Rows[currentRow]["QuyenSD"]     = quyenSDCBBox.SelectedValue;
                dsNguoiSD.Rows[currentRow]["MaTT"]        = maTTCBBox.SelectedValue;
            }

            command.ExecuteNonQuery();

            toggleEdit(false);
        }
Exemple #6
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if ((txtMalop.Text == "") || (txtTenlop.Text == "") || (cbTrungtam.SelectedIndex == -1))
     {
         MessageBox.Show("Lỗi nhập dữ liệu !");
     }
     else
     if ((blnThem) && (MyPublic.tonTaiKhoaChinh(txtMalop.Text, "MaLop", "LopHoc")))
     {
         MessageBox.Show("Mã số lớp này đã có rồi !");
         txtMalop.Focus();
     }
     else
     {
         Luu();
     }
 }