protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataSet ds = GetDataSet();
                if (ds != null && ds.Tables.Count == 2)
                {
                    gradesGrid.DataSource = ds;
                    gradesGrid.DataBind();
                }
                else
                {
                    SessionSet.PageMessage = "数据错误!";

                    return;
                }
                string strId             = Request.QueryString.Get("eid");
                RailExam.Model.Exam exam = new RailExam.Model.Exam();
                ExamBLL             eBll = new ExamBLL();
                exam = eBll.GetExam(int.Parse(strId));
                TextBoxExamCategory.Text = exam.CategoryName;
                TextBoxExamName.Text     = exam.ExamName;
                TextBoxExamTime.Text     = exam.BeginTime.ToString() + "/" + exam.EndTime.ToString();
            }
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strId = Request.QueryString.Get("id");
            int    i     = Grid1.Rows.Count;

            ExamArrange examArrange = new ExamArrange();

            ExamBLL examBLL = new ExamBLL();

            RailExam.Model.Exam exam = examBLL.GetExam(int.Parse(strId));

            if (exam != null)
            {
                examArrange.ExamId     = int.Parse(strId);
                examArrange.PaperId    = exam.paperId;
                examArrange.UserIds    = "选择考生!";
                examArrange.JudgeIds   = "选择评卷人!";
                examArrange.BeginTime  = DateTime.Now;
                examArrange.EndTime    = DateTime.Now.AddHours(1);
                examArrange.OrderIndex = 1;
                examArrange.Memo       = "";

                ExamArrangeBLL examArrangeBLL = new ExamArrangeBLL();
                examArrangeBLL.AddExamArrange(examArrange);

                Grid1.DataBind();
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string strId     = Request.QueryString.Get("PaperId");
            string strExamId = Request.QueryString.Get("ExamId");

            ViewState["BeginTime"] = DateTime.Now.ToString();

            ViewState["OrgID"]     = PrjPub.CurrentStudent.OrgID;
            ViewState["StudentID"] = PrjPub.StudentID;

            if (strId != null && strId != "")
            {
                try
                {
                    ExamResultBLL             examResultBLL = new ExamResultBLL();
                    RailExam.Model.ExamResult examResults   = examResultBLL.GetExamResult(int.Parse(strId), int.Parse(strExamId), PrjPub.CurrentStudent.EmployeeID);
                    if (examResults != null)
                    {
                        Response.Write("<script>alert('您已经参加过该考试!'); top.window.close();</script>");
                        return;
                    }
                }
                catch
                {
                    Pub.ShowErrorPage("无法连接路局服务器,请检查站段服务器网络连接是否正常!");
                }
                ExamBLL             examBLL = new ExamBLL();
                RailExam.Model.Exam exam    = examBLL.GetExam(int.Parse(strExamId));
                HiddenFieldExamTime.Value = DateTime.Now.AddMinutes(exam.ExamTime).ToString();
                HfExamTime.Value          = (exam.ExamTime * 60).ToString();

                FillPage(strId);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState["mode"] = Request.QueryString.Get("mode");
                hfMode.Value      = ViewState["mode"].ToString();

                string strId = Request.QueryString.Get("id");

                ExamBLL examBLL = new ExamBLL();

                RailExam.Model.Exam exam = examBLL.GetExam(int.Parse(strId));

                if (exam != null)
                {
                    txtPaperName.Text = exam.ExamName;
                    if (exam.paperId != 0)
                    {
                        PaperBLL paperBLL = new PaperBLL();

                        IList <RailExam.Model.Paper> paperList = paperBLL.GetPaperByPaperId(exam.paperId);

                        if (paperList != null)
                        {
                            Grid1.DataSource = paperList;
                            Grid1.DataBind();
                        }
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(hfPaperId.Value))
                {
                    PaperBLL paperBLL = new PaperBLL();

                    IList <RailExam.Model.Paper> paperList = paperBLL.GetPaperByPaperId(int.Parse(hfPaperId.Value));

                    if (paperList != null)
                    {
                        Grid1.DataSource = paperList;
                        Grid1.DataBind();
                    }
                }
            }
        }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (PrjPub.CurrentLoginUser == null)
                {
                    Response.Redirect("/RailExamBao/Common/Error.aspx?error=Session过期请重新登录本系统!");
                    return;
                }

                if (PrjPub.IsServerCenter && SessionSet.OrganizationID != 1)
                {
                    HfUpdateRight.Value = "False";
                }
                else
                {
                    HfUpdateRight.Value = PrjPub.HasEditRight("手工评卷").ToString();
                }

                hfJudgeId.Value = PrjPub.CurrentLoginUser.EmployeeID.ToString();

                string strId = Request.QueryString.Get("eid");
                hfExamID.Value = strId;
                RailExam.Model.Exam exam = new RailExam.Model.Exam();
                ExamBLL             eBll = new ExamBLL();
                exam = eBll.GetExam(int.Parse(strId));
                TextBoxExamCategory.Text = exam.CategoryName;
                TextBoxExamName.Text     = exam.ExamName;
                TextBoxExamTime.Text     = exam.BeginTime.ToString() + "/" + exam.EndTime.ToString();
            }
            else
            {
                papersGrid.DataBind();
            }


            string strRefresh = Request.Form.Get("Refresh");

            if (strRefresh != null && strRefresh != "")
            {
                papersGrid.DataBind();
            }
        }
示例#6
0
        protected void ButtonSave_Click(object sender, ImageClickEventArgs e)
        {
            string strId = Request.QueryString.Get("id");

            string strEndId = "";

            for (int i = 0; i < this.Grid2.Rows.Count; i++)
            {
                string strEmId = ((Label)this.Grid2.Rows[i].FindControl("LabelEmployeeID")).Text;

                if (strEndId.Length == 0)
                {
                    strEndId += strEmId;
                }
                else
                {
                    strEndId += "," + strEmId;
                }
            }

            if (strEndId == "" || strEndId == "0")
            {
                SessionSet.PageMessage = "请选择考生!";
                return;
            }

            int     PaperId = 0;
            ExamBLL examBLL = new ExamBLL();

            RailExam.Model.Exam exam = examBLL.GetExam(int.Parse(strId));
            if (exam != null)
            {
                PaperId = exam.paperId;
            }

            if (ViewState["UpdateMode"] != null && ViewState["UpdateMode"].ToString() == "0")
            {
                ExamArrange examArrange = new ExamArrange();
                examArrange.ExamId     = int.Parse(strId);
                examArrange.PaperId    = PaperId;
                examArrange.UserIds    = strEndId;
                examArrange.JudgeIds   = "1";
                examArrange.BeginTime  = DateTime.Now;
                examArrange.EndTime    = DateTime.Now;
                examArrange.OrderIndex = 1;
                examArrange.Memo       = "";
                ExamArrangeBLL examArrangeBLL = new ExamArrangeBLL();
                examArrangeBLL.AddExamArrange(examArrange);
                ViewState["UpdateMode"] = 1;
                SessionSet.PageMessage  = "保存成功!";
                return;
            }

            if (ViewState["UpdateMode"] != null && ViewState["UpdateMode"].ToString() == "1")
            {
                ExamArrangeBLL examArrangeBLL = new ExamArrangeBLL();
                examArrangeBLL.UpdateExamUser(int.Parse(strId), strEndId);
                SessionSet.PageMessage = "保存成功!";
                return;
            }
        }
示例#7
0
        protected void FillPage(int nExamID)
        {
            ExamBLL examBLL = new ExamBLL();

            RailExam.Model.Exam exam = examBLL.GetExam(nExamID);

            if (exam != null)
            {
                if (ViewState["mode"].ToString() == "Edit")
                {
                    if (exam.Downloaded == 1)
                    {
                        Response.Write("<script>alert('该考试已被下载,不能被编辑!');window.close();</script>");
                    }
                }
                txtCategoryName.Text    = exam.CategoryName;
                hfCategoryId.Value      = exam.CategoryId.ToString();
                ddlType.SelectedValue   = exam.ExamTypeId.ToString();
                txtExamName.Text        = exam.ExamName;
                txtExamTime.Text        = exam.ExamTime.ToString();
                dateBeginTime.DateValue = exam.BeginTime.ToString("yyyy-MM-dd HH:mm:ss");
                dateEndTime.DateValue   = exam.EndTime.ToString("yyyy-MM-dd HH:mm:ss");
                if (exam.ExamModeId == 1)
                {
                    rbExamMode1.Checked = true;
                }
                else
                {
                    rbExamMode2.Checked = true;
                }

                chUD.Checked          = exam.IsUnderControl;
                chAutoScore.Checked   = exam.IsAutoScore;
                chSeeAnswer.Checked   = exam.CanSeeAnswer;
                chSeeScore.Checked    = exam.CanSeeScore;
                chPublicScore.Checked = exam.IsPublicScore;
                txtDescription.Text   = exam.Description;
                txtMemo.Text          = exam.Memo;

                lblCreatePerson.Text = exam.CreatePerson;
                lblCreateTime.Text   = exam.CreateTime.ToString("yyyy-MM-dd HH:mm");

                ExamResultBLL reBll = new ExamResultBLL();

                try
                {
                    if (ViewState["mode"].ToString() == "Edit")
                    {
                        IList <RailExam.Model.ExamResult> examResults = reBll.GetExamResultByExamID(exam.ExamId);
                        if (examResults.Count > 0)
                        {
                            ViewState["mode"] = "ReadOnly";
                        }
                    }
                }
                catch
                {
                    Pub.ShowErrorPage("无法连接站段服务器,请检查站段服务器是否打开以及网络连接是否正常!");
                }
            }

            if (ViewState["mode"].ToString() == "ReadOnly")
            {
                txtExamName.Enabled      = false;
                dateBeginTime.Enabled    = false;
                this.dateEndTime.Enabled = false;
                ddlType.Enabled          = false;
                txtExamTime.Enabled      = false;
                rbExamMode1.Enabled      = false;
                rbExamMode2.Enabled      = false;

                chUD.Enabled           = false;
                chAutoScore.Enabled    = false;
                chSeeAnswer.Enabled    = false;
                chSeeScore.Enabled     = false;
                chPublicScore.Enabled  = false;
                txtDescription.Enabled = false;
                txtMemo.Enabled        = false;
            }
        }
示例#8
0
        protected void btnOutPut_Click(object sender, ImageClickEventArgs e)
        {
            DataSet   ds = GetDataSet();
            DataTable dt = ds.Tables[0];

            int    orgID   = Convert.ToInt32(Request.QueryString.Get("OrgID"));
            string OrgName = "";

            if (orgID != 1)
            {
                OrganizationBLL orgBll = new OrganizationBLL();
                Organization    org    = orgBll.GetOrganization(orgID);
                OrgName = org.ShortName;
            }

            string  strExamName = "";
            string  strExamTime = "";
            string  qsExamId    = Request.QueryString.Get("eid");
            ExamBLL examBll     = new ExamBLL();

            RailExam.Model.Exam exam = examBll.GetExam(int.Parse(qsExamId));
            if (exam != null)
            {
                strExamName = exam.ExamName;
                strExamTime = exam.BeginTime.ToString() + "--" + exam.EndTime.ToString();
            }

            SpreadsheetClass xlsheet = new SpreadsheetClass();
            Worksheet        ws      = (Worksheet)xlsheet.Worksheets[1];

            ws.Cells.Font.set_Size(10);
            ws.Cells.Font.set_Name("宋体");

            ws.Cells[1, 1] = PrjPub.GetRailName() + OrgName;
            Range rang1 = ws.get_Range(ws.Cells[1, 1], ws.Cells[2, 13]);

            rang1.set_MergeCells(true);
            rang1.set_HorizontalAlignment(XlHAlign.xlHAlignCenter);
            rang1.Font.set_Bold(true);
            rang1.Font.set_Size(17);
            rang1.Font.set_Name("宋体");


            ws.Cells[3, 1] = strExamName + "学员成绩登记表";

            rang1 = ws.get_Range(ws.Cells[3, 1], ws.Cells[3, 13]);
            rang1.set_MergeCells(true);
            rang1.set_HorizontalAlignment(XlHAlign.xlHAlignCenter);
            rang1.Font.set_Bold(true);
            rang1.Font.set_Size(12);
            rang1.Font.set_Name("宋体");

            ws.Cells[4, 1] = "考试日期: " + strExamTime;
            rang1          = ws.get_Range(ws.Cells[4, 1], ws.Cells[4, 13]);
            rang1.set_MergeCells(true);
            rang1.set_HorizontalAlignment(XlHAlign.xlHAlignRight);
            rang1.Font.set_Name("宋体");


            //write headertext
            ws.Cells[5, 1] = "序号";
            ((Range)ws.Cells[5, 1]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);


            ws.Cells[5, 2] = "姓名";
            ws.get_Range(ws.Cells[5, 2], ws.Cells[5, 4]).set_MergeCells(true);
            ws.get_Range(ws.Cells[5, 2], ws.Cells[5, 4]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);

            ws.Cells[5, 5] = "组织机构(车间)";
            ws.get_Range(ws.Cells[5, 5], ws.Cells[5, 7]).set_MergeCells(true);
            ws.get_Range(ws.Cells[5, 5], ws.Cells[5, 7]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);

            ws.Cells[5, 8] = "职名";
            ws.get_Range(ws.Cells[5, 8], ws.Cells[5, 10]).set_MergeCells(true);
            ws.get_Range(ws.Cells[5, 8], ws.Cells[5, 10]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);

            ws.Cells[5, 11] = "分数";
            ws.get_Range(ws.Cells[5, 11], ws.Cells[5, 13]).set_MergeCells(true);
            ws.get_Range(ws.Cells[5, 11], ws.Cells[5, 13]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);


            decimal decScore = 0;

            for (int j = 0; j < dt.Rows.Count; j++)
            {
                ws.Cells[6 + j, 1] = j + 1;

                ws.Cells[6 + j, 2] = dt.Rows[j]["ExamineeName"].ToString();
                ws.get_Range(ws.Cells[6 + j, 2], ws.Cells[6 + j, 4]).set_MergeCells(true);
                ws.get_Range(ws.Cells[6 + j, 2], ws.Cells[6 + j, 4]).set_HorizontalAlignment(XlHAlign.xlHAlignLeft);

                ws.Cells[6 + j, 5] = dt.Rows[j]["OrganizationName"].ToString();
                ws.get_Range(ws.Cells[6 + j, 5], ws.Cells[6 + j, 7]).set_MergeCells(true);
                ws.get_Range(ws.Cells[6 + j, 5], ws.Cells[6 + j, 7]).set_HorizontalAlignment(XlHAlign.xlHAlignLeft);


                ws.Cells[6 + j, 8] = dt.Rows[j]["PostName"].ToString();
                ws.get_Range(ws.Cells[6 + j, 8], ws.Cells[6 + j, 10]).set_MergeCells(true);
                ws.get_Range(ws.Cells[6 + j, 8], ws.Cells[6 + j, 10]).set_HorizontalAlignment(XlHAlign.xlHAlignLeft);

                decScore           += decimal.Parse(dt.Rows[j]["Score"].ToString());
                ws.Cells[6 + j, 11] = dt.Rows[j]["Score"].ToString();
                ws.get_Range(ws.Cells[6 + j, 11], ws.Cells[6 + j, 13]).set_MergeCells(true);
                ws.get_Range(ws.Cells[6 + j, 11], ws.Cells[6 + j, 13]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);
            }

            decimal dec1 = 0;

            if (dt.Rows.Count > 0)
            {
                dec1 = decScore / dt.Rows.Count;
            }

            ws.Cells[6 + dt.Rows.Count, 1] = "平均分:";
            ((Range)ws.Cells[5, 1]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);

            ws.Cells[6 + dt.Rows.Count, 2] = dec1.ToString("0.00");
            ws.get_Range(ws.Cells[6 + dt.Rows.Count, 2], ws.Cells[6 + dt.Rows.Count, 13]).set_MergeCells(true);
            ws.get_Range(ws.Cells[6 + dt.Rows.Count, 2], ws.Cells[6 + dt.Rows.Count, 13]).set_HorizontalAlignment(XlHAlign.xlHAlignRight);



            for (int k = 1; k <= 13; k++)
            {
                for (int j = 5; j <= 6 + dt.Rows.Count; j++)
                {
                    ((Range)ws.Cells[j, k]).BorderAround(1, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, Missing.Value);
                }
            }

            ws.Name = "1-1";
            ws.Cells.Columns.AutoFit();

            try
            {
                ((Worksheet)xlsheet.Worksheets[1]).Activate();

                string path = Server.MapPath("../Excel/Excel.xls");
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                xlsheet.Export(path, SheetExportActionEnum.ssExportActionNone, SheetExportFormat.ssExportAsAppropriate);

                System.IO.FileInfo file = new System.IO.FileInfo(path);
                this.Response.Clear();
                this.Response.Buffer          = true;
                this.Response.Charset         = "utf-7";
                this.Response.ContentEncoding = System.Text.Encoding.UTF7;
                // 添加头信息,为"文件下载/另存为"对话框指定默认文件名
                this.Response.AddHeader("Content-Disposition", "attachment; filename=" + "Excel.xls");
                // 添加头信息,指定文件大小,让浏览器能够显示下载进度
                this.Response.AddHeader("Content-Length", file.Length.ToString());

                // 指定返回的是一个不能被客户端读取的流,必须被下载
                this.Response.ContentType = "application/ms-excel";

                // 把文件流发送到客户端
                this.Response.WriteFile(file.FullName);
            }
            catch
            {
                SessionSet.PageMessage = "系统错误,导出Excel文件失败!";
            }
        }