Exemplo n.º 1
0
 public Boolean ThemDiem(DiemDTO diem)
 {
     try
     {
         return(diemdal.ThemDiem(diem));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemplo n.º 2
0
        public List <DiemDTO> LayDiem()
        {
            List <DiemDTO> list = new List <DiemDTO>();

            conn.Open();
            string        sql     = "select * from Diem";
            SqlCommand    sqlComm = new SqlCommand(sql, conn);
            SqlDataReader sqlDr   = sqlComm.ExecuteReader();

            while (sqlDr.Read())
            {
                DiemDTO diem = new DiemDTO(sqlDr.GetString(0), sqlDr.GetString(1),
                                           float.Parse(sqlDr["DiemTB"].ToString()), float.Parse(sqlDr["DiemThiLan1"].ToString()), float.Parse(sqlDr["DiemTongKet"].ToString()));
                list.Add(diem);
            }
            sqlDr.Close();
            conn.Close();
            return(list);
        }
Exemplo n.º 3
0
        public List <DiemDTO> LayDiemTheoLop(string malop)
        {
            List <DiemDTO> list = new List <DiemDTO>();

            conn.Open();
            string        sql     = "select Diem.* from Diem,SinhVien where Diem.MaSinhVien=SinhVien.MaSinhVien and SinhVien.MaLop='" + malop + "'";
            SqlCommand    sqlComm = new SqlCommand(sql, conn);
            SqlDataReader sqlDr   = sqlComm.ExecuteReader();

            while (sqlDr.Read())
            {
                DiemDTO diem = new DiemDTO(sqlDr.GetString(0), sqlDr.GetString(1),
                                           float.Parse(sqlDr["DiemTB"].ToString()), float.Parse(sqlDr["DiemThiLan1"].ToString()), float.Parse(sqlDr["DiemTongKet"].ToString()));
                list.Add(diem);
            }
            sqlDr.Close();
            conn.Close();
            return(list);
        }
        public List <DiemDTO> LayBangDiem()
        {
            List <DiemDTO> ds = new List <DiemDTO>();

            KetNoiCoSoDuLieu.MoKetNoi();
            string        sqlSELECT = "SELECT * FROM Diem";
            SqlCommand    cmd       = new SqlCommand(sqlSELECT, KetNoiCoSoDuLieu.KetNoi);
            SqlDataReader dr        = cmd.ExecuteReader();

            while (dr.Read())
            {
                DiemDTO diem = new DiemDTO(
                    dr["MaHocSinh"].ToString(),
                    dr["MaMonHoc"].ToString(),
                    Convert.ToInt32(dr["DiemTB_Ky1"]),
                    Convert.ToInt32(dr["DiemTB_ky2"]));
                ds.Add(diem);
            }
            KetNoiCoSoDuLieu.DongKetNoi();
            return(ds);
        }
Exemplo n.º 5
0
        public Boolean ThemDiem(DiemDTO diem)
        {
            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            string     sql     = "insert into Diem values(@masv,@mamon,@diemtb,@diemthilan1,@diemtk)";
            SqlCommand sqlComm = new SqlCommand(sql, conn);

            sqlComm.Parameters.Add(new SqlParameter("@masv", SqlDbType.NChar)).Value        = diem.maSV;
            sqlComm.Parameters.Add(new SqlParameter("@mamon", SqlDbType.NChar)).Value       = diem.maMon;
            sqlComm.Parameters.Add(new SqlParameter("@diemtb", SqlDbType.Float)).Value      = diem.DiemTB;
            sqlComm.Parameters.Add(new SqlParameter("@diemthilan1", SqlDbType.Float)).Value = diem.DiemThiLan1;
            sqlComm.Parameters.Add(new SqlParameter("@diemtk", SqlDbType.Float)).Value      = diem.DiemTongKet;
            int kq = sqlComm.ExecuteNonQuery();

            conn.Close();
            if (kq > 0)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
        public Boolean SuaDiem(DiemDTO diem)
        {
            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            string     sql     = "update Diem set DiemTB=@diemtb,DiemThiLan1=@diemthilan1,DiemTongKet=@diemtk where MaSinhVien=@masv and MaMonHoc=@mamon";
            SqlCommand sqlComm = new SqlCommand(sql, conn);

            sqlComm.Parameters.Add(new SqlParameter("@masv", SqlDbType.NChar)).Value        = diem.maSV;
            sqlComm.Parameters.Add(new SqlParameter("@mamon", SqlDbType.NChar)).Value       = diem.maMon;
            sqlComm.Parameters.Add(new SqlParameter("@diemtb", SqlDbType.Float)).Value      = diem.DiemTB;
            sqlComm.Parameters.Add(new SqlParameter("@diemthilan1", SqlDbType.Float)).Value = diem.DiemThiLan1;
            sqlComm.Parameters.Add(new SqlParameter("@diemtk", SqlDbType.Float)).Value      = diem.DiemTongKet;
            int kq = sqlComm.ExecuteNonQuery();

            conn.Close();
            if (kq > 0)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
        private void btnLuuDiem_Click(object sender, EventArgs e)
        {
            string[] colNames = { "colDiemMieng", "colDiem15Phut", "colDiem45Phut", "colDiemThi" };
            if (!KiemTraTruocKhiLuu.KiemTraDiem(dgvDiem, colNames) || STT == null)
            {
                return;
            }

            string maLop    = cmbLop.SelectedValue.ToString();
            string maNamHoc = cmbNamHoc.SelectedValue.ToString();
            string maMonHoc = cmbMonHoc.SelectedValue.ToString();
            string maHocKy  = cmbHocKy.SelectedValue.ToString();
            int    rowCount = 0;

            foreach (DataGridViewRow row in dgvDiem.Rows)
            {
                string maHocSinh = row.Cells["colMaHocSinh"].Value.ToString();
                rowCount++;

                for (int i = 0; i < colNames.Length; i++)
                {
                    if (row.Cells[colNames[i]].Value.ToString() == "")
                    {
                        row.Cells[colNames[i]].Value = 0;
                    }
                    string chuoiDiem = row.Cells[colNames[i]].Value.ToString();

                    if (string.IsNullOrWhiteSpace(chuoiDiem))
                    {
                        continue;
                    }
                    int count = 0;

                    for (int j = 0; j < chuoiDiem.Length; j++)
                    {
                        if (chuoiDiem[j] != ';' && j != chuoiDiem.Length - 1)
                        {
                            count++;
                        }
                        else
                        {
                            if (j == chuoiDiem.Length - 1)
                            {
                                j++;
                                count++;
                            }

                            string diemDaXuLy = chuoiDiem.Substring(j - count, count);
                            if (!string.IsNullOrWhiteSpace(diemDaXuLy) && QuyDinhBUS.Instance.KiemTraDiem(diemDaXuLy))
                            {
                                DiemDTO diem = new DiemDTO(maHocSinh, maMonHoc, maHocKy, maNamHoc, maLop, $"LD000{i + 1}", float.Parse(diemDaXuLy));
                                DiemBUS.Instance.ThemDiem(diem);
                            }
                            count = 0;
                        }
                    }
                }

                #region Xóa các kết quả cũ
                for (int i = 1; i < 60; i++)
                {
                    for (int j = 1; j < 20; j++)
                    {
                        int id = STT[i, j];
                        if (id > 0)
                        {
                            DiemBUS.Instance.XoaDiem(id);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                #endregion

                #region Lưu vào bảng kết quả
                if (rowCount <= dgvDiem.Rows.Count)
                {
                    KQHSMonHocBUS.Instance.LuuKetQua(maHocSinh, maLop, maNamHoc, maMonHoc, maHocKy);
                    KQHSCaNamBUS.Instance.LuuKetQua(maHocSinh, maLop, maNamHoc);
                    KQLHMonHocBUS.Instance.LuuKetQua(maLop, maNamHoc, maMonHoc, maHocKy);
                    KQLHHocKyBUS.Instance.LuuKetQua(maLop, maNamHoc, maHocKy);
                }
                #endregion
            }

            MessageBox.Show("Cập nhật thành công!", "COMPLETED", MessageBoxButtons.OK, MessageBoxIcon.Information);
            btnHienThiDanhSach_Click(sender, e);

            frmXemDiem frm = (frmXemDiem)Application.OpenForms["frmXemDiem"];
            if (frm != null)
            {
                frm.btnHienThiClicked(sender, e);
            }
        }