Summary description for ProductDAO
Ejemplo n.º 1
0
        public ActionResult Add(Product p)
        {
            ProductDAO pdao = new ProductDAO();

            if (p.CategoryId.Equals(1) && p.Price < 20000)
            {
                ModelState.AddModelError("p.SUVPrice", "The SUV price must be higher than $20k");
            }
            if (ModelState.IsValid)
            {
                pdao.Insert(p);
                return(RedirectToAction("Index"));
            }
            else
            {
                CatProdDAO cdao = new CatProdDAO();
                ViewBag.Categorys = cdao.CategoryList();
                ViewBag.Class     = "alert alert-danger";
                return(View("frmAdd"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Create(Product product)
        {
            if (ModelState.IsValid)
            {
                var dao = new ProductDAO();

                product.CreatedDate = DateTime.Now;
                product.CreatedBy   = "Neiht";

                long id = dao.Insert(product);
                if (id > 0)
                {
                    return(RedirectToAction("Index", "Product"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm mới thành công");
                }
            }
            return(View("Index"));
        }
        protected void BtnDelete_Click(object sender, EventArgs e)
        {
            int        id     = Convert.ToInt32(txtId.Text.Trim());
            ProductDAO dao    = new ProductDAO();
            bool       result = dao.DeleteProduct(id);

            if (result)
            {
                lblMessage.Text = "Delete is successful";
                ClearFields();
                GvProducts.DataBind();
                BtnInsert.Enabled = false;
                BtnUpdate.Enabled = false;
                BtnDelete.Enabled = false;
            }
            else
            {
                lblMessage.Text = "Delete is failed";
            }
            TxtOk.Text = "OK";
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Tìm kiếm sản phẩm theo từ khoá nhập vào
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public ActionResult Search(string keyword, int page = 1, int pageSize = 4)
        {
            int totalRecord = 0;
            var model       = new ProductDAO().Search(keyword, ref totalRecord, page, pageSize); //nên kiểm tra lại totalRecord xem nó đưa ra tổng bao nhiêu sản phẩm để phân trang

            ViewBag.keyword = keyword;                                                           //truyền từ khoá vào viewbag
            ViewBag.Total   = totalRecord;
            ViewBag.Page    = page;
            int maxPage   = 5;
            int totalPage = 0;

            totalPage         = (int)Math.Ceiling((double)(totalRecord / pageSize)); //lấy số bản ghi đến được trong ProductDAO / cho pageSize và ép kiểu sang double để làm tròn lên và chuyển lại kiểu int (tổng số trang hiện thị)
            ViewBag.TotalPage = totalPage;                                           //truyền totalPage vào viewbag
            //key tạo nút next và prev
            ViewBag.MaxPage = maxPage;
            ViewBag.First   = 1;         //trang đầu
            ViewBag.Last    = totalPage; //trang cuối cùng
            ViewBag.Next    = page + 1;
            ViewBag.Prev    = page - 1;
            return(View(model));
        }
Ejemplo n.º 5
0
        public ActionResult ConfirmInsertServices()
        {
            //รับ พารามิเตอร์ที่ส่งเข้ามา
            int custID    = Int32.Parse(Request.Params["custid"]);
            int productID = Int32.Parse(Request.Params["IDproduct"]);

            Database      db     = new Database();
            CustomerDAO   cDAO   = new CustomerDAO(db);
            CustomerModel cModel = cDAO.FindById(custID);

            db.Close();



            /// ถ้ามีข้อมูลให้เก็บไว้ที่ วิวดาต้าเพื่อนำไปแสดง <-- james
            if (cModel != null)
            {
                // หน้าคอนเฟิม เป็นหน้าที่มีพารามิเตอร์ค่อนข้่างครบ ให้ค้นจากข้อมูลหลักเลย
                // ค้นหาจากตารางโปรดัก Product
                db = new Database();
                ProductDAO   pDAO   = new ProductDAO(db);
                ProductModel pModel = pDAO.FindById(productID);
                db.Close();

                db = new Database();
                UsersDAO          uDAO   = new UsersDAO(db);
                List <UsersModel> uModel = uDAO.FindAll();
                db.Close();

                ViewData["USER"]    = uModel;
                ViewData["CUST"]    = cModel;
                ViewData["PRODUCT"] = pModel;
            }
            else
            {
                ViewData["CUST"] = null;
            }

            return(View());
        }
Ejemplo n.º 6
0
        public ActionResult AddItem(long productID)
        {
            var product = new ProductDAO().GetByID(productID);
            var cart    = Session[CARTSESSION];

            if (cart != null)
            {
                var list = (List <CartItem>)cart;
                if (list.Exists(x => x.product.ProductID == productID))
                {
                    foreach (var i in list)
                    {
                        if (i.product.ProductID == productID)
                        {
                            i.quanlity += 1;
                        }
                    }
                }
                else
                {
                    var item = new CartItem();
                    item.product  = product;
                    item.quanlity = 1;
                    list.Add(item);
                }

                Session[CARTSESSION] = list;
            }
            else
            {
                var item = new CartItem();
                item.product  = product;
                item.quanlity = 1;
                var list = new List <CartItem>();
                list.Add(item);

                Session[CARTSESSION] = list;
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 7
0
        public ActionResult AddItem(long productId, int quantity)
        {
            var product = new ProductDAO().ProductDetail(productId);
            var cart    = Session[CartSession];

            if (cart != null)
            {
                var listItem = (List <CartItem>)cart;
                if (listItem.Exists(x => x.Product.IDProduct == productId))
                {
                    foreach (var item in listItem)
                    {
                        if (item.Product.IDProduct == productId)
                        {
                            item.Quantity += quantity;
                        }
                    }
                }
                else
                {
                    var item = new CartItem();
                    item.Product  = product;
                    item.Quantity = quantity;
                    listItem.Add(item);
                }
                Session[CartSession] = listItem;
            }
            else
            {
                //tạo mới ddoiss tượng cart item
                var item = new CartItem();
                item.Product  = product;
                item.Quantity = quantity;
                var listItem = new List <CartItem>();
                listItem.Add(item);
                // gán vào session
                Session[CartSession] = listItem;
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 8
0
        public ActionResult AddItem(long productID, int quantity)
        {
            var product = new ProductDAO().ProductDetail(productID);
            var cart    = Session[CartSession];

            if (cart != null)
            {
                var list = (List <CartItem>)cart;
                if (list.Exists(x => x.Product.SanPhamID == productID))
                {
                    foreach (var item in list)
                    {
                        if (item.Product.SanPhamID == productID)
                        {
                            item.Quantity += quantity;
                        }
                    }
                }
                else
                {
                    var item = new CartItem();
                    item.Product  = product;
                    item.Quantity = quantity;
                    list.Add(item);
                }
                //Gán vào session
                Session[CartSession] = list;
            }
            else
            {
                //tạo mới đối tượng cart item
                var item = new CartItem();
                item.Product  = product;
                item.Quantity = quantity;
                var list = new List <CartItem>();
                list.Add(item);
                Session[CartSession] = list;
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 9
0
        public ActionResult AddProToCart(long?idtocart, int quantity)
        {
            var product = new ProductDAO().ViewDetail((int)idtocart);
            var cart    = Session[CommonConstants.CART_SESSION];

            if (cart != null)
            {
                var list = (List <CartChild>)cart;
                if (list.Exists(x => x.Product.ID == idtocart))
                {
                    foreach (var item in list)
                    {
                        if (item.Product.ID == idtocart)
                        {
                            item.Quantity += quantity;
                        }
                    }
                }
                else
                {
                    var item = new CartChild();
                    item.Product  = product;
                    item.Quantity = quantity;
                    list.Add(item);
                }
                Session[CommonConstants.CART_SESSION] = list;
            }
            else
            {
                var list = new List <CartChild>();
                var item = new CartChild();
                item.Product  = product;
                item.Quantity = quantity;
                list.Add(item);

                Session[CommonConstants.CART_SESSION] = list;
            }

            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 10
0
        public ActionResult AddItem(long productid, int quantity)
        {
            ProductDAO      dao     = new ProductDAO();
            Productt        product = dao.GetID(productid);
            List <CartItem> lst     = new List <CartItem>();
            var             cart    = Session[CartSession];

            if (cart != null)
            {
                lst = (List <CartItem>)cart;
                if (lst.Where(x => x.Product.ID == productid).SingleOrDefault() != null)
                {
                    //foreach (var item in lst)
                    //{
                    //    if (item.Product.ID == productid)
                    //    {
                    lst.Where(x => x.Product.ID == productid).SingleOrDefault().Quantity += quantity;
                    //    }

                    //}
                }
                else
                {
                    var c = new CartItem();
                    c.Product  = product;
                    c.Quantity = quantity;
                    lst.Add(c);
                }
                Session[CartSession] = lst;
            }
            else
            {
                var c = new CartItem();
                c.Product  = product;
                c.Quantity = quantity;
                lst.Add(c);
                Session[CartSession] = lst;
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult AddItem(long producID, int quantity)
        {
            var product = new ProductDAO().ViewDetail(producID);
            var cart    = Session[CartSession];

            if (cart != null)
            {
                var list = (List <CartItem>)cart;
                if (list.Exists(x => x.Product.ID == producID))
                {
                    foreach (var item in list)
                    {
                        if (item.Product.ID == producID)
                        {
                            item.Quantity += quantity;
                        }
                    }
                }
                else
                {
                    var item = new CartItem();
                    item.Product  = product;
                    item.Quantity = quantity;
                    list.Add(item);
                }
            }
            else
            {
                //create new object cartitem
                var item = new CartItem();
                item.Product  = product;
                item.Quantity = quantity;
                var list = new List <CartItem>();
                list.Add(item);

                //
                Session[CartSession] = list;
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 12
0
        public static DataTable BuildingCostApportionAllPayout(string projectCode, string DateBegin, string DateEnd, string AreaField)
        {
            DataTable table2;

            try
            {
                EntityData            buildings   = ProductDAO.GetBuildingNotAreaByProjectCode(projectCode);
                EntityData            pBSUnits    = PBSDAO.GetPBSUnitByProject(projectCode);
                EntityData            cBS         = CBSDAO.GetCBSByProject(projectCode);
                DataTable             dtApportion = BuildBuildingCostApportionTable();
                PayoutStrategyBuilder builder     = new PayoutStrategyBuilder("Payout");
                builder.AddStrategy(new Strategy(PayoutStrategyName.ProjectCode, projectCode));
                if ((DateBegin != "") || (DateEnd != ""))
                {
                    ArrayList pas = new ArrayList();
                    pas.Add(DateBegin);
                    pas.Add(DateEnd);
                    builder.AddStrategy(new Strategy(PayoutStrategyName.PayoutDateRange, pas));
                }
                string     queryString = builder.BuildMainQueryString();
                QueryAgent agent       = new QueryAgent();
                EntityData data4       = agent.FillEntityData("Payout", queryString);
                agent.Dispose();
                foreach (DataRow row in data4.CurrentTable.Rows)
                {
                    string payoutCode = ConvertRule.ToString(row["PayoutCode"]);
                    BuildingCostApportionOnePayout(projectCode, payoutCode, pBSUnits, buildings, cBS, dtApportion, AreaField);
                }
                data4.Dispose();
                pBSUnits.Dispose();
                buildings.Dispose();
                cBS.Dispose();
                table2 = dtApportion;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(table2);
        }
Ejemplo n.º 13
0
        public ActionResult AddItem(long ID, int Quantity)
        {
            var cart    = Session[CommonConstant.CartSession];
            var product = new ProductDAO().viewDetail(ID);

            if (cart != null)
            {
                var list = (List <CartItem>)cart;
                if (list.Exists(x => x.Product == product))
                {
                    foreach (var item in list)
                    {
                        if (item.Product == product)
                        {
                            item.Quantity += Quantity;
                            Session[CommonConstant.CartSession] = list;
                            break;
                        }
                    }
                }
                else
                {
                    var item = new CartItem();
                    item.Product  = product;
                    item.Quantity = Quantity;
                    list.Add(item);
                    Session[CommonConstant.CartSession] = list;
                }
            }
            else
            {
                var item = new CartItem();
                item.Product  = product;
                item.Quantity = Quantity;
                var list = new List <CartItem>();
                list.Add(item);
                Session[CommonConstant.CartSession] = list;
            }
            return(RedirectToAction("index"));
        }
Ejemplo n.º 14
0
        // Thêm sản phẩm vào giỏ hàng
        public ActionResult AddItem(long id, int quantity)
        {
            var product = new ProductDAO().GetByID(id);

            var cart = Session[Common.SessionCommonConstants.CART_SESSION];

            if (cart != null)    // Nếu đã có giỏ hàng
            {
                var list = (List <CartItem>)cart;
                if (list.Exists(x => x.Product.ID == id))   // Nếu giỏ hàng đã có sản phẩm này
                {
                    foreach (var item in list)              // Tìm sản phẩm đó trong giỏ hàng
                    {
                        if (item.Product.ID == id)
                        {
                            item.Quantity += quantity;      // Tăng số lượng
                        }
                    }
                }
                else                           // Nếu trong giỏ hàng chưa có sản phẩm này
                {
                    var item = new CartItem(); // Thêm mới sản phẩm vào giỏ hàng
                    item.Product  = product;
                    item.Quantity = quantity;
                    list.Add(item);
                }
                Session[Common.SessionCommonConstants.CART_SESSION] = list; // Cập nhật lại giỏ hàng trong Session
            }
            else                                                            // Nếu chưa có giỏ hàng
            {
                var item = new CartItem();
                item.Product  = product;
                item.Quantity = quantity;
                var list = new List <CartItem>();                           // Tạo ra 1 danh sách lưu các CartItem
                list.Add(item);                                             // Thêm sản phẩm vào giỏ hàng

                Session[Common.SessionCommonConstants.CART_SESSION] = list; // Cập nhật lại giỏ hàng
            }
            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 15
0
        public ActionResult UpdateProduct([Bind(Include = "productID, productName, productPrice, productSale, productInfor, productIntroduce, TypeID, Status")] Product product, HttpPostedFileBase image)
        {
            QL_Hang db = new QL_Hang();

            if (image != null && image.ContentLength > 0)
            {
                product.productImage = image.ContentLength.ToString();
                byte[] data     = Encoding.Unicode.GetBytes(product.productImage);
                string fileName = System.IO.Path.GetFileName(image.FileName);
                string urlImage = Server.MapPath("~/Content/Images/" + fileName);
                image.SaveAs(urlImage);
                product.productImage = fileName;
            }

            if (ModelState.IsValid)
            {
                ProductDAO productDAO = new ProductDAO();
                productDAO.Update(product);
                return(RedirectToAction("Index"));
            }
            return(View(product));
        }
Ejemplo n.º 16
0
        public ActionResult Add(int id, int amount = 1)
        {
            ProductDAO pro     = new ProductDAO();
            product    product = pro.ViewDetail(id);
            cart       Cart    = (cart)Session["Cart"];

            if (Cart == null)
            {
                Cart = new cart();
            }
            if (product.price == 0)
            {
                Cart.AddItem(product.id, product.name, product.big_photo, product.price_old, amount);
            }
            else
            {
                Cart.AddItem(product.id, product.name, product.big_photo, product.price, amount);
            }

            Session["Cart"] = Cart;
            return(Redirect(Request.UrlReferrer.ToString()));
        }
        public ActionResult FormAddProduct()
        {
            ProductDAO dao  = new ProductDAO();
            User       user = Session["User"] as User;

            if (user == null || user.LEVEL.Equals("10") == false)
            {
                return(RedirectToAction("Index", "Home", new { area = "" }));
            }
            else
            {
                ViewBag.ID          = "";
                ViewBag.Brands      = dao.listBrands();
                ViewBag.Rams        = dao.listRams();
                ViewBag.Memorys     = dao.listMemory();
                ViewBag.HeDieuHanhs = dao.listHDH();
                ViewBag.IsChange    = "Sửa Sản Phẩm";
                ViewBag.ID          = "noproduct";
                ViewBag.IsChange    = "Đăng Sản Phẩm";
                return(View());
            }
        }
Ejemplo n.º 18
0
        private void textBoxBarCode_TextChanged(object sender, EventArgs e)
        {
            string strBarCode = textBoxBarCode.Text;

            if (!string.IsNullOrEmpty(strBarCode))
            {
                ProductBO objProductBO = new ProductDAO().getproductbybarcode(strBarCode);

                if (objProductBO != null)
                {
                    labelProductName.Text = objProductBO.ProductName;
                }
                else
                {
                    labelProductName.Text = "";
                }
            }
            else
            {
                labelProductName.Text = "";
            }
        }
Ejemplo n.º 19
0
        public async Task <bool> Update(Product Product)
        {
            ProductDAO ProductDAO = DataContext.Product.Where(x => x.Id == Product.Id).FirstOrDefault();

            ProductDAO.Id                      = Product.Id;
            ProductDAO.Code                    = Product.Code;
            ProductDAO.Name                    = Product.Name;
            ProductDAO.Description             = Product.Description;
            ProductDAO.TypeId                  = Product.TypeId;
            ProductDAO.StatusId                = Product.StatusId;
            ProductDAO.MerchantId              = Product.MerchantId;
            ProductDAO.CategoryId              = Product.CategoryId;
            ProductDAO.BrandId                 = Product.BrandId;
            ProductDAO.WarrantyPolicy          = Product.WarrantyPolicy;
            ProductDAO.ReturnPolicy            = Product.ReturnPolicy;
            ProductDAO.ExpiredDate             = Product.ExpiredDate;
            ProductDAO.ConditionOfUse          = Product.ConditionOfUse;
            ProductDAO.MaximumPurchaseQuantity = Product.MaximumPurchaseQuantity;
            await DataContext.SaveChangesAsync();

            return(true);
        }
Ejemplo n.º 20
0
        public ActionResult ViewDetail(long proID)
        {
            var dao = new ProductDAO();

            dao.IncreaseView(proID);
            var model   = dao.GetByID(proID);
            var session = Session[Constant.VIEWEDPRODUCT];

            if (session == null)
            {
                var list = new List <Product>();
                list.Add(model);
                Session[Constant.VIEWEDPRODUCT] = list;
            }
            else
            {
                var list = (List <Product>)session;
                if (list.Exists(x => x.ProductID == model.ProductID))
                {
                }
                else
                {
                    if (list.Count > 4)
                    {
                        list.RemoveAt(0);
                        list.Add(model);
                    }
                    else
                    {
                        list.Add(model);
                    }
                }

                Session[Constant.VIEWEDPRODUCT] = list;
            }

            ViewBag.listOfSuggestions = dao.GetSuggestionList(model.CategoryID, 5, proID);
            return(View(model));
        }
        // GET: Admin/Product
        public ActionResult Index(string KeySearch = "")
        {
            if (Session["ADMIN_SESSION"] == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            ProductDAO  prdao       = new ProductDAO();
            CategoryDAO pcdao       = new CategoryDAO();
            var         ListProduct = prdao.GetAllProduct(KeySearch);
            var         model       = new List <ProductModel>();

            foreach (var item in ListProduct)
            {
                var ModelItem = new ProductModel();
                var Category  = pcdao.GetCategoryByID(item.IDCategory);
                ModelItem = ProducttoProductModel(item);
                ModelItem.NameCategory = Category.NameCategory;
                model.Add(ModelItem);
            }

            return(View(model));
        }
Ejemplo n.º 22
0
        public ActionResult UpdateItem(CartModel cartmodel)

        {
            try
            {
                int productID = int.Parse(cartmodel.ID);

                int quantity = int.Parse(cartmodel.Quantity);

                var product = new ProductDAO().getByID(productID);
                var cart    = Session[CartSession];
                if (cart != null)
                {
                    var list = (List <CartItem>)cart;

                    if (list.Exists(x => x.Product.ID == productID))
                    {
                        foreach (var item in list)
                        {
                            if (item.Product.ID == productID)
                            {
                                if (quantity > 1)
                                {
                                    item.Quantity = quantity;
                                }
                            }
                        }
                    }

                    //Session[CartSession] = list;
                }
                else
                {
                }
            }catch (System.FormatException e)
            {
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 23
0
        public void AddDataToDataBase()
        {
            ProductDAO productDao = new ProductDAO();


            List <string> name = new List <string> {
                "Acetaminophen", "Adderall", "Alprazolam", "Amitriptyline", "Amlodipine", "Amoxicillin", "Ativan", "Atorvastatin", "Azithromycin", "Ciprofloxacin", "Citalopram", "Clindamycin", "Clonazepam", "Codeine", "Cyclobenzaprine", "Cymbalta", "Doxycycline", "Gabapentin", "Hydrochlorothiazide", "Ibuprofen", "Lexapro", "Lisinopril", "Loratadine", "Lorazepam", "Losartan", "Lyrica", "Meloxicam", "Metformin", "Metoprolol", "Naproxen", "Omeprazole", "Oxycodone", "Pantoprazole", "Prednisone", "Tramadol", "Trazodone", "Viagra", "Wellbutrin", "Xanax", "Zoloft"
            };
            List <string> description = new List <string> {
                "the gastrointestinal tract (digestive system)", "For the cardiovascular system", "the central nervous system", "pain (analgesic drugs)", "musculo-skeletal disorders", "the eye", "the ear, nose and oropharynx", "the respiratory system", "endocrine problems", "For the reproductive system or urinary system", "For contraception", "For obstetrics and gynecology", "For the skin", "For infections and infestations", "For the immune system", "For allergic disorders", "For nutrition", "For neoplastic disorders", "For diagnostics", "For euthanasia", "the gastrointestinal tract (digestive system)", "For the cardiovascular system", "the central nervous system", "pain (analgesic drugs)", "musculo-skeletal disorders", "the eye", "the ear, nose and oropharynx", "the respiratory system", "endocrine problems", "For the reproductive system or urinary system", "For contraception", "For obstetrics and gynecology", "For the skin", "For infections and infestations", "For the immune system", "For allergic disorders", "For nutrition", "For neoplastic disorders", "For diagnostics", "For euthanasia"
            };
            List <string> brand = new List <string> {
                "A & Z Pharmaceutical, Inc.", "A-S Medication Solutions, LLC", "AAIPharma", "Abbott Laboratories", "AbbVie Inc.", "Acadia Pharmaceuticals, Inc.", "Accord Healthcare Inc.", "Accredo Health Group, Inc.", "Acella Pharmaceuticals, LLC", "Acorda Therapeutics, Inc.", "Actavis Pharma, Inc.", "Actelion Pharmaceuticals US, Inc.", "Acura Pharmaceuticals, Inc.", "Acusphere, Inc.", "Adapt Pharma, Inc.", "Adeona Pharmaceuticals, Inc.,", "Adolor Corporation", "Advance Pharmaceuticals Inc.", "Advanced Life Sciences, Inc", "Advanced Pharmaceutical Services Inc", "A & Z Pharmaceutical, Inc.", "A-S Medication Solutions, LLC", "AAIPharma", "Abbott Laboratories", "AbbVie Inc.", "Acadia Pharmaceuticals, Inc.", "Accord Healthcare Inc.", "Accredo Health Group, Inc.", "Acella Pharmaceuticals, LLC", "Acorda Therapeutics, Inc.", "Actavis Pharma, Inc.", "Actelion Pharmaceuticals US, Inc.", "Acura Pharmaceuticals, Inc.", "Acusphere, Inc.", "Adapt Pharma, Inc.", "Adeona Pharmaceuticals, Inc.,", "Adolor Corporation", "Advance Pharmaceuticals Inc.", "Advanced Life Sciences, Inc", "Advanced Pharmaceutical Services Inc"
            };
            List <int> price = new List <int> {
                50, 30, 70, 110, 190, 180, 30, 40, 90, 190, 80, 150, 100, 10, 130, 180, 130, 60, 190, 170, 170, 40, 140, 140, 170, 60, 80, 70, 60, 150, 120, 70, 190, 10, 20, 70, 150, 70, 70, 170
            };
            List <int> rack = new List <int> {
                2, 2, 12, 0, 5, 12, 0, 12, 2, 15, 1, 2, 2, 11, 11, 15, 9, 14, 4, 9, 5, 12, 13, 1, 5, 14, 13, 0, 11, 7, 10, 11, 4, 7, 3, 11, 8, 14, 14, 0
            };
            List <string> code = new List <string> {
                "900a", "901b", "902c", "903d", "904e", "905f", "906g", "907h", "908i", "909j", "910k", "911l", "912m", "913n", "914o", "915p", "916q", "917r", "918s", "919t", "920u", "921v", "922w", "923x", "924y", "925z", "926a", "927b", "928c", "929d", "930e", "931f", "932g", "933h", "934i", "935j", "936k", "937l", "938m", "939n"
            };

            Console.WriteLine("-");


            Console.WriteLine("--");

            for (int i = 0; i < 40; i++)
            {
                Console.WriteLine("---");
                productDao.addProduct(new Product(0, code[i], name[i], brand[i], rack[i], price[i], description[i]));
            }



            //  Assert.AreEqual();
        }
        protected void BtnAccept_Click(object sender, EventArgs e)
        {
            int index = GvOrder.SelectedIndex;
            int id    = Convert.ToInt32(GvOrder.Rows[index].Cells[1].Text);

            string        connectionString = ConfigurationManager.ConnectionStrings["CSharpAssignmentConnectionString"].ConnectionString;
            SqlConnection conn             = new SqlConnection(connectionString);

            GridViewRowCollection rows = GvOrderDetail.Rows;

            for (int i = 0; i < GvOrderDetail.Rows.Count; i++)
            {
                ProductDAO products        = new ProductDAO();
                TableCell  productId       = GvOrderDetail.Rows[i].Cells[0];
                TableCell  quanitity       = GvOrderDetail.Rows[i].Cells[4];
                int        proId           = Convert.ToInt32(productId.Text.ToString());
                int        quan            = Convert.ToInt32(quanitity.Text.ToString());
                int        currentQuantity = products.GetQuantityOfProduct(proId);
                bool       updateQuantity  = products.UpdateQuantityOfProduct(proId, currentQuantity - quan);
            }
            try
            {
                conn.Open();
                string     sql = "Update Booking SET StatusID = @statusID WHERE ID = @id";
                SqlCommand com = new SqlCommand(sql, conn);
                com.Parameters.AddWithValue("@statusID", STATUS_ACCEPTED);
                com.Parameters.AddWithValue("@id", id);
                if (com.ExecuteNonQuery() > 0)
                {
                    GvOrder.DataBind();
                    BtnAccept.Visible = false;
                    BtnCancel.Visible = false;
                }
            }
            finally
            {
                conn.Close();
            }
        }
Ejemplo n.º 25
0
        public ActionResult PriceList(int categoryID)
        {
            List <SelectListItem> categories = GetCategories();

            categories.Insert(0, new SelectListItem {
                Value = "-1", Text = "Все"
            });

            foreach (SelectListItem selectListItem in categories)
            {
                if (selectListItem.Value == categoryID.ToString())
                {
                    selectListItem.Selected = true;
                }
            }

            ViewBag.Categories = categories;

            List <ProductModel> list = ProductDAO.GetProductListByCategory(categoryID);

            return(View(list));
        }
Ejemplo n.º 26
0
        public ActionResult Register(Product product, HttpPostedFileBase upImage, int?Categories)
        {
            var  pub  = PubDAO.Search(UserSession.ReturnPubId(null));
            Guid guid = Guid.NewGuid();

            product.PubId      = UserSession.ReturnPubId(null);
            ViewBag.Categories = new SelectList(CategoryDAO.ReturnList(), "Id", "Name");
            product.Category   = CategoryDAO.Search(Categories);

            if (ModelState.IsValid == true)
            {
                product.PhotoUrl  = ImageHandler.HttpPostedFileBaseToByteArray(upImage);
                product.PhotoType = upImage.ContentType;

                ProductDAO.Insert(product);
                return(RedirectToAction("Product", "Pub"));
            }
            else
            {
                return(RedirectToAction("Product", "Pub"));
            }
        }
Ejemplo n.º 27
0
        static DataTable GetTable()
        {
            // Step 2: here we create a DataTable.
            // ... We add 4 columns, each with a Type.

            DataTable table = new DataTable();

            table.Columns.Add("Code", typeof(string));
            table.Columns.Add("Brand", typeof(string));
            table.Columns.Add("Name", typeof(string));
            try
            {
                // Step 3: here we add rows.
                ProductDAO     productsDAO = new ProductDAO();
                List <Product> products    = productsDAO.getProductsList();
                if (products != null)
                {
                    products.ForEach(item =>
                    {
                        var row      = table.NewRow();
                        row["Code"]  = item.Code;
                        row["Brand"] = item.Brand;
                        row["Name"]  = item.Name;
                        table.Rows.Add(row);
                    });
                }
                else
                {
                    throw new PAS_DE_PRODUITS_EXCEPTION("The products list is empty");
                }
            }
            catch (PAS_DE_PRODUITS_EXCEPTION exception)
            {
                Console.WriteLine(exception.Message);
                MessageBox.Show(exception.Message, "Exception", MessageBoxButtons.OK);
            }

            return(table);
        }
Ejemplo n.º 28
0
        public ActionResult Edit_Post(string productData)
        {
            try
            {
                Product Product = JsonConvert.DeserializeObject <Product>(productData);

                if (!Product.Name.Equals(string.Empty))
                {
                    Product.RemoveCheckoutPropertySettingsDuplicants();

                    if (ProductDAO.Save(Product))
                    {
                        Chimera.Core.Notifications.ProductStock.ProductStockUpdated(Product);

                        AddWebUserMessageToSession(Request, String.Format("Successfully saved/updated product \"{0}\"", Product.Name), SUCCESS_MESSAGE_TYPE);
                    }
                    else
                    {
                        AddWebUserMessageToSession(Request, String.Format("Unable to saved/update product \"{0}\" at this time", Product.Name), FAILED_MESSAGE_TYPE);
                    }
                }
                else
                {
                    AddWebUserMessageToSession(Request, "Product must have a name", FAILED_MESSAGE_TYPE);

                    return(RedirectToAction("Edit", "Product", new { productData = productData }));
                }

                return(RedirectToAction("Index", "Dashboard"));
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.ProductController.Edit_Post() " + e.Message);
            }

            AddWebUserMessageToSession(Request, String.Format("Unable to save/update products at this time."), FAILED_MESSAGE_TYPE);

            return(RedirectToAction("Index", "Dashboard"));
        }
Ejemplo n.º 29
0
        public JsonResult SaveImages(long productID, string images)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            // chuyển từ Json string  sang dạng List<string>
            var lstImage = serializer.Deserialize <List <string> >(images);
            // Tạo ra 1 thẻ XML Root <Images>
            XElement xElement = new XElement("Images");

            // Add các thẻ Image con vào Root
            foreach (var item in lstImage)
            {
                // cắt đường dẫn cho ảnh
                string str = item.Substring(FindStringIndex(item));
                xElement.Add(new XElement("Image", str));
            }
            bool update = new ProductDAO().UpdateImages(productID, xElement.ToString());

            return(Json(new
            {
                status = update
            }));
        }
Ejemplo n.º 30
0
        public ActionResult CategoryPro(long idcatepro, int page = 1, int pageSize = 3)
        {
            ViewBag.Category = new ProductCategoryDAO().ViewDetail((int)idcatepro);

            int totalRecord = 0;
            var model       = new ProductDAO().ListByCategoryId(idcatepro, ref totalRecord, page, pageSize);

            ViewBag.Total = totalRecord;
            ViewBag.Page  = page;
            int maxPage   = 5;
            int totalPage = 0;

            totalPage         = (int)Math.Ceiling((double)(totalRecord / pageSize));
            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = page + 1;
            ViewBag.Prev      = page - 1;

            return(View(model));
        }
Ejemplo n.º 31
0
 public ProductBUS()
 {
     prDao = new ProductDAO();
 }
Ejemplo n.º 32
0
 private ProductService()
 {
     //  _daoManager = ServiceConfig.GetInstance().DaoManager;
     // _productDao = _daoManager.GetDao(typeof(IProduct)) as IProduct;
     _productDao = new ProductDAO();
 }