Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(demo1.Model.yhjs model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_yhjs set ");
            strSql.Append("yhid=@yhid,");
            strSql.Append("jsid=@jsid");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@yhid", SqlDbType.Int, 4),
                new SqlParameter("@jsid", SqlDbType.Int, 4),
                new SqlParameter("@id",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.yhid;
            parameters[1].Value = model.jsid;
            parameters[2].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(demo1.Model.yhjs model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_yhjs(");
            strSql.Append("yhid,jsid)");
            strSql.Append(" values (");
            strSql.Append("@yhid,@jsid)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@yhid", SqlDbType.Int, 4),
                new SqlParameter("@jsid", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.yhid;
            parameters[1].Value = model.jsid;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public demo1.Model.yhjs DataRowToModel(DataRow row)
 {
     demo1.Model.yhjs model = new demo1.Model.yhjs();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["yhid"] != null && row["yhid"].ToString() != "")
         {
             model.yhid = int.Parse(row["yhid"].ToString());
         }
         if (row["jsid"] != null && row["jsid"].ToString() != "")
         {
             model.jsid = int.Parse(row["jsid"].ToString());
         }
     }
     return(model);
 }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public demo1.Model.yhjs GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,yhid,jsid from t_yhjs ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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