private bool setTotNghiepAndXepLoai(HocVienLopHocDTO hl) { bool totNghiep = false; string xepLoai = "Không xếp loại"; if (hl.PointFinal >= 7) { totNghiep = true; } double diemTB = (((hl.Point1 + hl.Point2) / 2) + hl.PointFinal) / 3; if (diemTB >= 5 && diemTB <= 7) { xepLoai = "Trung bình"; } else if (diemTB < 8.5) { xepLoai = "Khá"; } else { xepLoai = "Giỏi"; } hl.Graduating = totNghiep; hl.Rank = xepLoai; return(HocVienLopHocBLL.Instance.setGraduatAndRank(hl)); }
public bool setGraduatAndRank(HocVienLopHocDTO hl) { conn.Open(); try { string sql = "update hocvien_lophoc set xet_tot_nghiep = @tn, xeploai = @xl where id_HV = @idhv and id_LH = @idlh"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("idhv", hl.StudentId); cmd.Parameters.AddWithValue("idlh", hl.ClassId); cmd.Parameters.AddWithValue("tn", hl.Graduating); cmd.Parameters.AddWithValue("xl", hl.Rank); int rowEffect = cmd.ExecuteNonQuery(); Console.WriteLine(rowEffect); conn.Close(); if (rowEffect == 0) { return(false); } } catch (Exception e) { Console.WriteLine(e.Message); conn.Close(); return(false); } return(true); }
private bool setTotNghiepAndXepLoai(HocVienLopHocDTO hl) { bool totNghiep = false; string xepLoai = "Không xếp loại"; if (hl.PointFinal >= 5) { totNghiep = true; } if (totNghiep == true) { double diemTB = double.Parse(hl.getDTB()); if (diemTB >= 5 && diemTB <= 7) { xepLoai = "Trung bình"; } else if (diemTB < 8.5) { xepLoai = "Khá"; } else { xepLoai = "Giỏi"; } } hl.Rank = xepLoai; hl.Graduating = totNghiep; return(HocVienLopHocBLL.Instance.setGraduatAndRank(hl)); }
public void insertHV_LH(HocVienLopHocDTO hvlh) { conn.Open(); string query = "insert into HOCVIEN_LOPHOC" + "(id_LH, id_HV, diem_1, diem_2, danhgia, diem_do_an, xet_tot_nghiep, xeploai, ghichu_HVLH) values" + "(@id_LH, @id_HV, @diem1, @diem2, @danhgia, @diemdoan, @xtn, @xl, @ghichu_HVLH)"; SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("id_LH", hvlh.ClassId); cmd.Parameters.AddWithValue("id_HV", hvlh.StudentId); cmd.Parameters.AddWithValue("diem1", -1); cmd.Parameters.AddWithValue("diem2", -1); cmd.Parameters.AddWithValue("danhgia", 0); cmd.Parameters.AddWithValue("diemdoan", -1); cmd.Parameters.AddWithValue("xtn", 0); cmd.Parameters.AddWithValue("xl", "Không xếp loại"); cmd.Parameters.AddWithValue("ghichu_HVLH", ""); try { cmd.ExecuteNonQuery(); } catch (SqlException ee) { conn.Close(); throw ee; } conn.Close(); }
public void addHV_LH(List <HocVienLopHocDTO> lstHVLH, LopHocDTO currentLopHoc, string maHV) { string maLop = currentLopHoc.id_LH; if (maLop != null && maHV != null && maLop.Trim() != "" && maHV.Trim() != "") { if (findHocVienInDSHV(lstHVLH, maHV) == null && lstHVLH.Count < currentLopHoc.sucChua) { HocVienLopHocDTO hvlh = new HocVienLopHocDTO(); HocPhiDTO hp = new HocPhiDTO(); hp.ClassId = maLop; hp.StudentId = maHV; hvlh.StudentId = maHV; hvlh.ClassId = maLop; hocVienLopHocDAL.insertHV_LH(hvlh); HocPhiBLL.Instance.insertHocVien(hp); } else if (lstHVLH.Count >= currentLopHoc.sucChua) { hienThongBao("Lớp học đã đầy!"); } else { hienThongBao("Học viên này đã có trong lớp!"); } } else { hienThongBao("Bạn chưa chọn học viên nào!"); } }
public DiemDialog_nhapDiem(bool d1, bool d2, bool dfinal, HocVienLopHocDTO h) { InitializeComponent(); diem1 = d1; diem2 = d2; diemfinal = dfinal; hl = h; }
private void Bt_xacNhanDiem_Click(object sender, EventArgs e) { string point = cb_chonDiem.Text; int pointType = 0; if (point == "Điểm 1") { pointType = 1; } else if (point == "Điểm 2") { pointType = 2; } else if (point == "Điểm đồ án") { pointType = 3; } int i = 0; foreach (DataGridViewRow r in dgv_Diem.Rows) { HocVienLopHocDTO hl = getHVLHfromGridRowIndex(i); if (pointType == 1 && (r.Cells["diem_do_an"].Value.ToString() == "" || r.Cells["diem_do_an"].Value.ToString() == "------") || pointType == 2 && (r.Cells["diem_do_an"].Value.ToString() == "" || r.Cells["diem_do_an"].Value.ToString() == "------") || pointType == 3 && r.Cells["danhgia"].Value.ToString() == "Đạt") { if (HocVienLopHocBLL.Instance.setPoint(hl, pointType)) { if (pointType == 1 || pointType == 2) { if (r.Cells["diem_1"].Value != null && r.Cells["diem_2"].Value != null && r.Cells["diem_1"].Value.ToString() != "" && r.Cells["diem_2"].Value.ToString() != "") { setRate(hl); } else if ((r.Cells["diem_1"].Value == null || r.Cells["diem_2"].Value == null) && r.Cells["danhgia"].Value.ToString() != "Chưa đánh giá") { Console.WriteLine("d1d2 rong. rate khac chuadanhgia"); setRate(hl); } } else if (pointType == 3) { setTotNghiepAndXepLoai(hl); } } } i++; } reloadControl(); ChangeCollumnColorActive(); hienThiGrid(); cellVisiable(); thongKe(); }
private bool setRate(HocVienLopHocDTO hl) { bool rate = false; if (hl.Point1 >= 5 && hl.Point2 >= 5) { rate = true; } hl.Rate = rate; return(HocVienLopHocBLL.Instance.setRate(hl)); }
private bool setRate(HocVienLopHocDTO hl) { Console.WriteLine("trong ham rate: " + hl.Point1 + ";" + hl.Point2); bool rate = false; if (hl.Point1 >= 5 && hl.Point2 >= 5) { rate = true; } hl.Rate = rate; return(HocVienLopHocBLL.Instance.setRate(hl)); }
public List <HocVienLopHocDTO> readDSHV(string maLop) { Console.WriteLine("da vao readdshv"); conn.Open(); List <HocVienLopHocDTO> lstChiTietLop = new List <HocVienLopHocDTO>(); string query = "select " + "HOCVIEN.id_HV, " + "HOCVIEN.ten_HV, " + "HOCVIEN_LOPHOC.diem_1, " + "HOCVIEN_LOPHOC.diem_2, " + "HOCVIEN_LOPHOC.danhgia, " + "HOCVIEN_LOPHOC.diem_do_an, " + "HOCVIEN_LOPHOC.xet_tot_nghiep, " + "HOCVIEN_LOPHOC.xeploai, " + "HOCVIEN_LOPHOC.ghichu_HVLH " + "from HOCVIEN inner join HOCVIEN_LOPHOC on HOCVIEN.id_HV = HOCVIEN_LOPHOC.id_HV " + "where HOCVIEN_LOPHOC.id_LH = @id_LH"; SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("id_LH", maLop); Console.WriteLine("sau khi cmd pa"); try { SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { HocVienLopHocDTO hvlh = new HocVienLopHocDTO(); hvlh.StudentId = rd["id_HV"].ToString(); hvlh.StudentName = rd["ten_HV"].ToString(); hvlh.Point1 = double.Parse(rd["diem_1"].ToString()); hvlh.Point2 = double.Parse(rd["diem_2"].ToString()); hvlh.PointFinal = double.Parse(rd["diem_do_an"].ToString()); hvlh.Note = rd["ghiChu_HVLH"].ToString(); hvlh.Graduating = bool.Parse(rd["xet_tot_nghiep"].ToString()); hvlh.Rank = rd["xeploai"].ToString(); hvlh.Rate = bool.Parse(rd["danhgia"].ToString()); lstChiTietLop.Add(hvlh); } Console.WriteLine("try thanh cong"); } catch (SqlException ee) { Console.WriteLine("try loi"); conn.Close(); throw ee; } conn.Close(); Console.WriteLine("xong readdshv"); return(lstChiTietLop); }
public bool setPoint(HocVienLopHocDTO hl, int pointType) { conn.Open(); try { string sql = ""; SqlCommand cmd; if (pointType == 1) { sql = "update hocvien_lophoc set diem_1 = @d1 where id_HV = @idhv and id_LH = @idlh"; cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("d1", hl.Point1); } else if (pointType == 2) { sql = "update hocvien_lophoc set diem_2 = @d2 where id_HV = @idhv and id_LH = @idlh"; cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("d2", hl.Point2); } else { sql = "update hocvien_lophoc set diem_do_an = @dda where id_HV = @idhv and id_LH = @idlh"; cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("dda", hl.PointFinal); } cmd.Parameters.AddWithValue("idhv", hl.StudentId); cmd.Parameters.AddWithValue("idlh", hl.ClassId); int rowEffect = cmd.ExecuteNonQuery(); conn.Close(); if (rowEffect == 0) { return(false); } } catch (Exception ee) { Console.WriteLine(ee.Message); conn.Close(); return(false); } return(true); }
public bool setRate(HocVienLopHocDTO hl) { conn.Open(); string sql = "update hocvien_lophoc set danhgia = @rate where id_HV = @idhv and id_LH = @idlh"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("idhv", hl.StudentId); cmd.Parameters.AddWithValue("idlh", hl.ClassId); cmd.Parameters.AddWithValue("rate", hl.Rate); int rowEffect = cmd.ExecuteNonQuery(); conn.Close(); if (rowEffect == 0) { return(false); } return(true); }
private HocVienLopHocDTO getHVLHfromGridRowIndex(int index) { HocVienLopHocDTO hl = new HocVienLopHocDTO(); hl.StudentId = dgv_Diem.Rows[index].Cells["id_HV"].Value.ToString(); hl.StudentName = dgv_Diem.Rows[index].Cells["ten_HV"].Value.ToString(); hl.ClassId = cb_listClass.SelectedValue.ToString(); hl.ClassName = cb_listClass.Text; try{ hl.Point1 = double.Parse(dgv_Diem.Rows[index].Cells["diem_1"].Value.ToString()); }catch { hl.Point1 = -1; } try { hl.Point2 = double.Parse(dgv_Diem.Rows[index].Cells["diem_2"].Value.ToString()); } catch { hl.Point2 = -1; } if (dgv_Diem.Rows[index].Cells["danhgia"].Value.ToString() == "Đạt" && dgv_Diem.Rows[index].Cells["diem_do_an"].Value != null && dgv_Diem.Rows[index].Cells["diem_do_an"].Value.ToString() != "") { try { hl.PointFinal = double.Parse(dgv_Diem.Rows[index].Cells["diem_do_an"].Value.ToString()); } catch (Exception e) { hl.PointFinal = -1; } } else { hl.PointFinal = -1; } return(hl); }
public List <HocVienLopHocDTO> getsByClassName(string className) { List <HocVienLopHocDTO> hvlhList = new List <HocVienLopHocDTO>(); conn.Open(); string sql = "select hvlh.id_HV, hvlh.id_LH, hvlh.diem_1, hvlh.diem_2, hvlh.danhgia, " + "hvlh.diem_do_an, hvlh.xet_tot_nghiep, hvlh.xeploai, hvlh.ghichu_HVLH, lophoc.ten_LH, hocvien.ten_HV" + " from hocvien_lophoc as hvlh inner join hocvien on hvlh.id_HV = hocvien.id_HV inner join lophoc on hvlh.id_LH = lophoc.id_LH where lophoc.ten_LH = @className"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("className", className); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { HocVienLopHocDTO hvlh = HocVienLopHocMapper.map(dr); hvlhList.Add(hvlh); } conn.Close(); return(hvlhList); }
public bool setGraduatAndRank(HocVienLopHocDTO hl) { return(HocVienLopHocDAL.Instance.setGraduatAndRank(hl)); }
public bool setRate(HocVienLopHocDTO hl) { return(HocVienLopHocDAL.Instance.setRate(hl)); }
public bool setPoint(HocVienLopHocDTO hl, int typePoint) { return(HocVienLopHocDAL.Instance.setPoint(hl, typePoint)); }
private void Bt_nhap_Click(object sender, EventArgs e) { HocVienLopHocDTO hl = new HocVienLopHocDTO(); //Loại điểm = 0 - nhập điểm thường xuyên //Loại điểm = 1 - nhập điểm đồ án int pointType = 0; if (tb_diemfinal.Visible == false) { if (tb_diem1.Text == "") { errorProvider1.SetError(tb_diem1, "Điểm không được để trống"); return; } if (tb_diem2.Text == "") { errorProvider1.SetError(tb_diem2, "Điểm không được để trống"); return; } hl.Point1 = double.Parse(tb_diem1.Text); hl.Point2 = double.Parse(tb_diem2.Text); } else { if (tb_diemfinal.Text == "") { errorProvider1.SetError(tb_diemfinal, "Điểm không được để trống"); return; } hl.PointFinal = double.Parse(tb_diemfinal.Text); pointType = 1; } hl.StudentId = tb_hv_id.Text; hl.StudentName = tb_hv_name.Text; hl.ClassId = tb_class_id.Text; hl.ClassName = tb_class_name.Text; // save point if (HocVienLopHocBLL.Instance.setPoint(hl, pointType)) { MessageBox.Show("Nhập điểm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); // code auto change rate value after set point if (pointType == 0) { setRate(hl); } else { setTotNghiepAndXepLoai(hl); } // Đóng form this.Close(); } else { MessageBox.Show("Nhập điểm thất bại", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }