Ejemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public XCWeiXin.Model.wx_diancai_blacklist DataRowToModel(DataRow row)
 {
     XCWeiXin.Model.wx_diancai_blacklist model = new XCWeiXin.Model.wx_diancai_blacklist();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["openid"] != null)
         {
             model.openid = row["openid"].ToString();
         }
         if (row["blackName"] != null)
         {
             model.blackName = row["blackName"].ToString();
         }
         if (row["blackDate"] != null && row["blackDate"].ToString() != "")
         {
             model.blackDate = DateTime.Parse(row["blackDate"].ToString());
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
         if (row["shopid"] != null && row["shopid"].ToString() != "")
         {
             model.shopid = int.Parse(row["shopid"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(XCWeiXin.Model.wx_diancai_blacklist model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_diancai_blacklist(");
            strSql.Append("openid,blackName,blackDate,createDate,shopid)");
            strSql.Append(" values (");
            strSql.Append("@openid,@blackName,@blackDate,@createDate,@shopid)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@openid",     SqlDbType.VarChar,   300),
                new SqlParameter("@blackName",  SqlDbType.VarChar,   100),
                new SqlParameter("@blackDate",  SqlDbType.DateTime),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@shopid",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.openid;
            parameters[1].Value = model.blackName;
            parameters[2].Value = model.blackDate;
            parameters[3].Value = model.createDate;
            parameters[4].Value = model.shopid;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(XCWeiXin.Model.wx_diancai_blacklist model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_diancai_blacklist set ");
            strSql.Append("openid=@openid,");
            strSql.Append("blackName=@blackName,");
            strSql.Append("blackDate=@blackDate,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("shopid=@shopid");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@openid",     SqlDbType.VarChar,   300),
                new SqlParameter("@blackName",  SqlDbType.VarChar,   100),
                new SqlParameter("@blackDate",  SqlDbType.DateTime),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@shopid",     SqlDbType.Int,         4),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.openid;
            parameters[1].Value = model.blackName;
            parameters[2].Value = model.blackDate;
            parameters[3].Value = model.createDate;
            parameters[4].Value = model.shopid;
            parameters[5].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XCWeiXin.Model.wx_diancai_blacklist GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,openid,blackName,blackDate,createDate,shopid from wx_diancai_blacklist ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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