private void buttonRemoveCats_Click(object sender, EventArgs e) { CategoryBusiness categoryBusiness = new CategoryBusiness(); int selectedCategoryId = (int)comboBoxSelectCat.SelectedValue; var selectedCategory = categoryBusiness.GetCategoryById(selectedCategoryId); string result = categoryBusiness.Remove(selectedCategory); MessageBox.Show(result); showCategories.ShowCategories(dataGridViewShowCats); }
public JsonResult GetProducts(string sidx, string sord, int page, int rows, string colName, string colValue) //Gets the todo Lists. { int pageIndex = Convert.ToInt32(page) - 1; int pageSize = rows; var brandList = _productBusiness.GetListWT(); List <ProductViewModel> brandViewModelList = new List <ProductViewModel>(); var records = (from p in brandList select new ProductViewModel { TokenKey = p.TokenKey, Brand = _brandBusiness.GetBrandById(Convert.ToInt32(p.BrandId)).BrandName, Category = _categoryBusiness.GetCategoryById(Convert.ToInt32(p.CategoryId)).CategoryName, ProductName = p.ProductName, ProductCode = p.ProductCode }).AsQueryable(); //applying filter if (!string.IsNullOrEmpty(colName) && !string.IsNullOrEmpty(colValue)) { records = records.Where(c => c.GetType().GetProperty(colName).GetValue(c, null).ToString().ToLower().Contains(colValue.ToLower())); } int totalRecords = records.Count(); var totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows); if (!string.IsNullOrEmpty(sidx) && !string.IsNullOrEmpty(sord)) { if (sord.Trim().ToLower() == "asc") { records = SortHelper.OrderBy(records, sidx); } else { records = SortHelper.OrderByDescending(records, sidx); } } //applying paging records = records.Skip(pageIndex * pageSize).Take(pageSize); var jsonData = new { total = totalPages, page, records = totalRecords, rows = records }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); }
private void comboBoxSelectCat_SelectionChangeCommitted(object sender, EventArgs e) { int selectedCategoryId = (int)comboBoxSelectCat.SelectedValue; var category = categoryBusiness.GetCategoryById(selectedCategoryId); selectedCategory = category; textBoxCatsName.Text = selectedCategory.Name; textBoxCatsInfo.Text = selectedCategory.Info; buttonUpdateCats.Enabled = true; }
private void comboBoxUpdateCategory_SelectionChangeCommitted(object sender, EventArgs e) { int selectedCategoryId = (int)comboBoxUpdateCategory.SelectedValue; ////bana bir category parametresi ver, bunun kriterlerini söyle (true veya false döndürekecek) ben de ona göre filtreleyeyim. //var category = dbContext.Categories.Where(c => c.Id == selectedCategoryId).FirstOrDefault(); var category = categoryBusiness.GetCategoryById(selectedCategoryId); selectedCategory = category; textBoxCategoryName.Text = category.Name; textBoxCategoryDescription.Text = category.Description; buttonUpdateCategory.Enabled = true; buttonRemoveCategory.Enabled = true; }
private void buttonAddProds_Click(object sender, EventArgs e) { Product product = new Product(); product.Name = textBoxProdName.Text; product.ImgAddress = textBoxProdImage.Text; product.Price = Convert.ToDecimal(textBoxProdPrice.Text); product.Info = textBoxProdInfo.Text; product.Rating = Convert.ToDouble(textBoxProdRating.Text); int selectedCategoryId = (int)comboBoxShowCats.SelectedValue; selectedCategory = categoryBusiness.GetCategoryById(selectedCategoryId); product.CategoryId = selectedCategory.Id; productBusiness.Add(product); MessageBox.Show("Ürün başarıyla eklendi!"); showProducts.ShowProducts(dataGridViewShowProds); }
private void comboBoxShowProds_SelectionChangeCommitted(object sender, EventArgs e) { int selectedProductId = (int)comboBoxShowProds.SelectedValue; var product = productBusiness.GetProductById(selectedProductId); selectedProduct = product; int currentCategoryId = selectedProduct.CategoryId; var currentCategory = categoryBusiness.GetCategoryById(currentCategoryId); textBoxProdsName.Text = selectedProduct.Name; textBoxProdImage.Text = selectedProduct.ImgAddress; textBoxProdPrice.Text = selectedProduct.Price.ToString(); textBoxProdInfo.Text = selectedProduct.Info; textBoxProdRating.Text = selectedProduct.Rating.ToString(); comboBoxShowCats.SelectedValue = selectedProduct.CategoryId; buttonUpdateProds.Enabled = true; showProducts.ShowProducts(dataGridViewShowProds); }
public ActionResult EditCategory(int id) { return(View(_Category.GetCategoryById(id))); }