private void BtnCatList_Click(object sender, EventArgs e) { // Data Gride verileri getirmek için EntityCategory class'ından CategoryList adında generic bir liste oluşturuyoruz ve Mantıksal Katman(Logic Layer) // üzerinden LLCategoryList methodu Veri Erişim Katmanına Erişerek (DAL) gerekli SQL sorgusu ile kategoriler hakkında tüm bilgiler getirilir. List <EntityCategory> CategoryList = LogicCategory.LLCategoryList(); // DataSource veri kaynağı olarak bir Generic List almaktadır dataGridView1.DataSource = CategoryList; }
private void BtnCatDelete_Click(object sender, EventArgs e) { // Sadece ID kontrol etmemiz yeterli VeriTabanından Kayıtlar Nesneyi eşsiz yapan bir özelliği üzerinden silinirler // ID her kategorinin benzersiz sahip olduğu bir özelliktir if (TxtCatId.Text != "") { EntityCategory ent = new EntityCategory(); ent.categoryId = int.Parse(TxtCatId.Text); LogicCategory.LLCategoryDelete(ent.categoryId); MessageBox.Show("Kategori Başarılı Bir Şekilde Silindi"); TxtCatName.Text = ""; } else { MessageBox.Show("Id Alanını Boş Bırakmayınız"); } }
private void BtnCatAdd_Click(object sender, EventArgs e) { // Textbox'lardan gelen veriler kontrol ediliyor boş veri varsa uyarı mesajı bırakıyoruz çünkü veritabanında boş verilerin bulunmasını istemiyoruz // EntityCategory üzerinde oluşturduğumuz nesnemize gerekli atamaları yaptıktan sonra // Nesnelerimizin kontrolünü yapmak üzere Mantıksal Katmana verilerimizi gönderiyoruz. if (TxtCatName.Text != "") { EntityCategory cat = new EntityCategory(); cat.categoryName = TxtCatName.Text; LogicCategory.LLCategorySave(cat); MessageBox.Show("Kategori Başarılı Bir Şekilde Eklendi"); TxtCatName.Text = ""; } else { MessageBox.Show("Alanları Boş Bırakmayınız"); } }
private void BtnCatUpdt_Click(object sender, EventArgs e) { counterCategory += 1; if (counterCategory < 2) { // ComboBox kategorileri getirmek için Logic Layer'de daha önce tanımlanan LLCategoryList methodu ile tüm kategoriler getirilir // gelen liste foreach ile dönülerek combobox'ın add methodu ile comboxa eklenir List <EntityCategory> CatList = LogicCategory.LLCategoryList(); foreach (var item in CatList) { cmbBookCat.Items.Add(item.categoryName); } } else { MessageBox.Show("Butona sadece bir kez basabilirsiniz"); } }
/// <summary> /// 查询分类实体 /// </summary> /// <param name="Id"></param> /// <returns></returns> private ModelCategory GetCategoryDetail(string Id) { var resultMsg = string.Empty; var idx = 0; var logic = new LogicCategory(); int.TryParse(Id, out idx); var model = logic.CategoryDetail(out resultMsg,base.AuthorizeInfo, idx); return model; }
/// <summary> /// 侧边栏 分类 子类列表 /// </summary> /// <param name="categoryCode">父分类Id</param> public ActionResult SidebarCategory(string categoryCode = null, string adsCategoryCode=null) { var categoryId = 0; var resultMsg = string.Empty; var logic = new LogicCategory(); int.TryParse(categoryCode,out categoryId); IList<ModelCategory> list = new List<ModelCategory>(); list = logic.CategoryAll(out resultMsg,base.AuthorizeInfo, categoryId, "2"); var modelList = (from ModelCategory m in list where m.Id == categoryId select m).ToList(); var model = modelList != null && modelList.Count > 0 ? modelList.First() : new ModelCategory(); ViewBag.CategName = model.Name; ViewBag.Thumbnails = model.Thumbnails; ViewBag.CategoryCode = categoryCode; ViewBag.AdsCategoryCode = adsCategoryCode; list.Remove(model); return PartialView(list); }
/// <summary> /// 导航 /// </summary> public ActionResult Navigation() { var logic = new LogicCategory(); var resultMsg = string.Empty; IList<ModelCategory> list = new List<ModelCategory>(); list = logic.CategoryAll(out resultMsg,base.AuthorizeInfo, 1,"1"); return PartialView(list); }
/// <summary> /// 杂志版块 /// </summary> public ActionResult MagazineIndex(string Category, string Year, string Month, string PagerIndex = "1", string PagerSize = "30") { Year = string.IsNullOrWhiteSpace(Year) ? DateTime.Now.Year.ToString() : Year; Month = string.IsNullOrWhiteSpace(Month) ? DateTime.Now.Month.ToString() : Month; var idx = 0; var iYear = 0; var iMonth = 0; int.TryParse(Year, out iYear); int.TryParse(Month, out iMonth); int.TryParse(Category, out idx); var resultMsg = string.Empty; var logic = new LogicCategory(); var model = new ModelPagerArticle(); var monthDays = DateTime.DaysInMonth(iYear, iMonth); var startDate = new DateTime(iYear, iMonth, 1, 0, 0, 0); var endDate = new DateTime(iYear, iMonth, monthDays, 23, 59, 59); var cateModel = logic.CategoryDetailByPid(out resultMsg, base.AuthorizeInfo, idx, startDate, endDate); if (cateModel != null) { ViewBag.CategoryName = cateModel.Name; ViewBag.Thumbnails = cateModel.Thumbnails; model = GetData(Category: cateModel.Id.ToString(), PagerIndex: PagerIndex, PagerSize: PagerSize); model.Year = Year; model.Month = Month; model.Category = Category; } return View(model); }
/// <summary> /// 查询分类 /// </summary> private IList<ModelCategory> GetDataCategory(string Id) { var categoryId = 0; var resultMsg = string.Empty; var logic = new LogicCategory(); int.TryParse(Id, out categoryId); IList<ModelCategory> list = new List<ModelCategory>(); list = logic.CategoryAll(out resultMsg, base.AuthorizeInfo, categoryId, "2"); var modelList = (from ModelCategory m in list where m.Id == categoryId select m).ToList(); var model = modelList != null && modelList.Count > 0 ? modelList.First() : new ModelCategory(); ViewBag.CategName = model.Name; ViewBag.CategoryCode = Id; list.Remove(model); return list; }