public ReturnType RemoveItemCat(string cid) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { /*List<ItemCat> list = alading.ItemCat.Where(p => p.ItemCatID == itemcatID).ToList();*/ List <ItemCat> list = alading.ItemCat.Where(p => p.cid == cid).ToList(); if (list.Count == 0) { return(ReturnType.NotExisted); } else { ItemCat sy = list.First(); alading.DeleteObject(sy); alading.SaveChanges(); return(ReturnType.Success); } } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (System.Exception ex) { return(ReturnType.OthersError); } }
public ReturnType AddItemCat(ItemCat itemcat) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { alading.AddToItemCat(itemcat); if (alading.SaveChanges() == 1) { return(ReturnType.Success); } else { return(ReturnType.PropertyExisted); } } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
public List <ItemCat> GetAllItemCat(List <string> cidlist) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { List <ItemCat> listItemCat = alading.ItemCat.Where(BuildWhereInExpression <ItemCat, string>(v => v.cid, cidlist)).Distinct().ToList(); for (int i = 0; i < listItemCat.Count; i++) { ItemCat itemCat = listItemCat[i]; while (itemCat.parent_cid != "0") { ItemCat itemcat = alading.ItemCat.FirstOrDefault(p => p.cid == itemCat.parent_cid); if (listItemCat.Contains(itemcat)) { break; } listItemCat.Add(itemcat); itemCat = itemcat; } } return(listItemCat.Distinct().OrderBy(v => v.cid).ToList()); } } catch (System.Exception ex) { return(null); } }
public ReturnType UpdateItemCatPropTag(string cid, bool value) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { ItemCat result = alading.ItemCat.First(p => p.cid == cid); if (result == null) { return(ReturnType.NotExisted); } else { result.PropTag = value; } if (alading.SaveChanges() == 1) { return(ReturnType.Success); } else { return(ReturnType.SaveFailed); } } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
public void AddItemCat(ItemCat itemCat) { JustFeastDbDataContext db = new JustFeastDbDataContext(); db.ItemCats.InsertOnSubmit(itemCat); db.SubmitChanges(); }
private async void buttonCreate_Click(object sender, RoutedEventArgs e) { if (textBoxName.Text.Length < 2) { MessageBox.Show("EmptyName"); } else { var newItemCat = new ItemCat { Name = textBoxName.Text }; var validation = ValidateCat(newItemCat); if (validation == true) { await Services._ItemProxy.CreateItemCatAsync(newItemCat); dataGridItemCatList.Items.Clear(); var modelMenu = await Services._ItemProxy.GetAllItemCategoriesAsync(); foreach (ItemCat item in modelMenu) { dataGridItemCatList.Items.Add(item); } ; } else { MessageBox.Show("Validation did not pass!"); } } }
public ActionResult DeleteConfirmed(int id) { ItemCat itemCat = db.ItemCats.Find(id); db.ItemCats.Remove(itemCat); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ItemCat_ID,ItemCat_Name")] ItemCat itemCat) { if (ModelState.IsValid) { db.Entry(itemCat).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(itemCat)); }
public ActionResult Create([Bind(Include = "ItemCat_ID,ItemCat_Name")] ItemCat itemCat) { if (ModelState.IsValid) { db.ItemCats.Add(itemCat); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(itemCat)); }
public void UpdateItemCat(ItemCat beforeItemCat, ItemCat afterItemCat) { var db = new JustFeastDbDataContext(); var dbItemCat = db.ItemCats.SingleOrDefault(t => t.id == beforeItemCat.id && beforeItemCat.id == afterItemCat.id); dbItemCat.id = afterItemCat.id; dbItemCat.name = afterItemCat.name; db.SubmitChanges(); }
public ReturnType UpdateItemCat(ItemCat itemcat) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { /*ItemCat result = alading.ItemCat.Where(p => p.ItemCatID == itemcat.ItemCatID).FirstOrDefault();*/ ItemCat result = alading.ItemCat.Where(p => p.cid == itemcat.cid).FirstOrDefault(); if (result == null) { return(ReturnType.NotExisted); } #region Using Attach() Function Update,Default USE; alading.Attach(result); alading.ApplyPropertyChanges("ItemCat", itemcat); #endregion #region Using All Items Replace To Update ,Default UnUse /* * * result.cid = itemcat.cid; * * result.parent_cid = itemcat.parent_cid; * * result.name = itemcat.name; * * result.is_parent = itemcat.is_parent; * * result.status = itemcat.status; * * result.sort_order = itemcat.sort_order; * */ #endregion if (alading.SaveChanges() == 1) { return(ReturnType.Success); } else { return(ReturnType.OthersError); } } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
/// <summary> /// 获取后台供卖家发布商品的标准商品类目 /// </summary> internal List <ItemCat> GetItemcats(string Cids, string ParentCid) { ITopClient client = new DefaultTopClient(StaticSystemConfig.soft.ApiURL, StaticSystemConfig.soft.AppKey, StaticSystemConfig.soft.AppSecret, "json"); ItemcatsGetRequest req = new ItemcatsGetRequest(); req.Fields = "features,taosir_cat,cid,parent_cid,name,is_parent,status,sort_order"; if (ParentCid != null) { req.ParentCid = long.Parse(ParentCid); } if (Cids != null) { req.Cids = Cids; } ItemcatsGetResponse response = client.Execute(req); List <ItemCat> ListItemCat = new List <ItemCat>(); ItemCat newitem; if (response.ItemCats == null) { return(null); } foreach (Top.Api.Domain.ItemCat item in response.ItemCats) { newitem = new ItemCat(); newitem.Cid = item.Cid; newitem.Features = new List <Feature>(); newitem.IsParent = item.IsParent; newitem.Name = item.Name; newitem.ParentCid = item.ParentCid; newitem.SortOrder = item.SortOrder; newitem.Status = item.Status; if (!item.IsParent) { List <Feature> ListFeature = new List <Feature>(); Feature newfea; if (item.Features != null) { foreach (Top.Api.Domain.Feature itemchid in item.Features) { newfea = new Feature(); newfea.AttrKey = itemchid.AttrKey; newfea.AttrValue = itemchid.AttrValue; ListFeature.Add(newfea); } } } ListItemCat.Add(newitem); } return(ListItemCat); }
// GET: ItemCats/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ItemCat itemCat = db.ItemCats.Find(id); if (itemCat == null) { return(HttpNotFound()); } return(View(itemCat)); }
/// <summary> /// Create string from Item. Returns text for saving to txt file if "Save" is passed as parameter. /// </summary> /// <param name="Option">Null string formats text to display on listView1. "Save" string formats text for parsing from txt.</param> /// <returns></returns> public string ToString(string Option) { return(Option == "Save" ? ItemName + "^" + ItemCat + "^" + ItemSize + "^" + ItemPrice + "^" + ItemMeals : ItemName.PadRight(21, ' ') + ItemCat.PadRight(8, ' ') + ItemSize.ToString().PadRight(8, ' ') + ItemPrice.ToString("C").PadRight(8, ' ') + ItemMeals.ToString().PadRight(8, ' ') + (ItemPrice / ItemSize).ToString("C").PadRight(8, ' ') + (ItemPrice / ItemMeals).ToString("C").PadRight(8, ' ')); }
public string Yplb(string kfbh) { List <ItemCat> _list = new List <ItemCat>(); using (IDataReader dr = dal.ExecuteReader(String.Format(@"select DISTINCT T4.id,T4.dm + '.' + t4.mc from yf_t_cpkfjh as t1 INNER JOIN YX_T_Splb AS T4 ON T1.SPLBID=T4.ID WHERE kfbh='{0}'", kfbh))) { while (dr.Read()) { ItemCat cat = new ItemCat(); cat.Id = int.Parse(dr[0].ToString()); cat.Cname = dr[1].ToString(); _list.Add(cat); } } return(ToString <List <ItemCat> >(_list)); }
/// <summary> /// 循环获取父类ID /// </summary> /// <param name="cidList"></param> /// <param name="cid"></param> /// <returns></returns> public List <string> GetItemCatParentCid(List <string> cidList, string cid) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { ItemCat itemCat = alading.ItemCat.FirstOrDefault(i => i.cid == cid); if (itemCat.parent_cid != "0") { cidList.Add(itemCat.parent_cid); GetItemCatParentCid(cidList, itemCat.parent_cid); } return(cidList); } } catch (Exception ex) { return(new List <string>()); } }
private async void buttonEdit_Click(object sender, RoutedEventArgs e) { if (textBoxName.Text.Length < 2) { MessageBox.Show("InvalidName"); } else { var slectedItemCat = dataGridItemCatList.SelectedItem as ModelLibrary.ItemCat; var oldItem = new ItemCat { Name = slectedItemCat.Name, Id = slectedItemCat.Id }; var newItem = new ItemCat { Name = textBoxName.Text, Id = slectedItemCat.Id }; var validation = ValidateCat(newItem); if (validation == true) { await Services._ItemProxy.UpdateItemCatAsync(oldItem, newItem); dataGridItemCatList.Items.Clear(); var modelMenu = await Services._ItemProxy.GetAllItemCategoriesAsync(); foreach (ItemCat item in modelMenu) { dataGridItemCatList.Items.Add(item); } ; var selectedItem = dataGridItemCatList.SelectedItem as ModelLibrary.ItemCat; } else { MessageBox.Show("Validation did not pass!"); } } }
public ReturnType UpdateItemCat(string cid, ItemCat itemcat) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { /*var result = alading.ItemCat.Where(p => p.ItemCatID == itemcatID).ToList();*/ var result = alading.ItemCat.Where(p => p.cid == cid).ToList(); if (result.Count == 0) { return(ReturnType.NotExisted); } ItemCat ob = result.First(); ob.cid = itemcat.cid; ob.parent_cid = itemcat.parent_cid; ob.name = itemcat.name; ob.is_parent = itemcat.is_parent; ob.status = itemcat.status; ob.sort_order = itemcat.sort_order; if (alading.SaveChanges() == 1) { return(ReturnType.Success); } else { return(ReturnType.OthersError); } } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (System.Exception ex) { return(ReturnType.OthersError); } }
//根据淘宝的父类目和子类目->获取后台供卖家发布商品的标准商品类目id /// <summary> /// 根据淘宝的父类目和子类目->获取后台供卖家发布商品的标准商品类目id /// </summary> /// <param name="parentCatalog">父类目, 如:男装</param> /// <param name="childCatalog">子类目,如:T恤</param> public string GetCid(string parentCatalog, string childCatalog) { var parentItemCat = GetAllItemCatByApi(0).Find(c => c.Name.Contains(parentCatalog)); if (parentItemCat == null) { //如果在淘宝中没有找到就在映射中找 parentItemCat = GetAllItemCatByApi(0).Find(c => c.Name.Contains(SysUtils.GetCustomCategoryMap(parentCatalog))); if (parentItemCat == null) { throw new Exception(Resource.ExceptionTemplate_MethedParameterIsNullorEmpty.StringFormat(new System.Diagnostics.StackTrace().ToString())); } } ItemCat childItemCat = null; childItemCat = GetAllItemCatByApi(parentItemCat.Cid).Find(c => c.Name.Contains(childCatalog)); //如果淘宝子类别下还有子类别,如:女童->外套->普通外套等。 //那么直到遍历完相应子目录才结束。 while (childItemCat != null && childItemCat.IsParent) { childItemCat = GetAllItemCatByApi(childItemCat.Cid).Find(c => c.Name.Contains(childCatalog)); } if (childItemCat == null) { //没有找到然后在到GetCustomCidMap中查找 return(SysUtils.GetCustomCidMap(parentCatalog, childCatalog)); } return(childItemCat.Cid.ToString(CultureInfo.InvariantCulture)); }
public static bool Matches(this Item item, ItemCat isCategory) { return(CategoryDef.Categories[isCategory].Invoke(item)); }
public static ReturnType UpdateItemCat(string itemcatCode, ItemCat itemcat) { return(DataProviderClass.Instance().UpdateItemCat(itemcatCode, itemcat)); }
public Item(Controller controller, Point position, Map.Element baseElem) { this.controller = controller; this.position = position; this.baseElem = baseElem; Rarity rarity = RollRarity(); int random; switch (rarity) { case Rarity.Common: random = controller.random.Next(commonArray.Length); itemType = commonArray[random]; break; case Rarity.Uncommon: random = controller.random.Next(uncommonArray.Length); itemType = uncommonArray[random]; break; case Rarity.Rare: random = controller.random.Next(rareArray.Length); itemType = rareArray[random]; break; } switch (itemType)//ADDITEM { case ItemType.Potion: { texture = ContentManager.tPotion; itemCat = ItemCat.Consumable; break; } case ItemType.HealingPotion: { texture = ContentManager.tHealingPotion; itemCat = ItemCat.Consumable; break; } case ItemType.PotionRed: { texture = ContentManager.tPotionRed; itemCat = ItemCat.Consumable; break; } case ItemType.BigSword: { texture = ContentManager.tBigSword; itemCat = ItemCat.Weapon; damageStat = 5; break; } case ItemType.Shield: { texture = ContentManager.tShield; itemCat = ItemCat.Armor; defenseStat = 1; break; } case ItemType.PlateArmor: { texture = ContentManager.tPlateArmor; itemCat = ItemCat.Armor; defenseStat = 4; break; } case ItemType.BrokenSword: { texture = ContentManager.tBrokenSword; itemCat = ItemCat.Weapon; damageStat = 2; break; } } if (itemCat == ItemCat.Armor || itemCat == ItemCat.Weapon) { if (controller.random.Next(BONUSCHANCE) == BONUSCHANCE - 1) { if (damageStat > 0) { bonusStat = controller.random.Next(damageStat) + 1; damageStat += bonusStat; } if (defenseStat > 0) { bonusStat = controller.random.Next(defenseStat) + 1; defenseStat += bonusStat; } } } }
public static ReturnType AddItemCat(ItemCat itemcat) { return(DataProviderClass.Instance().AddItemCat(itemcat)); }