Ejemplo n.º 1
0
        public ActionResult AddProduct(ClassProduct a, Image imageModel, HttpPostedFileBase ImageFile)
        {
            ComputerShopEntities data = new ComputerShopEntities();
            InfoProduct          b    = new InfoProduct();

            b.Name          = a.Name;
            b.Price         = a.price;
            b.Description   = a.description;
            b.idProductType = a.idProduct;
            data.InfoProducts.Add(b);
            data.SaveChanges();
            imageModel.idProduct = b.Id;
            imageModel.Title     = b.Name;
            string fileName  = Path.GetFileNameWithoutExtension(ImageFile.FileName);
            string extension = Path.GetExtension(ImageFile.FileName);

            fileName             = fileName + DateTime.Now.ToString("yymmssfff") + extension;
            imageModel.ImagePath = fileName;
            fileName             = Path.Combine(Server.MapPath("~/img/"), fileName);
            ImageFile.SaveAs(fileName);
            using (ComputerShopEntities db = new ComputerShopEntities())
            {
                db.Images.Add(imageModel);
                db.SaveChanges();
                ViewBag.a = "Thêm sản phẩm thành cống";
            }
            ModelState.Clear();
            return(View());
        }
Ejemplo n.º 2
0
    public IEnumerator GetData(GameObject Product)
    {
        ClassProduct CP = Product.GetComponent <ClassProduct> ();

        WWW www = new WWW("http://mmahgoub-001-site1.htempurl.com/WebService.asmx/GetProductXml?ProductID=" + CP.PID.ToString());

        yield return(www);

        string text = www.text;

        XmlDocument Doc = new XmlDocument();

        try {
            Doc.LoadXml(text);
            XmlNodeList node = Doc.GetElementsByTagName("Product");

            CP.Quantity_In_Stock = node [0].ChildNodes.Item(0).InnerText.Trim();
            CP.Name        = node [0].ChildNodes.Item(1).InnerText.Trim();
            CP.shop        = node [0].ChildNodes.Item(2).InnerText.Trim();
            CP.Description = node [0].ChildNodes.Item(3).InnerText.Trim();
            CP.Unit_Price  = node [0].ChildNodes.Item(4).InnerText.Trim();
        } catch (XmlException e) {
            print(e.Message);
        }
        Canv.transform.GetChild(0).GetChild(0).GetComponent <Text> ().text    = CP.Name;
        Canv.transform.GetChild(0).GetChild(1).GetComponent <Text> ().text    = CP.Description;
        Canv.transform.GetChild(0).GetChild(2).GetComponent <Text> ().text    = CP.Unit_Price;
        Canv.transform.GetChild(0).GetChild(3).GetComponent <Image> ().sprite = CP.PSprite;
    }
Ejemplo n.º 3
0
    void SendSelectedProduct()
    {
        if (LastProductClicked != null)
        {
            ClassProduct CP = LastProductClicked.GetComponent <ClassProduct> ();

            WWW www = new WWW("http://mmahgoub-001-site1.htempurl.com/WebService.asmx/SelectedProduct?userID=" + UserID + "&productID=" + CP.PID.ToString());
        }
    }
Ejemplo n.º 4
0
        public async Task <IActionResult> Add([Bind("ClassId,Name,BusinessEntityId")] ClassProduct classProduct, bool continueAdd)
        {
            if (ModelState.IsValid)
            {
                await _classProductServices.AddAsync(classProduct);

                return(continueAdd ? RedirectToAction(nameof(Add)) : RedirectToAction(nameof(List)));
            }
            return(View(classProduct));
        }
Ejemplo n.º 5
0
        public Provider     MyProvider;                 // Структура описывающая поставщика товара

        public Product(int count, decimal idProd, double cost, ClassProduct typePr, char value, Provider provider)
        {
            Count            = count;
            IdProduct        = idProd;
            Cost             = cost;
            Presence         = Count > 0 ? true : false;
            TypeClassProduct = typePr;
            Value            = value;
            MyProvider       = provider;
        }
Ejemplo n.º 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtIMGid.Text.Equals("") && picImage.Image != null)
                {
                    int addIMG = ClassProduct.insertIMG(arr, int.Parse(ProID));
                    dt = ClassManagmentReport.displayAllIMGForPro(int.Parse(ProID));

                    MessageBox.Show("Done . .");
                    numOfImag = dt.Rows.Count;
                    btnFirstIMG_Click(null, null);
                }
            }
            catch (Exception) { }
        }
Ejemplo n.º 7
0
        public ActionResult Edit(ClassProduct a, Image imageModel, HttpPostedFileBase ImageFile)
        {
            ComputerShopEntities data = new ComputerShopEntities();
            var u = data.InfoProducts.Where(x => x.Id == a.id).FirstOrDefault();
            var y = data.Images.Where(k => k.idProduct == a.id).FirstOrDefault();

            if (u != null)
            {
                if (y != null)
                {
                    data.Images.Remove(y);
                }

                data.InfoProducts.Remove(u);
                data.SaveChanges();
            }
            InfoProduct b = new InfoProduct();

            b.Name          = a.Name;
            b.Price         = a.price;
            b.Description   = a.description;
            b.idProductType = a.idProduct;
            data.InfoProducts.Add(b);
            data.SaveChanges();
            imageModel.idProduct = b.Id;
            imageModel.Title     = b.Name;
            string fileName  = Path.GetFileNameWithoutExtension(ImageFile.FileName);
            string extension = Path.GetExtension(ImageFile.FileName);

            fileName             = fileName + DateTime.Now.ToString("yymmssfff") + extension;
            imageModel.ImagePath = fileName;
            fileName             = Path.Combine(Server.MapPath("~/img/"), fileName);
            ImageFile.SaveAs(fileName);
            using (ComputerShopEntities db = new ComputerShopEntities())
            {
                db.Images.Add(imageModel);
                db.SaveChanges();
                ViewBag.a = "Sửa thành công";
            }

            ModelState.Clear();
            return(View());
        }
Ejemplo n.º 8
0
 public async Task <IActionResult> Edit(int id, [Bind("ClassId,Name,BusinessEntityId")] ClassProduct classProduct, bool continueAdd)
 {
     if (id != classProduct.ClassId)
     {
         return(NotFound());
     }
     if (ModelState.IsValid)
     {
         try
         {
             await _classProductServices.UpdateAsync(classProduct);
         }
         catch (DbUpdateConcurrencyException)
         {
             throw;
         }
         return(continueAdd ? RedirectToAction(nameof(Edit), new { id = classProduct.ClassId }) : RedirectToAction(nameof(List)));
     }
     return(View(classProduct));
 }
Ejemplo n.º 9
0
        public ActionResult Product(ClassProduct b)
        {
            if (Session["SignIn"] == null)
            {
                return(RedirectToAction("SignUp", "MainProcess"));
            }
            else
            {
                User kq = (User)Session["SignIn"];

                if (kq.role == "admin")
                {
                    ComputerShopEntities data = new ComputerShopEntities();

                    var a = from x in data.InfoProducts select x;
                    return(View(a));
                }
                else
                {
                    return(RedirectToAction("ThongBao", new { tenaction = "Contact" }));
                }
            }
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int found = 0;

            if (txtname.Text.Equals(""))
            {
                MessageBox.Show("Please insert product name .");
            }
            else
            {
                DataTable ProName = ClassProduct.selectOnePro(txtbarcode.Text);
                if (ProName.Rows.Count > 0 && !ProName.Rows[0][0].ToString().Equals(ProID.ToString()))
                {
                    found = 1; MessageBox.Show("This Product or Barcode Already Exist . .");
                }
            }
            if (found == 0)
            {
                int i = ClassManagmentReport.updatePro(ProID, txtname.Text, txtbarcode.Text, txtCategory.Text, txtCountry.Text, txtcity.Text, txtCompany.Text, "0", "0", "0", rtxtdiscrp.Text, rtxtnote.Text);
                txtname.Text = txtbarcode.Text = txtCategory.Text = txtCountry.Text = txtcity.Text = txtCompany.Text = rtxtdiscrp.Text = rtxtnote.Text = "";
                MessageBox.Show("Done. .");
            }
            this.Close();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            btnSave.Enabled = false;
            int found = 0;

            if (txtname.Text.Equals(""))
            {
                MessageBox.Show("Please Insert Product Name ! ");
            }
            else
            {
                DataTable ProName = ClassProduct.selectOnePro(txtbarcode.Text);
                if (ProName.Rows.Count > 0)
                {
                    found = 1; MessageBox.Show("This Product or Barcode Already Exist . .");
                }
                if (found == 0)
                {
                    int product = ClassProduct.insertPro(txtname.Text, txtbarcode.Text, txtCategory.Text, txtCountry.Text, txtcity.Text, txtCompany.Text, "0", "0", "0", rtxtdiscrp.Text, rtxtnote.Text);
                    if (NumOfImage > 0)
                    {
                        DataTable LastOne = ClassProduct.LastPro();
                        for (int i = 0; i < images.Count; i++)
                        {
                            int AddImg = ClassProduct.insertIMG(images[i], int.Parse(LastOne.Rows[0][0].ToString()));
                        }
                    }
                    txtname.Text  = txtbarcode.Text = txtCategory.Text = txtCountry.Text = txtcity.Text = txtCompany.Text = rtxtdiscrp.Text = rtxtnote.Text = "";
                    lbNumIMG.Text = "0";
                    NumOfImage    = 0;
                    images.Clear();
                    MessageBox.Show("Done. .");
                }
            }
            btnSave.Enabled = true;
        }
