Exemple #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MxWeiXinPF.Model.wx_ucard_ticket model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_ucard_ticket(");
            strSql.Append("wid,tName,beginDate,endDate,typeId,usedContent,usedTimes,userDegree,userType,consumeMoney,sId,dyMoney,createDate,sort_id)");
            strSql.Append(" values (");
            strSql.Append("@wid,@tName,@beginDate,@endDate,@typeId,@usedContent,@usedTimes,@userDegree,@userType,@consumeMoney,@sId,@dyMoney,@createDate,@sort_id)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",          SqlDbType.Int,          4),
                new SqlParameter("@tName",        SqlDbType.VarChar,    100),
                new SqlParameter("@beginDate",    SqlDbType.DateTime),
                new SqlParameter("@endDate",      SqlDbType.DateTime),
                new SqlParameter("@typeId",       SqlDbType.Int,          4),
                new SqlParameter("@usedContent",  SqlDbType.VarChar,   1500),
                new SqlParameter("@usedTimes",    SqlDbType.Int,          4),
                new SqlParameter("@userDegree",   SqlDbType.VarChar,    500),
                new SqlParameter("@userType",     SqlDbType.Int,          4),
                new SqlParameter("@consumeMoney", SqlDbType.Int,          4),
                new SqlParameter("@sId",          SqlDbType.Int,          4),
                new SqlParameter("@dyMoney",      SqlDbType.Int,          4),
                new SqlParameter("@createDate",   SqlDbType.DateTime),
                new SqlParameter("@sort_id",      SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.wid;
            parameters[1].Value  = model.tName;
            parameters[2].Value  = model.beginDate;
            parameters[3].Value  = model.endDate;
            parameters[4].Value  = model.typeId;
            parameters[5].Value  = model.usedContent;
            parameters[6].Value  = model.usedTimes;
            parameters[7].Value  = model.userDegree;
            parameters[8].Value  = model.userType;
            parameters[9].Value  = model.consumeMoney;
            parameters[10].Value = model.sId;
            parameters[11].Value = model.dyMoney;
            parameters[12].Value = model.createDate;
            parameters[13].Value = model.sort_id;

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

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

            strSql.Append("select  top 1 id,wid,tName,beginDate,endDate,typeId,usedContent,usedTimes,userDegree,userType,consumeMoney,sId,dyMoney,createDate,sort_id from wx_ucard_ticket ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MxWeiXinPF.Model.wx_ucard_ticket DataRowToModel(DataRow row)
 {
     MxWeiXinPF.Model.wx_ucard_ticket model = new MxWeiXinPF.Model.wx_ucard_ticket();
     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["tName"] != null)
         {
             model.tName = row["tName"].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["typeId"] != null && row["typeId"].ToString() != "")
         {
             model.typeId = int.Parse(row["typeId"].ToString());
         }
         if (row["usedContent"] != null)
         {
             model.usedContent = row["usedContent"].ToString();
         }
         if (row["usedTimes"] != null && row["usedTimes"].ToString() != "")
         {
             model.usedTimes = int.Parse(row["usedTimes"].ToString());
         }
         if (row["userDegree"] != null)
         {
             model.userDegree = row["userDegree"].ToString();
         }
         if (row["userType"] != null && row["userType"].ToString() != "")
         {
             model.userType = int.Parse(row["userType"].ToString());
         }
         if (row["consumeMoney"] != null && row["consumeMoney"].ToString() != "")
         {
             model.consumeMoney = int.Parse(row["consumeMoney"].ToString());
         }
         if (row["sId"] != null && row["sId"].ToString() != "")
         {
             model.sId = int.Parse(row["sId"].ToString());
         }
         if (row["dyMoney"] != null && row["dyMoney"].ToString() != "")
         {
             model.dyMoney = int.Parse(row["dyMoney"].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());
         }
     }
     return(model);
 }
