Пример #1
0
        public ActionResult Create([Bind(Include = "id,categoryname,description")] category category)
        {
            if (ModelState.IsValid)
            {
                db.categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Пример #2
0
        public ActionResult Create([Bind(Include = "id,categoryid,subcategoryname,description")] subcategory subcategory)
        {
            if (ModelState.IsValid)
            {
                db.subcategories.Add(subcategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.categoryid = new SelectList(db.categories, "id", "categoryname", subcategory.category);
            return(View(subcategory));
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "stockid,productid,storeid,quantity,dateofstock,employeeid")] stock stock)
        {
            stock.storeid = Convert.ToInt32(Session["empsessionid"]);
            if (ModelState.IsValid)
            {
                db.stocks.Add(stock);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.productid  = new SelectList(db.products, "pid", "productname", stock.productid);
            ViewBag.employeeid = new SelectList(db.storeemployees, "id", "name", stock.employeeid);
            ViewBag.storeid    = new SelectList(db.stores, "storeid", "storename", stock.storeid);
            return(View(stock));
        }
        public ActionResult Create([Bind(Include = "cardnumber,cardholdernname,photo,Mobileno,address,memberid")] membership_cards membership_cards, HttpPostedFileBase photo)
        {
            if (ModelState.IsValid)
            {
                string photoname = photo.FileName;
                photo.SaveAs(Server.MapPath("~/uploads/" + photoname));
                membership_cards.photo = "~/uploads/" + photoname;
                db.membership_cards.Add(membership_cards);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.memberid = new SelectList(db.memberships, "memberid", "merchantname", membership_cards.memberid);
            return(View(membership_cards));
        }
        public ActionResult generateb(int cardnumber)
        {
            if (Session["cartlist"] == null)
            {
                cartlist = new List <CartVM>();
            }
            else
            {
                cartlist = (List <CartVM>)Session["cartlist"];
            }
            bill       b         = new bill();
            billdetail bd        = new billdetail();
            int        tamount   = 0;
            int        tdiscount = 0;
            int        tnetprice = 0;

            b.cardnumber = cardnumber;

            foreach (var cart in cartlist)
            {
                tamount      = tamount + Convert.ToInt32(cart.price * cart.qty);
                tdiscount    = tdiscount + Convert.ToInt32(cart.discount * cart.qty);
                b.storeid    = Convert.ToInt32(Session["empsessionid"]);
                b.empid      = Convert.ToInt32(Session["employeeid"]);
                b.dateofbill = DateTime.Now.ToString();
            }
            b.totalamount = tamount;
            b.billamount  = tamount - tdiscount;
            b.discount    = tdiscount;
            db.bills.Add(b);
            db.SaveChanges();
            bd.billid = b.billid;
            foreach (var cart in cartlist)
            {
                bd.productid   = cart.productid;
                bd.quantity    = cart.qty;
                bd.price       = Convert.ToInt32(cart.price);
                bd.netprice    = Convert.ToInt32(cart.netprice);
                bd.discount    = Convert.ToInt32(cart.discount);
                bd.totalamount = Convert.ToInt32(cart.totalamount);
                db.billdetails.Add(bd);
                db.SaveChanges();
            }
            return(View());
        }
        public ActionResult changepassword(empPasswordVM chview)
        {
            var user = db.storeemployees.SingleOrDefault(x => x.id == chview.username && x.password == chview.password);

            if (user != null)
            {
                user.password = chview.newpassword;

                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Success"));
            }
            else
            {
                ModelState.AddModelError("password", "Invalid Username or Password");
                return(View());
            }
        }
        public ActionResult Create([Bind(Include = "username,password,ConfirmPassword,fullname,gender,emailid,usertype")] Administrator administrator)
        {
            administrator.ConfirmPassword = administrator.password;
            if (ModelState.IsValid)
            {
                var result = db.Administrators.Find(administrator.username);
                if (result != null)
                {
                    ModelState.AddModelError("username", "Username Already Exists!");
                }
                else
                {
                    db.Administrators.Add(administrator);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            return(View(administrator));
        }
        public ActionResult Create([Bind(Include = "pid,productname,description,subcatid,price,discount,photo,storeid,skunumber")] product product, HttpPostedFileBase Photo)
        {
            product.storeid = Convert.ToInt32(Session["Storeid"]);
            var result = db.products.SingleOrDefault(x => x.skunumber == product.skunumber);

            if (result != null)
            {
                ModelState.AddModelError("skunumber", "Sku Number Already Exists");
            }
            if (ModelState.IsValid)
            {
                string photoname = Photo.FileName;

                Photo.SaveAs(Server.MapPath("~/uploads/" + photoname));
                product.photo = "~/uploads/" + photoname;
                db.products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            List <SelectListItem> discount = new List <SelectListItem> {
            };

            for (int i = 0; i <= 16; i++)
            {
                discount.Add(new SelectListItem()
                {
                    Text = "" + (i * 5), Value = "" + (i * 5)
                });
            }
            ViewBag.discount = discount;

            ViewBag.storeid = new SelectList(db.stores, "storeid", "storename", product.storeid);
            //ViewBag.subcatid = new SelectList(db.subcategories, "id", "subcategoryname", product.subcatid);
            ViewBag.categoryname = new SelectList(db.categories, "id", "categoryname");
            return(View(product));
        }
Пример #9
0
 public void Insert(Seller seller)
 {
     _context.Add(seller);
     _context.SaveChanges();
 }