Exemplo n.º 1
0
        public object GetItem(IDataReader dr, ref int index)
        {
            MarkettypeInfo item = new MarkettypeInfo();

            if (!dr.IsDBNull(++index))
            {
                item.Id = (uint?)dr.GetInt32(index);
            }
            if (!dr.IsDBNull(++index))
            {
                item.Market_id = (uint?)dr.GetInt32(index);
            }
            if (!dr.IsDBNull(++index))
            {
                item.Parent_id = (uint?)dr.GetInt32(index);
            }
            if (!dr.IsDBNull(++index))
            {
                item.Sort = (byte?)dr.GetByte(index);
            }
            if (!dr.IsDBNull(++index))
            {
                item.Title = dr.GetString(index);
            }
            return(item);
        }
Exemplo n.º 2
0
 private static void RemoveCache(MarkettypeInfo item)
 {
     if (item == null)
     {
         return;
     }
     RedisHelper.Remove(string.Concat("pifa_BLL_Markettype_", item.Id));
 }
Exemplo n.º 3
0
 public int Update(MarkettypeInfo item)
 {
     return(new SqlUpdateBuild(null, item.Id.Value)
            .SetMarket_id(item.Market_id)
            .SetParent_id(item.Parent_id)
            .SetSort(item.Sort)
            .SetTitle(item.Title).ExecuteNonQuery());
 }
Exemplo n.º 4
0
 public static pifa.DAL.Markettype.SqlUpdateBuild UpdateDiy(MarkettypeInfo item, uint Id)
 {
     if (itemCacheTimeout > 0)
     {
         RemoveCache(item != null ? item : GetItem(Id));
     }
     return(new pifa.DAL.Markettype.SqlUpdateBuild(item, Id));
 }
Exemplo n.º 5
0
 public static int Update(MarkettypeInfo item)
 {
     if (itemCacheTimeout > 0)
     {
         RemoveCache(item);
     }
     return(dal.Update(item));
 }
Exemplo n.º 6
0
 public static MarkettypeInfo Insert(MarkettypeInfo item)
 {
     item = dal.Insert(item);
     if (itemCacheTimeout > 0)
     {
         RemoveCache(item);
     }
     return(item);
 }
Exemplo n.º 7
0
 protected static MySqlParameter[] GetParameters(MarkettypeInfo item)
 {
     return(new MySqlParameter[] {
         GetParameter("?id", MySqlDbType.UInt32, 10, item.Id),
         GetParameter("?market_id", MySqlDbType.UInt32, 10, item.Market_id),
         GetParameter("?parent_id", MySqlDbType.UInt32, 10, item.Parent_id),
         GetParameter("?sort", MySqlDbType.UByte, 3, item.Sort),
         GetParameter("?title", MySqlDbType.VarChar, 255, item.Title)
     });
 }
Exemplo n.º 8
0
        public MarkettypeInfo Insert(MarkettypeInfo item)
        {
            uint loc1;

            if (uint.TryParse(string.Concat(SqlHelper.ExecuteScalar(TSQL.Insert, GetParameters(item))), out loc1))
            {
                item.Id = loc1;
            }
            return(item);
        }
Exemplo n.º 9
0
        public ActionResult Edit([FromQuery] uint Id)
        {
            MarkettypeInfo item = Markettype.GetItem(Id);

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            ViewBag.item = item;
            return(View());
        }
Exemplo n.º 10
0
        public APIReturn _Add([FromForm] uint?Market_id, [FromForm] uint?Parent_id, [FromForm] byte?Sort, [FromForm] string Title, [FromForm] uint[] mn_Category)
        {
            MarkettypeInfo item = new MarkettypeInfo();

            item.Market_id = Market_id;
            item.Parent_id = Parent_id;
            item.Sort      = Sort;
            item.Title     = Title;
            item           = Markettype.Insert(item);
            //关联 Category
            foreach (uint mn_Category_in in mn_Category)
            {
                item.FlagCategory(mn_Category_in);
            }
            return(APIReturn.成功.SetData("item", item.ToBson()));
        }
Exemplo n.º 11
0
        public APIReturn _Edit([FromQuery] uint Id, [FromForm] uint?Market_id, [FromForm] uint?Parent_id, [FromForm] byte?Sort, [FromForm] string Title, [FromForm] uint[] mn_Category)
        {
            MarkettypeInfo item = Markettype.GetItem(Id);

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            item.Market_id = Market_id;
            item.Parent_id = Parent_id;
            item.Sort      = Sort;
            item.Title     = Title;
            int affrows = Markettype.Update(item);

            //关联 Category
            if (mn_Category.Length == 0)
            {
                item.UnflagCategoryALL();
            }
            else
            {
                List <uint> mn_Category_list = mn_Category.ToList();
                foreach (var Obj_category in item.Obj_categorys)
                {
                    int idx = mn_Category_list.FindIndex(a => a == Obj_category.Id);
                    if (idx == -1)
                    {
                        item.UnflagCategory(Obj_category.Id);
                    }
                    else
                    {
                        mn_Category_list.RemoveAt(idx);
                    }
                }
                mn_Category_list.ForEach(a => item.FlagCategory(a));
            }
            if (affrows > 0)
            {
                return(APIReturn.成功.SetMessage($"更新成功,影响行数:{affrows}"));
            }
            return(APIReturn.失败);
        }
Exemplo n.º 12
0
        public static MarkettypeInfo GetItem(uint Id)
        {
            if (itemCacheTimeout <= 0)
            {
                return(Select.WhereId(Id).ToOne());
            }
            string key   = string.Concat("pifa_BLL_Markettype_", Id);
            string value = RedisHelper.Get(key);

            if (!string.IsNullOrEmpty(value))
            {
                try { return(MarkettypeInfo.Parse(value)); } catch { }
            }
            MarkettypeInfo item = Select.WhereId(Id).ToOne();

            if (item == null)
            {
                return(null);
            }
            RedisHelper.Set(key, item.Stringify(), itemCacheTimeout);
            return(item);
        }
Exemplo n.º 13
0
 public SqlUpdateBuild(MarkettypeInfo item, uint Id)
 {
     _item  = item;
     _where = SqlHelper.Addslashes("`id` = {0}", Id);
 }