Exemple #1
0
 public ActionResult Search(string Search)
 {
     using (Repository <ProductEntity> rep = new RepositoryProduct())
     {
         return(View("Index", rep.Get((p => p.Name_Product.Contains(Search) || p.Description.Contains(Search) || p.Category.Contains(Search) || p.Link_Image.Contains(Search))).ToList()));
     }
 }
        protected void deleteproducttype_Click(object sender, EventArgs e)
        {
            Int32 deletebyID = 0;

            Int32.TryParse(id.Text.ToString(), out deletebyID);
            bool cekKedua   = RepositoryProduct.CekProductTypeID(deletebyID);
            bool cekPertama = RepositoryProductType.CekID(deletebyID);

            if (cekPertama)
            {
                if (cekKedua)
                {
                    Response.Write("<script>alert('Deleted product type can not have reference to other table.')</script>");
                }
                else
                {
                    RepositoryProductType.DeleteProductType(deletebyID);
                    Response.Write("<script>alert('Delete product type successfully.')</script>");
                    refresh();
                }
            }
            else
            {
                Response.Write("<script>alert('ID does not exists.')</script>");
            }
        }
        public static ResponseEntity AddProductToCart(Product product)
        {
            ResponseEntity res = new ResponseEntity();

            //Saber si es nulo
            if (HttpContext.Current.Session["OrderView"] == null)
            {
                CreateOrderViewInSession();
            }

            //Recupero el listado de la Orden en sesion, debo castearlo.
            List <ModelNotMapped.OrderView.OrderView> ListOrderView = HttpContext.Current.Session["OrderView"] as List <ModelNotMapped.OrderView.OrderView>;

            //Consulto si existe el producto ID ya en la lista.
            if (ListOrderView.Any(x => x.ProductID == product.ProductID))
            {
                var GetProduct = ListOrderView.Where(x => x.ProductID == product.ProductID).First();

                int Quantity = GetProduct.Quantity + 1; //Sumo una nueva cantidad.

                //Consulto si la cantidad nueva excede al stock del producto.
                if (!RepositoryProduct.IsThereStockToProcess(GetProduct.ProductID, Quantity))
                {
                    return(res = new ResponseEntity()
                    {
                        status = false, message = "No hay suficiente stock para realizar tal operacion"
                    });
                }

                GetProduct.Quantity += 1; //Sumo una nueva cantidad.
            }
            else
            {
                var orderView = new ModelNotMapped.OrderView.OrderView()
                {
                    ProductID   = product.ProductID,
                    ProductName = product.Name,
                    Price       = product.Price,
                    Quantity    = 1,
                };

                if (!RepositoryProduct.IsThereStockToProcess(orderView.ProductID, orderView.Quantity))
                {
                    return(res = new ResponseEntity()
                    {
                        status = false, message = "No hay suficiente stock para realizar tal operacion"
                    });
                }

                ListOrderView.Add(orderView);
            }



            HttpContext.Current.Session["OrderView"] = ListOrderView;
            return(res = new ResponseEntity()
            {
                status = true, message = ""
            });
        }
        public ActionResult Delete(int?id)
        {
            try
            {
                if (id == null)
                {
                    TempData["Message"] = "Debe ingresar un ID valido de producto para eliminar";

                    return(RedirectToAction("Index"));
                }

                Product product = ctx.Products.Find(id);

                if (!RepositoryProduct.DeleteProduct(ctx, product))
                {
                    TempData["Message"] = "No puede eliminar un producto que ya fue pedido";

                    return(RedirectToAction("Index"));
                }

                TempData["Message"] = "Eliminacion correcta";

                return(RedirectToAction("Index"));
            }

            catch (Exception e)
            {
                TempData["Message"] = "Problema al cambiar estado -> " + e.Message;

                return(RedirectToAction("Index"));
            }
        }
Exemple #5
0
        public FrmEditProductLine(ModelViewProductLine productLine, bool newProductLine)
        {
            InitializeComponent();
            _newProductLine = newProductLine;
            ProductLineOut  = productLine;
            var repositoryStock   = new RepositoryStock();
            var repositoryProduit = new RepositoryProduct();

            _editProductLinePresenter = new EditProductLinePresenterPage(this, repositoryStock, repositoryProduit);
            _editProductLinePresenter.Display();

            comboBoxStock.DisplayMember   = "Name";
            comboBoxStock.ValueMember     = "Name";
            comboBoxProduit.DataSource    = Products;
            comboBoxProduit.DisplayMember = "Name";
            comboBoxProduit.ValueMember   = "Name";

            if (!newProductLine)
            {
                comboBoxStock.DataSource = Stocks.Where(s => s.Name == productLine.Stock.Name).ToList();
                //comboBoxStock.SelectedValue = productLine.Stock.Name;
                comboBoxProduit.SelectedValue = productLine.Name;
                textEditQuantité.Text         = productLine.Quantity.ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                comboBoxStock.DataSource = Stocks.OrderBy(s => s.Name).ToList();
            }

            IsProductLineModified = false;
        }
        public ActionResult ChangeStatusLogic(int?id)
        {
            try
            {
                if (id == null)
                {
                    TempData["Message"] = "Debe ingresar un ID valido de producto para cambiar su estado";

                    return(RedirectToAction("Index"));
                }

                Product product = ctx.Products.Find(id);

                RepositoryProduct.UpdateStatusLogic(ctx, product); //Actualizo el borrado logico

                TempData["Message"] = "Cambio de estado correcto";

                return(RedirectToAction("Index"));
            }

            catch (Exception e)
            {
                TempData["Message"] = "Problema al cambiar estado -> " + e.Message;

                return(RedirectToAction("Index"));
            }
        }
Exemple #7
0
        private void DispatcherTimerTick(object sender, EventArgs e)
        {
            var dt = DateTime.Now;

            _countTick++;

            ldt.Content = $"{dt} ({Sec - _countTick}) ";

            if (!Config.FromLoadSyncAll)
            {
                if (_countTick == Sec)
                {
                    _countTick = 0;

                    foreach (var bs in ClassEtcFun.FindVisualChildren <Button>(this).Where(bs => (string)bs.ToolTip == "UpdateDB"))
                    {
                        if (_bUpdText == string.Empty)
                        {
                            _bUpdText = bs.Content.ToString();
                        }
                        bs.Content = $"{_bUpdText} ({RepositoryProduct.GetAbCountFromDb()})";
                    }

                    ldtc.Content = "BD a été MàJ " + dt.ToLongTimeString();
                }
            }
            else
            {
                ldtc.Content = "Происходит фоновая синхронизация... работайте ....";
            }

            CommandManager.InvalidateRequerySuggested();
        }
Exemple #8
0
 private void AddElm()
 {
     RepositoryProduct.Add(FormToVar());
     dataGrid1.DataContext = null;
     dataGrid1.DataContext = RepositoryProduct.Document.GetXElements("Product", "rec");
     ClearForm();
 }
Exemple #9
0
        public ActionResult Index()

        {
            using (Repository <ProductEntity> rep = new RepositoryProduct())
            {
                return(View(rep.GetAll().ToList()));
            }
        }
        private void RemoveClick(object sender, RoutedEventArgs e)
        {
            var dg = (GetParents(this, 0)).DataGrid;

            RepositoryProduct.Delete(Product);
            CollectionViewSource.GetDefaultView(dg.ItemsSource).Refresh();
            Close();
        }
Exemple #11
0
 private void BSaveClick(object sender, RoutedEventArgs e)
 {
     if (RepositoryProduct.Products.Count > 0)
     {
         RepositoryProduct.AddRange(RepositoryProduct.Products);
         Close();
     }
 }
        public ActionResult Edit(Product product, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                RepositoryProduct.UpdateProduct(product, file);

                return(RedirectToAction("Index"));
            }
            return(View(product));
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     Page.Title = "View Product Page";
     if (Session["UserName"] == null)
     {
         Response.Redirect("../HomePage.aspx");
     }
     _allproduct.DataSource = RepositoryProduct.GetFiveProduct();
     _allproduct.DataBind();
 }
Exemple #14
0
 public ActionResult RemoverItem(int id)
 {
     using (Repository <ProductEntity> rep = new RepositoryProduct())
     {
         ProductEntity product = rep.Find(id);
         Cart.Produtos.Remove(product);
         Cart.QuantidadePorProduto.Remove(product.ID);
     }
     return(View("Index", Cart));
 }
Exemple #15
0
        public static void MegaSync()
        {
            // check tables
            var syncTask = Task <bool> .Factory.StartNew(
                () =>
            {
                RepositoryActionHashBox.Sync();
                //RepositoryCheck
                RepositoryCheckTicket.Sync();
                RepositoryCheckTicketTmp.Sync();
                RepositoryPro.Sync();
                RepositoryClientInfo.Sync();
                RepositoryCloseTicket.Sync();
                RepositoryCloseTicketCheckDiscount.Sync();
                RepositoryCloseTicketG.Sync();
                RepositoryCloseTicketTmp.Sync();
                RepositoryCountry.Sync();
                RepositoryCurrency.Sync();
                //RepositoryCurrencyRelations
                RepositoryDevisId.Sync();
                RepositoryDevisWeb.Sync();
                //RepositoryDiscount
                RepositoryDiscountCard.Sync();
                RepositoryEstablishment.Sync();
                RepositoryGeneral.Sync();
                RepositoryGroupProduct.Sync();
                //RepositoryHistoryChangeProduct
                RepositoryInfoClientsDiscountsType.Sync();
                RepositoryLastUpdate.Sync();
                RepositoryOpenTicketWindow.Sync();
                RepositoryPayProduct.Sync();
                RepositoryPayProductTmp.Sync();
                //RepositoryPriceGros
                RepositoryProduct.Sync();
                RepositoryProductBc.Sync();
                RepositoryStatNation.Sync();
                RepositoryStatNationPopup.Sync();
                RepositoryStatPlaceArrond.Sync();
                //RepositoryStockLogs
                RepositoryStockReal.Sync();
                RepositorySyncPlus.Sync();
                RepositorySyncPlusProduct.Sync();
                //RepositoryTes
                RepositoryTva.Sync();
                RepositoryTypePay.Sync();
                //RepositoryXmlFile
                return(true);
            });

            syncTask.ContinueWith(
                s => { });
        }
Exemple #16
0
        private void WorkerEditDoWork(object sender, DoWorkEventArgs e)
        {
            var product = (ProductType)e.Argument;

            RepositoryProduct.Update(product);
            RepositoryProduct.UpdateProductPrice(product);

            if (RepositoryAccountUser.LoginedUser.Role.IsPermiss(Privelege.RedactStockCount))
            {
                var stockReal = RepositoryStockReal.GetByProduct(product);
                RepositoryStockReal.UpdateProductCount(_stockRealCount, stockReal.CustomerId);
            }
        }
Exemple #17
0
 public ActionResult Edit([Bind(Include = "ID,Name_Product,Description,Price,Link_Image,Category")] ProductEntity productEntity)
 {
     if (ModelState.IsValid)
     {
         using (Repository <ProductEntity> rep = new RepositoryProduct())
         {
             rep.Update(productEntity);
             rep.SaveAll();
         }
         return(RedirectToAction("Index"));
     }
     return(View(productEntity));
 }
Exemple #18
0
        private void WorkerAddDoWork(object sender, DoWorkEventArgs e)
        {
            var product = (ProductType)e.Argument;

            RepositoryProduct.Add(product);

            if (RepositoryAccountUser.LoginedUser.Role.IsPermiss(Privelege.RedactStockCount))
            {
                var stockReal = RepositoryStockReal.GetByProduct(product);
                RepositoryStockReal.AddAsNull(product.CustomerId, Config.IdEstablishment);
                RepositoryStockReal.UpdateProductCount(_stockRealCount, stockReal.CustomerId);
            }
        }
Exemple #19
0
        // GET: Products
        public ActionResult Index(string category)
        {
            ViewBag.Categories = db.Categories.ToList();

            if (!string.IsNullOrEmpty(TempData["Message"] as string))
            {
                ViewBag.Message = TempData["Message"] as string;
                TempData.Remove("Message"); //Limpio el TempData Message.
            }
            var Products = RepositoryProduct.ListProductFromCategory(category);

            return(View(Products));
        }
Exemple #20
0
        public async Task ListaProdutosUsuario()
        {
            try
            {
                IProduct _IProduct     = new RepositoryProduct();
                var      listaProdutos = await _IProduct.ListarProdutosUsuario("e83452fa-aa0e-424a-a58c-ea9a116ffc53");

                Assert.IsTrue(listaProdutos.Any());
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
Exemple #21
0
        private string ValidTextBox(object sender)
        {
            string listError = null;
            var    box       = (TextBox)sender;

            var name = box.Name.Substring(1);

            switch (box.Name)
            {
            case "xCodeBar":
                try
                {
                    if ((RepositoryProduct.GetXElementByBarcode(long.Parse(box.Text).ToString()) != null) || (box.Text.Length < 5))
                    {
                        listError = ("the CodeBare is not correct");
                    }
                }
                catch
                {
                    listError = ("the CodeBare is not correct");
                }
                break;

            case "xName":
                if ((RepositoryProduct.GetXElementByElementName("Name", box.Text.Trim().ToUpper()) != null) || (box.Text.Length < 2))
                {
                    listError = ("the Name is not correct");
                }
                break;

            case "xTare":
            case "xPrice":
            case "xQTY":
            case "xContenance":
            case "xUnit_contenance":
                decimal decimalValue;
                if (!decimal.TryParse(box.Text, out decimalValue))
                {
                    listError = (string.Format("the {0} is not correct", name));
                }
                break;
            }
            box.Foreground = (listError != null)
                                ? new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 0, 0))
                                : new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 255, 0));

            ((Label)FindName("l" + box.Name)).Foreground = box.Foreground;

            return(listError);
        }
Exemple #22
0
        private static PriceGrosType[] Get(Guid[] g)
        {
            var res = new PriceGrosType[g.Length];

            for (var i = 0; i < res.Length; i++)
            {
                var x       = RepositoryProduct.GetXElementByElementName("CustomerId", g[i].ToString());
                var procent = (decimal)(Pro.DiscountValue) / 100;
                var prix    = x.GetXElementValue("price").ToDecimal();

                res[i] = new PriceGrosType(x.GetXElementValue("cusumerIdRealStock").ToGuid(), x.GetXElementValue("CustomerId").ToGuid(), prix + prix * procent);
            }

            return(res);
        }
        public async Task ListarProdutosUsuario()
        {
            try
            {
                IProduct _IProduct = new RepositoryProduct();

                var listaProdutos = await _IProduct.ListarProdutosUsuario("2355646e-2176-4524-9d8c-9688d4ee556b");

                Assert.IsTrue(listaProdutos.Any());
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
Exemple #24
0
        public async Task ListarProdutosUsuario()
        {
            try
            {
                IProduct _IProduct = new RepositoryProduct();

                var listaProdutos = await _IProduct.ListarProdutosUsuario("c5fe6ba9-8f82-4881-84c5-c3b6a8732edb");

                Assert.IsTrue(listaProdutos.Any());
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
        public async Task ListaProdutoUsuario()
        {
            try
            {
                IProduct _IProduct = new RepositoryProduct();

                var listaProdutods = await _IProduct.ListarProdutoUsuario("7c6eaaf0-55b8-46f3-b333-06fb24b19c9c");

                Assert.IsTrue(listaProdutods.Any());
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
Exemple #26
0
        public async Task ListarProdutosUsuario()
        {
            try
            {
                IProduct _IProduct = new RepositoryProduct();

                var listaProdutos = await _IProduct.ListarProdutosUsuario("83e61c23-2976-4c22-9355-d7732f26a53a");

                Assert.IsTrue(listaProdutos.Any());
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
Exemple #27
0
 public ActionResult Edit(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     using (Repository <ProductEntity> rep = new RepositoryProduct())
     {
         ProductEntity productEntity = rep.Find(id);
         if (productEntity == null)
         {
             return(HttpNotFound());
         }
         return(View(productEntity));
     }
 }
        public async Task GetEntityById()
        {
            try
            {
                IProduct _IProduct     = new RepositoryProduct();
                var      listaProdutos = await _IProduct.ListarProdutosUsuario("2355646e-2176-4524-9d8c-9688d4ee556b");

                var produto = await _IProduct.GetEntityById(listaProdutos.LastOrDefault().Id);

                Assert.IsTrue(produto != null);
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
        public ActionResult Create(Product product, HttpPostedFileBase File)
        {
            if (ModelState.IsValid)
            {
                RepositoryProduct.StoreProduct(product, File);

                TempData["Message"] = string.Format("Creado {0} correctamente", product.Name);

                return(RedirectToAction("Index"));
            }

            ViewBag.Message = string.Format("Error al crear {0}, debe colocar correctamente los datos", product.Name);

            ViewBag.CategoryID = ctx.Categories.ToList();
            return(View(product));
        }
Exemple #30
0
        public async Task GetEntityById()
        {
            try
            {
                IProduct _IProduct     = new RepositoryProduct();
                var      listaProdutos = await _IProduct.ListarProdutosUsuario("c5fe6ba9-8f82-4881-84c5-c3b6a8732edb");

                var produto = await _IProduct.GetEntityById(listaProdutos.LastOrDefault().Id);

                Assert.IsTrue(produto != null);
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }