コード例 #1
0
        private void btnXoaGv_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // bắt sự kiện bật tắt nút
            btnXacnhanGv.Enabled  = btnSuaGv.Enabled = btnLuuGv.Enabled =
                btnThemGv.Enabled = false;
            btnXoaGv.Enabled      = false;
            SqlDataReader myReader;
            String        strlenh = "DECLARE	@return_value int EXEC @return_value = [dbo].[CHECK_MAGV_DKI] "+
                                    "@MAGV = N'" + txtMaGv.Text + "' SELECT  'Return Value' = @return_value";

            myReader = Program.ExecSqlDataReader(strlenh);
            if (myReader == null)
            {
                return;
            }
            myReader.Read();
            int value = myReader.GetInt32(0);

            myReader.Close();
            if (value == 1)
            {
                MessageBox.Show("Giảng viên đã tạo câu hỏi. Không thể xóa!");
                btnThemGv.Enabled = btnSuaGv.Enabled = btnXoaGv.Enabled = true;
                return;
            }
            else
            {
                // xóa
                DialogResult dr = MessageBox.Show("Bạn có chắc chắc muốn xóa", "Xóa giảng viên viên", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
                if (dr == DialogResult.Yes)
                {
                    bdsGiaoVien.RemoveCurrent();
                    GiaoVienTableAdapter.Update(tTN_DS.GIAOVIEN);
                    MessageBox.Show("Xóa giảng viên thành công");
                    btnThemGv.Enabled = btnXoaGv.Enabled = btnSuaGv.Enabled = true;
                }
                else
                {
                    GiaoVienGridControl.Enabled = true;

                    if (Program.mGroup == "TRUONG")
                    {
                        btnXacnhanGv.Enabled      = btnSuaGv.Enabled =
                            btnXoaGv.Enabled      = btnLuuGv.Enabled =
                                btnThemGv.Enabled = false; // nhom truong ko duoc them moi 1 sv
                    }
                    else
                    {
                        btnXacnhanGv.Enabled = btnLuuGv.Enabled = false;
                        btnSuaGv.Enabled     = btnXoaGv.Enabled = btnThemGv.Enabled = true;
                    }
                }
            }
        }
コード例 #2
0
 private void btnLuuGv_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     //tắt btn xác nhận
     btnXacnhanGv.Enabled = false;
     btnXnsua.Visible     = false;
     btnXacnhanGv.Visible = true;
     btnHuyboGv.Enabled   = false;
     TrangThaiButton(false);
     TrangThaiButtonKhoa(true);
     btnLuuGv.Enabled                        = false;
     GiaoVienGridControl.Enabled             = btnSuaGv.Enabled
                                             = btnXoaGv.Enabled = btnThemGv.Enabled = true;
     GiaoVienTableAdapter.Update(tTN_DS.GIAOVIEN);
     GiaoVienTableAdapter.Fill(tTN_DS.GIAOVIEN);
     MessageBox.Show("Cập nhật danh sách thành công");
 }