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

            strSql.Append("update wx_ucard_gift set ");
            strSql.Append("wid=@wid,");
            strSql.Append("gName=@gName,");
            strSql.Append("score=@score,");
            strSql.Append("beginDate=@beginDate,");
            strSql.Append("endDate=@endDate,");
            strSql.Append("useContent=@useContent,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("sId=@sId");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",        SqlDbType.Int,          4),
                new SqlParameter("@gName",      SqlDbType.VarChar,    100),
                new SqlParameter("@score",      SqlDbType.Int,          4),
                new SqlParameter("@beginDate",  SqlDbType.DateTime),
                new SqlParameter("@endDate",    SqlDbType.DateTime),
                new SqlParameter("@useContent", SqlDbType.VarChar,   1500),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@sId",        SqlDbType.Int,          4),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.wid;
            parameters[1].Value = model.gName;
            parameters[2].Value = model.score;
            parameters[3].Value = model.beginDate;
            parameters[4].Value = model.endDate;
            parameters[5].Value = model.useContent;
            parameters[6].Value = model.createDate;
            parameters[7].Value = model.sId;
            parameters[8].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 MxWeiXinPF.Model.wx_ucard_gift DataRowToModel(DataRow row)
 {
     MxWeiXinPF.Model.wx_ucard_gift model=new MxWeiXinPF.Model.wx_ucard_gift();
     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["gName"]!=null)
         {
             model.gName=row["gName"].ToString();
         }
         if(row["score"]!=null && row["score"].ToString()!="")
         {
             model.score=int.Parse(row["score"].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["useContent"]!=null)
         {
             model.useContent=row["useContent"].ToString();
         }
         if(row["createDate"]!=null && row["createDate"].ToString()!="")
         {
             model.createDate=DateTime.Parse(row["createDate"].ToString());
         }
         if(row["sId"]!=null && row["sId"].ToString()!="")
         {
             model.sId=int.Parse(row["sId"].ToString());
         }
     }
     return model;
 }
Esempio n. 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MxWeiXinPF.Model.wx_ucard_gift DataRowToModel(DataRow row)
 {
     MxWeiXinPF.Model.wx_ucard_gift model = new MxWeiXinPF.Model.wx_ucard_gift();
     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["gName"] != null)
         {
             model.gName = row["gName"].ToString();
         }
         if (row["score"] != null && row["score"].ToString() != "")
         {
             model.score = int.Parse(row["score"].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["useContent"] != null)
         {
             model.useContent = row["useContent"].ToString();
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
         if (row["sId"] != null && row["sId"].ToString() != "")
         {
             model.sId = int.Parse(row["sId"].ToString());
         }
     }
     return(model);
 }
Esempio n. 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MxWeiXinPF.Model.wx_ucard_gift model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_ucard_gift(");
            strSql.Append("wid,gName,score,beginDate,endDate,useContent,createDate,sId)");
            strSql.Append(" values (");
            strSql.Append("@wid,@gName,@score,@beginDate,@endDate,@useContent,@createDate,@sId)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",        SqlDbType.Int,          4),
                new SqlParameter("@gName",      SqlDbType.VarChar,    100),
                new SqlParameter("@score",      SqlDbType.Int,          4),
                new SqlParameter("@beginDate",  SqlDbType.DateTime),
                new SqlParameter("@endDate",    SqlDbType.DateTime),
                new SqlParameter("@useContent", SqlDbType.VarChar,   1500),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@sId",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.wid;
            parameters[1].Value = model.gName;
            parameters[2].Value = model.score;
            parameters[3].Value = model.beginDate;
            parameters[4].Value = model.endDate;
            parameters[5].Value = model.useContent;
            parameters[6].Value = model.createDate;
            parameters[7].Value = model.sId;

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

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

            strSql.Append("select  top 1 id,wid,gName,score,beginDate,endDate,useContent,createDate,sId from wx_ucard_gift ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_ucard_gift GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 id,wid,gName,score,beginDate,endDate,useContent,createDate,sId from wx_ucard_gift ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

            MxWeiXinPF.Model.wx_ucard_gift model=new MxWeiXinPF.Model.wx_ucard_gift();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }