Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(PropertyInfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update wx_property_info set ");
            strSql.Append("wid=@wid,");
            strSql.Append("typeId=@typeId,");
            strSql.Append("typeName=@typeName,");
            strSql.Append("iName=@iName,");
            strSql.Append("iContent=@iContent,");
            strSql.Append("expires_in=@expires_in,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("count=@count,");
            strSql.Append("categoryId=@categoryId,");
            strSql.Append("categoryName=@categoryName,");
            strSql.Append("remark=@remark");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@wid", SqlDbType.Int,4),
                    new SqlParameter("@typeId", SqlDbType.Int,4),
                    new SqlParameter("@typeName", SqlDbType.VarChar,100),
                    new SqlParameter("@iName", SqlDbType.VarChar,200),
                    new SqlParameter("@iContent", SqlDbType.VarChar,-1),
                    new SqlParameter("@expires_in", SqlDbType.Int,4),
                    new SqlParameter("@createDate", SqlDbType.DateTime),
                    new SqlParameter("@count", SqlDbType.Int,4),
                    new SqlParameter("@categoryId", SqlDbType.Int,4),
                    new SqlParameter("@categoryName", SqlDbType.VarChar,50),
                    new SqlParameter("@remark", SqlDbType.VarChar,1000),
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = model.Wid;
            parameters[1].Value = model.TypeId;
            parameters[2].Value = model.typeName;
            parameters[3].Value = model.iName;
            parameters[4].Value = model.iContent;
            parameters[5].Value = model.expires_in;
            parameters[6].Value = model.createDate;
            parameters[7].Value = model.count;
            parameters[8].Value = model.categoryId;
            parameters[9].Value = model.categoryName;
            parameters[10].Value = model.remark;
            parameters[11].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 int Add(PropertyInfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into wx_property_info(");
            strSql.Append("wid,typeId,typeName,iName,iContent,expires_in,createDate,count,categoryId,categoryName,remark)");
            strSql.Append(" values (");
            strSql.Append("@wid,@typeId,@typeName,@iName,@iContent,@expires_in,@createDate,@count,@categoryId,@categoryName,@remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@wid", SqlDbType.Int,4),
                    new SqlParameter("@typeId", SqlDbType.Int,4),
                    new SqlParameter("@typeName", SqlDbType.VarChar,100),
                    new SqlParameter("@iName", SqlDbType.VarChar,200),
                    new SqlParameter("@iContent", SqlDbType.VarChar,-1),
                    new SqlParameter("@expires_in", SqlDbType.Int,4),
                    new SqlParameter("@createDate", SqlDbType.DateTime),
                    new SqlParameter("@count", SqlDbType.Int,4),
                    new SqlParameter("@categoryId", SqlDbType.Int,4),
                    new SqlParameter("@categoryName", SqlDbType.VarChar,50),
                    new SqlParameter("@remark", SqlDbType.VarChar,1000)};
            parameters[0].Value = model.Wid;
            parameters[1].Value = model.TypeId;
            parameters[2].Value = model.typeName;
            parameters[3].Value = model.iName;
            parameters[4].Value = model.iContent;
            parameters[5].Value = model.expires_in;
            parameters[6].Value = model.createDate;
            parameters[7].Value = model.count;
            parameters[8].Value = model.categoryId;
            parameters[9].Value = model.categoryName;
            parameters[10].Value = model.remark;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 添加access_token值
 /// </summary>
 /// <param name="wid"></param>
 /// <param name="access_token"></param>
 /// <param name="expires_in">过期(秒)</param>
 /// <returns></returns>
 public string AddAccess_Token(int wid, string access_token, int expires_in = 1200)
 {
     var ret = "";
     try
     {
         if (expires_in == 0)
         {
             expires_in = 1200;
         }
         var wxProperty = new PropertyInfo
         {
             iName = "access_token",
             TypeId = 1,
             typeName = "base",
             iContent = access_token,
             expires_in = expires_in,
             createDate = DateTime.Now,
             count = 1,
             Wid = wid
         };
         Add(wxProperty);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return "";
 }
Esempio n. 4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(PropertyInfo model)
 {
     return _repository.Update(model);
 }
Esempio n. 5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(PropertyInfo model)
 {
     return _repository.Add(model);
 }
Esempio n. 6
0
 /// <summary>
 /// 添加属性值
 /// </summary>
 /// <param name="wid"></param>
 /// <param name="key">对应这里的值 MXEnums.WXPropertyKeyName</param>
 /// <param name="value"></param>
 /// <returns></returns>
 public string AddProperty(int wid, string key, string value)
 {
     var ret = "";
     try
     {
         var wxProperty = new PropertyInfo();
         if (!ExistsWid(wid, key))
         {
             wxProperty.iName = key;
             wxProperty.TypeId = 1;
             wxProperty.typeName = "base";
             wxProperty.iContent = value;
             wxProperty.expires_in = 0;
             wxProperty.createDate = DateTime.Now;
             wxProperty.count = 1;
             wxProperty.Wid = wid;
             Add(wxProperty);
         }
         else
         {
             wxProperty = GetModelList("iName='" + key + "' and wid=" + wid)[0];
             wxProperty.iContent = value;
             Update(wxProperty);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return "";
 }
Esempio n. 7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public PropertyInfo GetModelByIName(int wid, string iName)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,wid,typeId,typeName,iName,iContent,expires_in,createDate,count,categoryId,categoryName,remark from wx_property_info ");
            strSql.Append(" where wid=@wid and iName=@iName");
            SqlParameter[] parameters = {
                    new SqlParameter("@wid", SqlDbType.Int,4),
                    new SqlParameter("@iName", SqlDbType.VarChar,200)
            };
            parameters[0].Value = wid;
            parameters[1].Value = iName;

            var model = new PropertyInfo();
            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. 8
0
        /// <summary>
		/// 得到一个对象实体
		/// </summary>
		public PropertyInfo DataRowToModel(DataRow row)
        {
            var model = new PropertyInfo();
            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["typeId"] != null && row["typeId"].ToString() != "")
                {
                    model.TypeId = int.Parse(row["typeId"].ToString());
                }
                if (row["typeName"] != null)
                {
                    model.typeName = row["typeName"].ToString();
                }
                if (row["iName"] != null)
                {
                    model.iName = row["iName"].ToString();
                }
                if (row["iContent"] != null)
                {
                    model.iContent = row["iContent"].ToString();
                }
                if (row["expires_in"] != null && row["expires_in"].ToString() != "")
                {
                    model.expires_in = int.Parse(row["expires_in"].ToString());
                }
                if (row["createDate"] != null && row["createDate"].ToString() != "")
                {
                    model.createDate = DateTime.Parse(row["createDate"].ToString());
                }
                if (row["count"] != null && row["count"].ToString() != "")
                {
                    model.count = int.Parse(row["count"].ToString());
                }
                if (row["categoryId"] != null && row["categoryId"].ToString() != "")
                {
                    model.categoryId = int.Parse(row["categoryId"].ToString());
                }
                if (row["categoryName"] != null)
                {
                    model.categoryName = row["categoryName"].ToString();
                }
                if (row["remark"] != null)
                {
                    model.remark = row["remark"].ToString();
                }
            }
            return model;
        }