コード例 #1
0
        // GET: Product/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            productModel productModel = db.productmodel.Find(id);

            if (productModel.sellerID != User.Identity.GetUserId())
            {
                TempData["ErrorMessage"] = "You may not edit a product that is not your own.";
                return(RedirectToAction("Index"));
            }
            createProductViewModel vm = modelToView(productModel);

            vm.seller = db.Users.Find(productModel.sellerID);
            if (productModel.sellerID != User.Identity.GetUserId())
            {
                ViewBag.StatusMessage = "You cannot edit a product that is not yours."; return(RedirectToAction("Index"));
            }
            vm.unitList = new List <SelectListItem>();
            foreach (var unit in db.unitsModel.ToList())
            {
                vm.unitList.Add(new SelectListItem {
                    Text = unit.unitAbvr, Value = unit.ID.ToString()
                });
            }
            if (productModel == null)
            {
                return(HttpNotFound());
            }
            return(View(vm));
        }
コード例 #2
0
        public ActionResult EditPropic(productModel ob, HttpPostedFileBase file)
        {
            SqlConnection con = new SqlConnection(constring);
            String        q   = "Update Product set Product_ImagePath=@imageid  where Product_ID=@id";



            SqlCommand cmd = new SqlCommand(q, con);

            con.Open();
            cmd.Parameters.AddWithValue("@id", ob.Product_ID);
            if (file != null && file.ContentLength > 0)
            {
                string filename = Path.GetFileName(file.FileName);
                string imgpath  = Path.Combine(Server.MapPath("/productimages/"), filename);
                file.SaveAs(imgpath);
            }
            cmd.Parameters.AddWithValue("@imageid", "/productimages/" + file.FileName);
            ViewData["img"] = "/productimages/" + file.FileName;



            cmd.ExecuteNonQuery();
            con.Close();

            return(RedirectToAction("ProductTables"));
        }
コード例 #3
0
        public productModel viewToModel(createProductViewModel oldModel)
        {
            productModel newModel = new productModel();

            newModel.ID              = oldModel.ID;
            newModel.address         = oldModel.address;
            newModel.zipcode         = oldModel.zipcode;
            newModel.city            = oldModel.city;
            newModel.state           = oldModel.state;
            newModel.images          = oldModel.images;
            newModel.categoryID      = oldModel.categoryID;
            newModel.productCategory = oldModel.category;
            newModel.price           = oldModel.price;
            newModel.qtyAvail        = oldModel.qtyAvail;
            newModel.qtyRemain       = oldModel.qtyRemain;
            newModel.productName     = oldModel.productName;
            newModel.unitQTY         = oldModel.unitQty;
            newModel.ratings         = oldModel.ratings;
            newModel.unitID          = oldModel.unitID;
            newModel.sellerID        = oldModel.sellerID;
            newModel.dateListed      = oldModel.dateListed;
            newModel.tags            = new List <string>();
            if (oldModel.tags != null)
            {
                newModel.tags = oldModel.tags.Split(',').ToList();
            }
            return(newModel);
        }
コード例 #4
0
        // GET: product/Edit/5
        public ActionResult Edit(int id)
        {
            productModel productModel = new productModel();
            DataTable    dtblProduct  = new DataTable();

            using (SqlConnection sqlCon = new SqlConnection(connectionString))
            {
                sqlCon.Open();
                string         query = "SELECT * FROM product where productID = @productID";
                SqlDataAdapter sqlDa = new SqlDataAdapter(query, sqlCon);
                sqlDa.SelectCommand.Parameters.AddWithValue("@productID", id);
                sqlDa.Fill(dtblProduct);
            }
            if (dtblProduct.Rows.Count == 1)
            {
                productModel.productID   = Convert.ToInt32(dtblProduct.Rows[0][0].ToString());
                productModel.productName = dtblProduct.Rows[0][1].ToString();
                productModel.price       = Convert.ToDecimal(dtblProduct.Rows[0][2].ToString());
                productModel.count       = Convert.ToInt32(dtblProduct.Rows[0][3].ToString());
                productModel.date        = Convert.ToDateTime(dtblProduct.Rows[0][4].ToString());
                return(View(productModel));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
コード例 #5
0
        //Opens the form to edit product information
        public ActionResult Edit(int id)
        {
            SqlConnection con = new SqlConnection(constring);
            String        q   = "SELECT * from Product where Product_ID=@id";

            con.Open();
            SqlCommand cmd = new SqlCommand(q, con);

            cmd.Parameters.AddWithValue("@id", id);

            cmd.ExecuteNonQuery();
            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
            DataTable      dt      = new DataTable();

            adapter.Fill(dt);
            productModel ob = new productModel();

            if (dt.Rows.Count == 1)
            {
                ob.Product_Name      = dt.Rows[0][1].ToString();
                ob.Product_ID        = Convert.ToInt32(dt.Rows[0][0].ToString());
                ob.Product_Price     = Convert.ToInt32(dt.Rows[0][6].ToString());
                ob.Product_Status    = dt.Rows[0][2].ToString();
                ob.Product_ImagePath = dt.Rows[0][7].ToString();
                ob.Product_Component = dt.Rows[0][4].ToString();

                ob.Product_Strength    = Convert.ToInt32(dt.Rows[0][3].ToString());
                ob.Product_Description = dt.Rows[0][5].ToString();
            }


            return(View(ob));
        }
コード例 #6
0
ファイル: deffController.cs プロジェクト: radtek/smsServ
        public async Task <productModel> Get()
        {
            productModel product = new productModel();

            try
            {
                if (dbconn.idbStatOK())
                {
                    DataTable      dt      = dbconn.getTable(smsQry.getBund());
                    List <Product> prdList = new List <Product>();

                    foreach (DataRow dr in dt.Rows)
                    {
                        Product prd = new Product();
                        prd.productName = dr["BUNDLE_CODE"].ToString();
                        prd.productCode = dr["PRODUCT_NAME"].ToString();
                        prdList.Add(prd);
                    }
                    product.isSuccess     = true;
                    product.resultMessage = "success";
                    product.products      = prdList;
                }
            }
            catch (Exception ex)
            {
                product.isSuccess     = false;
                product.resultMessage = ex.Message;
                LogWriter._error(TAG, ex.ToString());
            }
            return(product);
        }
コード例 #7
0
        private void ComputeCost_Click(object sender, EventArgs e)
        {
            try
            {
                if (!InputValid())
                {
                    return;
                }

                productModel _model   = GetValues();
                List <IBase> delivery = new DeliveryBuilder(_model).SetReject().SetHeavy().SetSmall().SetMedium().SetLarge().Build();

                foreach (var _base in delivery)
                {
                    var result = _base.Processed();
                    if (result)
                    {
                        cost.Text     = _base.GetCost().ToString();
                        category.Text = _base.GetCategory();

                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Code Chalenge", MessageBoxButtons.OK);
            }
        }
コード例 #8
0
        public void del_product(string id)
        {
            productModel pd = new productModel();

            pd.pd_id = id;
            pd.del_product();
        }
コード例 #9
0
        public IActionResult viewProduct(string id)
        {
            productModel pd = new productModel();

            pd.select_product("pd_id = '" + id + "'");

            ViewData["pd_id"]     = id;
            ViewData["pd_img"]    = pd.pd_img;
            ViewData["pd_code"]   = pd.pd_code;
            ViewData["pd_name"]   = pd.pd_name;
            ViewData["pd_color"]  = pd.pd_color;
            ViewData["pd_width"]  = pd.pd_width;
            ViewData["pd_long"]   = pd.pd_long;
            ViewData["pd_detail"] = pd.pd_detail;
            ViewData["pd_price"]  = pd.pd_price;
            ViewData["pd_sale"]   = pd.pd_sale;

            groupPoductModel gp = new groupPoductModel();

            ViewData["gp"]   = gp.drop_gp(pd.pd_ref_group_product);
            ViewData["gp_2"] = gp.drop_gp(pd.pd_ref_group_product_sale);

            unitModel un = new unitModel();

            ViewData["unit"] = un.drop_unit(pd.pd_unit);

            return(View());
        }
コード例 #10
0
        public ActionResult ProductTables(string searchString, string product_no_show)
        {
            int NoofProductstoShow = Convert.ToInt32(product_no_show);

            NoofProductstoShow = 100;
            DataTable dt = new DataTable();


            SqlConnection con = new SqlConnection(constring);
            String        q   = "select TOP " + NoofProductstoShow + " * from Product " +
                                " INNER JOIN ProductCategory ON Product.Product_ID=ProductCategory.Product_ID " +
                                " INNER JOIN SideEffects ON SideEffects.Product_ID=Product.Product_ID " +
                                "INNER JOIN Company On Company.Product_ID=Product.Product_ID " +
                                " where Product.Product_Name Like '%" + searchString + "%'";

            con.Open();
            SqlCommand cmd = new SqlCommand(q, con);

            SqlDataAdapter adapter = new SqlDataAdapter(cmd);

            adapter.Fill(dt);

            if (string.IsNullOrEmpty(Session["Email"] as string))
            {
                return(RedirectToAction("AdminLogin", "Admin"));
            }
            else
            {
                productModel ob = new productModel();
                return(View(dt));
            }
        }
コード例 #11
0
        //Opens the form to view and edit product picture
        public ActionResult EditPropic(int id)
        {
            SqlConnection con = new SqlConnection(constring);
            String        q   = "SELECT * from Product where Product_ID=@id";

            con.Open();
            SqlCommand cmd = new SqlCommand(q, con);

            cmd.Parameters.AddWithValue("@id", id);
            cmd.ExecuteNonQuery();
            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
            DataTable      dt      = new DataTable();

            adapter.Fill(dt);
            productModel ob = new productModel();

            if (dt.Rows.Count == 1)
            {
                ob.Product_ID = Convert.ToInt32(dt.Rows[0][0].ToString());

                ob.Product_ImagePath = dt.Rows[0][7].ToString();
            }

            ViewData["img"] = ob.Product_ImagePath;
            return(View(ob));
        }
コード例 #12
0
        public ActionResult Edit(productModel ob, int status)
        {
            SqlConnection con = new SqlConnection(constring);

            con.Open();
            String q = "Update Product set Product_Price=@price,Product_Status=@status,Product_Component=@component,Product_Description=@desc,Product_Name=@name,Product_Strength=@strength  where Product_ID= @id";

            SqlCommand cmd = new SqlCommand(q, con);

            cmd.Parameters.AddWithValue("@id", ob.Product_ID);
            cmd.Parameters.AddWithValue("@name", ob.Product_Name);
            cmd.Parameters.AddWithValue("@price", ob.Product_Price);
            if (status == 1)
            {
                cmd.Parameters.AddWithValue("@status", "Available");
            }
            else
            {
                cmd.Parameters.AddWithValue("@status", "Out of Stock");
            }

            cmd.Parameters.AddWithValue("@component", ob.Product_Component);
            cmd.Parameters.AddWithValue("@strength", ob.Product_Strength);
            cmd.Parameters.AddWithValue("@desc", ob.Product_Description);


            cmd.ExecuteNonQuery();
            return(RedirectToAction("ProductTables"));
        }
コード例 #13
0
        //ajax calls this function which will return json object
        public JsonResult GetProducts(string Department_Name
                                      , string Cost
                                      , string xFor
                                      , string Department_ID
                                      , string Description
                                      , string Last_Sold
                                      , string Price
                                      , string Product_ID
                                      , string Shelf_Life
                                      , string Unit
                                      )
        {
            productModel myproducts = new productModel();

            myproducts.Department_Name = Department_Name;
            myproducts.Cost            = Cost;
            myproducts.Department_ID   = Department_ID;
            myproducts.Description     = Description;
            myproducts.Last_Sold       = Last_Sold;
            myproducts.Price           = Price;
            myproducts.Product_ID      = Product_ID;
            myproducts.Shelf_Life      = Shelf_Life;
            myproducts.Unit            = Unit;
            myproducts.xFor            = xFor;

            productList resultData = products.getProducts(myproducts);

            return(Json(new { result = resultData }, JsonRequestBehavior.AllowGet));
        }
コード例 #14
0
        public ActionResult DeleteConfirmed(int id)
        {
            productModel productModel = db.productmodel.Find(id);

            db.productmodel.Remove(productModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #15
0
        // GET: product
        public ActionResult Index(int page = 1)
        {
            productModel pModel = new productModel();

            pModel.products   = ctx.productBll.getAll().ToPagedList(page, 12);
            pModel.categories = ctx.categoryBll.getAll();
            return(View(pModel));
        }
コード例 #16
0
        public IActionResult product()
        {
            productModel pd = new productModel();

            ViewData["product"] = pd.list_product();

            return(View());
        }
コード例 #17
0
        public ActionResult filterProduct(productModel model)
        {
            int pageIndex = model.page ?? 1;

            productModel pModel = new productModel();

            pModel.name       = model.name;
            pModel.products   = ctx.productBll.getAll().Where(x => x.name.Contains(model.name)).ToList().ToPagedList(pageIndex, 12);
            pModel.categories = ctx.categoryBll.getAll();
            return(View(pModel));
        }
コード例 #18
0
 //Opens a product creation form with the product model
 public ActionResult Create()
 {
     if (string.IsNullOrEmpty(Session["Email"] as string))
     {
         return(RedirectToAction("AdminLogin", "Admin"));
     }
     else
     {
         productModel ob = new productModel();
         return(View(ob));
     }
 }
コード例 #19
0
        public ActionResult Edit(createProductViewModel viewModel)
        {
            productModel productmodel = viewToModel(viewModel);

            if (ModelState.IsValid)
            {
                db.Entry(productmodel).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(viewModel));
        }
コード例 #20
0
 public bool addProduct(productModel coustomer)
 {
     try{
         coustomer.createon = System.DateTime.Now;
         coustomer.createby = 1;
         context.Add(coustomer);
         context.SaveChanges();
         return(true);
     }
     catch {
         return(false);
     }
 }
コード例 #21
0
        public IActionResult addMash()
        {
            productModel pd = new productModel();

            ViewData["product"]      = pd.drop_product("");
            ViewData["product_list"] = pd.list_product();

            MaterialModel mt = new MaterialModel();

            ViewData["material"] = mt.drop_mtr("");

            return(View());
        }
コード例 #22
0
        public async Task <IActionResult> update_product(IList <IFormFile> selectFile, string pd_img, string pd_id, string pd_code, string pd_group, string pd_group_sale, string pd_name, string pd_unit, string pd_color, string pd_width, string pd_long, string pd_detail, string pd_price, string pd_sale)
        {
            productModel pd = new productModel();

            pd.pd_id = pd_id;

            var uploads = Path.Combine(_hostingEnvironment.WebRootPath, "product_img");
            int num     = selectFile.Count();

            if (num != 0)
            {
                foreach (var file in selectFile)
                {
                    if (file.Length > 0)
                    {
                        var filePath = Path.Combine(uploads, file.FileName);
                        pd.pd_img = file.FileName;

                        using (var fileStream = new FileStream(filePath, FileMode.Create))
                        {
                            await file.CopyToAsync(fileStream);
                        }
                    }
                    else
                    {
                        pd.pd_img = pd_img;
                    }
                }
            }
            else
            {
                pd.pd_img = pd_img;
            }


            pd.pd_code = pd_code;
            pd.pd_ref_group_product      = pd_group;
            pd.pd_ref_group_product_sale = pd_group_sale;
            pd.pd_name   = pd_name;
            pd.pd_unit   = pd_unit;
            pd.pd_color  = pd_color;
            pd.pd_width  = pd_width;
            pd.pd_long   = pd_long;
            pd.pd_detail = pd_detail;
            pd.pd_price  = pd_price;
            pd.pd_sale   = pd_sale;

            pd.update_product();

            return(RedirectToAction("product", "Product"));
        }
コード例 #23
0
ファイル: ProductMapper.cs プロジェクト: alankle/solar-coffee
 /// <summary>
 /// Product MOdel to  DataMOdel
 /// </summary>
 /// <param name="product"></param>
 /// <returns></returns>
 public static Data.Models.Product SerialProductModel(productModel product)
 {
     return(new Data.Models.Product
     {
         Id = product.Id,
         CreatedOn = product.CreatedOn,
         UpdatedOn = product.UpdatedOn,
         Name = product.Name,
         Description = product.Description,
         Price = product.Price,
         IsTaxable = product.IsTaxable,
         IsArchived = product.IsArchived
     });
 }
コード例 #24
0
        // GET: Product/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            productModel productModel = db.productmodel.Find(id);

            if (productModel == null)
            {
                return(HttpNotFound());
            }
            return(View(productModel));
        }
コード例 #25
0
 public ActionResult Create(productModel productModel)
 {
     using (SqlConnection sqlCon = new SqlConnection(connectionString))
     {
         sqlCon.Open();
         string     query  = "INSERT INTO Product VALUES(@productName,@price, @count, @date)";
         SqlCommand sqlCmd = new SqlCommand(query, sqlCon);
         sqlCmd.Parameters.AddWithValue("@productName", productModel.productName);
         sqlCmd.Parameters.AddWithValue("@price", productModel.price);
         sqlCmd.Parameters.AddWithValue("@count", productModel.count);
         sqlCmd.Parameters.AddWithValue("@date", productModel.date);
         sqlCmd.ExecuteNonQuery();
     }
     return(RedirectToAction("Index"));
 }
コード例 #26
0
 public ActionResult addPictures(int productID)
 {
     if (User.Identity.GetUserId() == db.productmodel.Find(productID).sellerID)
     {
         addProductImagesModel model = new addProductImagesModel();
         model.productID = productID;
         return(View(productID));
     }
     else
     {
         productModel product = db.productmodel.Find(productID);
         TempData["StatusMessage"] = "This product does not belong to you, therefore you are not allowed to modify it.";
         return(View("publicListing", product));
     }
 }
コード例 #27
0
 public ActionResult Edit(productModel productModel)
 {
     using (SqlConnection sqlCon = new SqlConnection(connectionString))
     {
         sqlCon.Open();
         string     query  = "UPDATE product SET productName = @productName, price = @price, count = @count, date = @date WHERE productID = @productID";
         SqlCommand sqlCmd = new SqlCommand(query, sqlCon);
         sqlCmd.Parameters.AddWithValue("@productID", productModel.productID);
         sqlCmd.Parameters.AddWithValue("@productName", productModel.productName);
         sqlCmd.Parameters.AddWithValue("@price", productModel.price);
         sqlCmd.Parameters.AddWithValue("@count", productModel.count);
         sqlCmd.Parameters.AddWithValue("@date", productModel.date);
         sqlCmd.ExecuteNonQuery();
     }
     return(RedirectToAction("index"));
 }
コード例 #28
0
 public IActionResult Edit(int id, [Bind] productModel Product)
 {
     if (ModelState.IsValid)
     {
         if (obj_Product.getAllProduct().Any(x => x.id != id && x.productcode.ToUpper() == Product.productcode.ToUpper()))
         {
             ModelState.AddModelError("productcode", "Product code already exists");
         }
         else
         {
             obj_Product.updateProduct(id, Product);
             return(RedirectToAction("Index"));
         }
     }
     ViewBag.offers = iofferRepository.selectList();
     return(View(Product));
 }
コード例 #29
0
        public IActionResult mash()
        {
            MashModel ms = new MashModel();

            ViewData["mash"] = ms.list_mash();

            productModel pd = new productModel();

            ViewData["product"] = pd.drop_product("");

            MaterialModel mt = new MaterialModel();

            ViewData["material"] = mt.drop_mtr("");


            return(View());
        }
コード例 #30
0
        public createProductViewModel modelToView(productModel model)
        {
            createProductViewModel viewModel = new createProductViewModel();

            viewModel.ID          = model.ID;
            viewModel.dateListed  = model.dateListed;
            viewModel.address     = model.address;
            viewModel.zipcode     = model.zipcode;
            viewModel.city        = model.city;
            viewModel.state       = model.state;
            viewModel.images      = model.images;
            viewModel.categoryID  = model.categoryID;
            viewModel.category    = model.productCategory;
            viewModel.price       = model.price;
            viewModel.qtyAvail    = model.qtyAvail;
            viewModel.qtyRemain   = model.qtyRemain;
            viewModel.productName = model.productName;
            viewModel.unitQty     = model.unitQTY;
            viewModel.ratings     = model.ratings;
            viewModel.unitID      = model.unitID;
            viewModel.sellerID    = model.sellerID;
            if (model.tags != null)
            {
                foreach (string tag in model.tags)
                {
                    if (tag == model.tags.Last())
                    {
                        viewModel.tags += tag;
                    }
                    else
                    {
                        viewModel.tags += (tag + ',');
                    }
                }
            }
            else
            {
                viewModel.tags = "";
            }
            return(viewModel);
        }