private void button1_Click_1(object sender, EventArgs e) { CategoryVO temp = new CategoryVO(); temp.Id = category.Id; temp.Name = NameB.Text.Trim(); if (NameB.Text.Trim() == "") { Message("اسم التصنيف لايمكن أن يكون فارغاً"); } else if (!manager.IsCategoryNew(temp)) { Error("هناك تصنيف آخر له نفس الاسم", "فشل تعديل التصنيف"); return; } else { if (manager.Update(temp)) { category.Name = temp.Name; Message("تم تعديل التصنيف بنجاح"); DialogResult = System.Windows.Forms.DialogResult.OK; } else { Error(); } } }
protected void AddButton_Click1(object sender, EventArgs e) { try { Category _Category = new Category(); _Category.Code = (txtCategoryCode.Text); _Category.Name = txtCategoryName.Text; if (IdHiddenField.Value == "") { int success = _CategoriesManager.Add(_Category); if (success > 0) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Successefully Saved Category');", true); txtCategoryName.Text = ""; IdHiddenField.Value = ""; //Response.Redirect(Request.Url.AbsoluteUri); AutoCodeGenerate(); LoadCategories(); } else { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Failed Saved Category');", true); } } else { int UpdateSuccess = _CategoriesManager.Update(_Category); if (UpdateSuccess > 0) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Successefully Update Category');", true); txtCategoryName.Text = ""; IdHiddenField.Value = ""; AutoCodeGenerate(); LoadCategories(); AddButton.Text = "Add"; DeleteButton.Visible = false; } else { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Failed Update Category');", true); } } } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + ex.Message + "');", true); } }
public ActionResult Edit(Category category) { ModelState.Remove("CreatedOn"); ModelState.Remove("ModifiedOn"); ModelState.Remove("ModifiedUsername"); if (ModelState.IsValid) { Category cat = categoriesManager.Find(x => x.Id == category.Id); cat.Title = category.Title; cat.Description = category.Description; categoriesManager.Update(cat); CacheHelper.GetCategoriesFromCache(); return(RedirectToAction("Index")); } return(View(category)); }
private void setFlag(int recordId, bool value, string flagName) { if (!this.AllowEdit) return; try { var man = new CategoriesManager(true, true); var o1 = man.GetByKey(recordId); if (o1.Id > 0) { switch (flagName.ToLower()) { case "enabled": o1.Enabled = value; break; default: break; } man.Update(o1); } } catch (Exception e1) { LblErr.Text = RenderError(Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString()); } finally { } }