Example #1
0
        public static bool UpdateProduct(PRODUCTS product)
        {
            bool status = false;

            try
            {
                using (OracleConnection connection = new OracleConnection(conlink))
                {
                    if (connection.State == ConnectionState.Closed)
                    {
                        connection.Open();
                    }
                    string query = "UPDATE PRODUCTS SET PRODUCTNAME= :productname where PRODUCTNO = :productno";

                    OracleCommand cmd = new OracleCommand(query, connection);

                    cmd.Parameters.Add(new OracleParameter(":productname", product.PRODUCTNAME));
                    cmd.Parameters.Add(new OracleParameter(":productno", product.PRODUCTNO));
                    cmd.ExecuteNonQuery();
                    if (connection.State == ConnectionState.Open)
                    {
                        connection.Close();
                    }
                    status = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(status);
        }
Example #2
0
        public int AddToCart(int pid, int uid)
        {
            if (uid == -1)
            {
                return(-1);
            }
            PRODUCTS product = db.PRODUCTS.Find(pid);


            if (product == null)
            {
                return(4004);
            }

            CART chk     = db.CARTs.Where(c => c.UserId == uid && c.ProductId == pid).FirstOrDefault();
            CART cartobj = new CART();

            if (chk == null)
            {
                cartobj.UserId       = uid;
                cartobj.ProductId    = product.ProductId;
                cartobj.ItemQuantity = 1;
                db.CARTs.Add(cartobj);
                db.SaveChanges();
                return(2000);
            }
            else
            {
                chk.ItemQuantity += 1;

                db.Entry(chk).State = EntityState.Modified;
                db.SaveChanges();
                return(2001);
            }
        }
Example #3
0
        /// <summary>
        /// Edits the product.
        /// </summary>
        /// <param name="product">The product.</param>
        /// <param name="productId">The product identifier.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception"></exception>
        public static string EditProduct(PRODUCTS product, int productId)
        {
            try
            {
                var x = (from i in con.PRODUCTS
                         where i.ID == productId
                         select i).First();

                x.PRODUCT       = product.PRODUCT;
                x.QUANTITY      = product.QUANTITY;
                x.MODIFIED_DATE = DateTime.Now.ToString("MM/dd/yyyy");

                int result = con.SaveChanges();

                if (result > 0)
                {
                    return("Successful");
                }
                else
                {
                    return("Failed Operation");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #4
0
        public static bool InsertProduct(PRODUCTS product)
        {
            bool status = false;

            try
            {
                using (OracleConnection connection = new OracleConnection(conlink))
                {
                    if (connection.State == ConnectionState.Closed)
                    {
                        connection.Open();
                    }
                    string query = "INSERT INTO PRODUCTS (PRODUCTNAME) " +
                                   "VALUES (:productname)";
                    OracleCommand cmd = new OracleCommand(query, connection);
                    cmd.Parameters.Add(new OracleParameter(":productname", product.PRODUCTNAME));

                    cmd.ExecuteNonQuery();
                    if (connection.State == ConnectionState.Open)
                    {
                        connection.Close();
                    }
                    status = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(status);
        }
        public ActionResult Create([Bind(Include = "ID_PRODUCT,NAME,DESCRIPTION,PRICE,AMOUNTS,ACTIVE,DATE_CREATION,DATE_MODIFI")] PRODUCTS pRODUCT)
        {
            var keys          = Request.Form.AllKeys;
            var OptionStorage = Request.Form.Get("SelectedStorage");

            pRODUCT.ACTIVE        = true;
            pRODUCT.DATE_CREATION = DateTime.Now;
            pRODUCT.DATE_MODIFI   = DateTime.Now;

            if (ModelState.IsValid)
            {
                if (OptionStorage == "database")
                {
                    db.PRODUCTS.Add(pRODUCT);
                    db.SaveChanges();
                }
                else
                {
                    List <PRODUCTS> ListPRODUCTS = new List <PRODUCTS>();
                    if ((List <PRODUCTS>)Session["PRODUCT"] != null)
                    {
                        ListPRODUCTS = (List <PRODUCTS>)Session["PRODUCT"];
                    }

                    ListPRODUCTS.Add(pRODUCT);
                    Session["PRODUCT"] = ListPRODUCTS;
                }
                return(RedirectToAction("Index"));
            }
            return(View(pRODUCT));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            PRODUCTS pRODUCT = db.PRODUCTS.Find(id);

            db.PRODUCTS.Remove(pRODUCT);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #7
0
 public bool eliminarProducto(PRODUCTS product)
 {
     using (OmniconEntities db = new OmniconEntities())
     {
         db.PRODUCTS.Remove(db.PRODUCTS.Find(product.ID));
         db.SaveChanges();
         return(true);
     }
 }
 public bool InsertProduct(PRODUCTS newProduct)
 {
     using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
     {
         dbContext.PRODUCTS.Add(newProduct);
         dbContext.SaveChanges();
     }
     return(true);
 }
Example #9
0
        public PRODUCTS consultarProductosById(Guid id)
        {
            PRODUCTS productoById = new PRODUCTS();

            using (OmniconEntities db = new OmniconEntities())
            {
                productoById = db.PRODUCTS.Find(id);
            }

            return(productoById);
        }
Example #10
0
        public int CreateProduct(ProductEntity productEntity)
        {
            var product = new PRODUCTS
            {
                ProductName = productEntity.ProductName
            };

            _unitOfWork.ProductRepository.Insert(product);
            _unitOfWork.Save();
            return(product.ProductId);
        }
 public ActionResult Edit([Bind(Include = "ID_PRODUCT,NAME,DESCRIPTION,PRICE,AMOUNTS,ACTIVE,DATE_CREATION,DATE_MODIFI")] PRODUCTS pRODUCT)
 {
     if (ModelState.IsValid)
     {
         pRODUCT.DATE_MODIFI     = DateTime.Now;
         db.Entry(pRODUCT).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pRODUCT));
 }
        public PRODUCTS GetProductById(int id)
        {
            var product = new PRODUCTS();

            using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
            {
                product = dbContext.PRODUCTS.FirstOrDefault(x => x.product_id == id);
            }

            return(product);
        }
Example #13
0
        public List <PRODUCTS> consultarProductos()
        {
            List <PRODUCTS> lista_productos = new List <PRODUCTS>();
            PRODUCTS        productos       = new PRODUCTS();

            using (OmniconEntities db = new OmniconEntities())
            {
                lista_productos = db.PRODUCTS.AsNoTracking().ToList();
            }

            return(lista_productos);
        }
        private void buttonConfirmation_Click(object sender, EventArgs e)
        {
            if (id != Guid.Parse("00000000-0000-0000-0000-000000000000"))
            {
                PRODUCTS deleteProduct = new PRODUCTS();
                deleteProduct.ID = id;

                ProductsController controller = new ProductsController();
                controller.eliminarProducto(deleteProduct);
            }

            this.Close();
        }
Example #15
0
        /// <summary>
        /// Inserts the product.
        /// </summary>
        /// <param name="product">The product.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception"></exception>
        public static string  InsertProduct(PRODUCTS product)
        {
            try
            {
                con.PRODUCTS.Add(product);
                con.SaveChanges();

                return("Successful");
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        // GET: Products/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PRODUCTS pRODUCT = db.PRODUCTS.Find(id);

            if (pRODUCT == null)
            {
                return(HttpNotFound());
            }
            return(View(pRODUCT));
        }
Example #17
0
 public int AddProduct(PRODUCTS product)
 {
     if (product == null)
     {
         return(0);
     }
     else
     {
         product.Status = "Active";
         db.PRODUCTS.Add(product);
         db.SaveChanges();
         return(1);
     }
 }
Example #18
0
        public void actualizarProducto(PRODUCTS products)
        {
            string fechaActual = DateTime.UtcNow.ToString("d");

            using (OmniconEntities db = new OmniconEntities())
            {
                var update = (from a in db.PRODUCTS where a.ID == products.ID select a).FirstOrDefault();
                update.PRODUCT       = products.PRODUCT;
                update.QUANTITY      = products.QUANTITY;
                update.MODIFIED_DATE = DateTime.Parse(fechaActual);

                db.SaveChanges();
            }
        }
Example #19
0
        public ActionResult Robots(string id)
        {
            //ЫВАЫВА
            ProductsBaseEntities context = new ProductsBaseEntities();
            PRODUCTS             product = context.PRODUCTS.Where(c => c.URL_NAME.ToLower().Equals(id.ToLower())).ToList().FirstOrDefault();

            if (product != null)
            {
                return(View("Robots", product));
            }
            else
            {
                return(View("RobotsMenu"));
            }
        }
        public bool UpdateProduct(PRODUCTS editProduct)
        {
            bool result = false;

            using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
            {
                var recordToEdit = dbContext.PRODUCTS.FirstOrDefault(x => x.product_id == editProduct.product_id);
                recordToEdit.product_code = editProduct.product_code;
                recordToEdit.product_name = editProduct.product_name;
                recordToEdit.cost_price   = editProduct.cost_price;
                recordToEdit.sale_price   = editProduct.sale_price;
                recordToEdit.state        = editProduct.state;
            }

            return(result);
        }
Example #21
0
        public ActionResult Add(string productName, string productProizv, string productDesc, string productPrice, string category)
        {
            WebStoreEntities db   = new WebStoreEntities();
            PRODUCTS         prod = new PRODUCTS();

            name = productName;

            prod.PRODUCTNAME = productName;
            prod.DESCR       = productDesc;
            prod.MANUFACT    = productProizv;
            prod.PRICE       = productPrice;
            prod.CATEGORY    = category;
            db.PRODUCTS.Add(prod);
            db.SaveChanges();
            return(View());
        }
Example #22
0
        public static List <PRODUCTS> GetAll()
        {
            PRODUCTS        product  = null;
            List <PRODUCTS> products = new List <PRODUCTS>();

            try
            {
                using (OracleConnection con = new OracleConnection(conlink))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    string           query  = "SELECT * FROM PRODUCTS";
                    OracleCommand    cmd    = new OracleCommand(query, con);
                    OracleDataReader reader = cmd.ExecuteReader();
                    if (reader != null)
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                product = new PRODUCTS()
                                {
                                    PRODUCTNAME = reader["PRODUCTNAME"].ToString(),
                                    PRODUCTNO   = int.Parse(reader["PRODUCTNO"].ToString()),
                                };
                                products.Add(product);
                            }
                            reader.Close();
                        }
                    }
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(products);
        }
Example #23
0
        public ActionResult Delete(int id, PRODUCTS datosFront)
        {
            try
            {
                productService = new Order_Graber_DataService.Services.ProductService();
                Order_Graber_DataService.PRODUCTS deleteProduct = new Order_Graber_DataService.PRODUCTS()
                {
                    product_id = id,
                };

                productService.DeleteProduct(deleteProduct.product_id);

                return(RedirectToAction("IndexProduct"));
            }
            catch
            {
                return(View());
            }
        }
Example #24
0
        public bool crearProducto(PRODUCTS products)
        {
            string fechaActual = DateTime.UtcNow.ToString("d");

            PRODUCTS createProduct = new PRODUCTS();

            using (OmniconEntities db = new OmniconEntities())
            {
                createProduct.ID            = Guid.NewGuid();
                createProduct.PRODUCT       = products.PRODUCT;
                createProduct.QUANTITY      = products.QUANTITY;
                createProduct.MODIFIED_DATE = DateTime.Parse(fechaActual);

                db.PRODUCTS.Add(createProduct);
                db.SaveChanges();

                return(true);
            }
        }
Example #25
0
        public static PRODUCTS Get(string productname)
        {
            PRODUCTS product = null;

            try
            {
                using (OracleConnection con = new OracleConnection(conlink))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    string        query = "SELECT * FROM PRODUCTS WHERE PRODUCTNAME =:productname";
                    OracleCommand cmd   = new OracleCommand(query, con);
                    cmd.Parameters.Add(new OracleParameter(":productname", productname));
                    OracleDataReader reader = cmd.ExecuteReader();
                    if (reader != null)
                    {
                        if (reader.HasRows)
                        {
                            if (reader.Read())
                            {
                                product = new PRODUCTS()
                                {
                                    PRODUCTNO   = int.Parse(reader["PRODUCTNO"].ToString()),
                                    PRODUCTNAME = reader["PRODUCTNAME"].ToString(),
                                };
                            }
                            reader.Close();
                        }
                    }
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }
            }
            catch (Exception ex)
            { throw ex; }
            return(product);
        }
Example #26
0
        public ActionResult Create(PRODUCTS datosFront)
        {
            try
            {
                productService = new Order_Graber_DataService.Services.ProductService();
                Order_Graber_DataService.PRODUCTS newProduct = new Order_Graber_DataService.PRODUCTS()
                {
                    product_code = datosFront.product_code,
                    product_name = datosFront.product_name,
                    cost_price   = datosFront.cost_price,
                    sale_price   = datosFront.sale_price,
                    state        = datosFront.state
                };

                productService.InsertProduct(newProduct);
                return(RedirectToAction("IndexProduct"));
            }
            catch
            {
                return(View());
            }
        }
Example #27
0
        private void buttonCreateNewRegister_Click(object sender, EventArgs e)
        {
            if (id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
            {
                PRODUCTS newProduct = new PRODUCTS();
                newProduct.PRODUCT  = textBoxProductName.Text;
                newProduct.QUANTITY = decimal.Parse(textBoxQuantity.Text);

                controller.crearProducto(newProduct);
            }
            else
            {
                PRODUCTS updateProduct = new PRODUCTS();
                updateProduct.ID       = id;
                updateProduct.PRODUCT  = textBoxProductName.Text;
                updateProduct.QUANTITY = decimal.Parse(textBoxQuantity.Text);

                controller.actualizarProducto(updateProduct);
            }

            this.Close();
        }
 // GET: Products
 public ActionResult Index(string OptionStorage)
 {
     if (OptionStorage == "database")
     {
         return(View(db.PRODUCTS.ToList()));
     }
     else
     {
         List <PRODUCTS> ListPRODUCTS = new List <PRODUCTS>();
         ListPRODUCTS = (List <PRODUCTS>)Session["PRODUCT"];
         if (ListPRODUCTS != null)
         {
             return(View(ListPRODUCTS.ToList()));
         }
         else
         {
             ListPRODUCTS = new List <PRODUCTS>();
             PRODUCTS _PRODUCTS = new PRODUCTS();
             ListPRODUCTS.Add(_PRODUCTS);
             return(View(ListPRODUCTS.ToList()));
         }
     }
 }
Example #29
0
        public int ModifyProduct(PRODUCTS product)
        {
            var oldentry = db.PRODUCTS.Where(p => p.ProductId == product.ProductId).FirstOrDefault();

            if (product == null)
            {
                return(0);
            }
            else
            {
                oldentry.ProductName             = product.ProductName;
                oldentry.Price                   = product.Price;
                oldentry.Path                    = product.Path;
                oldentry.TagLine                 = product.TagLine;
                oldentry.ProductShortDiscription = product.ProductShortDiscription;
                oldentry.Category                = product.Category;

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

                return(1);
            }
        }
        public void Page_Load(object sender, EventArgs args)
        {
            RESPONSE.Text = "";
            if (Session["LOGEDIN"] != null)
            {
                UZR = (User)Session["LOGEDIN"];
            }

            try {
                if (!UZR.Username.Equals(""))
                {
                }
            }
            catch (Exception) {
                Response.Redirect("Default.aspx");
            }

            if (!IsPostBack)
            {
                DatabaseManager db = new DatabaseManager();
                PRODUCTS.DataSource = db.ProductQuery();
                PRODUCTS.DataBind();
            }
        }