Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WeiXinPF.Model.wx_sjb_richeng model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_sjb_richeng set ");
            strSql.Append("wid=@wid,");
            strSql.Append("rcName=@rcName,");
            strSql.Append("beginDate=@beginDate,");
            strSql.Append("endDate=@endDate,");
            strSql.Append("rcPic=@rcPic,");
            strSql.Append("remark=@remark,");
            strSql.Append("sort_id=@sort_id ");
            //strSql.Append("createDate=@createDate");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",       SqlDbType.Int,          4),
                new SqlParameter("@rcName",    SqlDbType.VarChar,    200),
                new SqlParameter("@beginDate", SqlDbType.DateTime),
                new SqlParameter("@endDate",   SqlDbType.DateTime),
                new SqlParameter("@rcPic",     SqlDbType.VarChar,    800),
                new SqlParameter("@remark",    SqlDbType.VarChar,   2000),
                new SqlParameter("@sort_id",   SqlDbType.Int,          4),
                //new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.wid;
            parameters[1].Value = model.rcName;
            parameters[2].Value = model.beginDate;
            parameters[3].Value = model.endDate;
            parameters[4].Value = model.rcPic;
            parameters[5].Value = model.remark;
            parameters[6].Value = model.sort_id;
            //parameters[7].Value = model.createDate;
            parameters[7].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WeiXinPF.Model.wx_sjb_richeng DataRowToModel(DataRow row)
 {
     WeiXinPF.Model.wx_sjb_richeng model = new WeiXinPF.Model.wx_sjb_richeng();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["wid"] != null && row["wid"].ToString() != "")
         {
             model.wid = int.Parse(row["wid"].ToString());
         }
         if (row["rcName"] != null)
         {
             model.rcName = row["rcName"].ToString();
         }
         if (row["beginDate"] != null && row["beginDate"].ToString() != "")
         {
             model.beginDate = DateTime.Parse(row["beginDate"].ToString());
         }
         if (row["endDate"] != null && row["endDate"].ToString() != "")
         {
             model.endDate = DateTime.Parse(row["endDate"].ToString());
         }
         if (row["rcPic"] != null)
         {
             model.rcPic = row["rcPic"].ToString();
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
         if (row["sort_id"] != null && row["sort_id"].ToString() != "")
         {
             model.sort_id = int.Parse(row["sort_id"].ToString());
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
     }
     return(model);
 }
Esempio n. 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WeiXinPF.Model.wx_sjb_richeng model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_sjb_richeng(");
            strSql.Append("wid,rcName,beginDate,endDate,rcPic,remark,sort_id,createDate)");
            strSql.Append(" values (");
            strSql.Append("@wid,@rcName,@beginDate,@endDate,@rcPic,@remark,@sort_id,@createDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",        SqlDbType.Int,          4),
                new SqlParameter("@rcName",     SqlDbType.VarChar,    200),
                new SqlParameter("@beginDate",  SqlDbType.DateTime),
                new SqlParameter("@endDate",    SqlDbType.DateTime),
                new SqlParameter("@rcPic",      SqlDbType.VarChar,    800),
                new SqlParameter("@remark",     SqlDbType.VarChar,   2000),
                new SqlParameter("@sort_id",    SqlDbType.Int,          4),
                new SqlParameter("@createDate", SqlDbType.DateTime)
            };
            parameters[0].Value = model.wid;
            parameters[1].Value = model.rcName;
            parameters[2].Value = model.beginDate;
            parameters[3].Value = model.endDate;
            parameters[4].Value = model.rcPic;
            parameters[5].Value = model.remark;
            parameters[6].Value = model.sort_id;
            parameters[7].Value = model.createDate;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WeiXinPF.Model.wx_sjb_richeng GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,wid,rcName,beginDate,endDate,rcPic,remark,sort_id,createDate from wx_sjb_richeng ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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