public int AddTuDong(KQHT_DanhSachKhongThiInfo pKQHT_DanhSachKhongThiInfo)
        {
            int ID = 0;

            ID            = oDKQHT_DanhSachKhongThi.AddTuDong(pKQHT_DanhSachKhongThiInfo);
            mErrorMessage = oDKQHT_DanhSachKhongThi.ErrorMessages;
            mErrorNumber  = oDKQHT_DanhSachKhongThi.ErrorNumber;
            return(ID);
        }
        public void TinhDiemTBHS_QCNghe(DataTable dtSV, DataRow drMonHoc, int IDDM_Lop, int IDDM_TrinhDo, int IDDM_NamHoc, int HocKy, int IDKQHT_ThanhPhanDiem, int LanThi, string CongThucDiem, int NS_GiaoVienID)
        {
            DataTable dtDiem               = GetTongHopTBHS(int.Parse(drMonHoc["XL_MonHocTrongKyID"].ToString()), int.Parse(drMonHoc["DM_MonHocID"].ToString()), IDDM_Lop, IDDM_TrinhDo, IDDM_NamHoc, HocKy, LanThi);
            DataTable dtTPBatBuoc          = (new cDKQHT_ThanhPhanDiemBatBuoc()).GetByTrinhDo(IDDM_TrinhDo);
            string    TinhCaTietNghiCoPhep = (new cBHT_ThamSoHeThong()).GetGiaTriByMaThamSo("TinhCaTietNghiCoPhep");
            string    LyDo;
            //int SoTietNghi;
            double DiemThapNhat = double.Parse((new cBHT_ThamSoHeThong()).GetGiaTriByMaThamSo("DieuKienDiemDuThi"));

            DataRow[] arrDr, arrDrTPBatBuoc;

            KQHT_DiemThanhPhanInfo pKQHT_DiemThanhPhanInfo = new KQHT_DiemThanhPhanInfo();

            pKQHT_DiemThanhPhanInfo.IDDM_MonHoc        = int.Parse(drMonHoc["DM_MonHocID"].ToString());
            pKQHT_DiemThanhPhanInfo.IDXL_MonHocTrongKy = int.Parse(drMonHoc["XL_MonHocTrongKyID"].ToString());
            pKQHT_DiemThanhPhanInfo.IDDM_NamHoc        = IDDM_NamHoc;
            pKQHT_DiemThanhPhanInfo.HocKy = HocKy;
            pKQHT_DiemThanhPhanInfo.IDKQHT_ThanhPhanDiem = IDKQHT_ThanhPhanDiem;
            pKQHT_DiemThanhPhanInfo.IDHT_User            = NS_GiaoVienID;
            pKQHT_DiemThanhPhanInfo.DiemThu = LanThi;
            pKQHT_DiemThanhPhanInfo.DiemLan = LanThi;

            cDKQHT_DanhSachKhongThi   oDKQHT_DanhSachKhongThi    = new cDKQHT_DanhSachKhongThi();
            KQHT_DanhSachKhongThiInfo pKQHT_DanhSachKhongThiInfo = new KQHT_DanhSachKhongThiInfo();

            pKQHT_DanhSachKhongThiInfo.IDDM_MonHoc = pKQHT_DiemThanhPhanInfo.IDDM_MonHoc;
            pKQHT_DanhSachKhongThiInfo.IDDM_NamHoc = IDDM_NamHoc;
            pKQHT_DanhSachKhongThiInfo.HocKy       = HocKy;

            foreach (DataRow dr in dtSV.Rows)
            {
                LyDo = "";
                // Kiểm tra số tiết nghỉ
                //SoTietNghi = int.Parse("0" + dr["KhongLyDo"]);
                //if (TinhCaTietNghiCoPhep != "0")
                //    SoTietNghi += int.Parse("0" + dr["CoLyDo"]);
                //if (SoTietNghi > SoTietNghiChoPhep * int.Parse("0" + drMonHoc["SoTiet"]))
                //{
                //    LyDo = "Nghỉ quá số tiết quy định;";
                //}
                // Kiểm tra số tiết học lại
                if ("" + dr["SoTietHocLai"] != "")
                {
                    LyDo = "Học lại " + dr["SoTietHocLai"] + " tiết";
                }
                // Kiểm tra số thành phần điểm
                arrDr = dtDiem.Select("IDSV_SinhVien = " + dr["SV_SinhVienID"]);
                if (arrDr.Length > 0)
                {
                    foreach (DataRow dr1 in arrDr)
                    {
                        arrDrTPBatBuoc = dtTPBatBuoc.Select("SoHocTrinh = " + drMonHoc["SoHocTrinh"] + " And IDKQHT_ThanhPhanDiem = " + dr1["IDKQHT_ThanhPhanDiem"]);
                        if (arrDrTPBatBuoc.Length > 0)
                        {
                            if (int.Parse("0" + dr1["SoDiem"]) < int.Parse("0" + arrDrTPBatBuoc[0]["SoDiemBatBuoc"]))
                            {
                                dr1["SoDiem"] = arrDrTPBatBuoc[0]["SoDiemBatBuoc"];
                                LyDo         += "Số thành phần của " + dr1["KyHieu"] + " ít hơn quy định;";
                            }
                        }
                    }
                    // Được phép tổng hợp điểm hệ số

                    pKQHT_DiemThanhPhanInfo.IDSV_SinhVien = int.Parse(dr["SV_SinhVienID"].ToString());
                    pKQHT_DiemThanhPhanInfo.Diem          = TestCongThuc(arrDr, CongThucDiem);
                    dr[IDKQHT_ThanhPhanDiem.ToString() + "_" + LanThi.ToString()] = pKQHT_DiemThanhPhanInfo.Diem;
                    oDKQHT_DiemThanhPhan.Add(pKQHT_DiemThanhPhanInfo);
                    if (pKQHT_DiemThanhPhanInfo.Diem < DiemThapNhat)
                    {
                        LyDo += "Điểm TBHS < " + DiemThapNhat.ToString() + ";";
                    }
                }
                else
                {
                    LyDo = "Chưa có điểm thành phần";
                    pKQHT_DiemThanhPhanInfo.IDSV_SinhVien = int.Parse(dr["SV_SinhVienID"].ToString());
                    oDKQHT_DiemThanhPhan.DeleteByInfo(pKQHT_DiemThanhPhanInfo);
                }

                if (LyDo != "" || "" + dr["SoTietHocLai"] != "")
                {
                    // Đưa SV vào danh sách không được thi
                    pKQHT_DanhSachKhongThiInfo.IDSV_SinhVien = int.Parse(dr["SV_SinhVienID"].ToString());
                    pKQHT_DanhSachKhongThiInfo.LyDo          = LyDo;
                    pKQHT_DanhSachKhongThiInfo.LanThi        = LanThi;
                    if ("" + dr["SoTietHocLai"] != "")
                    {
                        pKQHT_DanhSachKhongThiInfo.SoTietHocLai = int.Parse("" + dr["SoTietHocLai"]);
                    }
                    else
                    {
                        pKQHT_DanhSachKhongThiInfo.SoTietHocLai = null;
                    }
                    oDKQHT_DanhSachKhongThi.AddTuDong(pKQHT_DanhSachKhongThiInfo);
                    dr["LyDo"] = LyDo;
                }
                else if ("" + dr["LyDo"] != "" && "" + dr["SoTietHocLai"] == "")
                {
                    pKQHT_DanhSachKhongThiInfo.IDSV_SinhVien = int.Parse(dr["SV_SinhVienID"].ToString());
                    pKQHT_DanhSachKhongThiInfo.LanThi        = LanThi;
                    oDKQHT_DanhSachKhongThi.DeleteTuDong(pKQHT_DanhSachKhongThiInfo);
                    dr["LyDo"] = "";
                }
            }
        }