public string LoadSelectedEmployees()
        {
            string selectedStr = "";
            int    ExamPaperID = 0;

            if (Request.QueryString["ExamPaperID"] == null)
            {
                return("");
            }
            else
            {
                if (int.TryParse(Request.QueryString["ExamPaperID"].ToString(), out ExamPaperID))
                {
                    Entities.ExamPaper examPaper = new Entities.ExamPaper();
                    examPaper = BLL.ExamPaper.Instance.GetExamPaper(ExamPaperID);

                    selectedStr += "<tr id='tr_" + examPaper.EPID.ToString() + "'>"
                                   + "<td><a href='javascript:delSelectedEmployee(" + examPaper.EPID.ToString() + ")'><img title='删除' src='/Images/close.png'></a></td>"
                                   + "<td>" + examPaper.Name + "</td>"
                                   + "<td><input id='hdn_" + examPaper.EPID.ToString() + "' type='hidden' value=" + examPaper.EPID.ToString()
                                   + " />" + GetCatageName(examPaper.ECID.ToString()) + "</td>"
                                   + "<td>" + getCreateUserName(examPaper.CreaetUserID.ToString()) + "</td>"
                                   + "<td>" + DateTime.Parse(examPaper.CreateTime.ToString()).ToString("yyyy-MM-dd") + "</td></tr>";
                }
            }
            return(selectedStr);
        }
 public bool Action()
 {
     if (Request["id"] != null)
     {//编辑
         int EIID = 0;
         if (int.TryParse(Request["id"].ToString(), out EIID))
         {
             if (BLL.ExamInfo.Instance.IsExistsByEIID(EIID))
             {
                 examInfo  = BLL.ExamInfo.Instance.GetExamInfo(EIID);
                 examPaper = BLL.ExamPaper.Instance.GetExamPaper(examInfo.EPID);
                 GetExamPersions(examInfo.EIID, 0, out ExamPersionsIDs, out ExamPersionsNames);
                 if (examInfo.IsMakeUp == 1)
                 {
                     makeExamInfo  = BLL.MakeUpExamInfo.Instance.GetMakeUpExamInfoByEIID(EIID);
                     makeExamPaper = BLL.ExamPaper.Instance.GetExamPaper(makeExamInfo.MakeUpEPID);
                     GetExamPersions(examInfo.EIID, makeExamInfo.MEIID, out MakeExamPersionsIDs, out MakeExamPersionsNames);
                 }
             }
             else
             {
                 Response.Write("alert('未能找到ID为" + Request["id"].ToString() + "的考试项目');closePage();");
             }
         }
         else
         {
             Response.Write("alert('参数" + Request["id"].ToString() + "转换成数字失败');closePage();");
         }
         return(true);
     }
     else
     { //添加
         return(false);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int userID = BLL.Util.GetLoginUserID();
                if (!BLL.Util.CheckRight(userID, "SYS024MOD3004"))
                {
                    Response.Write(BLL.Util.GetNotAccessMsgPage("您没有访问该页面的权限"));
                    Response.End();
                }

                RequestEIID = BLL.Util.DecryptString(Request["eiid"]);
                if (come == "1" && Type == "1")
                {
                    RequestEIID = BLL.MakeUpExamInfo.Instance.GetMakeUpExamInfo(Convert.ToInt32(BLL.Util.DecryptString(Request["eiid"]))).EIID.ToString();
                }

                //come为1是查看个人成绩,come为2是管理员,质检员,质检经理查看成绩,come为3是阅卷
                username = BitAuto.YanFa.SysRightManager.Common.UserInfo.GerTrueName(Convert.ToInt32(ExamPersonID));

                //取是否已阅

                SumScore       = GetSumScore(out IsMarking);
                EOLID          = GetEOLID();
                fenshu.Visible = true;
                if (come == "1")
                {
                    ViewType = "成绩查看";
                    //ExamPersonID = BLL.Util.GetLoginUserID().ToString();
                    username = BitAuto.YanFa.SysRightManager.Common.UserInfo.GerTrueName(BLL.Util.GetLoginUserID());
                    //fenshu.Visible = true;
                }
                else if (come == "2")
                {
                    ViewType = "成绩查看";
                    //fenshu.Visible = true;
                }
                else if (come == "3" && IsMarking != "1")
                {
                    ViewType = "阅卷";
                    //fenshu.Visible = false;
                }
                else if (come == "3" && IsMarking == "1")
                {
                    ViewType = "成绩查看";
                    //fenshu.Visible = true;
                }
                if (!string.IsNullOrEmpty(RequestEPID))
                {
                    Entities.ExamPaper model = BLL.ExamPaper.Instance.GetExamPaper(Convert.ToInt32(RequestEPID));
                    ExamperName = model.Name;
                    Entities.ExamPaperInfo ExamPaperInfo = BLL.ExamPaper.Instance.GetExamPaperInfo(Convert.ToInt32(RequestEPID));
                    if (ExamPaperInfo.ExamBigQuestioninfoList != null)
                    {
                        repeaterTableList.DataSource = ExamPaperInfo.ExamBigQuestioninfoList;
                        repeaterTableList.DataBind();
                    }
                }
            }
        }
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public int Update(SqlTransaction sqltran, Entities.ExamPaper model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@EPID",             SqlDbType.Int,         8),
                new SqlParameter("@Name",             SqlDbType.NVarChar,  100),
                new SqlParameter("@ECID",             SqlDbType.Int,         4),
                new SqlParameter("@ExamDesc",         SqlDbType.NVarChar,  500),
                new SqlParameter("@TotalScore",       SqlDbType.Int,         4),
                new SqlParameter("@Status",           SqlDbType.Int,         4),
                new SqlParameter("@CreateTime",       SqlDbType.DateTime),
                new SqlParameter("@CreaetUserID",     SqlDbType.Int,         4),
                new SqlParameter("@LastModifyTime",   SqlDbType.DateTime),
                new SqlParameter("@LastModifyUserID", SqlDbType.Int,         4),
                new SqlParameter("@Bgid",             SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.EPID;
            parameters[1].Value  = model.Name;
            parameters[2].Value  = model.ECID;
            parameters[3].Value  = model.ExamDesc;
            parameters[4].Value  = model.TotalScore;
            parameters[5].Value  = model.Status;
            parameters[6].Value  = model.CreateTime;
            parameters[7].Value  = model.CreaetUserID;
            parameters[8].Value  = model.LastModifyTime;
            parameters[9].Value  = model.LastModifyUserID;
            parameters[10].Value = model.BGID;

            return(SqlHelper.ExecuteNonQuery(sqltran, CommandType.StoredProcedure, P_EXAMPAPER_UPDATE, parameters));
        }
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Insert(Entities.ExamPaper model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@EPID",             SqlDbType.BigInt,      8),
                new SqlParameter("@Name",             SqlDbType.NVarChar,  100),
                new SqlParameter("@ECID",             SqlDbType.Int,         4),
                new SqlParameter("@ExamDesc",         SqlDbType.NVarChar,  500),
                new SqlParameter("@TotalScore",       SqlDbType.Int,         4),
                new SqlParameter("@Status",           SqlDbType.Int,         4),
                new SqlParameter("@CreateTime",       SqlDbType.DateTime),
                new SqlParameter("@CreaetUserID",     SqlDbType.Int,         4),
                new SqlParameter("@LastModifyTime",   SqlDbType.DateTime),
                new SqlParameter("@LastModifyUserID", SqlDbType.Int,         4),
                new SqlParameter("@Bgid",             SqlDbType.Int, 4)
            };
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = model.Name;
            parameters[2].Value     = model.ECID;
            parameters[3].Value     = model.ExamDesc;
            parameters[4].Value     = model.TotalScore;
            parameters[5].Value     = model.Status;
            parameters[6].Value     = model.CreateTime;
            parameters[7].Value     = model.CreaetUserID;
            parameters[8].Value     = model.LastModifyTime;
            parameters[9].Value     = model.LastModifyUserID;
            parameters[10].Value    = model.BGID;

            SqlHelper.ExecuteNonQuery(CONNECTIONSTRINGS, CommandType.StoredProcedure, P_EXAMPAPER_INSERT, parameters);
            return((int)parameters[0].Value);
        }
        /// <summary>
        /// 删除试卷
        /// </summary>
        /// <param name="msg"></param>
        private void DeletePager(out string msg)
        {
            msg = "";
            CheckedDelPar(out msg);
            if (msg == "")
            {
                Entities.ExamPaper paperModel = BLL.ExamPaper.Instance.GetExamPaper(long.Parse(Epid));
                if (paperModel != null)
                {
                    Entities.QueryExamBigQuestion query = new Entities.QueryExamBigQuestion();
                    query.EPID = paperModel.EPID;

                    int       totalCount = 0;
                    DataTable dt         = BLL.ExamBigQuestion.Instance.GetExamBigQuestion(query, "", 1, 9999, out totalCount);

                    string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
                    SqlConnection connection        = new SqlConnection(connectionstrings);
                    connection.Open();
                    SqlTransaction tran = connection.BeginTransaction("SampleTransaction");

                    try
                    {
                        int retVal = BLL.ExamPaper.Instance.Delete(tran, int.Parse(Epid));
                        if (retVal > 0)
                        {
                            if (dt != null && dt.Rows.Count > 0)
                            {
                                foreach (DataRow dr in dt.Rows)
                                {
                                    retVal = BLL.ExamBigQuestion.Instance.Delete(tran, long.Parse(dr["BQID"].ToString()));
                                }
                            }
                        }

                        tran.Commit();
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        msg = ex.Message.ToString();
                    }
                    finally
                    {
                        connection.Close();
                    }
                }
                else
                {
                    msg = "没找到对应试卷";
                }
            }
        }
