Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Eastcom.Model.考试题库 model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update 考试题库 set ");
            strSql.Append("题目内容=@题目内容,");
            strSql.Append("A选项=@A选项,");
            strSql.Append("B选项=@B选项,");
            strSql.Append("C选项=@C选项,");
            strSql.Append("D选项=@D选项,");
            strSql.Append("其他选项=@其他选项,");
            strSql.Append("标准答案=@标准答案,");
            strSql.Append("标准答案2=@标准答案2");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@题目内容",  SqlDbType.NText),
                new SqlParameter("@A选项",   SqlDbType.VarChar, 5000),
                new SqlParameter("@B选项",   SqlDbType.VarChar, 5000),
                new SqlParameter("@C选项",   SqlDbType.VarChar, 5000),
                new SqlParameter("@D选项",   SqlDbType.VarChar, 5000),
                new SqlParameter("@其他选项",  SqlDbType.NText),
                new SqlParameter("@标准答案",  SqlDbType.VarChar,   50),
                new SqlParameter("@标准答案2", SqlDbType.VarChar,   50),
                new SqlParameter("@id",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.题目内容;
            parameters[1].Value = model.A选项;
            parameters[2].Value = model.B选项;
            parameters[3].Value = model.C选项;
            parameters[4].Value = model.D选项;
            parameters[5].Value = model.其他选项;
            parameters[6].Value = model.标准答案;
            parameters[7].Value = model.标准答案2;
            parameters[8].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Eastcom.Model.考试题库 DataRowToModel(DataRow row)
 {
     Eastcom.Model.考试题库 model = new Eastcom.Model.考试题库();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["题目内容"] != null)
         {
             model.题目内容 = row["题目内容"].ToString();
         }
         if (row["A选项"] != null)
         {
             model.A选项 = row["A选项"].ToString();
         }
         if (row["B选项"] != null)
         {
             model.B选项 = row["B选项"].ToString();
         }
         if (row["C选项"] != null)
         {
             model.C选项 = row["C选项"].ToString();
         }
         if (row["D选项"] != null)
         {
             model.D选项 = row["D选项"].ToString();
         }
         if (row["其他选项"] != null)
         {
             model.其他选项 = row["其他选项"].ToString();
         }
         if (row["标准答案"] != null)
         {
             model.标准答案 = row["标准答案"].ToString();
         }
         if (row["标准答案2"] != null)
         {
             model.标准答案2 = row["标准答案2"].ToString();
         }
     }
     return(model);
 }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private string CommonModel(Eastcom.Model.错题提交信息 model)
        {
            StringBuilder str = new StringBuilder();

            model.FK_考试题库 = FK_ID;
            model.错误提交信息  = Request.Params["area_Err"].Trim();
            model.提交人     = Submiter;
            model.提交时间    = CommonClass.StringHander.Common.GetDateTime(SubmitTime);

            Eastcom.Model.考试题库 考题 = new Eastcom.Model.考试题库();
            考题 = new Eastcom.BLL.考试题库().GetModel(CommonClass.StringHander.Common.GetInt(FK_ID));

            if (考题 != null)
            {
                model.题目信息 = 考题.题目内容;
                model.答案信息 = 考题.标准答案;
            }
            return(str.ToString());
        }
