Exemplo n.º 1
0
        private double TestCongThuc(DataRow drDiem, DataRow[] arrDrDiem, string CongThucDiem, string IDThanhPhanThi, int IDKQHT_ThanhPhanTBHS, int LanThi)
        {
            double Value = 0; int SoSauDauPhay;

            try
            {
                MathParser parser = new MathParser();
                parser.CreateVar("TBHS", double.Parse("0" + drDiem[IDKQHT_ThanhPhanTBHS.ToString() + "_" + LanThi.ToString()]), null);
                parser.CreateVar("THI", double.Parse("0" + drDiem[IDThanhPhanThi + "_" + LanThi.ToString()]), null);

                foreach (DataRow dr in arrDrDiem)
                {
                    if (!(dr["KyHieu"].ToString() == "TBHS" || dr["KyHieu"].ToString() == "THI"))
                    {
                        parser.CreateVar(dr["KyHieu"].ToString(), double.Parse("0" + dr["TongDiem"]), null);
                        parser.CreateVar("Count" + dr["KyHieu"], int.Parse("0" + dr["SoDiem"]), null);
                    }
                }

                string formula = CongThucDiem;
                parser.OptimizationOn = true;
                if (formula.IndexOf("R+(") == 0 | formula.IndexOf("R-(") == 0)
                {
                    SoSauDauPhay = int.Parse(formula.Substring(3, 1));
                    double tmp = 0;
                    if (formula.IndexOf("R+(") == 0)
                    {
                        formula           = formula.Substring(5, formula.Length - 5);
                        parser.Expression = formula;
                        parser.Parse();
                        tmp   = double.Parse(parser.Value.ToString());
                        Value = parser.Round(tmp, SoSauDauPhay, true);
                    }
                    else
                    {
                        formula           = formula.Substring(5, formula.Length - 5);
                        parser.Expression = formula;
                        parser.Parse();
                        tmp   = double.Parse(parser.Value.ToString());
                        Value = parser.Round(tmp, SoSauDauPhay, false);
                    }
                }
                else
                {
                    parser.Expression = formula;
                    parser.Parse();
                    Value = double.Parse(parser.Value.ToString());
                }
                return(Value);
            }
            catch (Exception)
            {
                return(0);
            }
        }
        private double TestCongThuc(double DiemTBMH, DataRow[] drDiem)
        {
            double Value = 0; int SoSauDauPhay;

            try
            {
                // add thanh phan diem TBTK
                parser.CreateVar("TBTK", DiemTBMH, null);
                foreach (DataRow dr in drDiem)
                {
                    parser.CreateVar(dr["MaMonHoc"].ToString(), double.Parse("0" + dr["Diem"].ToString()), null);
                }
                string formula = null;
                formula = strCongThucDiem;
                parser.OptimizationOn = true;
                if (formula.IndexOf("R+(") == 0 | formula.IndexOf("R-(") == 0)
                {
                    SoSauDauPhay = int.Parse(formula.Substring(3, 1));
                    double tmp = 0;
                    if (formula.IndexOf("R+(") == 0)
                    {
                        formula           = formula.Substring(5, formula.Length - 5);
                        parser.Expression = formula;
                        parser.Parse();
                        tmp   = double.Parse(parser.Value.ToString());
                        Value = parser.Round(tmp, SoSauDauPhay, true);
                    }
                    else
                    {
                        formula           = formula.Substring(5, formula.Length - 5);
                        parser.Expression = formula;
                        parser.Parse();
                        tmp   = double.Parse(parser.Value.ToString());
                        Value = parser.Round(tmp, SoSauDauPhay, false);
                    }
                }
                else
                {
                    parser.Expression = formula;
                    parser.Parse();
                    Value = double.Parse(parser.Value.ToString());
                }
                return(Value);
            }
            catch (Exception)
            {
                return(0);
            }
        }
Exemplo n.º 3
0
        private double TestCongThuc(DataRow[] drDiem)
        {
            double Value = 0; int SoSauDauPhay;

            try
            {
                MathParser parser = new MathParser();
                foreach (DataRow dr in drDiem)
                {
                    parser.CreateVar(dr["KyHieu"].ToString(), double.Parse("0" + dr["Diem"].ToString()), null);
                }
                string formula = null;
                formula = drDiem[0]["CongThuc"].ToString();
                parser.OptimizationOn = true;
                if (formula.IndexOf("R+(") == 0 | formula.IndexOf("R-(") == 0)
                {
                    SoSauDauPhay = int.Parse(formula.Substring(3, 1));
                    double tmp = 0;
                    if (formula.IndexOf("R+(") == 0)
                    {
                        formula           = formula.Substring(5, formula.Length - 5);
                        parser.Expression = formula;
                        parser.Parse();
                        tmp   = double.Parse(parser.Value.ToString());
                        Value = parser.Round(tmp, SoSauDauPhay, true);
                    }
                    else
                    {
                        formula           = formula.Substring(5, formula.Length - 5);
                        parser.Expression = formula;
                        parser.Parse();
                        tmp   = double.Parse(parser.Value.ToString());
                        Value = parser.Round(tmp, SoSauDauPhay, false);
                    }
                }
                else
                {
                    parser.Expression = formula;
                    parser.Parse();
                    Value = double.Parse(parser.Value.ToString());
                }
                return(Value);
            }
            catch (Exception)
            {
                return(0);
            }
        }