Example #7
0
        //绑定正常考试项目的答案数据和考试倒计时时间
        private void BindDataByNormalExam()
        {
            if (model_examInfo == null)
            {
                return;
            }

            EPID        = model_examInfo.EPID;
            model_paper = BLL.ExamPaper.Instance.GetExamPaper(EPID);

            if (model_paper == null)
            {
                return;
            }

            spanCountDown.InnerText = getSpanTime(model_examInfo.ExamEndTime);
        }
Example #8
0
        //绑定补考项目的答案数据和考试倒计时时间
        private void BindDataByMakeUpExam()
        {
            if (model_makeUpExamInfo == null)
            {
                return;
            }

            EPID        = int.Parse(model_makeUpExamInfo.MakeUpEPID.ToString());
            model_paper = BLL.ExamPaper.Instance.GetExamPaper(model_makeUpExamInfo.MakeUpEPID);

            if (model_paper == null)
            {
                return;
            }

            spanCountDown.InnerText = getSpanTime(model_makeUpExamInfo.MakeupExamEndTime);
        }
        private Entities.ExamPaper LoadSingleExamPaper(DataRow row)
        {
            Entities.ExamPaper model = new Entities.ExamPaper();

            if (row["EPID"].ToString() != "")
            {
                model.EPID = long.Parse(row["EPID"].ToString());
            }
            model.Name = row["Name"].ToString();
            if (row["ECID"].ToString() != "")
            {
                model.ECID = int.Parse(row["ECID"].ToString());
            }
            model.ExamDesc = row["ExamDesc"].ToString();
            if (row["TotalScore"].ToString() != "")
            {
                model.TotalScore = int.Parse(row["TotalScore"].ToString());
            }
            if (row["Status"].ToString() != "")
            {
                model.Status = int.Parse(row["Status"].ToString());
            }
            if (row["CreateTime"].ToString() != "")
            {
                model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
            }
            if (row["CreaetUserID"].ToString() != "")
            {
                model.CreaetUserID = int.Parse(row["CreaetUserID"].ToString());
            }
            if (row["LastModifyTime"].ToString() != "")
            {
                model.LastModifyTime = DateTime.Parse(row["LastModifyTime"].ToString());
            }
            if (row["LastModifyUserID"].ToString() != "")
            {
                model.LastModifyUserID = int.Parse(row["LastModifyUserID"].ToString());
            }
            if (row["bgid"].ToString() != "")
            {
                model.BGID = int.Parse(row["bgid"].ToString());
            }

            return(model);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (ISPDF != "1")
                {
                    BitAuto.YanFa.SysRightManager.Common.UserInfo.Check();
                }

                if (!string.IsNullOrEmpty(RequestEPID))
                {
                    Entities.ExamPaper model = BLL.ExamPaper.Instance.GetExamPaper(Convert.ToInt32(RequestEPID));
                    ExamperName = model.Name;
                    Entities.ExamPaperInfo ExamPaperInfo = BLL.ExamPaper.Instance.GetExamPaperInfo(Convert.ToInt32(RequestEPID));
                    this.ExamPaperView1.ExamPaperInfo = ExamPaperInfo;
                }
            }
        }
        /// <summary>
        /// 绑定试卷信息
        /// </summary>
        private void BindPaper()
        {
            long epid = 0;

            if (long.TryParse(EPID, out epid))
            {
                Entities.ExamPaper model = BLL.ExamPaper.Instance.GetExamPaper(epid);
                if (model != null)
                {
                    this.hidEPID.Value       = model.EPID.ToString();
                    this.txtName.Value       = model.Name;
                    this.txtDes.Value        = model.ExamDesc;
                    this.txtTotalScore.Value = model.TotalScore.ToString();
                    ddlBGIDs.SelectedValue   = model.BGID.ToString();
                    if (model.Status != 2)
                    {
                        this.btnSave.Visible = false;
                    }


                    #region 给分类赋值

                    foreach (RepeaterItem item in this.RptCatage.Items)
                    {
                        Control ctl = item.FindControl("ecID");
                        if (ctl != null)
                        {
                            HtmlInputRadioButton rdoBut = (HtmlInputRadioButton)ctl;
                            if (rdoBut.Value == model.ECID.ToString())
                            {
                                rdoBut.Checked = true;
                                break;
                            }
                        }
                    }
                    #endregion
                }
            }
        }