Exemple #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MxWeiXinPF.Model.wx_ucard_ticket model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_ucard_ticket set ");
            strSql.Append("wid=@wid,");
            strSql.Append("tName=@tName,");
            strSql.Append("beginDate=@beginDate,");
            strSql.Append("endDate=@endDate,");
            strSql.Append("typeId=@typeId,");
            strSql.Append("usedContent=@usedContent,");
            strSql.Append("usedTimes=@usedTimes,");
            strSql.Append("userDegree=@userDegree,");
            strSql.Append("userType=@userType,");
            strSql.Append("consumeMoney=@consumeMoney,");
            strSql.Append("sId=@sId,");
            strSql.Append("dyMoney=@dyMoney,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("sort_id=@sort_id");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",          SqlDbType.Int,          4),
                new SqlParameter("@tName",        SqlDbType.VarChar,    100),
                new SqlParameter("@beginDate",    SqlDbType.DateTime),
                new SqlParameter("@endDate",      SqlDbType.DateTime),
                new SqlParameter("@typeId",       SqlDbType.Int,          4),
                new SqlParameter("@usedContent",  SqlDbType.VarChar,   1500),
                new SqlParameter("@usedTimes",    SqlDbType.Int,          4),
                new SqlParameter("@userDegree",   SqlDbType.VarChar,    500),
                new SqlParameter("@userType",     SqlDbType.Int,          4),
                new SqlParameter("@consumeMoney", SqlDbType.Int,          4),
                new SqlParameter("@sId",          SqlDbType.Int,          4),
                new SqlParameter("@dyMoney",      SqlDbType.Int,          4),
                new SqlParameter("@createDate",   SqlDbType.DateTime),
                new SqlParameter("@sort_id",      SqlDbType.Int,          4),
                new SqlParameter("@id",           SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.wid;
            parameters[1].Value  = model.tName;
            parameters[2].Value  = model.beginDate;
            parameters[3].Value  = model.endDate;
            parameters[4].Value  = model.typeId;
            parameters[5].Value  = model.usedContent;
            parameters[6].Value  = model.usedTimes;
            parameters[7].Value  = model.userDegree;
            parameters[8].Value  = model.userType;
            parameters[9].Value  = model.consumeMoney;
            parameters[10].Value = model.sId;
            parameters[11].Value = model.dyMoney;
            parameters[12].Value = model.createDate;
            parameters[13].Value = model.sort_id;
            parameters[14].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MxWeiXinPF.Model.wx_ucard_ticket DataRowToModel(DataRow row)
 {
     MxWeiXinPF.Model.wx_ucard_ticket model = new MxWeiXinPF.Model.wx_ucard_ticket();
     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["tName"] != null)
         {
             model.tName = row["tName"].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["typeId"] != null && row["typeId"].ToString() != "")
         {
             model.typeId = int.Parse(row["typeId"].ToString());
         }
         if (row["usedContent"] != null)
         {
             model.usedContent = row["usedContent"].ToString();
         }
         if (row["usedTimes"] != null && row["usedTimes"].ToString() != "")
         {
             model.usedTimes = int.Parse(row["usedTimes"].ToString());
         }
         if (row["userDegree"] != null)
         {
             model.userDegree = row["userDegree"].ToString();
         }
         if (row["userType"] != null && row["userType"].ToString() != "")
         {
             model.userType = int.Parse(row["userType"].ToString());
         }
         if (row["consumeMoney"] != null && row["consumeMoney"].ToString() != "")
         {
             model.consumeMoney = int.Parse(row["consumeMoney"].ToString());
         }
         if (row["sId"] != null && row["sId"].ToString() != "")
         {
             model.sId = int.Parse(row["sId"].ToString());
         }
         if (row["dyMoney"] != null && row["dyMoney"].ToString() != "")
         {
             model.dyMoney = int.Parse(row["dyMoney"].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());
         }
     }
     return model;
 }
Exemple #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_ucard_ticket GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,wid,tName,beginDate,endDate,typeId,usedContent,usedTimes,userDegree,userType,consumeMoney,sId,dyMoney,createDate,sort_id from wx_ucard_ticket ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

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