Beispiel #1
0
        /// <summary>
        /// 获得Model
        /// </summary>
        /// <param name="Top">大于0取前几行数据,否则取全部</param>
        /// <param name="whereStr">where条件</param>
        /// <param name="filedOrder">排序字段Order By + filedOrder (不可为空)</param>
        /// <returns></returns>
        public Model.common_questions GetModel(int Top, string whereStr, string filedOrder)
        {
            DataTable dt = dal.GetList(Top, whereStr, filedOrder).Tables[0];

            Model.common_questions model = dt.Rows.Count > 0 ? DataRowToModel(dt.Rows[0]) : null;
            return(model);
        }
        private bool DoEdit()
        {
            bool result = false;

            BLL.common_questions   bll   = new BLL.common_questions();
            Model.common_questions model = bll.GetModel(this.id);

            model.group_id = Convert.ToInt32(this.rbtnGroup.SelectedValue);
            model.type     = Convert.ToInt32(this.rbtnType.SelectedValue);
            model.data_id  = this.chapter;
            model.number   = 0;
            model.title    = Convert.ToString(this.txttitle.Text.Trim());
            model.answer   = (model.type == (int)EnumCollection.questions_type.单选题 || model.type == (int)EnumCollection.questions_type.多选题 ||
                              model.type == (int)EnumCollection.questions_type.判断题) ? this.txtAnswers.Text.Trim().ToUpper() : this.txtAnswers.Text.Trim();
            model.score    = Convert.ToDecimal(this.txtscore.Text.Trim());
            model.analysis = Convert.ToString(this.txtanalysis.Text.Trim());
            model.add_time = System.DateTime.Now;

            if (bll.Update(model))
            {
                AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改试题信息,主键:" + id); //记录日志
                result = true;
            }
            return(result);
        }
Beispiel #3
0
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_ybd_common_questions", EnumCollection.ActionEnum.Modify.ToString()); //检查权限
            BLL.common_questions   bll   = new BLL.common_questions();
            Model.common_questions model = bll.GetModel(this.id);

            model.group_id = Convert.ToInt32(txtgroup_id.Text);
            model.type     = Convert.ToInt32(txttype.Text);
            model.data_id  = Convert.ToInt32(txtdata_id.Text);
            model.number   = Convert.ToInt32(txtnumber.Text);
            model.title    = Convert.ToString(txttitle.Text);
            model.answer   = Convert.ToString(txtanswer.Text);
            model.score    = Convert.ToDecimal(txtscore.Text);
            model.analysis = Convert.ToString(txtanalysis.Text);
            model.add_time = Convert.ToDateTime(txtadd_time.Text);

            if (bll.Update(model))
            {
                AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改题目信息信息,主键:" + id); //记录日志
                JscriptMsg("修改题目信息信息成功!", "Manage.aspx");
            }
            else
            {
                JscriptMsg("保存过程中发生错误!", "");
            }
        }
Beispiel #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.common_questions model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(@"Insert Into ybd_common_questions(
                group_id            
                            ,type            
                            ,data_id            
                            ,number            
                            ,title            
                            ,answer            
                            ,score            
                            ,analysis            
                            ,add_time            
             ) Values (
                @group_id               
                            ,@type               
                            ,@data_id               
                            ,@number               
                            ,@title               
                            ,@answer               
                            ,@score               
                            ,@analysis               
                            ,@add_time               
             );
            SELECT @@IDENTITY;");

            SqlParameter[] parameters =
            {
                new SqlParameter("@group_id", SqlDbType.Int,                             4)
                ,                             new SqlParameter("@type",     SqlDbType.Int, 4)
                ,                             new SqlParameter("@data_id",  SqlDbType.Int, 4)
                ,                             new SqlParameter("@number",   SqlDbType.Int, 4)
                ,                             new SqlParameter("@title",    SqlDbType.NVarChar, 200)
                ,                             new SqlParameter("@answer",   SqlDbType.NVarChar, 4000)
                ,                             new SqlParameter("@score",    SqlDbType.Decimal, 5)
                ,                             new SqlParameter("@analysis", SqlDbType.NVarChar, 2000)
                ,                             new SqlParameter("@add_time", SqlDbType.DateTime, 8)
            };
            parameters[0].Value = model.group_id;
            parameters[1].Value = model.type;
            parameters[2].Value = model.data_id;
            parameters[3].Value = model.number;
            parameters[4].Value = model.title;
            parameters[5].Value = model.answer;
            parameters[6].Value = model.score;
            parameters[7].Value = model.analysis;
            parameters[8].Value = model.add_time;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.common_questions DataRowToModel(DataRow row)
 {
     Model.common_questions model = new Model.common_questions();
     if (row != null)
     {
         if (row["id"] != null) //&& row["id"].ToString() != ""
         {
             model.id = Convert.ToInt32(row["id"]);
         }
         if (row["group_id"] != null) //&& row["group_id"].ToString() != ""
         {
             model.group_id = Convert.ToInt32(row["group_id"]);
         }
         if (row["type"] != null) //&& row["type"].ToString() != ""
         {
             model.type = Convert.ToInt32(row["type"]);
         }
         if (row["data_id"] != null) //&& row["data_id"].ToString() != ""
         {
             model.data_id = Convert.ToInt32(row["data_id"]);
         }
         if (row["number"] != null) //&& row["number"].ToString() != ""
         {
             model.number = Convert.ToInt32(row["number"]);
         }
         if (row["title"] != null) //&& row["title"].ToString() != ""
         {
             model.title = Convert.ToString(row["title"]);
         }
         if (row["answer"] != null) //&& row["answer"].ToString() != ""
         {
             model.answer = Convert.ToString(row["answer"]);
         }
         if (row["score"] != null) //&& row["score"].ToString() != ""
         {
             model.score = Convert.ToDecimal(row["score"]);
         }
         if (row["analysis"] != null) //&& row["analysis"].ToString() != ""
         {
             model.analysis = Convert.ToString(row["analysis"]);
         }
         if (row["add_time"] != null && row["add_time"].ToString() != "")
         {
             model.add_time = Convert.ToDateTime(row["add_time"]);
         }
         return(model);
     }
     else
     {
         return(null);
     }
 }
Beispiel #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.common_questions model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(@"UPDATE ybd_common_questions SET 
                group_id = @group_id
                ,type = @type
                ,data_id = @data_id
                ,number = @number
                ,title = @title
                ,answer = @answer
                ,score = @score
                ,analysis = @analysis
                ,add_time = @add_time
            WHERE id = @id");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int,                       4)
                ,                       new SqlParameter("@group_id", SqlDbType.Int, 4)
                ,                       new SqlParameter("@type",     SqlDbType.Int, 4)
                ,                       new SqlParameter("@data_id",  SqlDbType.Int, 4)
                ,                       new SqlParameter("@number",   SqlDbType.Int, 4)
                ,                       new SqlParameter("@title",    SqlDbType.NVarChar, 200)
                ,                       new SqlParameter("@answer",   SqlDbType.NVarChar, 4000)
                ,                       new SqlParameter("@score",    SqlDbType.Decimal, 5)
                ,                       new SqlParameter("@analysis", SqlDbType.NVarChar, 2000)
                ,                       new SqlParameter("@add_time", SqlDbType.DateTime, 8)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.group_id;
            parameters[2].Value = model.type;
            parameters[3].Value = model.data_id;
            parameters[4].Value = model.number;
            parameters[5].Value = model.title;
            parameters[6].Value = model.answer;
            parameters[7].Value = model.score;
            parameters[8].Value = model.analysis;
            parameters[9].Value = model.add_time;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void ShowInfo()
        {
            BLL.common_questions   bll   = new BLL.common_questions();
            Model.common_questions model = bll.GetModel(this.id);
            if (model == null)
            {
                JscriptMsg("信息不存在或已被删除!", "back");
                return;
            }

            this.rbtnGroup.SelectedValue = model.group_id + "";
            this.rbtnType.SelectedValue  = model.type + "";
            this.txttitle.Text           = model.title + "";
            this.txtAnswers.Text         = model.answer + "";
            this.txtscore.Text           = Convert.ToInt32(model.score) + "";
            this.txtanalysis.Text        = model.analysis + "";
        }
Beispiel #8
0
 private void BindInfo()
 {
     BLL.common_questions   bll   = new BLL.common_questions();
     Model.common_questions model = bll.GetModel(this.id);
     if (model == null)
     {
         JscriptMsg("信息不存在或已被删除!", "back");
         return;
     }
     txtgroup_id.Text = model.group_id + "";
     txttype.Text     = model.type + "";
     txtdata_id.Text  = model.data_id + "";
     txtnumber.Text   = model.number + "";
     txttitle.Text    = model.title + "";
     txtanswer.Text   = model.answer + "";
     txtscore.Text    = model.score + "";
     txtanalysis.Text = model.analysis + "";
     txtadd_time.Text = model.add_time + "";
 }
Beispiel #9
0
        private void saveQuestionOptions()
        {
            int    id       = RequestHelper.GetFormInt("id");
            int    group    = RequestHelper.GetFormInt("group", 0);
            int    type     = RequestHelper.GetFormInt("type", 0);
            int    chapter  = RequestHelper.GetFormInt("chapter", 0);
            string title    = RequestHelper.GetFormString("title");
            int    score    = RequestHelper.GetFormInt("score", 0);
            string answers  = RequestHelper.GetFormString("answers");
            string analysis = RequestHelper.GetFormString("analysis");
            string options  = RequestHelper.GetFormString("options");

            Appoa.Web.UI.ManagePage mngPage = new Web.UI.ManagePage();
            BLL.common_questions    bll     = new BLL.common_questions();
            Model.common_questions  model   = bll.GetModel(id);

            if (model != null)
            {
                #region 修改题目信息
                model.group_id = group;
                model.type     = type;
                model.data_id  = chapter;
                model.number   = 0;
                model.title    = title;
                model.answer   = (model.type == (int)EnumCollection.questions_type.单选题 || model.type == (int)EnumCollection.questions_type.多选题 ||
                                  model.type == (int)EnumCollection.questions_type.判断题) ? answers.Trim().ToUpper() : answers.Trim();
                model.score    = score;
                model.analysis = HttpUtility.UrlDecode(analysis, System.Text.Encoding.UTF8);

                if (bll.Update(model))
                {
                    try
                    {
                        #region  择题设置选项
                        if (model.type == (int)EnumCollection.questions_type.单选题 || model.type == (int)EnumCollection.questions_type.多选题 || model.type == (int)EnumCollection.questions_type.判断题)
                        {
                            JArray               optionArr = JsonConvert.DeserializeObject <JArray>(options);
                            BLL.common_answers   anBll     = new BLL.common_answers();
                            Model.common_answers anModel   = null;

                            List <int> ids = new List <int>();
                            foreach (JObject obj in optionArr)
                            {
                                ids.Add(Convert.ToInt32(obj["options_id"].ToString()));
                            }

                            DataTable dt = anBll.GetList(" question_id = " + model.id);
                            foreach (DataRow item in dt.Rows)
                            {
                                int afid = Convert.ToInt32(item["id"]);
                                if (afid > 0)
                                {
                                    if (!ids.Contains(afid))
                                    {
                                        anBll.Delete(afid);
                                    }
                                }
                            }

                            foreach (JObject item in optionArr)
                            {
                                int options_id = Convert.ToInt32(item["options_id"]);
                                anModel = anBll.GetModel(options_id);
                                if (anModel != null)
                                {
                                    #region 修改选项
                                    anModel.question_id = model.id;
                                    anModel.options     = item["options"].ToString();
                                    anModel.contents    = item["options_contents"].ToString();
                                    anModel.score       = Convert.ToInt32(item["options_score"].ToString());
                                    if (anBll.Update(anModel))
                                    {
                                        mngPage.AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改选项信息,主键:" + options_id); //记录日志
                                    }
                                    #endregion
                                }
                                else
                                {
                                    #region 添加选项
                                    anModel             = new Model.common_answers();
                                    anModel.question_id = model.id;
                                    anModel.options     = item["options"].ToString();
                                    anModel.contents    = item["options_contents"].ToString();
                                    anModel.score       = Convert.ToInt32(item["options_score"].ToString());
                                    anModel.add_time    = System.DateTime.Now;

                                    int anid = anBll.Add(anModel);
                                    if (anid > 0)
                                    {
                                        mngPage.AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加选项信息,主键:" + anid); //记录日志
                                    }
                                    #endregion
                                }
                            }
                        }
                        #endregion
                    }
                    catch (Exception e)
                    {
                        writeMsgError("系统错误:" + e.Message);
                    }

                    mngPage.AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改试题信息,主键:" + model.id); //记录日志

                    writeMsgSuccess("修改题目信息成功");
                }
                else
                {
                    writeMsgError("修改题目信息失败");
                }
                #endregion
            }
            else
            {
                #region 添加题目信息
                model          = new Model.common_questions();
                model.group_id = group;
                model.type     = type;
                model.data_id  = chapter;
                model.number   = 0;
                model.title    = title;
                model.answer   = (model.type == (int)EnumCollection.questions_type.单选题 || model.type == (int)EnumCollection.questions_type.多选题 ||
                                  model.type == (int)EnumCollection.questions_type.判断题) ? answers.Trim().ToUpper() : answers.Trim();
                model.score    = score;
                model.analysis = HttpUtility.UrlDecode(analysis, System.Text.Encoding.UTF8);
                model.add_time = System.DateTime.Now;

                int qid = bll.Add(model);
                if (qid > 0)
                {
                    try
                    {
                        #region  择题设置选项
                        if (model.type == (int)EnumCollection.questions_type.单选题 || model.type == (int)EnumCollection.questions_type.多选题 || model.type == (int)EnumCollection.questions_type.判断题)
                        {
                            JArray               optionArr = JsonConvert.DeserializeObject <JArray>(options);
                            BLL.common_answers   anBll     = new BLL.common_answers();
                            Model.common_answers anModel   = null;

                            foreach (JObject item in optionArr)
                            {
                                int options_id = Convert.ToInt32(item["options_id"]);
                                if (options_id > 0)
                                {
                                    #region 修改选项
                                    anModel = anBll.GetModel(options_id);
                                    if (anModel != null)
                                    {
                                        anModel.question_id = qid;
                                        anModel.options     = item["options"].ToString();
                                        anModel.contents    = item["options_contents"].ToString();
                                        anModel.score       = Convert.ToInt32(item["options_score"].ToString());
                                        if (anBll.Update(anModel))
                                        {
                                            mngPage.AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改选项信息,主键:" + options_id); //记录日志
                                        }
                                    }
                                    #endregion
                                }
                                else
                                {
                                    #region 添加选项
                                    anModel             = new Model.common_answers();
                                    anModel.question_id = qid;
                                    anModel.options     = item["options"].ToString();
                                    anModel.contents    = item["options_contents"].ToString();
                                    anModel.score       = Convert.ToInt32(item["options_score"].ToString());
                                    anModel.add_time    = System.DateTime.Now;

                                    int anid = anBll.Add(anModel);
                                    if (anid > 0)
                                    {
                                        mngPage.AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加选项信息,主键:" + anid); //记录日志
                                    }
                                    #endregion
                                }
                            }
                        }
                        #endregion
                    }
                    catch (Exception e)
                    {
                        writeMsgError("系统错误:" + e.Message);
                    }

                    mngPage.AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加试题信息,主键:" + qid); //记录日志

                    writeMsgSuccess("添加题目信息成功");
                }
                else
                {
                    writeMsgError("添加题目信息失败");
                }
                #endregion
            }
        }
Beispiel #10
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.common_questions model)
 {
     return(dal.Update(model));
 }
Beispiel #11
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.common_questions model)
 {
     return(dal.Add(model));
 }
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_ybd_common_questions", EnumCollection.ActionEnum.Add.ToString()); //检查权限

            #region
            string strError = string.Empty;
            if (txtgroup_id.Text.Trim() == "" || txtgroup_id.Text.Trim().Length > 4)
            {
                strError += "分组ID为空或超出长度![br]";
            }
            if (txttype.Text.Trim() == "" || txttype.Text.Trim().Length > 4)
            {
                strError += "题型为空或超出长度![br]";
            }
            if (txtdata_id.Text.Trim() == "" || txtdata_id.Text.Trim().Length > 4)
            {
                strError += "关联数据ID为空或超出长度![br]";
            }
            if (txtnumber.Text.Trim() == "" || txtnumber.Text.Trim().Length > 4)
            {
                strError += "序号为空或超出长度![br]";
            }
            if (txttitle.Text.Trim() == "" || txttitle.Text.Trim().Length > 200)
            {
                strError += "标题为空或超出长度![br]";
            }
            if (txtanswer.Text.Trim() == "" || txtanswer.Text.Trim().Length > 4000)
            {
                strError += "参考答案为空或超出长度![br]";
            }
            if (txtscore.Text.Trim() == "" || txtscore.Text.Trim().Length > 5)
            {
                strError += "分值为空或超出长度![br]";
            }
            if (txtanalysis.Text.Trim() == "" || txtanalysis.Text.Trim().Length > 2000)
            {
                strError += "解析为空或超出长度![br]";
            }
            if (txtadd_time.Text.Trim() == "" || txtadd_time.Text.Trim().Length > 8)
            {
                strError += "添加时间为空或超出长度![br]";
            }

            if (strError != string.Empty)
            {
                JscriptMsg(strError, "", "Error");
                return;
            }
            #endregion

            Model.common_questions model = new Model.common_questions();
            BLL.common_questions   bll   = new BLL.common_questions();

            model.group_id = Convert.ToInt32(txtgroup_id.Text);
            model.type     = Convert.ToInt32(txttype.Text);
            model.data_id  = Convert.ToInt32(txtdata_id.Text);
            model.number   = Convert.ToInt32(txtnumber.Text);
            model.title    = Convert.ToString(txttitle.Text);
            model.answer   = Convert.ToString(txtanswer.Text);
            model.score    = Convert.ToDecimal(txtscore.Text);
            model.analysis = Convert.ToString(txtanalysis.Text);
            model.add_time = Convert.ToDateTime(txtadd_time.Text);

            int id = bll.Add(model);
            if (id > 0)
            {
                AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加题目信息信息,主键:" + id); //记录日志
                JscriptMsg("添加题目信息信息成功!", "Manage.aspx", "");
            }
            else
            {
                JscriptMsg("保存过程中发生错误!", "");
            }
        }
        private DataTable ExcelToDataTable(string filePath, bool isColumnName)
        {
            int chapter = RequestHelper.GetQueryInt("chapter");

            DataTable  dataTable     = null;
            DataTable  dtOption      = null;
            FileStream fs            = null;
            DataColumn column        = null;
            DataRow    dataRow       = null;
            IWorkbook  workbook      = null;
            ISheet     sheetQuestion = null;
            ISheet     sheetOption   = null;
            IRow       row           = null;
            ICell      cell          = null;
            int        startRow      = 0;

            BLL.common_questions qbll = new BLL.common_questions();
            BLL.common_answers   obll = new BLL.common_answers();
            int group = Convert.ToInt32(this.rbtnGroup.SelectedValue);

            try
            {
                using (fs = File.OpenRead(filePath))
                {
                    // 2007版本
                    if (filePath.IndexOf(".xlsx") > 0)
                    {
                        workbook = new XSSFWorkbook(fs);
                    }
                    // 2003版本
                    else if (filePath.IndexOf(".xls") > 0)
                    {
                        workbook = new HSSFWorkbook(fs);
                    }

                    Dictionary <string, int> dic = GetQuestionDic();
                    if (workbook != null)
                    {
                        #region 问题表
                        sheetQuestion = workbook.GetSheetAt(0);//读取第一个sheetQuestion,当然也可以循环读取每个sheetQuestion
                        dataTable     = new DataTable();
                        if (sheetQuestion != null)
                        {
                            int rowCount = sheetQuestion.LastRowNum;//总行数
                            if (rowCount > 0)
                            {
                                IRow firstRow  = sheetQuestion.GetRow(0); //第一行
                                int  cellCount = firstRow.LastCellNum;    //列数

                                //构建datatable的列
                                if (isColumnName)
                                {
                                    startRow = 1;//如果第一行是列名,则从第二行开始读取
                                    for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
                                    {
                                        cell = firstRow.GetCell(i);
                                        if (cell != null)
                                        {
                                            if (cell.StringCellValue != null)
                                            {
                                                column = new DataColumn(cell.StringCellValue);
                                                dataTable.Columns.Add(column);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
                                    {
                                        column = new DataColumn("column" + (i + 1));
                                        dataTable.Columns.Add(column);
                                    }
                                }

                                //填充行
                                for (int i = startRow; i <= rowCount; ++i)
                                {
                                    row = sheetQuestion.GetRow(i);
                                    if (row == null)
                                    {
                                        continue;
                                    }

                                    dataRow = dataTable.NewRow();
                                    for (int j = row.FirstCellNum; j < cellCount; ++j)
                                    {
                                        cell = row.GetCell(j);
                                        if (cell == null)
                                        {
                                            dataRow[j] = "";
                                        }
                                        else
                                        {
                                            //CellType(Unknown = -1,Numeric = 0,String = 1,Formula = 2,Blank = 3,Boolean = 4,Error = 5,)
                                            switch (cell.CellType)
                                            {
                                            case CellType.Blank:
                                                dataRow[j] = "";
                                                break;

                                            case CellType.Numeric:
                                                short format = cell.CellStyle.DataFormat;
                                                //对时间格式(2015.12.5、2015/12/5、2015-12-5等)的处理
                                                if (format == 14 || format == 31 || format == 57 || format == 58)
                                                {
                                                    dataRow[j] = cell.DateCellValue;
                                                }
                                                else
                                                {
                                                    dataRow[j] = cell.NumericCellValue;
                                                }
                                                break;

                                            case CellType.String:
                                                dataRow[j] = cell.StringCellValue;
                                                break;
                                            }
                                        }
                                    }
                                    dataTable.Rows.Add(dataRow);
                                }
                            }
                        }
                        #endregion

                        Model.common_questions question = null;

                        foreach (DataRow item in dataTable.Rows)
                        {
                            question = qbll.GetModel(" group_id = " + group + " and title = '" + item[0].ToString() + "' ");
                            if (question == null)
                            {
                                question          = new Model.common_questions();
                                question.group_id = group;
                                question.type     = dic[item[1].ToString()];
                                question.data_id  = chapter;
                                question.number   = 0;
                                question.title    = item[0].ToString();
                                question.answer   = item[2].ToString();
                                question.score    = Convert.ToDecimal(item[3]);
                                question.analysis = item[4].ToString();
                                question.add_time = System.DateTime.Now;

                                qbll.Add(question);
                            }
                            else
                            {
                                question.group_id = group;
                                question.type     = dic[item[1].ToString()];
                                question.data_id  = chapter;
                                question.number   = 0;
                                question.answer   = item[2].ToString();
                                question.score    = Convert.ToDecimal(item[3]);
                                question.analysis = item[4].ToString();

                                qbll.Update(question);
                            }
                        }

                        #region  项表
                        sheetOption = workbook.GetSheetAt(1);//读取第一个sheetOption,当然也可以循环读取每个sheetOption
                        dtOption    = new DataTable();
                        if (sheetOption != null)
                        {
                            int rowCount = sheetOption.LastRowNum;//总行数
                            if (rowCount > 0)
                            {
                                IRow firstRow  = sheetOption.GetRow(0); //第一行
                                int  cellCount = firstRow.LastCellNum;  //列数

                                //构建datatable的列
                                if (isColumnName)
                                {
                                    startRow = 1;//如果第一行是列名,则从第二行开始读取
                                    for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
                                    {
                                        cell = firstRow.GetCell(i);
                                        if (cell != null)
                                        {
                                            if (cell.StringCellValue != null)
                                            {
                                                column = new DataColumn(cell.StringCellValue);
                                                dtOption.Columns.Add(column);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
                                    {
                                        column = new DataColumn("column" + (i + 1));
                                        dtOption.Columns.Add(column);
                                    }
                                }

                                //填充行
                                for (int i = startRow; i <= rowCount; ++i)
                                {
                                    row = sheetOption.GetRow(i);
                                    if (row == null)
                                    {
                                        continue;
                                    }

                                    dataRow = dtOption.NewRow();
                                    for (int j = row.FirstCellNum; j < cellCount; ++j)
                                    {
                                        cell = row.GetCell(j);
                                        if (cell == null)
                                        {
                                            dataRow[j] = "";
                                        }
                                        else
                                        {
                                            //CellType(Unknown = -1,Numeric = 0,String = 1,Formula = 2,Blank = 3,Boolean = 4,Error = 5,)
                                            switch (cell.CellType)
                                            {
                                            case CellType.Blank:
                                                dataRow[j] = "";
                                                break;

                                            case CellType.Numeric:
                                                short format = cell.CellStyle.DataFormat;
                                                //对时间格式(2015.12.5、2015/12/5、2015-12-5等)的处理
                                                if (format == 14 || format == 31 || format == 57 || format == 58)
                                                {
                                                    dataRow[j] = cell.DateCellValue;
                                                }
                                                else
                                                {
                                                    dataRow[j] = cell.NumericCellValue;
                                                }
                                                break;

                                            case CellType.String:
                                                dataRow[j] = cell.StringCellValue;
                                                break;
                                            }
                                        }
                                    }
                                    dtOption.Rows.Add(dataRow);
                                }
                            }
                        }
                        #endregion

                        Model.common_questions qModle = null;
                        Model.common_answers   option = null;

                        foreach (DataRow item in dtOption.Rows)
                        {
                            qModle = qbll.GetModel(" group_id = " + group + " and title = '" + item[0].ToString() + "' ");
                            if (qModle != null)
                            {
                                option = obll.GetModel(" question_id = " + qModle.id + " and contents = '" + item[2].ToString() + "' ");
                                if (option == null)
                                {
                                    option             = new Model.common_answers();
                                    option.question_id = qModle.id;
                                    option.options     = item[1].ToString();
                                    option.contents    = item[2].ToString();
                                    option.score       = dtOption.Columns.Count > 3 ? Convert.ToInt32(item[3].ToString()) : 0;
                                    option.add_time    = System.DateTime.Now;

                                    obll.Add(option);
                                }
                                else
                                {
                                    option.options = item[1].ToString();
                                    option.score   = dtOption.Columns.Count > 3 ? Convert.ToInt32(item[3].ToString()) : 0;

                                    obll.Update(option);
                                }
                            }
                        }
                    }
                }
                return(dataTable);
            }
            catch (Exception)
            {
                if (fs != null)
                {
                    fs.Close();
                }
                return(null);
            }
        }