Exemplo n.º 4
0
 private void btnTongHop_Click(object sender, EventArgs e)
 {
     if (dtChiTiet != null && dtGiangVien != null)
     {
         int        TyLe     = 0;
         float      TongDiem = 0;
         MathParser parser   = new MathParser();
         //DataRow[] dr;
         for (int i = 0; i < dtChiTiet.Rows.Count; i++)
         {
             TongDiem = 0;
             TyLe     = 0;
             for (int j = 0; j < grbGiangVien.Columns.Count; j++)
             {
                 //  dr = dtChiTiet.Select(" SV_SinhVienID = " + dtChiTiet.Rows[i]["SV_SinhVienID"].ToString());// + " and KQHT_HoiDongMon_ChiTietID =" + dtGiangVien.Rows[j]["KQHT_HoiDongMon_ChiTietID"].ToString());
                 TongDiem += int.Parse(grbGiangVien.Columns[j].FieldName.Substring(grbGiangVien.Columns[j].FieldName.IndexOf("_") + 1)) * float.Parse("0" + dtChiTiet.Rows[i][grbGiangVien.Columns[j].FieldName].ToString());
                 TyLe     += int.Parse(grbGiangVien.Columns[j].FieldName.Substring(grbGiangVien.Columns[j].FieldName.IndexOf("_") + 1));
             }
             if (TongDiem > 0 && TyLe > 0)
             {
                 dtChiTiet.Rows[i]["DiemTK"] = parser.Round(TongDiem / TyLe, 1, true);
             }
         }
     }
 }
 private bool TestCongThuc()
 {
     try
     {
         MathParser parser = new MathParser();
         foreach (DataRow dr in dtThanhPhan.Rows)
         {
             parser.CreateVar(dr["KyHieu"].ToString(), double.Parse(dr["GiaTri"].ToString()), null);
         }
         string formula = null;
         formula = txtCongThuc.Text;
         parser.OptimizationOn = true;
         if (formula.IndexOf("R+(") == 0 | formula.IndexOf("R-(") == 0)
         {
             SoSauDauPhay = int.Parse(formula.Substring(3, 1));
             double tmp = 0;
             if (formula.IndexOf("R+(") == 0)
             {
                 formula           = formula.Substring(5, formula.Length - 5);
                 parser.Expression = formula;
                 parser.Parse();
                 tmp   = double.Parse(parser.Value.ToString());
                 Value = parser.Round(tmp, SoSauDauPhay, true);
             }
             else
             {
                 formula           = formula.Substring(5, formula.Length - 5);
                 parser.Expression = formula;
                 parser.Parse();
                 tmp   = double.Parse(parser.Value.ToString());
                 Value = parser.Round(tmp, SoSauDauPhay, false);
             }
         }
         else
         {
             parser.Expression = formula;
             parser.Parse();
             Value = double.Parse(parser.Value.ToString());
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 6
0
        protected override void InvokeEvents()
        {
            base.InvokeEvents();
            var value = Random.Range(_min, _max);

            //Debug.Log(value);
            _floatValueEvent.Invoke(value);
            _intValueEvent.Invoke(MathParser.Round(value, roundMethod));
        }
Exemplo n.º 7
0
        private void TongHop()
        {
            grbTongHop.Visible = true;
            MathParser parser       = new MathParser();
            int        TongHeSoTemp = 0;
            float      TongSoDiem   = 0;

            if (dtSinhVien != null && dtThanhPhan != null)
            {
                if (dtSinhVien.Rows.Count > 0 && dtThanhPhan.Rows.Count > 0)
                {
                    for (int i = 0; i < dtSinhVien.Rows.Count; i++)
                    {
                        TongSoDiem   = 0;
                        TongHeSoTemp = 0;
                        for (int j = 0; j < grbNhapDiem.Columns.Count; j++)
                        {
                            if (dtSinhVien.Rows[i][grbNhapDiem.Columns[j].FieldName].ToString() != "")
                            {
                                TongHeSoTemp += 1;
                                TongSoDiem   += float.Parse("0" + dtSinhVien.Rows[i][grbNhapDiem.Columns[j].FieldName].ToString());
                            }
                        }
                        if (TongHeSoTemp > 0)
                        {
                            dtSinhVien.Rows[i]["DiemTB"] = parser.Round(TongSoDiem / TongHeSoTemp, 1, true);
                            if (parser.Round(TongSoDiem / TongHeSoTemp, 1, true) < 3)
                            {
                                dtSinhVien.Rows[i]["LyDo"] = "Điểm TB thành phần < 3.0";
                            }
                        }
                        else
                        {
                            dtSinhVien.Rows[i]["LyDo"] = "Không có điểm thành phần nào";
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void btnTongHop_Click(object sender, EventArgs e)
        {
            grbDiemTK.Visible = true;
            MathParser parser       = new MathParser();
            double     TongHeSoTemp = 0;
            double     TongSoDiem   = 0;
            DataTable  dtTemp       = oBXL_MonHocTrongKy.GetToanKhoa(IDDM_Lop, 0, 0);

            if (dtSinhVien.Rows.Count > 0)
            {
                for (int i = 0; i < dtSinhVien.Rows.Count; i++)
                {
                    TongSoDiem   = 0;
                    TongHeSoTemp = 0;
                    for (int h = 0; h < grbMonHoc.Children.Count; h++)
                    {
                        for (int k = 0; k < grbMonHoc.Children[h].Children.Count; k++)
                        {
                            for (int j = 0; j < grbMonHoc.Children[h].Children[k].Columns.Count; j++)
                            {
                                DataRow[] dr = dtTemp.Select("XL_MonHocTrongKyID=" + grbMonHoc.Children[h].Children[k].Columns[j].FieldName.Substring(grbMonHoc.Children[h].Children[k].Columns[j].FieldName.IndexOf("_") + 1));
                                if (dr.Length > 0 && dtSinhVien.Rows[i][grbMonHoc.Children[h].Children[k].Columns[j].FieldName].ToString() != "")
                                {
                                    TongHeSoTemp += double.Parse("0" + dr[0]["SoHocTrinh"].ToString());
                                    TongSoDiem   += double.Parse("0" + dtSinhVien.Rows[i][grbMonHoc.Children[h].Children[k].Columns[j].FieldName].ToString()) * double.Parse("0" + dr[0]["SoHocTrinh"].ToString());
                                }
                            }
                        }
                        dtSinhVien.Rows[i]["DiemTK"] = parser.Round(TongSoDiem / TongHeSoTemp, 1, true);
                        //if (dtSinhVien.Rows[i]["DiemTK"] != "")
                        //{
                        //    DiemTK = float.Parse(dtSinhVien.Rows[i]["DiemTK"].ToString());
                        //    for (int j = 0; j < dtXepLoai.Rows.Count; j++)
                        //    {
                        //        if (DiemTK >= float.Parse(dtXepLoai.Rows[j]["TuDiem"].ToString()))
                        //        {
                        //            dtSinhVien.Rows[i]["KQHT_XepLoaiTotNghiepID"] = dtXepLoai.Rows[j]["KQHT_XepLoaiTotNghiepID"];
                        //            break;
                        //        }
                        //    }
                        //}
                    }
                }
            }
        }
        private void btnTongHop_Click(object sender, EventArgs e)
        {
            grbDiemTK.Visible = true;
            MathParser parser = new MathParser();
            int        SoMonL1, SoMonL2;
            double     TongHeSo = 0, TongSoDiemL1, TongSoDiemL2, DiemTK;
            bool       IsCoDiemLan2      = false;
            int        SoThapPhanLamTron = int.Parse((new cBKQHT_QuyChe()).GetByMaThamSo(pDM_LopInfo.IDDM_TrinhDo, "TBC_LAMTRON"));

            string[] arrStr;
            int      SoMonCoDiem = oBKQHT_DiemTongKetMon.GetSoMonCoDiemByLop(pDM_LopInfo.DM_LopID, Program.IDNamHoc, Program.HocKy, ref TongHeSo);

            if (dtSinhVien.Rows.Count > 0 && dtMonHoc != null && dtMonHoc.Rows.Count > 0 && SoMonCoDiem > 0)
            {
                for (int i = 0; i < dtSinhVien.Rows.Count; i++)
                {
                    TongSoDiemL1 = 0;
                    TongSoDiemL2 = 0;
                    SoMonL1      = 0;
                    SoMonL2      = 0;
                    IsCoDiemLan2 = false;

                    for (int j = dtColStart; j < dtSinhVien.Columns.Count; j += 2)
                    {
                        arrStr = dtSinhVien.Columns[j].ColumnName.Split('_');
                        if (arrStr.Length > 0)
                        {
                            DataRow[] dr = dtMonHoc.Select("DM_MonHocID=" + arrStr[0]);
                            if (dr.Length > 0 && (bool)dr[0]["TinhDiemToanKhoa"] == true)
                            {
                                if (dtSinhVien.Rows[i][dtSinhVien.Columns[j].ColumnName].ToString() != "")
                                {
                                    TongSoDiemL1 += double.Parse("0" + dtSinhVien.Rows[i][dtSinhVien.Columns[j].ColumnName]) * double.Parse("0" + dr[0]["SoHocTrinh"]);
                                    SoMonL1++;
                                }
                                if (dtSinhVien.Rows[i][dtSinhVien.Columns[j + 1].ColumnName].ToString() != "")
                                {
                                    IsCoDiemLan2  = true;
                                    TongSoDiemL2 += double.Parse("0" + dtSinhVien.Rows[i][dtSinhVien.Columns[j + 1].ColumnName].ToString()) * double.Parse("0" + dr[0]["SoHocTrinh"].ToString());
                                    SoMonL2++;
                                }
                                else if (dtSinhVien.Rows[i][dtSinhVien.Columns[j].ColumnName].ToString() != "")
                                {
                                    TongSoDiemL2 += double.Parse("0" + dtSinhVien.Rows[i][dtSinhVien.Columns[j].ColumnName].ToString()) * double.Parse("0" + dr[0]["SoHocTrinh"].ToString());
                                    SoMonL2++;
                                }
                            }
                        }
                    }

                    dtSinhVien.Rows[i]["DiemTK1"] = parser.Round(TongSoDiemL1 / TongHeSo, SoThapPhanLamTron, true);
                    DiemTK = double.Parse(dtSinhVien.Rows[i]["DiemTK1"].ToString());
                    for (int j = 0; j < dtXepLoai.Rows.Count; j++)
                    {
                        if (DiemTK >= double.Parse(dtXepLoai.Rows[j]["TuDiem"].ToString()))
                        {
                            dtSinhVien.Rows[i]["KQHT_XepLoaiTotNghiepID1"] = dtXepLoai.Rows[j]["KQHT_XepLoaiTotNghiepID"];
                            if (SoMonL1 < SoMonCoDiem)
                            {
                                dtSinhVien.Rows[i]["GhiChuL1"] = (SoMonCoDiem - SoMonL1).ToString() + " môn không có điểm";
                            }
                            else
                            {
                                dtSinhVien.Rows[i]["GhiChuL1"] = "";
                            }
                            break;
                        }
                    }
                    if (IsCoDiemLan2)
                    {
                        dtSinhVien.Rows[i]["DiemTK2"] = parser.Round(TongSoDiemL2 / TongHeSo, SoThapPhanLamTron, true);
                        DiemTK = double.Parse(dtSinhVien.Rows[i]["DiemTK2"].ToString());
                        for (int j = 0; j < dtXepLoai.Rows.Count; j++)
                        {
                            if (DiemTK >= double.Parse(dtXepLoai.Rows[j]["TuDiem"].ToString()))
                            {
                                dtSinhVien.Rows[i]["KQHT_XepLoaiTotNghiepID2"] = dtXepLoai.Rows[j]["KQHT_XepLoaiTotNghiepID"];
                                if (SoMonL2 < SoMonCoDiem)
                                {
                                    dtSinhVien.Rows[i]["GhiChuL2"] = (SoMonCoDiem - SoMonL2).ToString() + " môn không có điểm";
                                }
                                else
                                {
                                    dtSinhVien.Rows[i]["GhiChuL2"] = "";
                                }
                                break;
                            }
                        }
                    }
                    else
                    {
                        dtSinhVien.Rows[i]["DiemTK2"] = DBNull.Value;
                        dtSinhVien.Rows[i]["KQHT_XepLoaiTotNghiepID2"] = DBNull.Value;
                        dtSinhVien.Rows[i]["GhiChuL2"] = "";
                    }
                }
            }
        }
        private void TongHopDiem()
        {
            grbDiemTK.Visible = true;
            MathParser parser = new MathParser();
            double     SoMonCoDiem = 0;
            double     TongHeSoTemp = 0, TongHeSoTN = 0, TongSoDiem = 0, DiemTHXL = 0;
            int        IDDM_LopTemp = 0;

            if (dtSinhVien.Rows.Count > 0)
            {
                IDDM_LopTemp = int.Parse(dtSinhVien.Rows[0]["IDDM_Lop"].ToString());
                //DataTable dtTemp = oBXL_MonHocTrongKy.GetToanKhoa(IDDM_LopTemp, 0, 0);
                DataTable dtMonTotNghiep = oBKQHT_MonThiTotNghiep_Lop.GetIn_Mon(IDDM_LopTemp);

                SoMonCoDiem = oBKQHT_DiemTongKetMon.GetSoMonCoDiemByLop(IDDM_LopTemp, 0, 0, ref TongHeSoTemp);
                for (int i = 0; i < dtSinhVien.Rows.Count; i++)
                {
                    TongSoDiem = 0;
                    if (IDDM_LopTemp != int.Parse(dtSinhVien.Rows[i]["IDDM_Lop"].ToString()))
                    {
                        IDDM_LopTemp = int.Parse(dtSinhVien.Rows[i]["IDDM_Lop"].ToString());
                        //dtTemp = oBXL_MonHocTrongKy.GetToanKhoa(IDDM_LopTemp, 0, 0);
                        dtMonTotNghiep = oBKQHT_MonThiTotNghiep_Lop.GetIn_Mon(IDDM_LopTemp);
                        SoMonCoDiem    = oBKQHT_DiemTongKetMon.GetSoMonCoDiemByLop(IDDM_LopTemp, 0, 0, ref TongHeSoTemp);
                    }
                    //// môn học trong kỳ
                    //for (int j = 0; j < dtSinhVien.Columns.Count; j++)
                    //{
                    //    if (dtSinhVien.Columns[j].ColumnName.IndexOf("C_") >= 0 && "" + dtSinhVien.Rows[i][dtSinhVien.Columns[j].ColumnName] != "")
                    //    {
                    //        DataRow[] dr = dtTemp.Select("XL_MonHocTrongKyID = " + dtSinhVien.Columns[j].ColumnName.Substring(2));
                    //        if (dr.Length > 0)
                    //        {
                    //            TongSoDiem += double.Parse("0" + dtSinhVien.Rows[i][dtSinhVien.Columns[j].ColumnName].ToString()) * double.Parse("0" + dr[0]["SoHocTrinh"].ToString());
                    //        }
                    //    }
                    //}
                    TongSoDiem = double.Parse("0" + dtDiem.Compute("Sum(TongDiemMon)", "TinhDiemToanKhoa = 1 And SV_SinhVienID = " + dtSinhVien.Rows[i]["SV_SinhVienID"]).ToString());

                    if (TongHeSoTemp != 0)
                    {
                        dtSinhVien.Rows[i]["DiemTBMH"] = parser.Round(TongSoDiem / TongHeSoTemp, 1, true);
                    }
                    else
                    {
                        dtSinhVien.Rows[i]["DiemTBMH"] = 0;
                    }

                    // môn thi tốt nghiệp
                    if (dtMonTotNghiep != null)
                    {
                        if (rdTongHop.SelectedIndex == 0)
                        {
                            TongHeSoTN = TongHeSoTemp;
                            // tinh diem theo don vi hoc trinh
                            for (int n = 0; n < dtMonTotNghiep.Rows.Count; n++)
                            {
                                try
                                {
                                    if ("" + dtSinhVien.Rows[i]["TN_" + dtMonTotNghiep.Rows[n]["DM_MonHocID"].ToString()] != "" && bool.Parse(dtMonTotNghiep.Rows[n]["TinhDiem"].ToString()) == true)
                                    {
                                        TongHeSoTN += double.Parse("0" + dtMonTotNghiep.Rows[n]["SoHocTrinh"].ToString());
                                        TongSoDiem += double.Parse("0" + dtSinhVien.Rows[i]["TN_" + dtMonTotNghiep.Rows[n]["DM_MonHocID"].ToString()].ToString()) * double.Parse("0" + dtMonTotNghiep.Rows[n]["SoHocTrinh"].ToString());
                                    }
                                }
                                catch { }
                            }
                            if (TongHeSoTN > 0)
                            {
                                dtSinhVien.Rows[i]["DiemTK"] = parser.Round(TongSoDiem / TongHeSoTN, 1, true);
                            }
                        }
                        else
                        {
                            // tinh diem theo cong thuc diem
                            if (dtDiemTotNghiep != null)
                            {
                                DataRow[] drTemp = dtDiemTotNghiep.Select("SV_SinhVienID = " + dtSinhVien.Rows[i]["SV_SinhVienID"]);
                                dtSinhVien.Rows[i]["DiemTK"] = TestCongThuc(double.Parse(dtSinhVien.Rows[i]["DiemTBMH"].ToString()), drTemp);
                            }
                        }
                    }
                    else
                    {
                        dtSinhVien.Rows[i]["DiemTK"] = dtSinhVien.Rows[i]["DiemTBMH"];
                    }

                    //// Điểm xếp loại
                    // Tính điểm theo công thức
                    dtSinhVien.Rows[i]["DiemTHXL"] = dtSinhVien.Rows[i]["DiemTK"];
                    // xep loai
                    if ("" + dtSinhVien.Rows[i]["DiemTHXL"] != "")
                    {
                        DiemTHXL = double.Parse(dtSinhVien.Rows[i]["DiemTHXL"].ToString());
                        int SoMonTNDuoi5  = (int)dtDiemTotNghiep.Compute("Count(SV_SinhVienID)", "SV_SinhVienID = " + dtSinhVien.Rows[i]["SV_SinhVienID"] + " and Diem < 5");
                        int SoMonTNCoDiem = (int)dtDiemTotNghiep.Compute("count(Diem)", "SV_SinhVienID = " + dtSinhVien.Rows[i]["SV_SinhVienID"]);

                        if (SoMonTNDuoi5 > 0 || SoMonTNCoDiem < 3)
                        {
                            dtSinhVien.Rows[i]["KQHT_XepLoaiTotNghiepID"] = 0;
                            dtSinhVien.Rows[i]["GhiChu"] = "Không đạt";
                        }
                        else
                        {
                            for (int j = 0; j < dtXepLoai.Rows.Count; j++)
                            {
                                if (DiemTHXL >= 5)
                                {
                                    if (DiemTHXL >= double.Parse(dtXepLoai.Rows[j]["TuDiem"].ToString()))
                                    {
                                        dtSinhVien.Rows[i]["KQHT_XepLoaiTotNghiepID"] = dtXepLoai.Rows[j]["KQHT_XepLoaiTotNghiepID"];
                                        dtSinhVien.Rows[i]["GhiChu"] = "";
                                        break;
                                    }
                                }
                                else
                                {
                                    dtSinhVien.Rows[i]["KQHT_XepLoaiTotNghiepID"] = 0;
                                    dtSinhVien.Rows[i]["GhiChu"] = "Không đạt";
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }