コード例 #1
0
 [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());
     }
 }
コード例 #2
0
 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));
 }
コード例 #3
0
ファイル: FrmCategory.cs プロジェクト: Sopheak088/iThinking
 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);
         }
     }
 }
コード例 #4
0
        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"));
        }
コード例 #5
0
        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();
        }
コード例 #6
0
        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());
            }
        }
コード例 #7
0
        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());
            }
        }
コード例 #8
0
        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"));
        }
コード例 #9
0
        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));
        }
コード例 #10
0
 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());
 }
コード例 #11
0
 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"));
 }
コード例 #12
0
ファイル: CategoryController.cs プロジェクト: hgia9/ShopDT
 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());
 }
コード例 #13
0
 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());
 }
コード例 #14
0
 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());
 }
コード例 #15
0
        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);
            }
        }
コード例 #16
0
 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"));
 }
コード例 #17
0
        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"));
        }
コード例 #18
0
 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"));
 }
コード例 #19
0
ファイル: CategoryController.cs プロジェクト: tho2503/CDIO4
        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"));
        }
コード例 #20
0
 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"));
 }
コード例 #21
0
 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());
 }
コード例 #22
0
 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"));
 }
コード例 #23
0
ファイル: ClassifyForm.cs プロジェクト: oliverhk/AutoScan
        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();
        }