Ejemplo n.º 12
0
        public IActionResult Add()
        {
            var data = new ClassProduct();

            return(View(data));
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> Delete(ClassProduct classProduct)
        {
            await _classProductServices.DeleteAsync(classProduct);

            return(RedirectToAction(nameof(List)));
        }
Ejemplo n.º 14
0
        public List <SqlParameter> SetParameters(ClassProduct datos)
        {
            List <SqlParameter> sp = new List <SqlParameter>()
            {
                new SqlParameter()
                {
                    ParameterName = "@p1", SqlDbType = SqlDbType.NVarChar, Value = datos.Product_id
                },
                new SqlParameter()
                {
                    ParameterName = "@p2", SqlDbType = SqlDbType.NVarChar, Value = datos.ProductName
                },
                new SqlParameter()
                {
                    ParameterName = "@p3", SqlDbType = SqlDbType.NVarChar, Value = datos.Descripcion
                },
                new SqlParameter()
                {
                    ParameterName = "@p4", SqlDbType = SqlDbType.NVarChar, Value = datos.Referencia
                },
                new SqlParameter()
                {
                    ParameterName = "@p5", SqlDbType = SqlDbType.NVarChar, Value = datos.Codebar
                },
                new SqlParameter()
                {
                    ParameterName = "@p6", SqlDbType = SqlDbType.NVarChar, Value = datos.Categoria
                },
                new SqlParameter()
                {
                    ParameterName = "@p7", SqlDbType = SqlDbType.Bit, Value = datos.MasterRolls
                },
                new SqlParameter()
                {
                    ParameterName = "@p8", SqlDbType = SqlDbType.Bit, Value = datos.Rollo_Cortado
                },
                new SqlParameter()
                {
                    ParameterName = "@p9", SqlDbType = SqlDbType.Bit, Value = datos.Resmas
                },
                new SqlParameter()
                {
                    ParameterName = "@p10", SqlDbType = SqlDbType.Bit, Value = datos.Graphics
                },
                new SqlParameter()
                {
                    ParameterName = "@p11", SqlDbType = SqlDbType.Bit, Value = datos.Anulado
                },
                new SqlParameter()
                {
                    ParameterName = "@p12", SqlDbType = SqlDbType.Decimal, Value = datos.Precio
                },
                new SqlParameter()
                {
                    ParameterName = "@p13", SqlDbType = SqlDbType.NVarChar, Value = datos.Code_RC
                },
                new SqlParameter()
                {
                    ParameterName = "@p14", SqlDbType = SqlDbType.Decimal, Value = datos.Ratio
                }
            };

            return(sp);
        }
Ejemplo n.º 15
0
 public void Update(ClassProduct datos)
 {
     CommandSqlGeneric(R.SQL.DATABASE.NAME, R.SQL.QUERY_SQL.PRODUCTS.SQL_QUERY_UPDATE_PRODUCTS,
                       SetParameters(datos), true, R.ERROR_MESSAGES.MODULO_PRODUCTOS.MESSAGE_UPDATE_PRODUCTS_ERROR);
 }
Ejemplo n.º 16
0
 public void Add(ClassProduct datos, Boolean mensajeok)
 {
     CommandSqlGeneric(R.SQL.DATABASE.NAME, R.SQL.QUERY_SQL.PRODUCTS.SQL_QUERY_INSERT_PRODUCT,
                       SetParameters(datos), mensajeok, R.ERROR_MESSAGES.MODULO_PRODUCTOS.MESSAGE_ADD_PRODUCTS_ERROR);
 }