Example #1
0
        public static bool Add(ProdCategory record)
        {
            using (MainContext db = new MainContext())
            {
                try
                {
                    record.TimeCreated = DateTime.Now;
                    record.Deleted     = false;
                    record.Online      = true;
                    record.SortNumber  = 9999;
                    db.ProdCategory.Add(record);
                    db.SaveChanges();

                    //LogtrackManager logkeeper = new LogtrackManager();
                    //logkeeper.LogDate = DateTime.Now;
                    //logkeeper.LogProcess = EnumLogType.DokumanGrup.ToString();
                    //logkeeper.Message = LogMessages.ProductGroupAdded;
                    //logkeeper.User = HttpContext.Current.User.Identity.Name;
                    //logkeeper.Data = record.GroupName;
                    //logkeeper.AddInfoLog(logger);

                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
Example #2
0
        protected override void Seed(wpf_datagrid.Models.Model1 context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.
            var cat = new ProdCategory()
            {
                Name = "金属製品"
            };

            context.ProdCategories.AddOrUpdate(cat);
            context.SaveChanges();

            context.Products.AddOrUpdate(new Product()
            {
                Name        = "ABC 123",
                NameKana    = "エイビーシー123",
                Description = "",
                CategoryId  = cat.Id
            });
            context.Products.AddOrUpdate(new Product()
            {
                Name        = "XYZ 567",
                NameKana    = "エックスワイゼット567",
                Description = "",
                CategoryId  = cat.Id
            });
            context.SaveChanges();
        }
        public void Change(ProdCategory pc)
        {
            vikingcompContext.ProdCategory.Find(pc.Id).Description = pc.Description;
            vikingcompContext.ProdCategory.Find(pc.Id).Name        = pc.Name;

            vikingcompContext.SaveChanges();
        }
        public ActionResult Add(ProdCategory c)
        {
            CatProdDAO cdao = new CatProdDAO();

            cdao.Insert(c);
            return(RedirectToAction("Index"));
        }
Example #5
0
        public ActionResult ProdCatDetails(int id)
        {
            ProdCategory pc = prodCategoryRepository.GetByID(id);

            ViewBag.Title = pc.Name + " details";

            return(View(pc));
        }
        public ActionResult Remove(string id)
        {
            CatProdDAO   cdao = new CatProdDAO();
            ProdCategory c    = cdao.FindById(Convert.ToInt32(id));

            cdao.Remove(c);
            return(RedirectToAction("Index"));
        }
        public ActionResult FormUp(string id)
        {
            CatProdDAO   cdao = new CatProdDAO();
            ProdCategory cat  = cdao.FindById(Convert.ToInt32(id));

            ViewBag.CatId = cat;
            return(View());
        }
Example #8
0
 //Constructor taking in all the paramaters.
 public Product(string name, ProdCategory cat, decimal price, string description)
 {
     Name        = name;
     Category    = cat;
     Price       = price;
     Description = description;
     Products.Add(this);
 }
Example #9
0
        public ActionResult ProdCatDelete(int id)
        {
            ProdCategory pc = prodCategoryRepository.GetByID(id);

            ViewBag.Title = "Delete " + pc.Name;

            return(View(pc));
        }
Example #10
0
        public ActionResult DeleteConfirmed(int id)
        {
            ProdCategory prodCategory = db.ProdCategory.Find(id);

            db.ProdCategory.Remove(prodCategory);
            db.SaveChanges();
            Success("Deleted successfully!", true);
            return(RedirectToAction("Index"));
        }
Example #11
0
        public ActionResult Update(ProdCategory c)
        {
            CatProdDAO   cdao = new CatProdDAO();
            ProdCategory cat  = cdao.FindById(Convert.ToInt32(c.Id));

            cat.Name        = c.Name;
            cat.Description = c.Description;
            cdao.Update();
            return(RedirectToAction("Index"));
        }
Example #12
0
        public ActionResult Details(int Id)
        {
            ProductDAO           pdao = new ProductDAO();
            CatProdDAO           cdao = new CatProdDAO();
            IList <ProdCategory> cat  = cdao.CategoryList();
            Product      p            = pdao.FindById(Convert.ToInt32(Id));
            ProdCategory catid        = cdao.FindById(Convert.ToInt32(p.CategoryId));

            ViewBag.CatId  = catid;
            ViewBag.ProdId = p;
            return(View());
        }
        public ActionResult Add(string ddlLanguage, int ddlParentCategory, string txtName)
        {
            ViewBag.SubCategory = false;
            ProdCategory category = new ProdCategory();

            category.Lang          = ddlLanguage;
            category.ParentId      = ddlParentCategory;
            category.Name          = txtName;
            ViewBag.ProcessMessage = ProdCategoryManager.Add(category);
            FillLanguagesList();
            return(View());
        }
Example #14
0
        public ActionResult ProdCatCreate(ProdCategory p)
        {
            try
            {
                prodCategoryRepository.Add(p);

                return(RedirectToAction("ProdCatIndex"));
            }
            catch
            {
                return(View());
            }
        }
Example #15
0
        public ActionResult ProdCatEdit(ProdCategory edited)
        {
            try
            {
                prodCategoryRepository.Change(edited);

                return(RedirectToAction("ProdCatIndex"));
            }
            catch
            {
                return(View());
            }
        }
Example #16
0
        // GET: ProdCategory/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProdCategory prodCategory = db.ProdCategory.Find(id);

            if (prodCategory == null)
            {
                return(HttpNotFound());
            }
            return(View(prodCategory));
        }
Example #17
0
        public ActionResult FormUp(string id)
        {
            ProductDAO           pdao = new ProductDAO();
            CatProdDAO           cdao = new CatProdDAO();
            IList <ProdCategory> cat  = cdao.CategoryList();

            ViewBag.Categorys = cat;
            Product prod = pdao.FindById(Convert.ToInt32(id));

            ViewBag.ProdId = prod;
            ProdCategory catid = cdao.FindById(Convert.ToInt32(prod.CategoryId));

            ViewBag.CatId = catid;
            return(View());
        }
Example #18
0
        // GET: ProdCategory/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProdCategory prodCategory = db.ProdCategory.Find(id);

            if (prodCategory == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BuyerInfoId = new SelectList(db.BuyerInfo.OrderBy(x => x.Name), "Id", "Name", prodCategory.BuyerInfoId);

            return(View(prodCategory));
        }
Example #19
0
 public ActionResult Edit([Bind(Include = "Id,BuyerInfoId,Name,Description,IsAuth,OpBy,OpOn,AuthBy,AuthOn")] ProdCategory prodCategory)
 {
     if (ModelState.IsValid)
     {
         if (db.ProdCategory.Where(x => x.BuyerInfoId == prodCategory.BuyerInfoId && x.Name.ToLower() == prodCategory.Name.ToLower() && x.Id != prodCategory.Id).Count() > 0)
         {
             Danger("Name exists! Try different.", true);
         }
         else
         {
             prodCategory.OpBy            = 1;
             prodCategory.OpOn            = DateTime.Now;
             db.Entry(prodCategory).State = EntityState.Modified;
             db.SaveChanges();
             Success("Saved successfully", true);
             return(RedirectToAction("Index"));
         }
     }
     ViewBag.BuyerInfoId = new SelectList(db.BuyerInfo.OrderBy(x => x.Name), "Id", "Name", prodCategory.BuyerInfoId);
     return(View(prodCategory));
 }
Example #20
0
 public void Remove(ProdCategory cat)
 {
     context.Categorys.Remove(cat);
     context.SaveChanges();
 }
Example #21
0
 public void Insert(ProdCategory cat)
 {
     context.Categorys.Add(cat);
     context.SaveChanges();
 }
 public void Delete(ProdCategory n)
 {
     vikingcompContext.ProdCategory.Remove(n);
     vikingcompContext.SaveChanges();
 }
 public void Add(ProdCategory n)
 {
     vikingcompContext.ProdCategory.Add(n);
     vikingcompContext.SaveChanges();
 }