예제 #1
0
        public PartialViewResult _ChiTiet(string productId = "")
        {
            int height = (int)(Request.Browser.ScreenPixelsHeight * 0.85);

            TB_PRODUCTS s = Products_Service.GetById(productId);

            ViewBag.Product = s;

            List <TB_SUPPLIERS> list = Suppliers_Service.GetAll()
                                       .Where(x => x.SupplierState == "A").ToList();

            ViewBag.SupplierList = list;

            List <TB_CATEGORIES> list2 = Categories_Service.GetAll()
                                         .Where(x => x.CategoryState == "A").ToList();

            ViewBag.CategoryList = list2;

            try
            {
                ViewBag.Images = Files_Service.GetByRefecense("" + s.ProductCode).Where(x => x.FileType == "PRODUCT").ToList();
            }
            catch (Exception ex)
            {
                CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "Blogs/_List :", ex.Message, ex.ToString());
            }

            return(PartialView(height));
        }
예제 #2
0
        public ActionResult Detail(string Id = "")
        {
            TB_PRODUCTS d = Products_Service.GetById(Id);

            List <TB_FILES> file = Files_Service.GetByRefecense(Id).Where(x => x.FileType == "PRODUCT").ToList();

            ViewBag.Files = file;

            return(View(d));
        }
예제 #3
0
        public JsonResult UpdateProduct(string product_code, string product_name, decimal product_price, string product_state, string product_supplierCode, string product_categoryCode)
        {
            AjaxResultModel Result = new AjaxResultModel();

            try
            {
                TB_PRODUCTS t = Products_Service.GetById(product_code);
                t.ProductName         = product_name;
                t.ProductPrice        = product_price;
                t.ProductState        = product_state;
                t.ProductSupplierCode = product_supplierCode;
                t.ProductCategoryCode = product_categoryCode;

                if (Products_Service.Update(t))
                {
                    if (Request.Files.Count > 0)
                    {
                        for (int i = 0; i < Request.Files.Count; i++)
                        {
                            HttpPostedFileBase file     = Request.Files[i];
                            string             fileName = Path.GetFileName(file.FileName);
                            string             filePath = SaveFile(file);
                            Files_Service.Insert(new TB_FILES
                            {
                                FileOrg         = fileName,
                                FilePath        = filePath,
                                FileData        = "",
                                FileStatus      = "A",
                                FileType        = "PRODUCT",
                                FileReferenceId = product_code
                            });
                        }
                    }

                    Result.Code   = 000;
                    Result.Result = "Thành công";
                }
                else
                {
                    Result.Code   = 001;
                    Result.Result = "Không thành công";
                }
            }
            catch (Exception Ex)
            {
                Result.Code   = 2000;
                Result.Result = "Có lỗi xảy ra. Vui lòng thử lại sau hoặc liên hệ với người quản trị.";
                CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "UpdatePassword :", Ex.Message, Ex.ToString());
            }

            return(Json(Result));
        }
예제 #4
0
        public JsonResult AddToCart(string productCode, int number)
        {
            AjaxResultModel Result = new AjaxResultModel();

            try
            {
                List <CartModel> list = new List <CartModel>();
                if (Session[AppSession.AppSessionKeys.USER_CART] != null)
                {
                    list = (List <CartModel>)Session[AppSession.AppSessionKeys.USER_CART];
                }

                if (list.Exists(x => x.ProductCode == productCode))
                {
                    foreach (CartModel item in list)
                    {
                        if (item.ProductCode == productCode)
                        {
                            item.Quantity += number;
                        }
                    }
                }
                else
                {
                    TB_PRODUCTS p = Products_Service.GetById(productCode);
                    list.Add(new CartModel
                    {
                        ProductCode = productCode,
                        ProductName = p.ProductName,
                        Quantity    = number,
                        Price       = p.ProductPrice
                    });
                }

                Session[AppSession.AppSessionKeys.USER_CART] = list;

                Result.Code   = 000;
                Result.Result = list.Count;
            }
            catch (Exception Ex)
            {
                Result.Code   = 2000;
                Result.Result = "Có lỗi xảy ra. Vui lòng thử lại sau hoặc liên hệ với người quản trị.";
                CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "UpdatePassword :", Ex.Message, Ex.ToString());
            }

            return(Json(Result));
        }
예제 #5
0
 public bool Insert(TB_PRODUCTS product)
 {
     return(new TB_PRODUCTSSql().Insert(product, true));
 }
예제 #6
0
 public bool Update(TB_PRODUCTS product)
 {
     return(new TB_PRODUCTSSql().Update(product));
 }