Пример #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public OnLineTest.Model.PaperCodes DataRowToModel(DataRow row)
 {
     OnLineTest.Model.PaperCodes model = new OnLineTest.Model.PaperCodes();
     if (row != null)
     {
         if (row["PaperCodeId"] != null && row["PaperCodeId"].ToString() != "")
         {
             model.PaperCodeId = int.Parse(row["PaperCodeId"].ToString());
         }
         if (row["SubjectId"] != null && row["SubjectId"].ToString() != "")
         {
             model.SubjectId = int.Parse(row["SubjectId"].ToString());
         }
         if (row["PaperCode"] != null && row["PaperCode"].ToString() != "")
         {
             model.PaperCode = int.Parse(row["PaperCode"].ToString());
         }
         if (row["ChineseName"] != null)
         {
             model.ChineseName = row["ChineseName"].ToString();
         }
         if (row["PaperCodePassScore"] != null && row["PaperCodePassScore"].ToString() != "")
         {
             model.PaperCodePassScore = int.Parse(row["PaperCodePassScore"].ToString());
         }
         if (row["PaperCodeTotalScore"] != null && row["PaperCodeTotalScore"].ToString() != "")
         {
             model.PaperCodeTotalScore = int.Parse(row["PaperCodeTotalScore"].ToString());
         }
         if (row["TimeRange"] != null && row["TimeRange"].ToString() != "")
         {
             model.TimeRange = int.Parse(row["TimeRange"].ToString());
         }
         if (row["PaperCodeRemark"] != null)
         {
             model.PaperCodeRemark = row["PaperCodeRemark"].ToString();
         }
         if (row["IsVerified"] != null && row["IsVerified"].ToString() != "")
         {
             if ((row["IsVerified"].ToString() == "1") || (row["IsVerified"].ToString().ToLower() == "true"))
             {
                 model.IsVerified = true;
             }
             else
             {
                 model.IsVerified = false;
             }
         }
     }
     return(model);
 }
Пример #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(OnLineTest.Model.PaperCodes model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update PaperCodes set ");
            strSql.Append("SubjectId=@SubjectId,");
            strSql.Append("ChineseName=@ChineseName,");
            strSql.Append("PaperCodePassScore=@PaperCodePassScore,");
            strSql.Append("PaperCodeTotalScore=@PaperCodeTotalScore,");
            strSql.Append("TimeRange=@TimeRange,");
            strSql.Append("PaperCodeRemark=@PaperCodeRemark,");
            strSql.Append("IsVerified=@IsVerified");
            strSql.Append(" where PaperCodeId=@PaperCodeId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SubjectId",           SqlDbType.Int,        4),
                new SqlParameter("@ChineseName",         SqlDbType.NVarChar, 100),
                new SqlParameter("@PaperCodePassScore",  SqlDbType.Int,        4),
                new SqlParameter("@PaperCodeTotalScore", SqlDbType.Int,        4),
                new SqlParameter("@TimeRange",           SqlDbType.Int,        4),
                new SqlParameter("@PaperCodeRemark",     SqlDbType.Text),
                new SqlParameter("@IsVerified",          SqlDbType.Bit,        1),
                new SqlParameter("@PaperCodeId",         SqlDbType.Int,        4),
                new SqlParameter("@PaperCode",           SqlDbType.Int, 4)
            };
            parameters[0].Value = model.SubjectId;
            parameters[1].Value = model.ChineseName;
            parameters[2].Value = model.PaperCodePassScore;
            parameters[3].Value = model.PaperCodeTotalScore;
            parameters[4].Value = model.TimeRange;
            parameters[5].Value = model.PaperCodeRemark;
            parameters[6].Value = model.IsVerified;
            parameters[7].Value = model.PaperCodeId;
            parameters[8].Value = model.PaperCode;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(OnLineTest.Model.PaperCodes model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into PaperCodes(");
            strSql.Append("SubjectId,PaperCode,ChineseName,PaperCodePassScore,PaperCodeTotalScore,TimeRange,PaperCodeRemark,IsVerified)");
            strSql.Append(" values (");
            strSql.Append("@SubjectId,@PaperCode,@ChineseName,@PaperCodePassScore,@PaperCodeTotalScore,@TimeRange,@PaperCodeRemark,@IsVerified)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SubjectId",           SqlDbType.Int,        4),
                new SqlParameter("@PaperCode",           SqlDbType.Int,        4),
                new SqlParameter("@ChineseName",         SqlDbType.NVarChar, 100),
                new SqlParameter("@PaperCodePassScore",  SqlDbType.Int,        4),
                new SqlParameter("@PaperCodeTotalScore", SqlDbType.Int,        4),
                new SqlParameter("@TimeRange",           SqlDbType.Int,        4),
                new SqlParameter("@PaperCodeRemark",     SqlDbType.Text),
                new SqlParameter("@IsVerified",          SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.SubjectId;
            parameters[1].Value = model.PaperCode;
            parameters[2].Value = model.ChineseName;
            parameters[3].Value = model.PaperCodePassScore;
            parameters[4].Value = model.PaperCodeTotalScore;
            parameters[5].Value = model.TimeRange;
            parameters[6].Value = model.PaperCodeRemark;
            parameters[7].Value = model.IsVerified;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public OnLineTest.Model.PaperCodes GetModel(int PaperCodeId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 PaperCodeId,SubjectId,PaperCode,ChineseName,PaperCodePassScore,PaperCodeTotalScore,TimeRange,PaperCodeRemark,IsVerified from PaperCodes ");
            strSql.Append(" where PaperCodeId=@PaperCodeId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PaperCodeId", SqlDbType.Int, 4)
            };
            parameters[0].Value = PaperCodeId;

            OnLineTest.Model.PaperCodes model = new OnLineTest.Model.PaperCodes();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }