private void btnDelete_Click(object sender, EventArgs e) { try { DialogResult option; option = MessageBox.Show("Do you really want to delete?", "SysBusiness", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (option == DialogResult.OK) { string Code; string resp = ""; foreach (DataGridViewRow row in dataList.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { Code = Convert.ToString(row.Cells[1].Value); resp = BCategory.Delete(Convert.ToInt32(Code)); if (resp.Equals("OK")) { this.MessageOk("Success deleted"); } else { this.MessageError(resp); } } } this.ShowValues(); } } catch (Exception ex) { } }
public static List <BCategory> GetCategoriesWithProducts(TrucksReserveEntities trModel, bool loadCategories, int?onlyForCategoryID = null) { trModel.ExcIfNull(); List <BCategory> bCategories = new List <BCategory>(); if (onlyForCategoryID.HasValue == true) { BCategory wantedCategory = null; if (loadCategories == true) { bCategories = GetCategories(trModel); wantedCategory = bCategories.First(c => c.ID == onlyForCategoryID.Value); } else { wantedCategory = GetCategory(trModel, onlyForCategoryID.Value); bCategories.Add(wantedCategory); } wantedCategory.ExcIfNull(); wantedCategory.LoadProducts(trModel); wantedCategory.LoadImages(trModel); } else { bCategories = GetCategories(trModel, true); } return(bCategories); }
public ActionResult DeleteConfirmed(int id) { BCategory bCategory = db.BCategories.Find(id); db.BCategories.Remove(bCategory); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,BCategoryType")] BCategory bCategory) { if (ModelState.IsValid) { db.Entry(bCategory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bCategory)); }
public ActionResult Create([Bind(Include = "Id,BCategoryType")] BCategory bCategory) { if (ModelState.IsValid) { db.BCategories.Add(bCategory); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bCategory)); }
public BCategory Get(int id) { string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; Shop MainShop = userMgr.Main_Shop; ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, MainShop, userMgr.CurrentUserPermission); BCategory cate = cateMgr.GetCategory(id); return(cate); }
private void btnSave_Click(object sender, EventArgs e) { try { string resp = ""; if (txtNameConfig.Text == string.Empty) { MessageError("Fill the fields"); errorIcon.SetError(txtNameConfig, "Insert the name"); } else { if (this.eNew) { resp = BCategory.Insert(this.txtNameConfig.Text.Trim().ToUpper(), txtDescription.Text.Trim()); } else { resp = BCategory.Edit(Convert.ToInt32(this.txtIdCategory.Text), this.txtNameConfig.Text.Trim().ToUpper(), txtDescription.Text.Trim()); } if (resp.Equals("OK")) { if (this.eNew) { this.MessageOk("Register saved"); } else { this.MessageOk("Register Edited"); } } else { this.MessageError(resp); } this.eNew = false; this.eEdit = false; this.Enabledbuttons(); this.Clean(); this.ShowValues(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
// GET: BCategories/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BCategory bCategory = db.BCategories.Find(id); if (bCategory == null) { return(HttpNotFound()); } return(View(bCategory)); }
public static BCategory GetCategory(TrucksReserveEntities trModel, int id) { trModel.ExcIfNull(); BCategory category = null; Category dbCategory = trModel.Categories.FirstOrDefault(c => c.ID == id); if (dbCategory != null) { category = new BCategory(dbCategory, false, false); } return(category); }
public ApiMessage Add() { string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; Shop cShop = userMgr.Shop; ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, cShop, userMgr.CurrentUserPermission); HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; ApiMessage message = new ApiMessage(); try { BCategory cate = new BCategory(); cate.Name = request["name"].ToString(); cate.ID = 0; cate.Mall_ID = ""; cate.Mall_PID = ""; cate.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now); cate.Parent = new BCategory() { ID = int.Parse(request["parent_id"].ToString()) }; cateMgr.CreateCategory(cate); message.Status = "ok"; message.Message = "分类创建成功"; message.Item = cate; } catch (KM.JXC.Common.KMException.KMJXCException ex) { message.Status = "failed"; message.Message = ex.Message; } catch (Exception ex) { message.Status = "failed"; message.Message = "分类创建失败"; } return(message); }
private void SearchName() { this.dataList.DataSource = BCategory.SearchName(this.txtSearch.Text); this.HideCollumns(); lblTotal.Text = Convert.ToString(dataList.Rows.Count) + " registers found"; }
private void ShowValues() { this.dataList.DataSource = BCategory.ShowValues(); this.HideCollumns(); lblTotal.Text = Convert.ToString(dataList.Rows.Count) + " registers found"; }