[HttpPost]//gui thong tin insert user len server public ActionResult Create(Category model) { try { if (ModelState.IsValid) { var dao = new CategoryDao(); long id = dao.Insert(model); if (id > 0) { SetAlert("Thêm user thành công", "success"); return(RedirectToAction("Index", "Category")); } else { ModelState.AddModelError("", "Thêm không thành công"); } return(View("Index")); } else { return(View()); } } catch { return(View()); } }
public ActionResult Add(CategoryServicesModel input) { if (ModelState.IsValid) { input.UserId = SessionHelper.GetSessionUser().UserId; input.Taxonomy = input.Taxonomy ?? "Service"; input.Status = input.Status ?? true; input.Order = input.Order ?? 0; input.Date = input.Date ?? DateTime.Now; input.Modified = input.Modified ?? DateTime.Now; var entity = new tb_Catogory(); entity.Date = input.Date; entity.Meta_Description = input.Meta_Description; entity.Meta_Keyword = input.Meta_Keyword; entity.Meta_Title = input.Meta_Title; entity.Modified = input.Modified; entity.Name = input.Name; entity.Order = input.Order; entity.ParentId = input.ParentId; entity.Slug = input.Slug; entity.Status = input.Status; entity.Taxonomy = input.Taxonomy; entity.Thumbnail = input.Thumbnail; entity.Title = input.Title; entity.UserId = input.UserId; long Id = Dao.Insert(entity); return(RedirectToAction("Edit", "CategoryServices", new { Id = Id })); } ViewBag.ParentId = new SelectList(Dao.ListAllByTaxonomy("Service"), "Id", "Name", input.ParentId); return(View(input)); }
private void Save() { //Note* if (Helpers.CheckEmpty(errorProvider1, txtName, txtOther)) { return; } else { SaveCompleted = true; errorProvider1.Clear(); CategoryEntity categoryEntity = new CategoryEntity(); categoryEntity.CategoryName = txtName.Text; categoryEntity.Other = txtOther.Text; if (categoryID != Guid.Empty) { categoryEntity.Id = categoryID; categoryEntity.Update(USER.UserName); CategoryDao.Update(categoryEntity); } else { categoryEntity.Id = Guid.NewGuid(); categoryEntity.Create(USER.UserName); CategoryDao.Insert(categoryEntity); } } }
public ActionResult Create(Category entity) { if (ModelState.IsValid) { var categoryDao = new CategoryDao(); entity.Name = entity.Name.Trim(); long result = categoryDao.Insert(entity); if (result > 0) { ShowNotify("Add successfully", "success"); return(RedirectToAction("Index", "Category")); } else if (result == -1) { ShowNotify("This name of category already exists", "error"); } else { ShowNotify("System error", "error"); } } return(View("Create")); }
private static void AddItemOKClicked(object sender, RoutedEventArgs e) { switch (WPFDbContext.Instance.AddItemType) { case ItemTypeEnum.Category: WPFCategoryDao.SaveTempSelectedIndex(); CategoryDao.Insert(WPFDbContext.Instance.ItemName); WPFCategoryDao.GetCategories(); WPFCategoryDao.GetCategoryFromTempSelectedIndex(); break; case ItemTypeEnum.ParameterName: if (WPFDbContext.Instance.Description.Length == 0) { MessageBox.Show("Please input description of parameter!"); return; } ParameterNameDao.Insert(WPFDbContext.Instance.ItemName, WPFDbContext.Instance.Description); WPFParameterNameDao.Update(); break; case ItemTypeEnum.Task: WPFTaskDao.SaveTempSelectedIndex(); TaskDao.Insert(WPFDbContext.Instance.ItemName); WPFTaskDao.GetTasks(); WPFTaskDao.GetTaskFromTempSelectedIndex(); break; } WPFDbContext.Instance.ItemName = ""; WPFDbContext.Instance.Description = ""; WPFDbContext.Instance.AddItem.Hide(); }
public ActionResult Create(Category collection) { try { CategoryDao bdDao = new CategoryDao(); UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; collection.CreateBy = us.UserName; collection.CreateDate = Hepper.GetDateServer(); collection.ModifiedBy = us.UserName; collection.ModifiedDate = Hepper.GetDateServer(); collection.LanguageID = "vi"; //collection.CreateBy = us.UserName; //collection.ModifiedBy = us.UserName; if (bdDao.Insert(collection)) { SetAlert(@Resources.ResourceAdmin.AdminCreateRecordSuccess, "success"); return(RedirectToAction("Index")); } else { SetAlert(@Resources.ResourceAdmin.AdminCreateRecordFailed, "danger"); } return(RedirectToAction("Index")); } catch { SetAlert(@Resources.ResourceAdmin.AdminCreateRecordFailed, "danger"); return(View()); } }
public ActionResult Create(Category collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here CategoryDao bdDao = new CategoryDao(); UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; collection.CreateDate = Hepper.GetDateServer(); collection.ModifiedDate = Hepper.GetDateServer(); collection.CreateBy = us.UserName; collection.ModifiedBy = us.UserName; if (bdDao.Insert(collection) > 0) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không thêm được", "danger"); } } return(View()); } catch { SetAlert("Không thêm được", "danger"); return(View()); } }
public ActionResult CreateNhomSanPham(NhomSanPhamModel model) { LoaiSanPham loaisanpham = new LoaiSanPham(); loaisanpham.TenLoaiSanPham = model.Ten; loaisanpham.SanPhamChinh = model.SPChinhPhu; var dao = new CategoryDao(); dao.Insert(loaisanpham); return(RedirectToAction("Index", "NhomSanPhamAdmin")); }
public ActionResult Create([Bind(Include = "ID,Name,MetaTitle,CreateDate,Image,Icon,ParentID,Status")] Category category, HttpPostedFileBase image) { try { if (ModelState.IsValid) { var dao = new CategoryDao(); var path = ""; var filename = ""; if (image != null) { filename = DateTime.Now.ToString("dd-MM-yy-hh-mm-ss-") + image.FileName; path = Path.Combine(Server.MapPath("~/Image"), filename); image.SaveAs(path); category.Image = filename; } //else //{ // content.Image = "~/Image/logo.png"; //} category.Name = category.Name; category.Icon = category.Icon; category.MetaTitle = StringHelper.ToUnsignString(category.Name); category.CreateDate = Convert.ToDateTime(DateTime.UtcNow.ToLocalTime()); category.Status = Convert.ToBoolean(true); category.ParentID = category.ParentID; var id = dao.Insert(category); if (id > 0) { SetAlert("Thêm mới thành thành công", "success"); ViewBag.Success = "Thêm thành công"; category = new Category(); return(RedirectToAction("Index", "Category")); } else { ModelState.AddModelError("", "Thêm mới ko thành công"); } } } catch (DbEntityValidationException e) { throw e; } catch (Exception ex) { throw ex; } return(View(category)); }
public ActionResult Create(Category category) { if (ModelState.IsValid) { var dao = new CategoryDao(); var id = dao.Insert(category); if (id > 0) { return(RedirectToAction("Index", "Category")); } else { ModelState.AddModelError("", "Not add category success!"); } } return(View()); }
public ActionResult Create(Category Category) { if (ModelState.IsValid) { var dao = new CategoryDao(); long id = dao.Insert(Category); if (id > 0) { return(RedirectToAction("Index", "Category")); } else { ModelState.AddModelError("", "Add Category successfully"); } } return(View("Index")); }
public ActionResult Create(Category cate) { if (ModelState.IsValid) { var dao = new CategoryDao(); long id = dao.Insert(cate); if (id > 0) { ModelState.AddModelError("", "Thêm mới danh mục thành công"); } else { ModelState.AddModelError("", "Thêm mới danh mục thất bại"); } } return(View()); }
public ActionResult Create(Category category) { if (ModelState.IsValid) { var iplCategory = new CategoryDao(); var res = iplCategory.Insert(category); if (res > 0) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Them moi khong thanh cong"); } } return(View()); }
public ActionResult Create(Category entity) { if (ModelState.IsValid) { var dao = new CategoryDao(); long id = dao.Insert(entity); if (id > 0) { return(RedirectToAction("Index", "Content")); } else { ModelState.AddModelError("", "Không thêm được thông tin"); } } return(View()); }
private void Save() { CategoryEntity categoryEntity = new CategoryEntity(); categoryEntity.Category = txtCategory.Text; categoryEntity.Des = txtDes.Text; if (getID != Guid.Empty) { categoryEntity.ID = getID; CategoryDao.Update(categoryEntity); } else { categoryEntity.ID = Guid.NewGuid(); CategoryDao.Insert(categoryEntity); } }
public ActionResult Create(DanhMucSP tt) { if (ModelState.IsValid) { var dao = new CategoryDao(); long id = dao.Insert(tt); if (id > 0) { SetAlert("Thêm danh mục sản phẩm thành công", "success"); return(RedirectToAction("Index", "Category")); } else { ModelState.AddModelError("", "Thêm danh mục không thành công"); } } return(View("Index")); }
public ActionResult Create(Categorys model) { if (ModelState.IsValid) { var dao = new CategoryDao(); long id = dao.Insert(model); if (id > 0) { return(RedirectToAction("Index", "Category")); } else { ModelState.AddModelError("", "Them category thanh cong"); } } return(View("Index")); }
public ActionResult Create(Category category) { if (ModelState.IsValid) { var dao = new CategoryDao(); category.CreatedDate = DateTime.Now; long id = dao.Insert(category); if (id > 0) { return(RedirectToAction("Index", "Category")); } else { ModelState.AddModelError("", "Thêm danh mục không thành công"); } } return(View("Create")); }
public ActionResult Create(DanhMuc cate) { if (ModelState.IsValid) { var dao = new CategoryDao(); var res = dao.Insert(cate); if (res > 0) { return(RedirectToAction("Index", "Category")); } else { ModelState.AddModelError("", "Thêm thất bại"); } } return(View("Index")); }
public ActionResult Create(Category category) { if (ModelState.IsValid) { var dao = new CategoryDao(); long id = dao.Insert(category); if (id > 0) { SetAlert("Thêm danh mục thành công", "success"); return(RedirectToAction("Index", "ContentCategories")); } else { ModelState.AddModelError("", "Thêm danh mục không thành công"); } } return(View("Index")); }
public ActionResult AddProductCategory(ProductCategory category) { if (ModelState.IsValid) { CategoryDao prcategory = new CategoryDao(); category.CreatedDate = DateTime.Now; category.ModifiedDate = DateTime.Now; if (prcategory.Insert(category)) { SetAlert("Thêm loại cửa thành công", "success"); return(RedirectToAction("Index", "ProductCategory")); } else { ModelState.AddModelError("", "Có lỗi xảy ra. Vui lòng thử lại"); } } return(View()); }
public ActionResult Create(Category model) { if (ModelState.IsValid) { var dao = new CategoryDao(); model.CreateDate = DateTime.Now; model.ModifiedDate = DateTime.Now; long id = dao.Insert(model); if (id > 0) { SetAlert("Add category successfully", "success"); return(RedirectToAction("Index", "Category")); } else { SetAlert("Add category failure", "danger"); ModelState.AddModelError("", "Add failure"); } } return(View("Index")); }
private void btnSave_Click(object sender, EventArgs e) { Category cate = new Category(); Types cellType = new Types(); //合法性检查 if (((TreeNodeTag)treeView.SelectedNode.Tag).NodeType == TreeNodeType.Root) { cate.CategoryName = txtCateName.Text.Trim(); if (operate == "add") { if (cateDao.Insert(cate) == false) { MessageBox.Show("保存失败"); } } } else if (((TreeNodeTag)treeView.SelectedNode.Tag).NodeType == TreeNodeType.Category) { if (operate == "add") { cellType.CateId = Convert.ToInt32(cmbCateID.Text); cellType.CellCode = txtCellCode.Text.Trim(); cellType.CellType = txtCellType.Text.Trim(); cellType.Description = txtDescription.Text.Trim(); if (typesDao.Insert(cellType) == false) { MessageBox.Show("保存失败"); } } else if (operate == "update") { cate.CateId = Convert.ToInt32(cmbCateID.Text); cate.CategoryName = txtCateName.Text; if (cateDao.Update(cate) == false) { MessageBox.Show("更新失败"); } } } else if (((TreeNodeTag)treeView.SelectedNode.Tag).NodeType == TreeNodeType.Type) { if (operate == "update") { cellType.CateId = Convert.ToInt32(cmbCateID.Text); cellType.TypeId = Convert.ToInt32(txtTypeId.Text); cellType.CellCode = txtCellCode.Text.Trim(); cellType.CellType = txtCellType.Text.Trim(); cellType.Description = txtDescription.Text.Trim(); cellType.ColorStr = ColorTranslator.ToHtml(btnColor.BackColor); if (typesDao.Update(cellType) == false) { MessageBox.Show("更新失败"); } } } ChangeToEditMode(false); btnRefresh_Click(sender, e); MainForm.UpdateCategoryDictionary(); MainForm.UpdateCellTypeDictionary(); }