Пример #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Eastcom.Model.考试题库 model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into 考试题库(");
            strSql.Append("题目内容,A选项,B选项,C选项,D选项,其他选项,标准答案,标准答案2)");
            strSql.Append(" values (");
            strSql.Append("@题目内容,@A选项,@B选项,@C选项,@D选项,@其他选项,@标准答案,@标准答案2)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@题目内容",  SqlDbType.NText),
                new SqlParameter("@A选项",   SqlDbType.VarChar, 5000),
                new SqlParameter("@B选项",   SqlDbType.VarChar, 5000),
                new SqlParameter("@C选项",   SqlDbType.VarChar, 5000),
                new SqlParameter("@D选项",   SqlDbType.VarChar, 5000),
                new SqlParameter("@其他选项",  SqlDbType.NText),
                new SqlParameter("@标准答案",  SqlDbType.VarChar,   50),
                new SqlParameter("@标准答案2", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.题目内容;
            parameters[1].Value = model.A选项;
            parameters[2].Value = model.B选项;
            parameters[3].Value = model.C选项;
            parameters[4].Value = model.D选项;
            parameters[5].Value = model.其他选项;
            parameters[6].Value = model.标准答案;
            parameters[7].Value = model.标准答案2;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Eastcom.Model.考试题库 GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select   top 1 id,题目内容,A选项,B选项,C选项,D选项,其他选项,标准答案,标准答案2  from 考试题库 ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Eastcom.Model.考试题库 model = new Eastcom.Model.考试题库();
            DataSet            ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        public void AjaxMethod()
        {
            Eastcom.BLL.月度考核内容_详细 BLL_model_详细 = new Eastcom.BLL.月度考核内容_详细();
            Eastcom.BLL.月度考核内容    BLL_model_列表 = new Eastcom.BLL.月度考核内容();

            Eastcom.Model.月度考核内容_详细 model_详细 = null;
            Eastcom.Model.月度考核内容    model_列表 = null;

            StringBuilder strMsg   = new StringBuilder();
            int           isReload = 0;//0:不刷新父页面   1:刷新父页面
            bool          IsError  = false;

            switch (handleType) //this.PageType
            {
            case "Save":
                #region 保存
                model_详细 = BLL_model_详细.GetModelByBH_YD(CommonClass.StringHander.Common.GetInt(FK_YDKHNR), CommonClass.StringHander.Common.GetInt(id));
                strMsg.Append(this.CommonModel(model_详细));
                if (strMsg.Length == 0)
                {
                    if (BLL_model_详细.Update(model_详细))
                    {
                        IsError = false;
                        strMsg.Append("");
                        Get考核月份();
                    }
                    else
                    {
                        IsError = true;
                        strMsg.Append("更新失败");
                    }
                }
                else
                {
                    IsError = false;
                }
                #endregion
                break;

            case "Submit":
                #region 提交
                List <Eastcom.Model.月度考核内容_详细> ModelList = new List <Eastcom.Model.月度考核内容_详细>();
                ModelList = BLL_model_详细.GetModelList("FK_月度考核内容='" + FK_YDKHNR + "'");
                model_列表  = BLL_model_列表.GetModel(Common.GetInt(FK_YDKHNR));

                decimal 总得分 = 0;
                if (undoneid != 0)
                {
                    IsError = true;
                    strMsg.Append("你还有未完成的题!");
                }
                else
                {
                    foreach (Eastcom.Model.月度考核内容_详细 m in ModelList)
                    {
                        string             用户答案     = m.用户答案 == "" ? ",,," : m.用户答案;
                        Eastcom.Model.考试题库 model_题库 = new Eastcom.Model.考试题库();
                        model_题库 = new Eastcom.BLL.考试题库().GetModel(Common.GetInt(m.题目编号));
                        if (model_题库 != null)
                        {
                            UserPoint c = new UserPoint();
                            c      = c.Get用户得分情况(用户答案, model_题库.标准答案.Trim());
                            m.得分   = c.用户得分;
                            m.回答情况 = c.得分情况;
                            BLL_model_详细.Update(m);
                            总得分 += Common.GetDecimal(m.得分);
                        }
                    }
                }

                model_列表.得分   = 总得分;
                model_列表.提交时间 = DateTime.Now;
                model_列表.提交情况 = Eastcom.ConfigUntility.ConfigArgs.提交情况.已提交.ToString();

                //strMsg.Append(this.CommonModel(model_详细));
                if (strMsg.Length == 0)
                {
                    if (BLL_model_列表.Update(model_列表))
                    {
                        IsError = false;
                        strMsg.Append("提交成功");
                    }
                    else
                    {
                        IsError = true;
                        strMsg.Append("更新失败");
                    }
                }
                else
                {
                    IsError = true;
                }
                #endregion
                break;

            default:
                strMsg.Append("页面操作类型不明确,操作失败!");
                break;
            }

            CommonClass.Message.Log.WriteMessage(new CommonClass.Message.GoAjaxPara()
            {
                msg      = strMsg.ToString(),
                isReload = isReload,
                isError  = IsError,
                msnLog   = "",
                Data     = new ExamId()
                {
                    nextid = nextid.ToString(), preid = preid.ToString(), Undoneid = undoneid.ToString()
                }
            });
        }
Пример #7
0
        protected void Upload1_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                Lbl_Messaage.Text = "";
                Label_1.Text      = "";

                #region

                string fileExt = System.IO.Path.GetExtension(FileUpload1.FileName);
                if (fileExt == ".xls" || fileExt == ".xlsx")
                {
                    #region

                    try
                    {
                        string newname = System.DateTime.Now.ToString("yyyyMMddHHmmssffff");//重命名
                        newname += ".xls";
                        FileUpload1.SaveAs(Server.MapPath("excel") + "\\" + newname);
                        string filename = (Server.MapPath("excel") + "\\" + newname).ToString();


                        if (filename != "")
                        {
                            try
                            {
                                DataTable dt = CommonClass.DataHandler.ExcelToData.ReadExcelToTable(filename, 0);
                                #region 插入
                                Eastcom.BLL.考试题库 bll = new Eastcom.BLL.考试题库();
                                int    success = 0, error = 0;
                                string ErrorMsg = "";

                                DateTime now = DateTime.Now;
                                /*添加备份*/

                                string RealName = "";
                                if (CurrentUserModel != null)
                                {
                                    RealName = CurrentUserModel.RealName;
                                }

                                bll.AddHisBak(now, RealName.ToString());

                                bll.ExecuteTrunCate();


                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    try
                                    {
                                        string 题目内容 = dt.Rows[i]["题目内容"].ToString().Trim();
                                        string 项A   = dt.Rows[i]["选项A"].ToString().Trim();
                                        string 项B   = dt.Rows[i]["选项B"].ToString().Trim();
                                        string 项C   = dt.Rows[i]["选项C"].ToString().Trim();
                                        string 项D   = dt.Rows[i]["选项D"].ToString().Trim();
                                        string 项E   = dt.Rows[i]["选项E"].ToString().Trim();
                                        string 标准答案 = dt.Rows[i]["答案"].ToString().Trim();
                                        //string 标准答案2 = dt.Rows[i]["标准答案2"].ToString().Trim();

                                        Eastcom.Model.考试题库 model = new Eastcom.Model.考试题库();

                                        model.题目内容 = 题目内容;
                                        model.A选项  = 项A;
                                        model.B选项  = 项B;
                                        model.C选项  = 项C;
                                        model.D选项  = 项D;
                                        model.其他选项 = 项E;
                                        //model.标准答案 = 标准答案;
                                        model.标准答案2 = 标准答案;

                                        bll.Add(model);
                                        success++;
                                    }
                                    catch
                                    {
                                        ErrorMsg += "第" + (i + 1) + "行数据录入出错<br>";
                                        error++;
                                    }
                                }
                                bll.Update标准答案();

                                if (error == 0)
                                {
                                    Lbl_Messaage.Text      = success.ToString() + "条导入成功";
                                    Lbl_Messaage.ForeColor = System.Drawing.Color.Green;
                                }
                                else
                                {
                                    Lbl_Messaage.Text = success.ToString() + "条导入成功," + error.ToString()
                                                        + "条导入失败.失败数据请修改后重新导入!<BR>" + ErrorMsg;
                                    Lbl_Messaage.ForeColor = System.Drawing.Color.Red;
                                }

                                #endregion
                            }
                            catch (Exception ex)
                            {
                                Eastcom.Common.MessageBox.Show(this, "导入失败");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Label_1.Text      = "ERROR: " + ex.Message.ToString();
                        Label_1.ForeColor = System.Drawing.Color.Red;
                    }
                    #endregion
                }
                else
                {
                    Label_1.Text      = "只能上传Excel文件!";
                    Label_1.ForeColor = System.Drawing.Color.Red;
                }
                #endregion
            }
            else
            {
                Label_1.Text      = "请选择一个Excel文件。";
                Label_1.ForeColor = System.Drawing.Color.Red;  //字体为 红色 System.Drawing.Color.Red
            }
        }