Ejemplo n.º 1
0
        internal void Addtocart(int _ID)
        {
            //con = new SqlConnection(@"Data Source=DESKTOP-55RJ8FH;Initial Catalog=jootaShopDB;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework");
            string query = "select * from productTable where productID='" + _ID + "'";

            con.Open();
            SqlCommand    cmd    = new SqlCommand(query, con);
            SqlDataReader reader = cmd.ExecuteReader();

            string[] data = new string[4];

            Models.productTable pt = new productTable();
            while (reader.Read())
            {
                pt.ProductID  = Convert.ToInt32(reader[0]);
                pt.name       = reader[1].ToString();
                pt.catagoryID = Convert.ToInt32(reader[2]);
                pt.imagePath  = reader[3].ToString();
                pt.price      = Convert.ToInt32(reader[4]);
                pt.quantity   = Convert.ToInt32(reader[5]);
            }


            con.Close();

            //con = new SqlConnection(@"Data Source=DESKTOP-55RJ8FH;Initial Catalog=jootaShop;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework");
            con.Open();
            cmd = new SqlCommand("insert into cartTable(Name,Price,ImagePath,Qty) values('" + pt.name + "','" + pt.price + "','" + pt.imagePath + "','" + pt.quantity + "')", con);
            cmd.ExecuteNonQuery();
            con.Close();
            return;
        }
        public ActionResult BidFromSearch(productTable upd)
        {
            //upd.biddedPrice = 69;
            //ViewBag.shohan = new SelectList(acForBid.productTables, "productID", "basePrice");

            searchProduct.Entry(upd).State = EntityState.Modified;
            searchProduct.SaveChanges();
            return(RedirectToAction("ShowBidListForUser", "Product"));
        }
Ejemplo n.º 3
0
 public ActionResult uploadProduct(productTable pt)
 {
     using (acForproduct)
     {
         acForproduct.productTables.Add(pt);
         acForproduct.SaveChanges();
         return(RedirectToAction("ShowListForUser"));
         //return RedirectToAction("PORE KORBO");
     }
 }
Ejemplo n.º 4
0
        public ActionResult updateBid(productTable upd)
        {
            //upd.biddedPrice = 69;
            //ViewBag.shohan = new SelectList(acForBid.productTables, "productID", "basePrice");

            acForBid.Entry(upd).State = EntityState.Modified;
            acForBid.SaveChanges();

            //return returnre("availableProducts");
            //return RedirectToAction("~/Bid/availableProducts");
            //return View("availableProducts");
            return(RedirectToAction("ShowBidListForUser", "Product"));
        }
Ejemplo n.º 5
0
        public ActionResult AddProduct(productTable table)
        {
            string fileName  = Path.GetFileNameWithoutExtension(table.ImageFile.FileName);
            string extension = Path.GetExtension(table.ImageFile.FileName);

            fileName = fileName + DateTime.Now.ToString("yymmssffff") + extension;

            table.imagePath = "~/Content/ProductImages/" + fileName;
            fileName        = Path.Combine(Server.MapPath("~/Content/ProductImages/"), fileName);

            table.ImageFile.SaveAs(fileName);
            dbo.AddDAta(table);
            ModelState.Clear();
            //  return View();
            ViewBag.Message = "OperationSuccessfull";
            return(RedirectToAction("AddProduct", "Admin"));
        }
Ejemplo n.º 6
0
        public List <productTable> readManData(int option = 0)
        {
            con = new SqlConnection(@"Data Source=DESKTOP-R9J3FU2;Initial Catalog=jootaShopDB;Integrated Security=True");
            string query = "Select * from productTable where catagoryID='1'";

            if (option == 1)
            {
                query = "Select * from productTable where catagoryID='3'";
            }
            else if (option == 2)
            {
                query = "Select * from productTable where catagoryID='2'";
            }
            else if (option == 3)
            {
                query = "Select * from productTable where catagoryID='1'";
            }
            else
            {
                query = "Select * from productTable";
            }
            con.Open();
            SqlDataAdapter adp = new SqlDataAdapter(query, con);
            DataTable      dt  = new DataTable();

            adp.Fill(dt);
            con.Close();

            List <productTable> tableData = new List <productTable>();

            foreach (DataRow item in dt.Rows)
            {
                productTable cst = new productTable()
                {
                    ProductID  = Convert.ToInt32(item["productID"].ToString()),
                    name       = item["name"].ToString(),
                    catagoryID = Convert.ToInt32(item["catagoryID"]),
                    price      = Convert.ToInt32(item["price"].ToString()),
                    imagePath  = item["imagePath"].ToString(),
                    quantity   = Convert.ToInt32(item["quantity"]),
                };

                tableData.Add(cst);
            }
            return(tableData);
        }
Ejemplo n.º 7
0
        public int AddDAta(productTable table)
        {
            int a = 0;
            // con = new SqlConnection(@"Data Source=DESKTOP-55RJ8FH;Initial Catalog=jootaShopDB;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework");
            string query = "";

            con.Open();
            query = "insert into productTable(name,catagoryID,imagePath,price,quantity) values('" + table.name + "',(select catagoryID from catagoryTable where catagoryName='" + table.catagoryName + "'),'" + table.imagePath + "','" + table.price + "','" + table.quantity + "')";


            SqlCommand cmd = new SqlCommand(query, con);

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


            return(a);
        }