public StoreItem(uint id, StoreItemType type, int dbId, uint price, Currency currency) { Id = id; Type = type; DatabaseId = dbId; Price = price; Currency = currency; switch (Currency) { case Currency.Coins: CurrencyEmote = "$emotecoins"; break; case Currency.Tokens: CurrencyEmote = "$emotetokens"; break; } switch (type) { case StoreItemType.PermanentRole: var dbData = Task.Run(() => DB.Roles.GetAsync(dbId)).Result; if (dbData is null) { RiftBot.Log.Error($"No data for role {dbId.ToString()}!"); break; } Name = dbData.Name; RoleId = dbData.RoleId; break; } }
public StoreItemInfoWindow ChangeProductType(StoreItemType type) { _model.StoreItemType = type; if (type == StoreItemType.Service) { StackPanelAttribute.Visibility = Visibility.Collapsed; DataGridPairs.Visibility = Visibility.Collapsed; } return(this); }
private void itemsBtn_Click(object sender, EventArgs e) { StoreItemType Type = controller.GetStoreType(int.Parse(IdText.Text)); StoreItemForm userForm = new StoreItemForm(Type) { TopLevel = false }; this.Controls.Clear(); this.Controls.Add(userForm); userForm.Show(); }
public List <StoreItemVM> ViewItemsType(StoreItemType type) { return((from sI in context.StoreItems where sI.ItemType_ID == type.ID select new StoreItemVM { ID = sI.ID, Name = sI.Name, Price = sI.Price, CurrentCount = sI.CurrentCount, RequiredCount = sI.RequiredCount, TypeName = sI.StoreItemType.Name, }).ToList()); }
private void saveBtn_Click(object sender, EventArgs e) { DefaultText(NameText, "Enter Name", true); StoreItemType storeItemType = new StoreItemType(); getDate(storeItemType); if (Validation.IsName(NameText.Text)) { if (saveBtn.Text == "Create") { bool flag = controller.Insert(storeItemType); if (flag) { MessageBox.Show(null, "Store type inserted successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); //refresh table dataGrid.DataSource = controller.ViewAll(); } else { MessageBox.Show(null, "Something went wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { storeItemType.ID = int.Parse(IdText.Text); bool flag = controller.Update(storeItemType); if (flag) { MessageBox.Show(null, "Store type updated successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); //refresh table dataGrid.DataSource = controller.ViewAll(); } else { MessageBox.Show(null, "Something went wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show(null, "Please check your input", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private static StoreItem GetStoreItem( string icon, string name, string description, int?price, StoreItemType type, string groupName) { return(new StoreItem { Icon = icon, Name = name, Description = description, Price = price, Type = type, GroupName = groupName }); }
public StoreItem(uint id, string name, StoreItemType type, int dbId, uint price, Currency currency) { Id = id; Name = name; Type = type; DatabaseId = dbId; Price = price; Currency = currency; switch (Currency) { case Currency.Coins: CurrencyEmote = "$emotecoins"; break; case Currency.Tokens: CurrencyEmote = "$emotetokens"; break; } }
public StoreItemType AddType(StoreItemType storeType) { try { using (var db = new ShopKeeperStoreEntities(_connectionString)) { StoreItemType storeTypeInfo; var types = db.StoreItemTypes.Where(b => b.Name.Trim().ToLower().Replace(" ", "") == storeType.Name.Trim().ToLower().Replace(" ", "")).ToList(); if (!types.Any()) { var processedType = db.StoreItemTypes.Add(storeType); db.SaveChanges(); storeTypeInfo = processedType; } else { storeTypeInfo = types[0]; } return(storeTypeInfo); } } catch (DbEntityValidationException e) { var str = ""; foreach (var eve in e.EntityValidationErrors) { str += string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State) + "\n"; foreach (var ve in eve.ValidationErrors) { str += string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage) + " \n"; } } ErrorLogger.LogError(e.StackTrace, e.Source, str); return(new StoreItemType()); } }
private void getDate(StoreItemType storeItemType) { storeItemType.Name = NameText.Text; }
private long ProcessRecord(DataRowView dv, ref string msg) { if (dv == null) { return(0); } try { using (var db = _dbStoreEntities) { var mInfo = new StoreItem { Name = dv.Row["Name"].ToString().Trim() }; var duplicates = db.StoreItems.Count(m => m.Name.ToLower().Trim() == mInfo.Name.ToLower().Trim()); if (duplicates > 0) { return(0); } var parentProductStr = dv.Row["Parent_Product_Name"].ToString().Trim(); if (!string.IsNullOrEmpty(parentProductStr)) { var parentItems = db.StoreItems.Where(m => m.Name.ToLower().Trim() == parentProductStr.ToLower().Trim()).ToList(); if (parentItems.Any()) { var parentItemId = parentItems[0].StoreItemId; if (parentItemId > 0) { mInfo.ParentItemId = parentItemId; } } } var productTypeStr = dv.Row["Product_Type"].ToString().Trim(); if (!string.IsNullOrEmpty(productTypeStr)) { var productTypes = db.StoreItemTypes.Where(m => m.Name.ToLower().Trim() == productTypeStr.ToLower().Trim()).ToList(); if (productTypes.Any()) { var productType = productTypes[0]; if (productType != null && productType.StoreItemTypeId > 0) { mInfo.StoreItemTypeId = productType.StoreItemTypeId; } } else { var productType = new StoreItemType { Name = productTypeStr.Trim() }; var processedProductType = db.StoreItemTypes.Add(productType); db.SaveChanges(); if (processedProductType.StoreItemTypeId > 0) { mInfo.StoreItemTypeId = processedProductType.StoreItemTypeId; } else { msg = "Product Type Information could not be added."; return(0); } } } else { msg = "Product Type is empty."; return(0); } var productBrandStr = dv.Row["Product_Brand"].ToString().Trim(); if (!string.IsNullOrEmpty(productBrandStr)) { var productTypes = db.StoreItemTypes.Where(m => m.Name.ToLower().Trim() == productBrandStr.ToLower().Trim()).ToList(); if (productTypes.Any()) { var productType = productTypes[0]; if (productType != null && productType.StoreItemTypeId > 0) { mInfo.StoreItemTypeId = productType.StoreItemTypeId; } } else { var productBrand = new StoreItemBrand { Name = productBrandStr.Trim() }; var processedProductBrand = db.StoreItemBrands.Add(productBrand); db.SaveChanges(); if (processedProductBrand.StoreItemBrandId > 0) { mInfo.StoreItemBrandId = processedProductBrand.StoreItemBrandId; } else { msg = "Product Brand Information could not be added."; return(0); } } } else { msg = "Product Brand is empty."; return(0); } var productCategoryStr = dv.Row["Product_Category"].ToString().Trim(); if (!string.IsNullOrEmpty(productCategoryStr)) { var productCategories = db.StoreItemCategories.Where(m => m.Name.ToLower().Trim() == productCategoryStr.ToLower().Trim()).ToList(); if (productCategories.Any()) { var productCategory = productCategories[0]; if (productCategory != null && productCategory.StoreItemCategoryId > 0) { mInfo.StoreItemTypeId = productCategory.StoreItemCategoryId; } } else { var productCategory = new StoreItemCategory { Name = productCategoryStr.Trim() }; var processedProductCategory = db.StoreItemCategories.Add(productCategory); db.SaveChanges(); if (processedProductCategory.StoreItemCategoryId > 0) { mInfo.StoreItemCategoryId = processedProductCategory.StoreItemCategoryId; } else { msg = "Product Category is empty."; return(0); } } } else { msg = "Product Category is empty."; return(0); } var processedProduct = db.StoreItems.Add(mInfo); db.SaveChanges(); return(processedProduct.StoreItemId); } } catch (Exception ex) { ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public static StoreItemType GetStoreItemType(string data) { StoreItemType val = (StoreItemType)(System.Enum.Parse(typeof(StoreItemType), data)); return(val); }
public StoreItemForm(StoreItemType storeType = null) { InitializeComponent(); this.storeType = storeType; }
private StoreItem TrySearchObject(StoreItemType objType, string nameWithPrefix, XElement def) { if (nameWithPrefix == null) return null; if (!nameWithPrefix.Contains(":")) return null; string prefix = (string)nameWithPrefix.Split(char.Parse(":")).GetValue(0); XNamespace objNS = def.GetNamespaceOfPrefix(prefix); string name = (string)nameWithPrefix.Split(char.Parse(":")).GetValue(1); var objs = from c in store where c.objectType == objType && c.name == name && c.ownNS == objNS select c; if (objs.Count<StoreItem>() != 1) { return null; } else { return objs.First<StoreItem>(); } }
private StoreItem SearchObject(StoreItemType objType, string nameWithPrefix, XElement def) { StoreItem result = TrySearchObject(objType,nameWithPrefix,def); if (result == null) { Wr("Searched Object not found: " + nameWithPrefix); throw new Exception(); } return result; }
private void AddNewStoreItem(StoreItemType type) => new StoreItemInfoWindow(this).ChangeProductType(type).Show();
private void OpenStoreItemsInfo(object sender, StoreItemType type) { var item = ((Button)sender).DataContext as StoreItem; new StoreItemInfoWindow(this, item).ChangeProductType(type).Show(); }