private void btnXoa_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Chọn câu hỏi muốn xóa"); } else { try { tsbs = new ThiSinhBS(); int kq = tsbs.DeleteCauHoi(label4.Text); if (kq != 0) { MessageBox.Show("Xóa thành công"); ClearAll(); Data(); } else { MessageBox.Show("Không xóa được"); ClearAll(); Data(); } } catch (Exception) { MessageBox.Show("Không xóa được"); } } }
private void comboBox_mon_SelectedIndexChanged(object sender, EventArgs e) { tsbs = new ThiSinhBS(); DataTable dt = tsbs.GetCauHoiNV_Mon(label1.Text, comboBox_mon.SelectedValue.ToString()).Tables[0]; dataGridView1.DataSource = dt; }
public void Data() { tsbs = new ThiSinhBS(); DataTable dt = tsbs.GetCauHoi().Tables[0]; dataGridView1.DataSource = dt; }
private void ThongtinTS_Load(object sender, EventArgs e) { label15.Visible = false; label11.Text = GetStringFromAnotherForm(); label11.Visible = false; DataTable data = tsbs.GetMonThi().Tables[0]; comboBox_monthi.DisplayMember = "TenMon"; comboBox_monthi.ValueMember = "MaMon"; comboBox_monthi.DataSource = data; comboBox_cauhoi.Items.Add("50"); comboBox_cauhoi.Text = "50"; tsbs = new ThiSinhBS(); DataTable dt = new DataTable(); dt = tsbs.GetThiSinh(label11.Text).Tables[0]; //lay thong tin tu form dang nhap sang foreach (DataRow dr in dtData.Rows) { label15.Text = dr[0].ToString(); label8.Text = dr[1].ToString(); label9.Text = dr[3].ToString(); label10.Text = dr[2].ToString(); label7.Text = dr[6].ToString(); label12.Text = dr[7].ToString(); } }
private void button1_Click(object sender, EventArgs e) { tsbs = new ThiSinhBS(); string a = tsbs.KiemTraMon(comboBox_monthi.SelectedValue.ToString()).Tables[0].Rows[0][0].ToString(); int b = Int32.Parse(a.ToString()); if (b < 20) { MessageBox.Show("Hiện tại môn : " + comboBox_monthi.Text + " chưa đủ câu hỏi để tạo đề thi!"); return; } else { Form_THI f = new Form_THI(); f.Getten += delegate { return(label8.Text); }; f.Getngaysinh += delegate { return(label9.Text); }; f.Gettruong += delegate { return(label7.Text); }; f.Getlop += delegate { return(label12.Text); }; f.Getmonthi += delegate { return(comboBox_monthi.Text); }; f.Getsocau += delegate { return(comboBox_cauhoi.Text); }; f.Getmamon += delegate { return(comboBox_monthi.SelectedValue.ToString()); }; f.GetMaTS += delegate { return(label15.Text); }; f.Show(); this.Hide(); } }
private void Form_QLCH_Load(object sender, EventArgs e) { //label1.Text = LayGTri(); label1.Visible = false; label_a.Visible = false; label_b.Visible = false; label_c.Visible = false; label_d.Visible = false; Radio(false); Enl(false); Dataload(); tsbs = new ThiSinhBS(); DataTable dt = tsbs.GetMonThi().Tables[0]; comboBox_mon.DisplayMember = "TenMon"; comboBox_mon.ValueMember = "MaMon"; comboBox_mon.DataSource = dt; ////----Hien thi ma loai cau hoi--- cbbLoaiCauHoi.DisplayMember = "LoaiCauHoi"; cbbLoaiCauHoi.ValueMember = "MaLoaiCauHoi"; cbbLoaiCauHoi.DataSource = tsbs.GetLoaiCauHoi().Tables[0]; }
private void cboMonthi_SelectedIndexChanged(object sender, EventArgs e) { radioButton2.Checked = false; radioButton3.Checked = false; tsbs = new ThiSinhBS(); dataGridView1.DataSource = tsbs.GetKetQuaCSDL(cboMonthi.SelectedValue.ToString()).Tables[0]; }
public void LoadCombo() { tsbs = new ThiSinhBS(); DataTable dt = tsbs.GetMonThi().Tables[0]; comboBox_tenmon.DisplayMember = "TenMon"; comboBox_tenmon.ValueMember = "MaMon"; comboBox_tenmon.DataSource = dt; }
private void btn_dn_Click(object sender, EventArgs e) { if (radioButton_thisinh.Checked == true) { if (textBox_dn.Text == "" || textBox_pa.Text == "") { MessageBox.Show("Nhập đầy đủ thông tin của thí sinh"); textBox_dn.Focus(); } else { tsbs = new ThiSinhBS(); DataTable dt = new DataTable(); dt = tsbs.GetThiSinhDN(textBox_dn.Text, textBox_pa.Text).Tables[0]; if (dt.Rows.Count > 0) { ThongtinTS ts = new ThongtinTS(dt); ts.GetStringFromAnotherForm += delegate { return(textBox_pa.Text); }; ts.Show(); this.Hide(); } else { MessageBox.Show("Tên đăng nhập hoặc mật khẩu không tồn tại"); } } } else { if (textBox_dn.Text == "" || textBox_pa.Text == "") { MessageBox.Show("Nhập đầy đủ thông tin của người quản lý"); textBox_dn.Focus(); } else { nvbs = new GiaoVienBS(); DataTable dt = new DataTable(); dt = nvbs.DangNhapNV(textBox_dn.Text, textBox_pa.Text).Tables[0]; if (dt.Rows.Count > 0) { DataRow dr; dr = dt.Rows[0]; Form_Dieuhanh d = new Form_Dieuhanh(); d.GetStringFromAnotherFormdn += delegate { return(textBox_pa.Text); }; d.GetStringFromAnotherFormdn2 += delegate { return(dr[10].ToString()); }; MySession.strUserName = dr["MaNguoiDung"].ToString(); d.Show(); this.Hide(); } else { MessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng"); } } } }
public void HienthiDA() { tsbs = new ThiSinhBS(); DataTable dt = tsbs.GetDapAn(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()).Tables[0]; richTextBox1.Text = dt.Rows[0][0].ToString(); richTextBox2.Text = dt.Rows[1][0].ToString(); richTextBox3.Text = dt.Rows[2][0].ToString(); richTextBox4.Text = dt.Rows[3][0].ToString(); richTextBox5.Text = tsbs.GetDapAnDung(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()).Tables[0].Rows[0][0].ToString(); }
private void Form_QLCHCS_Load(object sender, EventArgs e) { //label1.Text = Laygt(); label1.Visible = false; tsbs = new ThiSinhBS(); DataTable dt = tsbs.GetMonThi().Tables[0]; comboBox_mon.DisplayMember = "TenMon"; comboBox_mon.ValueMember = "MaMon"; comboBox_mon.DataSource = dt; Data(); }
private void frm_nganhangcauhoi_Load(object sender, EventArgs e) { tsbs = new ThiSinhBS(); DataTable dt = tsbs.GetMonThi().Tables[0]; comboBox_mon.DisplayMember = "TenMon"; comboBox_mon.ValueMember = "MaMon"; comboBox_mon.DataSource = dt; tsbs = new ThiSinhBS(); dataGridView1.DataSource = tsbs.GetCauHoi().Tables[0]; }
private void btnTimKiem_Click(object sender, EventArgs e) { string maTS = txtTimKiem.Text; string tenTs = txtTimKiem.Text; try { tsbs = new ThiSinhBS(); dataGridView1.DataSource = tsbs.TimKiemThiSinh(maTS, tenTs); } catch (Exception ex) { MessageBox.Show("Loi:" + ex.Message); } }
public void HienDA() { tsbs = new ThiSinhBS(); DataTable dt = tsbs.GetDapAn(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()).Tables[0]; textBox2.Text = dt.Rows[0][0].ToString(); textBox3.Text = dt.Rows[1][0].ToString(); textBox4.Text = dt.Rows[2][0].ToString(); textBox5.Text = dt.Rows[3][0].ToString(); textBox2ma.Text = dt.Rows[0][2].ToString(); textBox3ma.Text = dt.Rows[1][2].ToString(); textBox4ma.Text = dt.Rows[2][2].ToString(); textBox5ma.Text = dt.Rows[3][2].ToString(); }
private void btnLuu_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox1ma.Text == "" || textBox2ma.Text == "" || textBox3ma.Text == "" || textBox4ma.Text == "" || textBox5ma.Text == "" || label_a.Text == "") { MessageBox.Show("Nhập đầy đủ! Chọn câu trả lời đúng"); } else { try { tsbs = new ThiSinhBS(); int kq = tsbs.ThemCauHoi(textBox1ma.Text, textBox1.Text, cbbLoaiCauHoi.SelectedValue.ToString(), label1.Text, comboBox_mon.SelectedValue.ToString(), textBox2ma.Text, textBox2.Text, label_a.Text, textBox3ma.Text, textBox3.Text, label_b.Text, textBox4ma.Text, textBox4.Text, label_c.Text, textBox5ma.Text, textBox5.Text, label_d.Text); if (kq == 5) { ClearAll(); Enl(false); Radio(false); radioButton_a.Checked = false; radioButton_b.Checked = false; radioButton_c.Checked = false; radioButton_d.Checked = false; label_a.Text = ""; label_b.Text = ""; label_c.Text = ""; label_d.Text = ""; btnThem.Text = "Thêm câu hỏi"; Dataload(); MessageBox.Show("Thêm thành công"); } else { MessageBox.Show("Thêm thất bại"); ClearAll(); Enl(false); Radio(false); btnThem.Text = "Thêm câu hỏi"; Dataload(); } } catch (Exception ex) { MessageBox.Show("Trùng mã câu hỏi hoặc mã câu trả lời"); } } }
public void HienDA() { try { tsbs = new ThiSinhBS(); DataTable dt = tsbs.GetDapAn(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()).Tables[0]; textBox2.Text = dt.Rows[0][0].ToString(); textBox3.Text = dt.Rows[1][0].ToString(); textBox4.Text = dt.Rows[2][0].ToString(); textBox5.Text = dt.Rows[3][0].ToString(); } catch (Exception ex) { MessageBox.Show("Loi:" + ex.Message); } }
private void btnChinhsua_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Chọn câu hỏi cần sửa"); } else { tsbs = new ThiSinhBS(); int kq = tsbs.UpdateCauHoi(textBox1.Text, label1.Text, txtMaCH.Text, textBox2.Text, txtMaA.Text, textBox3.Text, txtMaB.Text, textBox4.Text, txtMaC.Text, textBox5.Text, txtMaD.Text); if (kq != 0) { MessageBox.Show("Đã cập nhật câu hỏi"); //CAp nhat dap an dung string maCauTraLoi = ""; if (radioButton_a.Checked == true) { maCauTraLoi = txtMaA.Text; } if (radioButton_b.Checked == true) { maCauTraLoi = txtMaB.Text; } if (radioButton_c.Checked == true) { maCauTraLoi = txtMaC.Text; } if (radioButton_d.Checked == true) { maCauTraLoi = txtMaD.Text; } tsbs.UpdateDapAnDung(txtMaCH.Text, maCauTraLoi); Data(); ClearAll(); } else { MessageBox.Show("Cập nhật thất bại"); } } }
public void HienDA() { tsbs = new ThiSinhBS(); DataTable dt = tsbs.GetDapAn(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()).Tables[0]; textBox2.Text = dt.Rows[0][0].ToString(); textBox3.Text = dt.Rows[1][0].ToString(); textBox4.Text = dt.Rows[2][0].ToString(); textBox5.Text = dt.Rows[3][0].ToString(); txtMaA.Text = dt.Rows[0][2].ToString(); txtMaB.Text = dt.Rows[1][2].ToString(); txtMaC.Text = dt.Rows[2][2].ToString(); txtMaD.Text = dt.Rows[3][2].ToString(); //Hien thi ket qua dung len radio radioButton_a.Checked = (dt.Rows[0]["KieuDapAn"].ToString().Trim() == "1"); radioButton_b.Checked = (dt.Rows[1]["KieuDapAn"].ToString().Trim() == "1"); radioButton_c.Checked = (dt.Rows[2]["KieuDapAn"].ToString().Trim() == "1"); radioButton_d.Checked = (dt.Rows[3]["KieuDapAn"].ToString().Trim() == "1"); }
private void HienThiKetQua(string maTS, string maMon, string ngayThi) { ThiSinhBS tsbs = new ThiSinhBS(); DataTable dtData = tsbs.ChiTietBaiThi(maTS, maMon, ngayThi); int x = 0, y = 0; for (int i = 0; i < dtData.Rows.Count; i++) { DataRow row = dtData.Rows[i]; string noiDung = "Câu " + (i + 1) + ": " + row["NoiDung"].ToString(); string DAA = row["DAA"].ToString(); string DAB = row["DAB"].ToString(); string DAC = row["DAC"].ToString(); string DAD = row["DAD"].ToString(); int luaChon = int.Parse(row["LuaChon"].ToString()); int dapAn = int.Parse(row["DapAn"].ToString()); UCBaiThi ucBaiThi = new UCBaiThi(noiDung, DAA, DAB, DAC, DAD, luaChon, dapAn); ucBaiThi.Location = new Point(x, y); ucBaiThi.Width = panelBaiThi.Width - 2; panelBaiThi.Controls.Add(ucBaiThi); y += ucBaiThi.Height; } }
public void KetThuc() { //Lấy GruopBox các đáp án trong GruopBox Đáp án //IEnumerator ie=this.groupBox2.Controls.GetEnumerator(); IEnumerator ie = panelSroll.Controls.GetEnumerator(); int i = 0; int j = 0; GroupBox[] mgroupbox = new GroupBox[sch]; while (ie.MoveNext()) { i++; if (i <= sch) { try { GroupBox r = (GroupBox)ie.Current; mgroupbox[j] = r; j++; } catch { MessageBox.Show("Khong phai groupbox" + i); } } } //Lấy Radiobutton trong GroupBox trả lời int[] mangdapan = new int[sch]; for (int k = 0; k < mgroupbox.Length; k++) { RadioButton[] ra = new RadioButton[4]; IEnumerator ie2 = mgroupbox[k].Controls.GetEnumerator(); i = 0; while (ie2.MoveNext()) { ra[i] = (RadioButton)ie2.Current; i++; } mangdapan[k] = XetRadio(ra); } //Message Box kiểm tra các đáp án được chọn String str = ""; int cdd = 0; for (int y = 0; y < sch; y++) { str += mangdapan[y]; if (mangdapan[y].ToString().Trim() != "0") { cdd++; } } foreach (object s in madapandung) { str1 += s.ToString(); } //MessageBox.Show(str1); double socaudung = Chamdiem(madapandung, mangdapan); double ketqua = (socaudung * diem) / 10; //Thêm kết quả của thí sinh tsbs = new ThiSinhBS(); string maTS = lbMaTS.Text; string maMon = label_mamon.Text; string ngayThi = label_ngaythi.Text; tsbs.ThemKetQua(maTS, ketqua.ToString(), maMon, ngayThi); //---Luu lua chon tung cau hoi cho bai thi--- for (int index = 0; index < sch; index++) { try { string maCH = Array_Mach[index].ToString(); string luaChon = mangdapan[index].ToString(); string dapAn = madapandung[index].ToString(); tsbs.LuuBaiThi(maTS, maCH, maMon, ngayThi, luaChon, dapAn); } catch (Exception ex) { MessageBox.Show("Loi:" + ex.Message); } } //Hiện kết quả Form_KetQua f = new Form_KetQua(); f.GetTen += delegate { return(label_ten.Text); }; f.GetCDD += delegate { return(cdd.ToString()); }; f.GetTS += delegate { return(label_socauhoi.Text); }; f.GetSoCau += delegate { return(socaudung.ToString()); }; f.GetDiem += delegate { return(ketqua.ToString()); }; f.Show(); this.Hide(); }
private void Form_THI_Load(object sender, EventArgs e) { //Khởi động thời gian đếm ngược time = new DateTime(2014, 09, 09, 00, 59, 59, 999); timer1.Interval = 1000; timer1.Start(); //Lấy thông tin thí sinh label_ten.Text = Getten(); label_ngaysinh.Text = Getngaysinh(); label_lop.Text = Getlop(); label_truong.Text = Gettruong(); label_monthi.Text = Getmonthi(); label_socauhoi.Text = Getsocau(); lbMaTS.Text = GetMaTS(); lbMaTS.Visible = false; //Lấy mã môn thi label_mamon.Text = Getmamon(); label_mamon.Visible = false; label_macauhoi.Visible = false; //Hiển thị ngày/tháng/năm hiện hành label_ngaythi.Text = System.DateTime.Now.Day.ToString() + "/" + System.DateTime.Now.Month.ToString() + "/" + System.DateTime.Now.Year.ToString(); //Lấy giá trị câu hỏi if (label_socauhoi.Text == "10") { socauhoi = 10; } else { //socauhoi = 20; socauhoi = 50; } //Lấy câu hỏi và lưu vào mảng-------------------------------------------- tsbs = new ThiSinhBS(); dt = tsbs.RanDom50CauHoi(label_mamon.Text); for (int i = 0; i < socauhoi; i++) { Array_Cauhoi.Add(dt.Rows[i][1].ToString()); Array_Mach.Add(dt.Rows[i][0].ToString()); DataTable dt2 = tsbs.GetDapAn(Array_Mach[i].ToString()).Tables[0]; for (int j = 0; j < 4; j++) { Array_Dapan.Add(dt2.Rows[j][0].ToString()); Array_Kieudapan.Add(dt2.Rows[j][1].ToString()); if (dt2.Rows[j][1].ToString().Trim().Equals("1")) { madapandung.Add(Convert.ToString(j + 1)); } } } //------------------------------------------------------------------------ //Hiển thị câu hỏi đầu tiên Hienthicauhoi(0); //Thông báo //Hiển thị GroupBox HienThiGroupBox(); Label(); string tr = ""; foreach (object o in madapandung) { tr += o.ToString() + ";"; } }
public void LoadSoCH() { tsbs = new ThiSinhBS(); textBox_soch.Text = tsbs.SoCH_Mon(comboBox_tenmon.SelectedValue.ToString()).Tables[0].Rows[0][0].ToString(); }
private void button2_Click(object sender, EventArgs e) { if (button2.Text == "Lưu") { if (textBox_themma.Text == "" || textBox_themmon.Text == "") { MessageBox.Show("Nhập đầy đủ thông tin"); } else { try { tsbs = new ThiSinhBS(); int kq = tsbs.ThemMon(textBox_themma.Text, textBox_themmon.Text); if (kq == 1) { MessageBox.Show("Đã thêm môn: " + textBox_themmon.Text); //LoadFormMin(); button1.Text = "Thêm môn"; button2.Text = "Xóa môn"; textBox_themma.Text = ""; textBox_themmon.Text = ""; } else { MessageBox.Show("Không thể thêm được"); //LoadFormMin(); button1.Text = "Thêm môn"; button2.Text = "Xóa môn"; textBox_themma.Text = ""; textBox_themmon.Text = ""; } } catch (Exception) { MessageBox.Show("Trùng mã môn"); } } } else { if (textBox_mamon.Text == "") { MessageBox.Show("Chọn môn muốn xóa"); } else { if (textBox_soch.Text != "0") { MessageBox.Show("Không thể xóa môn: " + comboBox_tenmon.Text + " Môn này có: " + textBox_soch.Text + " câu hỏi trong ngân hàng câu hỏi"); textBox_mamon.Text = ""; textBox_soch.Text = ""; } else { DialogResult OK; OK = MessageBox.Show("Bạn muốn xóa môn: " + comboBox_tenmon.Text + " Môn này không có câu hỏi nào trong ngân hàng câu hỏi. Bạn chắc chắn muốn xóa!", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (OK == DialogResult.Yes) { tsbs = new ThiSinhBS(); int kq = tsbs.XoaMon_0(comboBox_tenmon.SelectedValue.ToString());; if (kq != 0) { MessageBox.Show("Đã xóa môn: " + comboBox_tenmon.Text); //LoadFormMin(); } } else { //LoadFormMin(); return; } } } } LoadCombo(); }
public ThongtinTS(DataTable dtData) { InitializeComponent(); tsbs = new ThiSinhBS(); this.dtData = dtData; }
private void radioButton3_CheckedChanged(object sender, EventArgs e) { tsbs = new ThiSinhBS(); dataGridView1.DataSource = tsbs.GetKetQuaDiemTN(cboMonthi.SelectedValue.ToString()).Tables[0]; }