Example #12
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Insert(Entities.ExamPaper model)
 {
     return(Dal.ExamPaper.Instance.Insert(model));
 }
        public void Validate(out Entities.ExamPaper examPaper, out List <Entities.ExamBigQuestion> bigQList, out List <Entities.ExamBSQuestionShip> shipList, out string delBigQIDs, out string msg)
        {
            examPaper  = null;
            bigQList   = null;
            shipList   = null;
            delBigQIDs = DelBigQIDs;

            msg = "";

            #region 验证试卷信息

            if (ExamPaper != null)
            {
                examPaper = new Entities.ExamPaper();

                #region 验证

                int intVal = 0;

                if (ExamPaper.EPID != "" && !int.TryParse(ExamPaper.EPID, out intVal))
                {
                    msg += "试卷ID应该为数字!";
                }

                if (ExamPaper.Name == "")
                {
                    msg += "试卷名称不能为空!";
                }
                if (ExamPaper.ECID == "")
                {
                    msg += "试卷分类不能为空!";
                }
                if (!int.TryParse(ExamPaper.ECID, out intVal))
                {
                    msg += "试卷分类应该为数字!";
                }
                if (ExamPaper.ExamDesc == "")
                {
                    msg += "试卷说明不能为空!";
                }
                if (ExamPaper.TotalScore == "")
                {
                    msg += "总分不能为空!";
                }
                if (!int.TryParse(ExamPaper.TotalScore, out intVal))
                {
                    msg += "总分应该为数字!";
                }

                #endregion

                #region 赋值

                if (msg == "")
                {
                    if (ExamPaper.EPID != "" && int.TryParse(ExamPaper.EPID, out intVal))
                    {
                        examPaper.EPID = intVal;
                    }
                    examPaper.Name       = ExamPaper.Name;
                    examPaper.ECID       = int.Parse(ExamPaper.ECID);
                    examPaper.ExamDesc   = ExamPaper.ExamDesc;
                    examPaper.TotalScore = int.Parse(ExamPaper.TotalScore);
                    examPaper.BGID       = int.Parse(ExamPaper.BGID);
                }
                #endregion
            }

            #endregion

            #region 验证试卷大题信息

            if (ExamBigQuestioninfoList != null)
            {
                bigQList = new List <Entities.ExamBigQuestion>();

                #region 验证

                int intVal = 0;

                foreach (ExamBigQuestionPageinfo item in ExamBigQuestioninfoList)
                {
                    #region 验证大题数据

                    BigQPageInfo itemBigInfo = item.bigqpageinfo;
                    if (itemBigInfo != null)
                    {
                        if (itemBigInfo.BQID != "" && !int.TryParse(itemBigInfo.BQID, out intVal))
                        {
                            msg += "试卷大题ID应该为数字!";
                        }
                    }

                    if (itemBigInfo.EPID != "" && !int.TryParse(itemBigInfo.EPID, out intVal))
                    {
                        msg += "试卷大题的试卷ID应该为数字!";
                    }
                    if (itemBigInfo.Name == "")
                    {
                        msg += "试卷大题的名称不能为空!";
                    }
                    if (itemBigInfo.BQDesc == "")
                    {
                        msg += "试卷大题的描述不能为空!";
                    }
                    if (itemBigInfo.AskCategory == "")
                    {
                        msg += "试卷大题的题型不能为空!";
                    }
                    if (!int.TryParse(itemBigInfo.AskCategory, out intVal))
                    {
                        msg += "试卷大题的题型应该为数字!";
                    }
                    if (itemBigInfo.EachQuestionScore == "")
                    {
                        msg += "试卷大题的每题分值不能为空!";
                    }
                    if (!int.TryParse(itemBigInfo.EachQuestionScore, out intVal))
                    {
                        msg += "试卷大题的每题分值应该为数字!";
                    }
                    if (itemBigInfo.QuestionCount == "")
                    {
                        msg += "试卷大题的试题总量不能为空!";
                    }
                    if (!int.TryParse(itemBigInfo.QuestionCount, out intVal))
                    {
                        msg += "试卷大题的试题总量应该为数字!";
                    }

                    #endregion

                    #region 验证大小题关系数据

                    List <QuestinShipPageInfo> shiplist = item.shipList;
                    if (shiplist != null)
                    {
                        foreach (QuestinShipPageInfo shipItem in shiplist)
                        {
                            if (shipItem.BQID != "" && !int.TryParse(shipItem.BQID, out intVal))
                            {
                                msg += "大小题关系的大题ID应该为数字!";
                            }
                            if (shipItem.KLQID == "" && !int.TryParse(shipItem.KLQID, out intVal))
                            {
                                msg += "大小题关系的小题ID应该为数字!";
                            }
                        }
                    }

                    #endregion
                }

                #endregion

                #region 赋值

                if (msg == "")
                {
                    bigQList = new List <Entities.ExamBigQuestion>();
                    shipList = new List <Entities.ExamBSQuestionShip>();

                    Entities.ExamBigQuestion    bigQModel;
                    Entities.ExamBSQuestionShip shipModel;
                    int rownum = 0;
                    foreach (ExamBigQuestionPageinfo item in ExamBigQuestioninfoList)
                    {
                        #region 大题赋值

                        BigQPageInfo itemBigInfo = item.bigqpageinfo;
                        bigQModel = new Entities.ExamBigQuestion();
                        if (itemBigInfo.BQID != "")
                        {
                            bigQModel.BQID = int.Parse(itemBigInfo.BQID);
                        }
                        bigQModel.Name              = itemBigInfo.Name;
                        bigQModel.BQDesc            = itemBigInfo.BQDesc;
                        bigQModel.AskCategory       = int.Parse(itemBigInfo.AskCategory);
                        bigQModel.EachQuestionScore = int.Parse(itemBigInfo.EachQuestionScore);
                        bigQModel.QuestionCount     = int.Parse(itemBigInfo.QuestionCount);
                        bigQModel.NO = rownum++;

                        bigQList.Add(bigQModel);

                        #endregion

                        #region 大小题关系赋值

                        List <QuestinShipPageInfo> shiplist = item.shipList;
                        if (shiplist != null)
                        {
                            foreach (QuestinShipPageInfo shipItem in shiplist)
                            {
                                shipModel = new Entities.ExamBSQuestionShip();

                                if (shipItem.BQID != "")
                                {
                                    shipModel.BQID = int.Parse(shipItem.BQID);
                                }
                                else if (itemBigInfo.BQID != "")
                                {
                                    shipModel.BQID = int.Parse(itemBigInfo.BQID);
                                }

                                if (shipItem.KLQID != "")
                                {
                                    shipModel.KLQID = int.Parse(shipItem.KLQID);
                                }
                                shipModel.NO = bigQModel.NO;
                                shipList.Add(shipModel);
                            }
                        }
                        #endregion
                    }
                }
                #endregion
            }


            #endregion

            #region 验证删除的大题IDs

            if (!String.IsNullOrEmpty(delBigQIDs))
            {
                long     longval = 0;
                string[] idslist = delBigQIDs.Split(',');
                foreach (string item in idslist)
                {
                    if (!long.TryParse(item, out longval))
                    {
                        msg += "删除的大题ID格式不正确!";
                        break;
                    }
                }
            }

            #endregion
        }
        //提交或保存:type=submit 提交;type=save 保存
        public void examOnlineOperate(string type, out string msg)
        {
            msg = string.Empty;


            int  loginerID   = BLL.Util.GetLoginUserID(); //登陆者ID
            int  _EOLID      = 0;                         //插入该考生在线考试记录后返回的主键
            int  _EOLDID     = 0;                         //插入在线考试小题明细记录后返回的主键
            int  _totalScore = 0;                         //记录总得分,最后一步更新到在线考试表中
            bool isSubject   = false;                     //是否存在主观题,默认false 不存在(在线考试试卷则为已阅);true存在(在线考试试卷则为未阅)
            int  _paperID;                                //试卷ID

            if (!int.TryParse(RequestExamPaperID, out _paperID))
            {
                msg = "{msg:'试卷ID出错,操作失败!'}";
                return;
            }
            Entities.ExamOnline model_examOnlineInsert       = null;            //新增时增加的在线考试实体,如果之前没保存过,则需要新增
            Entities.ExamOnline model_examOnlineToUpdate     = null;            //需要修改之前保存过的试卷信息
            ArrayList           array_examOnlineDetailDelete = new ArrayList(); //如果有过保存的记录,则保存需要删除的小题明细ID 集合
            ArrayList           array_examOnlineAnswerDelete = new ArrayList(); //如果有过保存的记录,则保存需要删除的答案ID 集合
            bool paperIsSave = false;                                           //该考生试卷是否被保存过,false 没有;true 是;

            ArrayList array_appendValueAnswer = new ArrayList();                //记录答案对应的小题明细数组
            int       examOnlineDetailIndex   = 0;                              //数组值

            int _EIID;

            if (!int.TryParse(RequestEIID, out _EIID))
            {
                msg = "{msg:'项目ID出错,操作失败!'}";
                return;
            }

            judgeSubmitExamLimit(_EIID, out msg);
            if (msg != string.Empty)
            {
                return;
            }

            //在线考试明细表 集合(非主观题)
            List <Entities.ExamOnlineDetail> list_examOnlineDetail = new List <Entities.ExamOnlineDetail>();
            //在线考试答案表 集合(非主观题)
            List <Entities.ExamOnlineAnswer> list_examOnlineAnswer = new List <Entities.ExamOnlineAnswer>();

            //在线考试明细表 集合(主观题)
            List <Entities.ExamOnlineDetail> list_SubjetExamOnlineDetail = new List <Entities.ExamOnlineDetail>();
            //在线考试答案表 集合(主观题)
            List <Entities.ExamOnlineAnswer> list_SubjetExamOnlineAnswer = new List <Entities.ExamOnlineAnswer>();

            //日志:修改 在线考试表 集合
            ArrayList array_updateExamOnlineLog = new ArrayList();

            //在线考试表 修改前的model
            Entities.ExamOnline model_updateExamOnlineLog_Old = null;
            //日志:插入 在线考试表 集合
            ArrayList arry_insertExamOnlineLog = new ArrayList();
            //日志:插入 在线考试明细表 记录集合
            ArrayList array_insertExamOnlineDetailLog = new ArrayList();
            //日志:插入 在线考试答案表 记录集合
            ArrayList array_insertExamOnlineAnswerLog = new ArrayList();



            #region 准备数据

            Entities.QueryExamOnline query_examOnlineSave = new Entities.QueryExamOnline();
            int saveCount;
            if (RequestExamType == "1")    //补考项目考试
            {
                query_examOnlineSave.MEIID    = _EIID;
                query_examOnlineSave.IsMakeUp = 1;
            }
            else if (RequestExamType == "0")    //正常项目考试
            {
                query_examOnlineSave.IsMakeUp = 0;
                query_examOnlineSave.EIID     = _EIID;
            }
            query_examOnlineSave.ExamPersonID = loginerID;
            DataTable dt_examOnlineSave = BLL.ExamOnline.Instance.GetExamOnline(query_examOnlineSave, "", 1, 10000, out saveCount);
            if (dt_examOnlineSave.Rows.Count > 0)
            {
                paperIsSave = true;
                //存在数据,准备上次保存的数据,对其进行修改
                model_examOnlineToUpdate      = BLL.ExamOnline.Instance.GetExamOnline(long.Parse(dt_examOnlineSave.Rows[0]["EOLID"].ToString()));
                model_updateExamOnlineLog_Old = model_examOnlineToUpdate;
                if (model_examOnlineToUpdate != null)
                {
                    model_examOnlineToUpdate.ExamEndTime = DateTime.Now;
                    model_examOnlineToUpdate.IsLack      = 0;
                    //准备需要删除的小题明细ID 集合
                    Entities.QueryExamOnlineDetail query_examOnlineDetailDelete = new Entities.QueryExamOnlineDetail();
                    query_examOnlineDetailDelete.EOLID = int.Parse(model_examOnlineToUpdate.EOLID.ToString());
                    DataTable dt_detailDelete = BLL.ExamOnlineDetail.Instance.GetExamOnlineDetail(query_examOnlineDetailDelete, "", 1, 10000, out saveCount);
                    for (int i = 0; i < dt_detailDelete.Rows.Count; i++)
                    {
                        //插入 集合
                        array_examOnlineDetailDelete.Add(dt_detailDelete.Rows[i]["EOLDID"].ToString());
                        //准备需要删除的该小题答案ID 集合
                        Entities.QueryExamOnlineAnswer query_examOnlineAnswerDelete = new Entities.QueryExamOnlineAnswer();
                        query_examOnlineAnswerDelete.EOLDID = int.Parse(dt_detailDelete.Rows[i]["EOLDID"].ToString());
                        DataTable dt_answerDelete = BLL.ExamOnlineAnswer.Instance.GetExamOnlineAnswer(query_examOnlineAnswerDelete, "", 1, 10000, out saveCount);
                        for (int j = 0; j < dt_answerDelete.Rows.Count; j++)
                        {
                            //插入 集合
                            array_examOnlineAnswerDelete.Add(dt_answerDelete.Rows[j]["RecID"].ToString());
                        }
                    }
                }
            }

            //  a、准备 插入在线考试表记录 数据

            //  如果之前保存过数据,则不需要新增,修改即可
            if (paperIsSave == false)
            {
                model_examOnlineInsert = new Entities.ExamOnline();
                if (RequestExamType == "1")    //补考项目考试
                {
                    model_examOnlineInsert.IsMakeUp = 1;
                    model_examOnlineInsert.MEIID    = _EIID;
                    //根据补考项目ID,找到对应的考试项目ID,并赋值
                    Entities.MakeUpExamInfo model_makeUpExamInfoGetEIID = BLL.MakeUpExamInfo.Instance.GetMakeUpExamInfo(_EIID);
                    if (model_makeUpExamInfoGetEIID == null)
                    {
                        msg = "{msg:'该补考项目对应考试项目ID未找到,操作失败!'}";
                        return;
                    }
                    model_examOnlineInsert.EIID = int.Parse(model_makeUpExamInfoGetEIID.EIID.ToString());
                }
                else if (RequestExamType == "0")    //正常项目考试
                {
                    model_examOnlineInsert.IsMakeUp = 0;
                    model_examOnlineInsert.EIID     = _EIID;
                }
                model_examOnlineInsert.ExamPersonID  = loginerID;
                model_examOnlineInsert.ExamStartTime = DateTime.Parse(RequestExamStartTime);
                model_examOnlineInsert.ExamEndTime   = DateTime.Now;
                model_examOnlineInsert.CreateTime    = DateTime.Now;
                model_examOnlineInsert.CreaetUserID  = loginerID;
                model_examOnlineInsert.IsLack        = 0; //不算缺考

                //_EOLID = insertExamOnline(tran, model_examOnlineInsert);
            }
            if (model_examOnlineInsert != null)
            {
                model_examOnlineInsert.Status = type == "save" ? 0 : 1;
            }
            if (model_examOnlineToUpdate != null)
            {
                model_examOnlineToUpdate.Status = type == "save" ? 0 : 1;
            }

            #endregion

            #region b、准备 插入在线考试小题明细 数据

            #region 1)准备 非主观题 数据
            if (RequestNoSubjectQestion != "")
            {
                //分解成每一个小题数组,类似['大题ID:小题ID:单选题答案','大题ID:小题ID:复选题答案1;复选题答案2;复选题答案3']
                string[] noSubjectQuestion = RequestNoSubjectQestion.Split(',');
                for (int i = 0; i < noSubjectQuestion.Length; i++)
                {
                    examOnlineDetailIndex = i;
                    //分解成每一个小题详细信息的数组,类似['大题ID','小题ID','复选题答案1;复选题答案2;复选题答案3']
                    string[] eachNoSubjectQuestion = noSubjectQuestion[i].Split(':');
                    //如果该小题的详细信息都有值,则插入;否则,不插入
                    if (eachNoSubjectQuestion[0] != "" && eachNoSubjectQuestion[1] != "" && eachNoSubjectQuestion[2] != "")
                    {
                        Entities.ExamOnlineDetail model_examOnlineDetailInsert = new Entities.ExamOnlineDetail();
                        //model_examOnlineDetailInsert.EOLID = int.Parse(_EOLID.ToString());
                        model_examOnlineDetailInsert.EPID  = _paperID;
                        model_examOnlineDetailInsert.BQID  = long.Parse(eachNoSubjectQuestion[0]);
                        model_examOnlineDetailInsert.KLQID = long.Parse(eachNoSubjectQuestion[1]);
                        model_examOnlineDetailInsert.Score = 0;

                        //  (1)根据该生给出的答案去比较正确的答案
                        //  先根据该小题ID去找出该题正确答案串
                        string rightAnswer = string.Empty;
                        Entities.QueryKLQAnswer query_KLQAnswer = new Entities.QueryKLQAnswer();
                        int totalCount;
                        query_KLQAnswer.KLQID = model_examOnlineDetailInsert.KLQID;
                        DataTable dt_KLQAnswer = BLL.KLQAnswer.Instance.GetKLQAnswer(query_KLQAnswer, "", 1, 10000, out totalCount);
                        if (dt_KLQAnswer.Rows.Count == 0)
                        {
                            msg = "{msg:'对应题目的答案未找到,操作失败!'}";
                            return;
                        }
                        for (int j = 0; j < dt_KLQAnswer.Rows.Count; j++)
                        {
                            rightAnswer += dt_KLQAnswer.Rows[j]["KLAOID"].ToString() + ";";
                        }
                        rightAnswer = rightAnswer.TrimEnd(';');

                        //  比较该串与考生给出的答案串是否相同,相同则得分;不相同给零分
                        //  比较方法(两个长度相同,分解考生答案,保证每一个答案都在正确答案内)
                        if (eachNoSubjectQuestion[2].Length == rightAnswer.Length)
                        {
                            string[] eachNoSubjectAnswer = eachNoSubjectQuestion[2].Split(';');
                            bool     IsRightOrWrong      = true; //  答案是否正确,正确true;错误false
                            for (int ea = 0; ea < eachNoSubjectAnswer.Length; ea++)
                            {
                                if (!rightAnswer.Contains(eachNoSubjectAnswer[ea]))
                                {
                                    IsRightOrWrong = false;
                                }
                            }
                            if (IsRightOrWrong)
                            {
                                //  (2)找到该小题如果正确则应得的分数
                                Entities.ExamBigQuestion model_examBigQuestion = BLL.ExamBigQuestion.Instance.GetExamBigQuestion(model_examOnlineDetailInsert.BQID);
                                if (model_examBigQuestion == null)
                                {
                                    msg = "{msg:'对应该小题的对应的分数未找到,操作失败!'}";
                                    return;
                                }
                                int eachQuestionScore = model_examBigQuestion.EachQuestionScore;
                                model_examOnlineDetailInsert.Score = eachQuestionScore;
                                _totalScore += eachQuestionScore;   //计入总得分
                            }
                        }
                        model_examOnlineDetailInsert.CreaetUserID = loginerID;
                        model_examOnlineDetailInsert.CreateTime   = DateTime.Now;
                        //插入在线考试小题明细表 集合
                        list_examOnlineDetail.Add(model_examOnlineDetailInsert);
                        //插入在线考试小题明细表 日志集合
                        string detailsLog = "在线考试小题明细表【插入】";
                        int    epidLog;
                        int    bqidLog;
                        int    klqidLog;
                        if (int.TryParse(model_examOnlineDetailInsert.EPID.ToString(), out epidLog))
                        {
                            Entities.ExamPaper model_examPaperLog = BLL.ExamPaper.Instance.GetExamPaper(epidLog);
                            if (model_examPaperLog != null)
                            {
                                detailsLog += "试卷名称【" + model_examPaperLog.Name + "】";
                            }
                        }
                        if (int.TryParse(model_examOnlineDetailInsert.BQID.ToString(), out bqidLog))
                        {
                            Entities.ExamBigQuestion model_examBigQuestionLog = BLL.ExamBigQuestion.Instance.GetExamBigQuestion(bqidLog);
                            if (model_examBigQuestionLog != null)
                            {
                                detailsLog += "大题名称【" + model_examBigQuestionLog.Name + "】";
                            }
                        }
                        if (int.TryParse(model_examOnlineDetailInsert.KLQID.ToString(), out klqidLog))
                        {
                            Entities.KLQuestion model_klqQestionLog = BLL.KLQuestion.Instance.GetKLQuestion(klqidLog);
                            if (model_klqQestionLog != null)
                            {
                                detailsLog += "小题内容【" + model_klqQestionLog.Ask + "】";
                            }
                        }
                        detailsLog += "本小题得分【" + model_examOnlineDetailInsert.Score + "】插入时间【" + model_examOnlineDetailInsert.CreateTime + "】的记录";
                        array_insertExamOnlineDetailLog.Add(detailsLog);

                        //  (3)插入在线考试答案表
                        //  分解答案串,分条插入该表
                        string[] eachAnswer = eachNoSubjectQuestion[2].Split(';');
                        for (int k = 0; k < eachAnswer.Length; k++)
                        {
                            Entities.ExamOnlineAnswer model_examOnlineAnswer = new Entities.ExamOnlineAnswer();
                            //model_examOnlineAnswer.EOLDID = int.Parse(_EOLDID.ToString());
                            model_examOnlineAnswer.ExamAnswer   = eachAnswer[k];
                            model_examOnlineAnswer.CreaetUserID = loginerID;
                            model_examOnlineAnswer.CreateTime   = DateTime.Now;
                            //插入在线考试答案表 集合
                            list_examOnlineAnswer.Add(model_examOnlineAnswer);

                            array_appendValueAnswer.Add(examOnlineDetailIndex);

                            //插入在线考试答案表 日志集合
                            array_insertExamOnlineAnswerLog.Add("在线考试答案表【插入】提交答案:【" + model_examOnlineAnswer.ExamAnswer + "】插入时间【" + model_examOnlineAnswer.CreateTime + "】的记录");
                        }
                    }
                }
            }

            #endregion

            #region 2)准备 插入主观题 数据(主观题答案为空,也会插入)

            if (RequestSubjectQuestion != "")
            {
                //分解成每一个小题数组,类似['大题ID^^小题ID^^答案','大题ID^^小题ID^^答案','大题ID^^小题ID^^答案']
                string[] subjectQuestion = RequestSubjectQuestion.Split(new string[] { "$$" }, StringSplitOptions.None);
                for (int i = 0; i < subjectQuestion.Length; i++)
                {
                    //分解成每一题的每个详细信息,类似['大题ID','小题ID','答案']
                    string[] eachSubjectQuestion = subjectQuestion[i].Split(new string[] { "^^" }, StringSplitOptions.None);
                    Entities.ExamOnlineDetail model_subjectExamOnlineDetail = new Entities.ExamOnlineDetail();
                    //model_subjectExamOnlineDetail.EOLID = _EOLID.ToString;
                    model_subjectExamOnlineDetail.EPID         = _paperID;
                    model_subjectExamOnlineDetail.BQID         = long.Parse(eachSubjectQuestion[0]);
                    model_subjectExamOnlineDetail.KLQID        = long.Parse(eachSubjectQuestion[1]);
                    model_subjectExamOnlineDetail.Score        = 0;
                    model_subjectExamOnlineDetail.CreaetUserID = loginerID;
                    model_subjectExamOnlineDetail.CreateTime   = DateTime.Now;
                    //插入在线考试小题明细表 集合
                    list_SubjetExamOnlineDetail.Add(model_subjectExamOnlineDetail);
                    //插入在线考试小题明细表 日志集合
                    string detailsLog = "在线考试小题明细表【主观题】【插入】";
                    int    epidLog;
                    int    bqidLog;
                    int    klqidLog;
                    if (int.TryParse(model_subjectExamOnlineDetail.EPID.ToString(), out epidLog))
                    {
                        Entities.ExamPaper model_examPaperLog = BLL.ExamPaper.Instance.GetExamPaper(epidLog);
                        if (model_examPaperLog != null)
                        {
                            detailsLog += "试卷名称【" + model_examPaperLog.Name + "】";
                        }
                    }
                    if (int.TryParse(model_subjectExamOnlineDetail.BQID.ToString(), out bqidLog))
                    {
                        Entities.ExamBigQuestion model_examBigQuestionLog = BLL.ExamBigQuestion.Instance.GetExamBigQuestion(bqidLog);
                        if (model_examBigQuestionLog != null)
                        {
                            detailsLog += "大题名称【" + model_examBigQuestionLog.Name + "】";
                        }
                    }
                    if (int.TryParse(model_subjectExamOnlineDetail.KLQID.ToString(), out klqidLog))
                    {
                        Entities.KLQuestion model_klqQestionLog = BLL.KLQuestion.Instance.GetKLQuestion(klqidLog);
                        if (model_klqQestionLog != null)
                        {
                            detailsLog += "小题内容【" + model_klqQestionLog.Ask + "】";
                        }
                    }
                    detailsLog += "本小题得分【" + model_subjectExamOnlineDetail.Score + "】插入时间【" + model_subjectExamOnlineDetail.CreateTime + "】的记录";
                    array_insertExamOnlineDetailLog.Add(detailsLog);

                    //在线考试答案表 实体
                    Entities.ExamOnlineAnswer model_subjectExamOnlineAnswer = new Entities.ExamOnlineAnswer();
                    //model_subjectExamOnlineAnswer.EOLDID = _EOLDID;
                    model_subjectExamOnlineAnswer.ExamAnswer   = eachSubjectQuestion[2];
                    model_subjectExamOnlineAnswer.CreaetUserID = loginerID;
                    model_subjectExamOnlineAnswer.CreateTime   = DateTime.Now;
                    //插入在线考试答案表 集合
                    list_SubjetExamOnlineAnswer.Add(model_subjectExamOnlineAnswer);

                    //插入在线考试答案表 日志集合
                    array_insertExamOnlineAnswerLog.Add("在线考试答案表【插入】提交答案:【" + model_subjectExamOnlineAnswer.ExamAnswer + "】插入时间【" + model_subjectExamOnlineAnswer.CreateTime + "】的记录");

                    //将isSubject字段修改为 true;在线考试的IsMarking需修改为0未阅
                    isSubject = true;
                }
            }

            if (model_examOnlineInsert != null)
            {
                model_examOnlineInsert.SumScore  = _totalScore;
                model_examOnlineInsert.IsMarking = isSubject == false ? 1 : 0;

                //准备插入数据的日志
                string logStr = string.Empty;
                if (type == "save")
                {
                    logStr += "【保存】";
                }
                else
                {
                    logStr += "【提交】";
                }
                logStr += "在线考试表【插入】";
                string meiidStr  = model_examOnlineInsert.IsMakeUp == 1 ? "补考项目ID【" + model_examOnlineInsert.MEIID + "】" : "";
                string isMakeUp  = model_examOnlineInsert.IsMakeUp == 1 ? "补考" : "未补考";
                string isMakeing = model_examOnlineInsert.IsMarking == 1 ? "已阅" : "未阅";
                string status    = model_examOnlineInsert.Status == 1 ? "提交" : "保存";
                //考试项目名称
                string            eiidName       = string.Empty;
                Entities.ExamInfo model_examInfo = BLL.ExamInfo.Instance.GetExamInfo(model_examOnlineInsert.EIID);
                if (model_examInfo != null)
                {
                    eiidName = model_examInfo.Name;
                    logStr  += "考试项目名称【" + eiidName + "】";
                }
                logStr += meiidStr + "考生名称【" + BLL.Util.GetNameInHRLimitEID(loginerID) + "】考试开始时间【"
                          + model_examOnlineInsert.ExamStartTime + "】考试结束时间【"
                          + model_examOnlineInsert.ExamEndTime + "】总得分【"
                          + model_examOnlineInsert.SumScore + "】是否补考【"
                          + isMakeUp + "】是否阅卷【" + isMakeing + "】状态【" + status + "】的记录";

                arry_insertExamOnlineLog.Add(logStr);
            }
            if (model_examOnlineToUpdate != null)
            {
                model_examOnlineToUpdate.SumScore  = _totalScore;
                model_examOnlineToUpdate.IsMarking = isSubject == false ? 1 : 0;

                //准备修改数据的日志
                string logStr = string.Empty;
                if (type == "save")
                {
                    logStr += "【保存】";
                }
                else
                {
                    logStr += "【提交】";
                }
                logStr += "在线考试表【更新】";
                if (model_updateExamOnlineLog_Old.SumScore != model_examOnlineToUpdate.SumScore)
                {
                    logStr += "总得分从【" + model_updateExamOnlineLog_Old.SumScore + "】修改成【" + model_examOnlineToUpdate.SumScore + "】";
                }
                if (model_updateExamOnlineLog_Old.IsMarking != model_examOnlineToUpdate.IsMarking)
                {
                    string isMarking_Old = model_updateExamOnlineLog_Old.IsMarking == 1 ? "是" : "否";
                    string isMarking_Now = model_examOnlineToUpdate.IsMarking == 1 ? "是" : "否";
                    logStr += "是否阅卷从【" + isMarking_Old + "】修改成【" + isMarking_Now + "】";
                }
                if (model_updateExamOnlineLog_Old.ExamEndTime != model_examOnlineToUpdate.ExamEndTime)
                {
                    logStr += "考试结束时间从【" + model_updateExamOnlineLog_Old.ExamEndTime + "】修改成【" + model_examOnlineToUpdate.ExamEndTime + "】";
                }
                if (model_updateExamOnlineLog_Old.Status != model_examOnlineToUpdate.Status)
                {
                    string status_Old = model_updateExamOnlineLog_Old.Status == 1 ? "提交" : "保存";
                    string status_Now = model_examOnlineToUpdate.Status == 1 ? "提交" : "保存";
                    logStr += "考生试卷状态从【" + status_Old + "】修改成【" + status_Now + "】";
                }
                logStr += "记录";
                array_updateExamOnlineLog.Add(logStr);
            }

            #endregion

            #endregion

            #region 提交、保存 实务操作

            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);
            connection.Open();
            SqlTransaction tran = connection.BeginTransaction("SampleTransaction");
            try
            {
                //如果没有保存过的,新增一条;如果被保存过,修改在线考试这条记录并删除之前的小题明细和答案,然后重新插入,反之都要插入
                if (paperIsSave == false)
                {
                    //插入在线考试表一条记录 _EOLID得到返回的主键值
                    _EOLID = insertExamOnline(tran, model_examOnlineInsert);
                }
                else
                {
                    _EOLID = int.Parse(model_examOnlineToUpdate.EOLID.ToString());

                    //修改在线考试表的该条记录
                    updateExamOnline(tran, model_examOnlineToUpdate);
                    //删除明细表的该考生本张试卷ID的所有明细记录
                    for (int i = 0; i < array_examOnlineDetailDelete.Count; i++)
                    {
                        long eoldid = long.Parse(array_examOnlineDetailDelete[i].ToString());
                        BLL.ExamOnlineDetail.Instance.Delete(tran, eoldid);
                        BLL.Util.InsertUserLog(tran, "在线考试明细表【删除】主键ID:【" + eoldid + "】的记录");
                    }
                    //删除答案表的该考生本张试卷ID的所有答案记录
                    for (int j = 0; j < array_examOnlineAnswerDelete.Count; j++)
                    {
                        long recid = long.Parse(array_examOnlineAnswerDelete[j].ToString());
                        BLL.ExamOnlineAnswer.Instance.Delete(tran, recid);
                        BLL.Util.InsertUserLog(tran, "在线考试答案表【删除】主键ID:【" + recid + "】的记录");
                    }
                }

                //插入非主观题
                for (int kk = 0; kk < list_examOnlineDetail.Count; kk++)
                {
                    //插入在线考试小题明细表 _EOLDID到返回的主键值
                    Entities.ExamOnlineDetail eachExamOnlineDetail = list_examOnlineDetail[kk];
                    eachExamOnlineDetail.EOLID = _EOLID;
                    _EOLDID = insertOnlineDetail(tran, eachExamOnlineDetail);

                    //插入在线考试答案表  这两个表的插入不一定是一对,因为有的是多选,需要多条插入
                    for (int n = kk; n < array_appendValueAnswer.Count; n++)
                    {
                        if (kk == int.Parse(array_appendValueAnswer[n].ToString()))
                        {
                            Entities.ExamOnlineAnswer eachExamOnlineAnswer = list_examOnlineAnswer[n];
                            eachExamOnlineAnswer.EOLDID = _EOLDID;
                            insertExamOnlineAnswer(tran, eachExamOnlineAnswer);
                        }
                    }
                }

                //插入主观题
                for (int tt = 0; tt < list_SubjetExamOnlineDetail.Count; tt++)
                {
                    //插入在线考试小题明细表 _EOLDID到返回的主键值
                    Entities.ExamOnlineDetail eachExamOnlineDetail = list_SubjetExamOnlineDetail[tt];
                    eachExamOnlineDetail.EOLID = _EOLID;
                    _EOLDID = int.Parse(insertOnlineDetail(tran, eachExamOnlineDetail).ToString());

                    //插入在线考试答案表 这两个表的插入肯定是一对,所以不用循环list
                    Entities.ExamOnlineAnswer eachExamOnlineAnswer = list_SubjetExamOnlineAnswer[tt];
                    eachExamOnlineAnswer.EOLDID = _EOLDID;
                    insertExamOnlineAnswer(tran, eachExamOnlineAnswer);
                }

                //插入日志
                for (int log1 = 0; log1 < arry_insertExamOnlineLog.Count; log1++)
                {
                    BLL.Util.InsertUserLog(tran, arry_insertExamOnlineLog[log1].ToString());
                }
                for (int log2 = 0; log2 < array_updateExamOnlineLog.Count; log2++)
                {
                    BLL.Util.InsertUserLog(tran, array_updateExamOnlineLog[log2].ToString());
                }
                for (int log3 = 0; log3 < array_insertExamOnlineDetailLog.Count; log3++)
                {
                    BLL.Util.InsertUserLog(tran, array_insertExamOnlineDetailLog[log3].ToString());
                }
                for (int log4 = 0; log4 < array_insertExamOnlineAnswerLog.Count; log4++)
                {
                    BLL.Util.InsertUserLog(tran, array_insertExamOnlineAnswerLog[log4].ToString());
                }

                //事务提交
                tran.Commit();

                msg = "{msg:'true'}";
            }
            catch (Exception ex)
            {
                tran.Rollback();
                msg = "{msg:'" + ex.Message.ToString() + "'}";
                BLL.Loger.Log4Net.Error("在线考试异常", ex);
            }
            finally
            {
                connection.Close();
            }

            #endregion
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //long longVal = 0;
                //if (EIID != String.Empty && long.TryParse(EIID,out longVal))
                //{
                //    model = BLL.ExamInfo.Instance.GetExamInfo(longVal);
                //    examPaper = BLL.ExamPaper.Instance.GetExamPaper(model.EPID);
                //    EmployeeNames = getEmployeeNames(long.Parse(EIID), 0,model.EPID);

                //    if (model.IsMakeUp == 1)
                //    {
                //        examInfo_Make = BLL.MakeUpExamInfo.Instance.GetMakeUpExamInfoByEIID( Convert.ToInt32(model.EIID));

                //        examPaper_Make = BLL.ExamPaper.Instance.GetExamPaper(examInfo_Make.MakeUpEPID);

                //        EmployeeNames_Make = getEmployeeNames(long.Parse(EIID), examInfo_Make.MEIID,Convert.ToInt32(examInfo_Make.MakeUpEPID));
                //    }
                //    if (model != null)
                //    {
                //        hidEIID.Value = EIID;
                //        hidEName.Value = model.Name;
                //    }
                //}


                if (string.IsNullOrEmpty(EIID))
                {
                    Response.Write(@"<script language='javascript'>alert('考试项目ID不能为空,页面将被关闭。');try {
                                                           window.external.MethodScript('/browsercontrol/closepagereloadppage');
                                                       }
                                                       catch (e) {
                                                           window.opener = null; window.open('', '_self'); window.close();
                                                       }</script>");
                }
                else
                {
                    long longVal = 0;
                    if (long.TryParse(EIID, out longVal))
                    {
                        model = BLL.ExamInfo.Instance.GetExamInfo(longVal);


                        if (model == null)
                        {
                            Response.Write(@"<script language='javascript'>alert('考试项目不存在,页面将被关闭。');try {
                                                           window.external.MethodScript('/browsercontrol/closepagereloadppage');
                                                       }
                                                       catch (e) {
                                                           window.opener = null; window.open('', '_self'); window.close();
                                                       }</script>");
                        }
                        else
                        {
                            examPaper = BLL.ExamPaper.Instance.GetExamPaper(model.EPID);
                            if (examPaper == null)
                            {
                                Response.Write(@"<script language='javascript'>alert('考试试卷不存在,页面将被关闭。');try {
                                                           window.external.MethodScript('/browsercontrol/closepagereloadppage');
                                                       }
                                                       catch (e) {
                                                           window.opener = null; window.open('', '_self'); window.close();
                                                       }</script>");
                            }
                            else
                            {
                                EmployeeNames  = getEmployeeNames(long.Parse(EIID), 0, model.EPID);
                                hidEIID.Value  = EIID;
                                hidEName.Value = model.Name;
                                if (model.IsMakeUp == 1)
                                {
                                    examInfo_Make = BLL.MakeUpExamInfo.Instance.GetMakeUpExamInfoByEIID(Convert.ToInt32(model.EIID));
                                    if (examInfo_Make != null)
                                    {
                                        examPaper_Make = BLL.ExamPaper.Instance.GetExamPaper(examInfo_Make.MakeUpEPID);
                                        if (examPaper_Make != null)
                                        {
                                            EmployeeNames_Make = getEmployeeNames(long.Parse(EIID), examInfo_Make.MEIID, Convert.ToInt32(examInfo_Make.MakeUpEPID));
                                        }
                                        else
                                        {
                                            Response.Write(@"<script language='javascript'>alert('补考试卷不存在,页面将被关闭。');try {
                                                           window.external.MethodScript('/browsercontrol/closepagereloadppage');
                                                       }
                                                       catch (e) {
                                                           window.opener = null; window.open('', '_self'); window.close();
                                                       }</script>");
                                        }
                                    }
                                    else
                                    {
                                        Response.Write(@"<script language='javascript'>alert('补考项目不存在,页面将被关闭。');try {
                                                           window.external.MethodScript('/browsercontrol/closepagereloadppage');
                                                       }
                                                       catch (e) {
                                                           window.opener = null; window.open('', '_self'); window.close();
                                                       }</script>");
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Response.Write(@"<script language='javascript'>alert('考试项目ID数据格式不正确,页面将被关闭。');try {
                                                           window.external.MethodScript('/browsercontrol/closepagereloadppage');
                                                       }
                                                       catch (e) {
                                                           window.opener = null; window.open('', '_self'); window.close();
                                                       }</script>");
                    }
                }
            }
        }
Example #16
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(Entities.ExamPaper model)
 {
     return(Dal.ExamPaper.Instance.Update(model));
 }
Example #17
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(SqlTransaction sqltran, Entities.ExamPaper model)
 {
     return(Dal.ExamPaper.Instance.Update(sqltran, model));
 }
        private void Submit(out string msg, int userID, out int epid)
        {
            msg  = "";
            epid = 0;//返回的试卷ID

            //将页面的上的数据转换成类
            ExamPaperPageInfo Info = (ExamPaperPageInfo)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ExamPaperInfoStr, typeof(ExamPaperPageInfo));

            Entities.ExamPaper examPaper = null;
            List <Entities.ExamBigQuestion>    bigQList = null;
            List <Entities.ExamBSQuestionShip> shipList = null;
            string delBigQIDs = string.Empty;
            string DelShipIDs = string.Empty;


            //验证数据并转换成实体类
            Info.Validate(out examPaper, out bigQList, out shipList, out delBigQIDs, out msg);

            if (string.IsNullOrEmpty(msg))
            {
                //如果验证通过

                //记录用户操作日志
                List <StringBuilder> listLogStr = new List <StringBuilder>();
                StringBuilder        sblogstr   = new StringBuilder();

                #region 获得最终的试卷实体类

                if (examPaper.EPID > 0)
                {
                    //编辑
                    Entities.ExamPaper oldExamPaper = null;
                    oldExamPaper = BLL.ExamPaper.Instance.GetExamPaper((long)examPaper.EPID);
                    if (oldExamPaper != null)
                    {
                        #region 判断

                        if (oldExamPaper.Status == (int)ExamPaperState.InUsed)
                        {
                            msg = "已使用状态的试卷不能编辑";
                            return;
                        }
                        if (oldExamPaper.Status == (int)ExamPaperState.NotUsed && Action == "save")
                        {
                            msg = "未使用状态的试卷不能进行保存操作,只能提交";
                            return;
                        }

                        if (oldExamPaper.Status == -1)
                        {
                            msg = "已删除的试卷不能编辑";
                            return;
                        }

                        #endregion

                        #region 记日志

                        sblogstr = new StringBuilder();
                        string logstr = "";

                        if (oldExamPaper.Name != examPaper.Name)
                        {
                            logstr += "将试卷名称由‘" + oldExamPaper.Name + "’改为‘" + examPaper.Name + "’,";
                        }
                        if (oldExamPaper.ECID != examPaper.ECID)
                        {
                            logstr += "将试卷分类由‘" + oldExamPaper.ECID + "’改为‘" + examPaper.ECID + "’,";
                        }
                        if (oldExamPaper.ExamDesc != examPaper.ExamDesc)
                        {
                            logstr += "将考试说明由‘" + oldExamPaper.ExamDesc + "’改为‘" + examPaper.ExamDesc + "’,";
                        }
                        if (oldExamPaper.TotalScore != examPaper.TotalScore)
                        {
                            logstr += "将总分由‘" + oldExamPaper.TotalScore + "’改为‘" + examPaper.TotalScore + "’,";
                        }
                        if (logstr != "")
                        {
                            logstr += "编辑了试卷【" + oldExamPaper.Name + "】:" + logstr;
                        }
                        if (logstr != "")
                        {
                            sblogstr.Append(logstr);

                            listLogStr.Add(sblogstr);
                        }

                        #endregion

                        oldExamPaper.Name             = examPaper.Name;
                        oldExamPaper.ECID             = examPaper.ECID;
                        oldExamPaper.ExamDesc         = examPaper.ExamDesc;
                        oldExamPaper.TotalScore       = examPaper.TotalScore;
                        oldExamPaper.LastModifyTime   = DateTime.Now;
                        oldExamPaper.LastModifyUserID = userID;
                        oldExamPaper.BGID             = examPaper.BGID;
                        examPaper = oldExamPaper;
                    }
                    else
                    {
                        msg = "没有找到对应的试卷信息";
                        return;
                    }
                }
                else
                {
                    #region 记日志

                    sblogstr = new StringBuilder();
                    sblogstr.Append("添加了试卷【" + examPaper.Name + "】");
                    listLogStr.Add(sblogstr);

                    #endregion

                    //新增
                    examPaper.CreateTime       = DateTime.Now;
                    examPaper.CreaetUserID     = userID;
                    examPaper.LastModifyTime   = DateTime.Now;
                    examPaper.LastModifyUserID = userID;
                }

                #region 根据保存或者提交,设置试卷状态

                if (Action == "save")
                {
                    #region 记日志

                    sblogstr = new StringBuilder();
                    sblogstr.Append("保存了试卷【" + examPaper.Name + "】");

                    listLogStr.Add(sblogstr);

                    #endregion

                    examPaper.Status = (int)Entities.ExamPaperState.NotComplete;
                }
                else if (Action == "sub")
                {
                    #region 记日志

                    sblogstr = new StringBuilder();
                    sblogstr.Append("提交了试卷【" + examPaper.Name + "】");

                    listLogStr.Add(sblogstr);

                    #endregion

                    examPaper.Status = (int)Entities.ExamPaperState.NotUsed;
                }
                else
                {
                    msg = "没有找到对应的试卷信息";
                    return;
                }
                #endregion

                #endregion

                #region 获得大题实体类

                if (bigQList != null)
                {
                    ExamBigQuestion oldBigQModel;

                    for (int i = 0; i < bigQList.Count; i++)
                    {
                        if (bigQList[i].BQID > 0)
                        {
                            //编辑
                            oldBigQModel = null;
                            oldBigQModel = BLL.ExamBigQuestion.Instance.GetExamBigQuestion((long)bigQList[i].BQID);

                            if (oldBigQModel == null)
                            {
                                msg = "没有找到ID为" + bigQList[i].BQID + "大题信息";
                                return;
                            }
                            else
                            {
                                #region 记日志

                                sblogstr = new StringBuilder();
                                string logstr = "";

                                sblogstr.Append("编辑了大题【" + oldBigQModel.Name + "】:");

                                if (oldBigQModel.Name != bigQList[i].Name)
                                {
                                    logstr += "将大题名称由‘" + oldBigQModel.Name + "’改为‘" + bigQList[i].Name + "’,";
                                }
                                if (oldBigQModel.BQDesc != bigQList[i].BQDesc)
                                {
                                    logstr += "将大题描述由‘" + oldBigQModel.BQDesc + "’改为‘" + bigQList[i].BQDesc + "’,";
                                }
                                if (oldBigQModel.AskCategory != bigQList[i].AskCategory)
                                {
                                    logstr += "将题型由‘" + oldBigQModel.AskCategory + "’改为‘" + bigQList[i].AskCategory + "’,";
                                }
                                if (oldBigQModel.EachQuestionScore != bigQList[i].EachQuestionScore)
                                {
                                    logstr += "将每题分值由‘" + oldBigQModel.EachQuestionScore + "’改为‘" + bigQList[i].EachQuestionScore + "’,";
                                }
                                if (oldBigQModel.QuestionCount != bigQList[i].QuestionCount)
                                {
                                    logstr += "将试题总量由‘" + oldBigQModel.QuestionCount + "’改为‘" + bigQList[i].QuestionCount + "’,";
                                }

                                if (logstr != "")
                                {
                                    sblogstr.Append(logstr);

                                    listLogStr.Add(sblogstr);
                                }

                                #endregion

                                oldBigQModel.Name              = bigQList[i].Name;
                                oldBigQModel.BQDesc            = bigQList[i].BQDesc;
                                oldBigQModel.AskCategory       = bigQList[i].AskCategory;
                                oldBigQModel.EachQuestionScore = bigQList[i].EachQuestionScore;
                                oldBigQModel.QuestionCount     = bigQList[i].QuestionCount;
                                oldBigQModel.NO = bigQList[i].NO;

                                bigQList[i] = oldBigQModel;
                            }
                        }
                        else
                        {
                            #region 记日志

                            sblogstr = new StringBuilder();
                            sblogstr.Append("添加了大题【" + bigQList[i].Name + "】");

                            listLogStr.Add(sblogstr);

                            #endregion

                            //新增
                            bigQList[i].Status       = 0;
                            bigQList[i].CreateTime   = DateTime.Now;
                            bigQList[i].CreateUserID = userID;
                            bigQList[i].ModifyTime   = DateTime.Now;
                            bigQList[i].ModifyUserID = userID;
                        }
                    }
                }

                #endregion

                #region 获得大小题关系实体类

                if (shipList != null)
                {
                    Entities.ExamBSQuestionShip oldshipMode;

                    for (int i = 0; i < shipList.Count; i++)
                    {
                        if (shipList[i].BQID > 0)
                        {
                            //编辑的大题

                            oldshipMode = null;
                            oldshipMode = BLL.ExamBSQuestionShip.Instance.GetExamBSQuestionShip((long)shipList[i].BQID, (long)shipList[i].KLQID);
                            if (oldshipMode != null)
                            {
                                //编辑

                                Entities.KLQuestion klQuestion = BLL.KLQuestion.Instance.GetKLQuestion((long)shipList[i].KLQID);
                                if (klQuestion.Status == -1)
                                {
                                    msg = "小题【" + klQuestion.Ask + "】已经被删除";
                                    return;
                                }
                                oldshipMode.BQID  = shipList[i].BQID;
                                oldshipMode.KLQID = shipList[i].KLQID;
                                oldshipMode.NO    = shipList[i].NO;
                                shipList[i]       = oldshipMode;
                            }
                            else
                            {
                                #region 记日志

                                sblogstr = new StringBuilder();
                                sblogstr.Append("添加了大题【" + shipList[i].BQID + "】下的小题【" + shipList[i].KLQID + "】");
                                listLogStr.Add(sblogstr);

                                #endregion

                                //新增
                                shipList[i].CreateTime   = DateTime.Now;
                                shipList[i].CreateUserID = userID;
                            }
                        }
                        else
                        {
                            //新增的大题
                            shipList[i].CreateTime   = DateTime.Now;
                            shipList[i].CreateUserID = userID;
                        }
                    }

                    #region 查出所有删除的小题

                    Entities.QueryExamBSQuestionShip shipquery;
                    foreach (Entities.ExamBigQuestion item in bigQList)//循环大题
                    {
                        if (item.BQID <= 0)
                        {
                            continue;
                        }
                        shipquery      = new QueryExamBSQuestionShip();
                        shipquery.BQID = item.BQID;
                        int totalCount = 0;

                        //查找大题下的所有对应关系
                        DataTable olddt = BLL.ExamBSQuestionShip.Instance.GetExamBSQuestionShip(shipquery, "", 1, 9999, out totalCount);
                        if (olddt != null)
                        {
                            int f = 0;
                            foreach (DataRow dr in olddt.Rows)
                            {
                                f = 0;
                                foreach (Entities.ExamBSQuestionShip shipItem in shipList)
                                {
                                    if (dr["BQID"].ToString() == shipItem.BQID.ToString() && dr["KLQID"].ToString() == shipItem.KLQID.ToString())
                                    {
                                        //存在
                                        f = 1;
                                        break;
                                    }
                                }
                                if (f == 0)
                                {
                                    //如果不存在,就是删除了
                                    DelShipIDs = DelShipIDs + dr["BQID"].ToString() + "," + dr["KLQID"].ToString() + ";";
                                }
                            }
                        }
                    }

                    #endregion
                }

                #endregion

                #region 事务提交

                string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
                SqlConnection connection        = new SqlConnection(connectionstrings);
                connection.Open();
                SqlTransaction tran = connection.BeginTransaction("SampleTransaction");

                //真实的数据操作
                try
                {
                    #region 保存试卷信息

                    if (examPaper.EPID > 0)
                    {
                        //edit
                        epid = (int)examPaper.EPID;

                        BLL.ExamPaper.Instance.Update(tran, examPaper);
                    }
                    else
                    {
                        //add
                        epid = BLL.ExamPaper.Instance.Insert(tran, examPaper);
                    }

                    #endregion

                    #region 保存大题和大小题关系

                    int bigQId = 0;
                    if (bigQList != null)
                    {
                        foreach (Entities.ExamBigQuestion item in bigQList)
                        {
                            if (item.BQID > 0)
                            {
                                //编辑
                                bigQId = (int)item.BQID;
                                BLL.ExamBigQuestion.Instance.Update(tran, item);
                            }
                            else
                            {
                                //添加
                                item.EPID = epid;
                                bigQId    = BLL.ExamBigQuestion.Instance.Insert(tran, item);
                            }

                            #region 保存大小题关系信息

                            if (shipList != null)
                            {
                                foreach (Entities.ExamBSQuestionShip shipItem in shipList)
                                {
                                    if (shipItem.NO == item.NO)//当前大题的
                                    {
                                        shipItem.BQID = bigQId;
                                        BLL.ExamBSQuestionShip.Instance.Delete(tran, shipItem.BQID, shipItem.KLQID);
                                        BLL.ExamBSQuestionShip.Instance.Insert(tran, shipItem);
                                    }
                                }
                            }

                            #endregion
                        }
                    }

                    #endregion

                    #region  除小题关系

                    if (DelShipIDs != string.Empty)
                    {
                        DelShipIDs = DelShipIDs.Substring(0, DelShipIDs.Length - 1);

                        string[] idGroup = DelShipIDs.Split(';');
                        foreach (string group in idGroup)
                        {
                            BLL.ExamBSQuestionShip.Instance.Delete(tran, long.Parse(group.Split(',')[0]), long.Parse(group.Split(',')[1]));
                        }
                    }

                    #endregion

                    #region  除大题

                    if (!String.IsNullOrEmpty(delBigQIDs))
                    {
                        #region 记日志

                        sblogstr = new StringBuilder();
                        sblogstr.Append("删除了大题【" + delBigQIDs + "】");
                        listLogStr.Add(sblogstr);

                        #endregion

                        foreach (string item in delBigQIDs.Split(','))
                        {
                            BLL.ExamBigQuestion.Instance.Delete(tran, long.Parse(item));
                        }
                    }
                    #endregion

                    #region 保存用户操作日志

                    foreach (StringBuilder sbStr in listLogStr)
                    {
                        BLL.Util.InsertUserLog(tran, sbStr.ToString());
                    }
                    #endregion

                    tran.Commit();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    msg = ex.Message.ToString();
                    BLL.Loger.Log4Net.Info(ex.ToString());
                }
                finally
                {
                    connection.Close();
                }

                #endregion
            }
        }