Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ScoreManage.Model.StudScoreInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update StudScoreInfo set ");
            strSql.Append("studNo=SQL2012studNo,");
            strSql.Append("courseID=SQL2012courseID,");
            strSql.Append("studScore=SQL2012studScore");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012studNo",    SqlDbType.NVarChar, 255),
                new SqlParameter("SQL2012courseID",  SqlDbType.NVarChar, 255),
                new SqlParameter("SQL2012studScore", SqlDbType.Float, 8)
            };
            parameters[0].Value = model.studNo;
            parameters[1].Value = model.courseID;
            parameters[2].Value = model.studScore;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ScoreManage.Model.StudScoreInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into StudScoreInfo(");
            strSql.Append("studNo,courseID,studScore)");
            strSql.Append(" values (");
            strSql.Append("@SQL2012studNo,@SQL2012courseID,@SQL2012studScore)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SQL2012studNo",    SqlDbType.NVarChar, 255),
                new SqlParameter("@SQL2012courseID",  SqlDbType.NVarChar, 255),
                new SqlParameter("@SQL2012studScore", SqlDbType.Float, 8)
            };
            parameters[0].Value = model.studNo;
            parameters[1].Value = model.courseID;
            parameters[2].Value = model.studScore;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ScoreManage.Model.StudScoreInfo DataRowToModel(DataRow row)
 {
     ScoreManage.Model.StudScoreInfo model = new ScoreManage.Model.StudScoreInfo();
     if (row != null)
     {
         if (row["studNo"] != null)
         {
             model.studNo = row["studNo"].ToString();
         }
         if (row["courseID"] != null)
         {
             model.courseID = row["courseID"].ToString();
         }
         if (row["studScore"] != null && row["studScore"].ToString() != "")
         {
             model.studScore = decimal.Parse(row["studScore"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ScoreManage.Model.StudScoreInfo GetModel()
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 studNo,courseID,studScore from StudScoreInfo ");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
            };

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

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