Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DiDaJiangCheng.Model.tbScoreInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tbScoreInfo(");
            strSql.Append("filedStuNo,filedCourseId,filedScore");
            strSql.Append(") values (");
            strSql.Append("@filedStuNo,@filedCourseId,@filedScore");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@filedStuNo",    SqlDbType.NVarChar, 50),
                new SqlParameter("@filedCourseId", SqlDbType.Int,       4),
                new SqlParameter("@filedScore",    SqlDbType.Float, 8)
            };

            parameters[0].Value = model.filedStuNo;
            parameters[1].Value = model.filedCourseId;
            parameters[2].Value = model.filedScore;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DiDaJiangCheng.Model.tbScoreInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tbScoreInfo set ");

            strSql.Append(" filedStuNo = @filedStuNo , ");
            strSql.Append(" filedCourseId = @filedCourseId , ");
            strSql.Append(" filedScore = @filedScore  ");
            strSql.Append(" where filedaScoreId=@filedaScoreId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@filedaScoreId", SqlDbType.Int,       4),
                new SqlParameter("@filedStuNo",    SqlDbType.NVarChar, 50),
                new SqlParameter("@filedCourseId", SqlDbType.Int,       4),
                new SqlParameter("@filedScore",    SqlDbType.Float, 8)
            };

            parameters[0].Value = model.filedaScoreId;
            parameters[1].Value = model.filedStuNo;
            parameters[2].Value = model.filedCourseId;
            parameters[3].Value = model.filedScore;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DiDaJiangCheng.Model.tbScoreInfo GetModel(int filedaScoreId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select filedaScoreId, filedStuNo, filedCourseId, filedScore  ");
            strSql.Append("  from tbScoreInfo ");
            strSql.Append(" where filedaScoreId=@filedaScoreId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@filedaScoreId", SqlDbType.Int, 4)
            };
            parameters[0].Value = filedaScoreId;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["filedaScoreId"].ToString() != "")
                {
                    model.filedaScoreId = int.Parse(ds.Tables[0].Rows[0]["filedaScoreId"].ToString());
                }
                model.filedStuNo = ds.Tables[0].Rows[0]["filedStuNo"].ToString();
                if (ds.Tables[0].Rows[0]["filedCourseId"].ToString() != "")
                {
                    model.filedCourseId = int.Parse(ds.Tables[0].Rows[0]["filedCourseId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["filedScore"].ToString() != "")
                {
                    model.filedScore = decimal.Parse(ds.Tables[0].Rows[0]["filedScore"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }