public void Suabd(BangDiem bd) { int i; List <BangDiem> list = bdDA.GetAllData(); for (i = 0; i < list.Count; ++i) { if (list[i].Mahs == bd.Mahs) { break; } } if (i < list.Count) { list.RemoveAt(i); list.Add(bd, i); bdDA.Update(list); } else { throw new Exception(" Du lieu sai "); } }
private void btnLuu_Click(object sender, EventArgs e) { if (status == "Them") { int result = BangDiemBUS.Instance.InsertBangDiem(getBangDiem()); if (result == 1) { MessageBox.Show("Thêm học sinh thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm học sinh không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { BangDiem bd = getBangDiem(); bd.maHS = int.Parse(dgvBangDiem.CurrentRow.Cells["maHS"].Value.ToString()); bd.maMH = int.Parse(dgvBangDiem.CurrentRow.Cells["maMH"].Value.ToString()); int result = BangDiemBUS.Instance.EditBangDiem(bd); if (result == 1) { MessageBox.Show("Sửa học sinh thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Sửa học sinh không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } tool_Disenabled(); btnSua.Enabled = true; btnThem.Enabled = true; btnCapNhat.Enabled = true; btnXoa.Enabled = true; LoadDB(); status = ""; }
private void btSua_Click(object sender, EventArgs e) { BangDiem bangDiem = new BangDiem(); try { bangDiem.MaHocSinh = Convert.ToInt32(lbMaHS.Text); bangDiem.MaMon = this.maMon; bangDiem.HocKi = Convert.ToInt16(tbHocKi.Text); if (checkDiem(tbDMieng.Text) == true) { bangDiem.DiemMieng = Convert.ToDouble(tbDMieng.Text); if (checkDiem(tbD15ph.Text) == true) { bangDiem.Diem15ph = Convert.ToDouble(tbD15ph.Text); if (checkDiem(tbDMotTiet.Text) == true) { bangDiem.Diem1tiet = Convert.ToDouble(tbDMotTiet.Text); if (checkDiem(tbDiemCuoiKi.Text) == true) { bangDiem.DiemCuoiKi = Convert.ToDouble(tbDiemCuoiKi.Text); bangDiem.DiemTB = (bangDiem.Diem15ph + bangDiem.DiemMieng + bangDiem.Diem1tiet * 2 + bangDiem.DiemCuoiKi * 3) / 7.0; bangDiem.DiemTB = Math.Round(bangDiem.DiemTB, 2); BangDiemDAL bangDiemDAl = new BangDiemDAL(); bangDiemDAl.updateBangdiem(bangDiem); dgvHocSinh.DataSource = bangDiemDAl.LoadBangDiemHS(maMon, maLop); } } } } } catch { MessageBox.Show("diem", "Loi"); } }
public bool Them(BangDiem bd) { try { string query = @"INSERT INTO dbo.BangDiem ( MaHS , MaMH , DMieng , D15Phut , D1Tiet , DCuoiKy ) VALUES ( '" + bd.MaHS + "' ,'" + bd.MaMH + "' , '" + bd.DiemMieng + "' ,'" + bd.Diem15Phut + "' ,'" + bd.Diem1Tiet + "' ,'" + bd.DiemCK + "')"; OpenConection(); ExecuteQueries(query); CloseConnection(); return(true); } catch (Exception ex) { SetEx(ex); return(false); } }
private void btnXemTatCa_Click(object sender, EventArgs e) { gridLop.DataSource = BangDiem.SelectDSLop(GlobalSettings.UserID); gridLop_Click(sender, e); }
/// <summary> /// Nạp danh sách học viên của lớp lên giao diện /// </summary> public void LoadDSHVLopChuaDu() { try { string maLop = cboLop.SelectedValue.ToString(); dsLopChuaDu = BangDiem.SelectDSHV(maLop); gridDSHVLop.Rows.Clear(); foreach (var i in dsLopChuaDu) { string[] s = { i.MaHV, i.TenHV, i.NgaySinh.ToString(), i.GioiTinhHV, i.SdtHV, i.DiaChi, BangDiem.Select(i.MaHV, maLop).MaPhieu }; gridDSHVLop.Rows.Add(s); } } catch { gridDSHVLop.Rows.Clear(); } }
private void btnHienTatCa_Click(object sender, EventArgs e) { gridKetQua.DataSource = BangDiem.DanhSachNoHocPhi(); }
private void btOk_Click(object sender, EventArgs e) { if (type == "Them") { if (txtDiemMieng.Text != "" && txtDiem15.Text != "" && txtDiem1.Text != "" && txtDiemHK.Text != "") { BangDiem bd = new BangDiem(cbMaHS.SelectedValue.ToString().Trim(), cbMaMH.SelectedValue.ToString().Trim(), float.Parse(txtDiemMieng.Text.Trim()), float.Parse(txtDiem15.Text.Trim()), float.Parse(txtDiem1.Text.Trim()), float.Parse(txtDiemHK.Text.Trim())); if (dal_bd.Them(bd) == true) { FormatData(); ShowData(); EnableMethod(true); MessageBox.Show("Thêm thành công"); } else { Exception ex = dal_bd.GetEx(); MessageBox.Show(ex.Message); } } else { MessageBox.Show("Bạn cần nhập đủ thông tin phòng ban"); } } else if (type == "Sua") { if (txtDiemMieng.Text != "" && txtDiem15.Text != "" && txtDiem1.Text != "" && txtDiemHK.Text != "") { BangDiem bd = new BangDiem(cbMaHS.SelectedValue.ToString().Trim(), cbMaMH.SelectedValue.ToString().Trim(), float.Parse(txtDiemMieng.Text.Trim()), float.Parse(txtDiem15.Text.Trim()), float.Parse(txtDiem1.Text.Trim()), float.Parse(txtDiemHK.Text.Trim())); if (dal_bd.Sua(bd, maHS, maMH) == true) { FormatData(); ShowData(); MessageBox.Show("Sửa thành công"); EnableMethod(true); } else { Exception ex = dal_bd.GetEx(); MessageBox.Show(ex.Message); } } else { MessageBox.Show("Bạn cần nhập đủ thông tin phòng ban"); } } else if (type == "Xoa") { if (txtDiemMieng.Text != "" && txtDiem15.Text != "" && txtDiem1.Text != "" && txtDiemHK.Text != "") { DialogResult dr = MessageBox.Show("Bạn có muốn xóa khồng?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { dal_bd.Xoa(txtMaHS.Text, txtMaMH.Text); EnableMethod(true); ShowData(); FormatData(); } else { EnabledData(false); EnableMethod(true); } } } }
private void ghiBangDiemVaBaiThi() { GiaoVienDK g = GiaoVienDK.gv_dk; BangDiem bd = new BangDiem(Program.mUserId, g.MaMH, g.Lan, g.NgayThi.ToString(), tongDiem); bd.ghiDiem(); String strlenh = "EXEC SP_TIMBANGDIEM_THI '" + Program.mUserId + "', '" + g.MaMH + "', " + g.Lan; Program.myReader.Close(); Program.myReader = Program.ExecSqlDataReader(strlenh); Program.myReader.Read(); int idBangDiem = Program.myReader.GetInt32(5); Program.myReader.Close(); foreach (CT_BaiThi ct in CT_BaiThi.ct_baiThi) { bdsCT_BAITHI.AddNew(); ((DataRowView)bdsCT_BAITHI[bdsCT_BAITHI.Position])["THUTU"] = ct.getThuTu(); ((DataRowView)bdsCT_BAITHI[bdsCT_BAITHI.Position])["NOIDUNG"] = ct.getNoiDung(); ((DataRowView)bdsCT_BAITHI[bdsCT_BAITHI.Position])["A"] = ct.getA().Trim(); ((DataRowView)bdsCT_BAITHI[bdsCT_BAITHI.Position])["B"] = ct.getB().Trim(); ((DataRowView)bdsCT_BAITHI[bdsCT_BAITHI.Position])["C"] = ct.getC().Trim(); ((DataRowView)bdsCT_BAITHI[bdsCT_BAITHI.Position])["D"] = ct.getD().Trim(); ((DataRowView)bdsCT_BAITHI[bdsCT_BAITHI.Position])["DAPANDUNG"] = ct.getDapAnDung().Trim().ElementAt(0); ((DataRowView)bdsCT_BAITHI[bdsCT_BAITHI.Position])["DAPANDACHON"] = ct.getDapAnDaChon().Length == 0 ? ' ': ct.getDapAnDaChon().ElementAt(0); ((DataRowView)bdsCT_BAITHI[bdsCT_BAITHI.Position])["MA_BAI_THI"] = idBangDiem; ((DataRowView)bdsCT_BAITHI[bdsCT_BAITHI.Position])["CAU_HOI"] = ct.getCauHoi(); bdsCT_BAITHI.EndEdit(); } try { cT_BAITHITableAdapter.Update(this.dS.CHITIETBAITHI); } catch (Exception ex) { MessageBox.Show(ex.Message); } DialogResult dialogResult = MessageBox.Show("Số câu đúng: " + soCauDung + "/" + soCauThi + "\nTổng điểm: " + tongDiem + "\nBạn có muốn xem lại bài thi?", "KẾT QUẢ", MessageBoxButtons.YesNoCancel); if (dialogResult == DialogResult.Yes) { rpXemBaiThi rp = new rpXemBaiThi(idBangDiem); rp.lbHoTen.Text = "HỌ TÊN: " + Program.mHoTen; rp.lbLop.Text = "LỚP: " + Program.tenlop; rp.lbMonHoc.Text = "MÔN THI" + this.lblMONHOC.Text; rp.lbNgayThi.Text = "NGÀY THI: " + lblNGAYTHI.Text; rp.lbLanThi.Text = "LẦN: " + g.Lan; ReportPrintTool print = new ReportPrintTool(rp); print.ShowPreviewDialog(); } else if (dialogResult == DialogResult.No) { } else if (dialogResult == DialogResult.Cancel) { } GiaoVienDK.gv_dk = null; CT_BaiThi.ct_baiThi.Clear(); BoDe.boDe.Clear(); }
public int Insert(BangDiem bangDiem) { _context.BangDiems.Add(bangDiem); _context.SaveChanges(); return(bangDiem.MaBangDiem); }
public void updateBangdiem(BangDiem bd) { string query = string.Format("UPDATE dbo.BANGDIEM SET HOCKY={0}, DIEM15PHUT={1},DIEMMIENG={2},DIEM1TIET={3},DIEMHK={4},DIEMTB={5} WHERE MAHOCSINH={6} AND MAMONHOC={7} ", bd.HocKi, bd.DiemMieng, bd.Diem15ph, bd.Diem1tiet, bd.DiemCuoiKi, bd.DiemTB, bd.MaHocSinh, bd.MaMon); dtConnect.ExecuteNonQuery(query); }