Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WeiXinPF.Model.wx_wq_chexi model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_wq_chexi set ");
            strSql.Append("pid=@pid,");
            strSql.Append("pic=@pic,");
            strSql.Append("jName=@jName,");
            strSql.Append("Name=@Name,");
            strSql.Append("remark=@remark,");
            strSql.Append("createdate=@createdate,");
            strSql.Append("sort_id=@sort_id,");
            strSql.Append("wid=@wid");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@pid",        SqlDbType.Int,          4),
                new SqlParameter("@pic",        SqlDbType.VarChar,    500),
                new SqlParameter("@jName",      SqlDbType.VarChar,    500),
                new SqlParameter("@Name",       SqlDbType.VarChar,   4000),
                new SqlParameter("@remark",     SqlDbType.VarChar,   2000),
                new SqlParameter("@createdate", SqlDbType.DateTime),
                new SqlParameter("@sort_id",    SqlDbType.Int,          4),
                new SqlParameter("@wid",        SqlDbType.Int,          4),
                new SqlParameter("@Id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.pid;
            parameters[1].Value = model.pic;
            parameters[2].Value = model.jName;
            parameters[3].Value = model.Name;
            parameters[4].Value = model.remark;
            parameters[5].Value = model.createdate;
            parameters[6].Value = model.sort_id;
            parameters[7].Value = model.wid;
            parameters[8].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WeiXinPF.Model.wx_wq_chexi DataRowToModel(DataRow row)
 {
     WeiXinPF.Model.wx_wq_chexi model = new WeiXinPF.Model.wx_wq_chexi();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["pid"] != null && row["pid"].ToString() != "")
         {
             model.pid = int.Parse(row["pid"].ToString());
         }
         if (row["pic"] != null)
         {
             model.pic = row["pic"].ToString();
         }
         if (row["jName"] != null)
         {
             model.jName = row["jName"].ToString();
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
         if (row["createdate"] != null && row["createdate"].ToString() != "")
         {
             model.createdate = DateTime.Parse(row["createdate"].ToString());
         }
         if (row["sort_id"] != null && row["sort_id"].ToString() != "")
         {
             model.sort_id = int.Parse(row["sort_id"].ToString());
         }
         if (row["wid"] != null && row["wid"].ToString() != "")
         {
             model.wid = int.Parse(row["wid"].ToString());
         }
     }
     return(model);
 }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WeiXinPF.Model.wx_wq_chexi model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_wq_chexi(");
            strSql.Append("pid,pic,jName,Name,remark,createdate,sort_id,wid)");
            strSql.Append(" values (");
            strSql.Append("@pid,@pic,@jName,@Name,@remark,@createdate,@sort_id,@wid)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@pid",        SqlDbType.Int,          4),
                new SqlParameter("@pic",        SqlDbType.VarChar,    500),
                new SqlParameter("@jName",      SqlDbType.VarChar,    500),
                new SqlParameter("@Name",       SqlDbType.VarChar,   4000),
                new SqlParameter("@remark",     SqlDbType.VarChar,   2000),
                new SqlParameter("@createdate", SqlDbType.DateTime),
                new SqlParameter("@sort_id",    SqlDbType.Int,          4),
                new SqlParameter("@wid",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.pid;
            parameters[1].Value = model.pic;
            parameters[2].Value = model.jName;
            parameters[3].Value = model.Name;
            parameters[4].Value = model.remark;
            parameters[5].Value = model.createdate;
            parameters[6].Value = model.sort_id;
            parameters[7].Value = model.wid;

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

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

            strSql.Append("select  top 1 Id,pid,pic,jName,Name,remark,createdate,sort_id,wid from wx_wq_chexi ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

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