示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Score scoreRatio = scoreBll.getRatio();

            if (scoreRatio == null)
            {
                sguide     = 0;
                scross     = 0;
                sdedence   = 0;
                sexcellent = 0;
            }
            else
            {
                sguide     = scoreRatio.guideRatio;
                scross     = scoreRatio.crossRatio;
                sdedence   = scoreRatio.defenceRatio;
                sexcellent = scoreRatio.excellent;
            }

            string op = Request["op"];

            if (op == "submit")
            {
                string   guide     = Request["guide"];
                string   cross     = Request["cross"];
                string   defence   = Request["defence"];
                string   excellent = Request["excellent"];
                ScoreBll scoreBll  = new ScoreBll();
                Score    score     = new Score();
                try
                {
                    score.guideRatio   = Convert.ToDouble(guide);
                    score.crossRatio   = Convert.ToDouble(cross);
                    score.defenceRatio = Convert.ToDouble(defence);
                    score.excellent    = Convert.ToInt32(excellent);
                    Result row = scoreBll.updateRatio(score);
                    if (row == Result.更新成功)
                    {
                        Teacher teacher = (Teacher)Session["user"];
                        LogHelper.Info(this.GetType(), teacher.TeaAccount + " - " + teacher.TeaName + " - 更新成绩占比信息");
                        Response.Write("更新成功");
                        Response.End();
                    }
                    else
                    {
                        Response.Write("更新失败");
                        Response.End();
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Error(this.GetType(), ex);
                }
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string op = Request.QueryString["op"];

            //获取数据
            state = Convert.ToInt32(Session["state"]);
            if (state == 1)
            {
                teacher = (Teacher)Session["loginuser"];
            }
            else if (state == 2)
            {
                teacher = (Teacher)Session["user"];
            }
            dsPlan = planBll.getPlanByCid(teacher.college.ColID);
            dsPro  = proBll.SelectByCollegeId(teacher.college.ColID);
            //展示数据
            string type = Request.QueryString["type"];

            order = Request.QueryString["order"];
            if (!IsPostBack)
            {
                if (order == "up")
                {
                    Search();
                    getdata(Search(), 0);
                }
                else
                {
                    Search();
                    getdata(Search(), 1);
                }
            }
            //导出列表
            if (op == "export")
            {
                try
                {
                    //获取成绩占比
                    Score  scoreRatio = scoreBll.getRatio();
                    double guide = scoreRatio.guideRatio, cross = scoreRatio.crossRatio, defen = scoreRatio.defenceRatio;
                    //分院id
                    int collegeId = teacher.college.ColID;
                    //专业id
                    string pro = Request.QueryString["dropstrWherepro"];
                    //批次Id
                    string batch = Request.QueryString["dropstrWhereplan"];
                    //输入框条件
                    string input    = Request.QueryString["search"];
                    string strWhere = "";

                    if (state == 2)
                    {
                        if (input == null)
                        {
                            if ((pro == null || pro == "0") && batch == null || pro == "0")
                            {
                                strWhere = string.Format(" where collegeId = {0}", collegeId);
                            }
                            else if (pro != "null" && batch == "null")
                            {
                                strWhere = string.Format(" where proId = {0} and collegeId = {1}", "'" + pro + "'", collegeId);
                            }
                            else if ((pro == "null" || pro == "0") && batch != "null")
                            {
                                strWhere = string.Format(" where planId = {0} and collegeId = {1}", "'" + batch + "'", collegeId);
                            }
                            else
                            {
                                strWhere = string.Format(" where planId = {0} and proId = {1} and collegeId = {2}", "'" + batch + "'", "'" + pro + "'", collegeId);
                            }
                        }
                        //如果不为空传 input里的值
                        else
                        {
                            strWhere = string.Format(" where (teaName {0} or title {0} or realName {0} or planName {0} or proName {0}) and collegeId = {1}", "like '%" + input + "%'", collegeId);
                        }
                    }
                    else
                    {
                        if (input == null)
                        {
                            strWhere = string.Format(" where collegeId = {0}", collegeId);
                        }
                        //如果不为空传 input里的值
                        else
                        {
                            strWhere = string.Format(" where (teaName {0} or title {0} or realName {0} or planName {0} or proName {0}) and collegeId = {1}", "like '%" + input + "%'", collegeId);
                        }
                    }

                    var       name = "学生成绩" + DateTime.Now.ToString("yyyyMMddhhmmss") + new Random(DateTime.Now.Second).Next(10000);
                    DataTable dt   = scoreBll.ExportExcel(strWhere, scoreRatio);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        var path = Server.MapPath("~/download/学生成绩导出/" + name + ".xls");
                        ExcelHelper.x2007.TableToExcelForXLSX(dt, path);
                        downloadfile(path);
                    }
                    else
                    {
                        Response.Write("<script language='javascript'>alert('查询不到数据,不能执行导出操作!')</script>");
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Error(this.GetType(), ex);
                }
            }
            if (order == "down")
            {
                //批次下拉菜单
                if (type == "plandrop")
                {
                    planId = Request.QueryString["dropstrWhereplan"].ToString();
                    if (planId == "0")
                    {
                        getdata("", 1);
                    }
                    string strWhere = string.Format(" planId = {0}", planId);
                    getdata(strWhere, 1);
                }
                //专业下拉菜单
                if (type == "prodrop")
                {
                    proId = Request.QueryString["dropstrWherepro"].ToString();
                    if (proId == "0")
                    {
                        getdata("", 1);
                    }
                    string strWhere = string.Format(" proId = {0}", proId);
                    getdata(strWhere, 1);
                }
                //所有下拉菜单
                if (type == "alldrop")
                {
                    planId = Request.QueryString["dropstrWhereplan"].ToString();
                    proId  = Request.QueryString["dropstrWherepro"].ToString();
                    string strWhere = string.Format(" proId = {0} and planId = {1}", proId, planId);
                    getdata(strWhere, 1);
                }
            }
            else if (order == "up")
            {
                //批次下拉菜单、升序
                if (type == "plandropUp")
                {
                    planId = Request.QueryString["dropstrWhereplan"].ToString();
                    if (planId == "0")
                    {
                        getdata("", 0);
                    }
                    string strWhere = string.Format(" planId = {0}", planId);
                    getdata(strWhere, 0);
                }
                //专业下拉菜单、升序
                if (type == "prodropUp")
                {
                    proId = Request.QueryString["dropstrWherepro"].ToString();
                    if (proId == "0")
                    {
                        getdata("", 0);
                    }
                    string strWhere = string.Format(" proId = {0}", proId);
                    getdata(strWhere, 0);
                }
                //所有下拉菜单、升序
                if (type == "alldropUp")
                {
                    planId = Request.QueryString["dropstrWhereplan"].ToString();
                    proId  = Request.QueryString["dropstrWherepro"].ToString();
                    string strWhere = string.Format(" proId = {0} and planId = {1}", proId, planId);
                    getdata(strWhere, 0);
                }
                //仅升序
                if (type == "up")
                {
                    getdata("", 0);
                }
            }
        }