public async Task <IActionResult> Edit(int id, [Bind("Id,Product_Name,Price,Brand_DetailId,Category_DetailId")] Product_Detail product_Detail) { if (id != product_Detail.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product_Detail); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Product_DetailExists(product_Detail.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Brand_DetailId"] = new SelectList(_context.Brand_Detail, "Id", "Brand_Name", product_Detail.Brand_DetailId); ViewData["Category_DetailId"] = new SelectList(_context.Category_Detail, "Id", "Product", product_Detail.Category_DetailId); return(View(product_Detail)); }
protected void hienthiTT() { //khai bao doi tuong Product_Detail similar = new Product_Detail(); if (Request.QueryString["category_id"] != null) { similar.category_id = Int32.Parse(Request.QueryString["category_id"]); } List <Product> List = data2.getListProduct(similar, 1, 0); string tmp = ""; for (int i = 0; i < List.Count; i++) { Product p = List[i]; tmp += "<div class=\"owl-item\">"; tmp += "<div class=\"viewed_item is_new d-flex flex-column align-items-center justify-content-center text-center\">"; tmp += "<div class=\"viewed_image\"><img src=\"/Web/images/" + p.image + "\" alt=\"\"></div>"; tmp += "<div class=\"viewed_content text-center\">"; tmp += "<div class=\"viewed_price\">" + p.price.ToString("#,##0").Replace(',', '.') + "</div>"; tmp += "<div class=\"viewed_name\"><a href=\"/HomeXQ/product_detail.aspx?product_id=" + p.product_id + "\">" + p.product_name + "</a></div>"; tmp += "</div>"; tmp += "<ul class=\"item_marks\">"; //tmp += "<li class=\"item_mark item_discount\">-25%</li>"; tmp += "<li class=\"item_mark item_new\">new</li>"; tmp += "</ul>"; tmp += "</div>"; tmp += "</div>"; Response.Write(tmp); } }
public Product_Detail getCart(int product_id, int color_id) { Product_Detail pd = null; //Cau lenh truy van string sqlSelect = "SELECT * FROM dbo.product_detail left join product on product_detail.product_id = product.product_id where product_detail.product_id = '" + product_id + "'and color_id = '" + color_id + "'"; //string sqlSelect = "SELECT * FROM dbo.product_detail where product_detail.product_id = '" + product_id + "'"; //Mo cong ket noi conn.Open(); //Thuc thi cau lenh SqlCommand cmd = new SqlCommand(sqlSelect, conn); //Doc du lieu tren table trong sql SqlDataReader rd = cmd.ExecuteReader(); //doi tuong if (rd.Read()) { pd = new Product_Detail(); pd.product_detail_id = (int)rd["product_detail_id"]; pd.product_id = (int)rd["product_id"]; // pd.size_id = (int)rd["size_id"]; pd.color_id = (int)rd["color_id"]; pd.quantity = (int)rd["quantity"]; pd.product_name = (string)rd["product_name"]; pd.price = (int)rd["price"]; pd.image = (string)rd["image"]; } //Dong bo quan ly ket noi conn.Close(); return(pd); }
protected void Page_Load(object sender, EventArgs e) { int product_detail_id = int.Parse(Request.QueryString["id"]); int quantity = Int32.Parse(Request.QueryString["quantity"]); if (Session["giohang"] != null) { if (product_detail_id != null) { List <Product_Detail> shopppingCart = Session["giohang"] as List <Product_Detail>; Product_Detail cardItem = shopppingCart.Single(p => p.product_detail_id == product_detail_id); //shopppingCart.Remove(cardItem); if (cardItem != null) { cardItem.quantity = quantity; Response.Write("hello" + product_detail_id); } //if (Request.QueryString["qua"] == "plus") //{ // cardItem.quantity++; //} Response.Redirect("cart.aspx"); } //Response.Write("hello 111" + product_detail_id); } else { Response.Write("hello" + product_detail_id); } // int sl = Int32.Parse(Request["quantity_input"]); // Response.Write("hello" + sl); }
public void EditarVenta(int pk, String des, String idClient, String name, String email, String phone, double dis) { FAJA_MODELDataContext dc = new FAJA_MODELDataContext(); Sale_Bill Venta = dc.Sale_Bill.First(c => c.SalBil_Pk == pk); Venta.SalBil_Description = des; Venta.SalBil_IdClient = idClient; Venta.SalBil_ClientName = name; Venta.SalBil_ClientEmail = email; Venta.SalBil_PhoneClient = phone; double cGross = 0; foreach (BOP_FAJAS_spListarDetalleVentasResult DBB in spListarDetalleVentas(pk)) { cGross += Convert.ToDouble(DBB.Pro_SalePrice * DBB.DetSalBil_Quantity - DBB.DetSalBil_Detail); Product_Detail Producto = dc.Product_Detail.FirstOrDefault(c => c.ProDet_PK == DBB.DetBil_FK_ProDet); Producto.ProDet_Quantity -= (int)DBB.DetSalBil_Quantity; dc.SubmitChanges(); } Venta.SalBil_GrossTotal = cGross; Venta.SalBil_Tax = cGross * 0.13; Venta.SalBil_Discount = dis; Venta.SalBil_NetTotal = cGross - dis + cGross * 0.13; Venta.SalBil_Status = "A"; dc.SubmitChanges(); }
private List <Product_Detail> DicToDetails(Dictionary <string, object> dic, IEnumerable <CustomField> customfields) { var result = new List <Product_Detail>(); foreach (var item in dic) { var pattern = @"(\[(?:.*?)\])"; var fieldNames = System.Text.RegularExpressions.Regex.Split(item.Key, pattern).FirstOrDefault(); var customfield = customfields.FirstOrDefault(o => o.Name == fieldNames.Split('-').FirstOrDefault()); var detail = new Product_Detail { Name = customfield.Name, Type = customfield.ValueType, }; var value = (item.Value as string[]); if (customfield.Type == (int)FieldTypes.File) { detail.FileId = value.FirstOrDefault(); } else if (customfield.Type == (int)FieldTypes.Select) { detail.EnumId = int.Parse(value.FirstOrDefault()); } else { detail.Value = value.FirstOrDefault() != string.Empty ? value.FirstOrDefault() : null; } result.Add(detail); } return(result); }
public ActionResult DeleteConfirmed(int id) { Product_Detail product_Detail = db.Product_Detail.Find(id); db.Product_Detail.Remove(product_Detail); db.SaveChanges(); return(RedirectToAction("Index")); }
public void EliminarDetalle(int det) { FAJA_MODELDataContext dc = new FAJA_MODELDataContext(); Product_Detail Producto = dc.Product_Detail.First(c => c.ProDet_PK == det); Producto.ProDet_Status = "I"; dc.SubmitChanges(); }
protected void Page_Load(object sender, EventArgs e) { //Lấy id //int comd = Int32.Parse(Request.Form["command111"]); // int id = Int32.Parse(Request.Form["quantity_input"]); int quantity = Int32.Parse(Request["quantity_input"]); int product_id = Int32.Parse(Request["product_id"]); int color_id = Int32.Parse(Request["color_id"]); //lay san pham theo id Product item = new Product(); Product_Detail pdd = data.getCart(product_id, color_id); //item = product.getProduct(product_id); //Lay chi tiet san pham Product_Detail detail = new Product_Detail(); detail.product_detail_id = pdd.product_detail_id; detail.product_id = pdd.product_id; detail.product_name = pdd.product_name; detail.image = pdd.image; detail.price = pdd.price; detail.color_id = color_id; //tao danh sach gio hang List <Product_Detail> ds = (List <Product_Detail>)Session["giohang"]; if (ds == null) { ds = new List <Product_Detail>(); } else //int c = li.i { // Product_Detail x = new Product_Detail(); // x.product_id = 10; // ds.Remove(x); if (ds.Any(prod => prod.product_id == detail.product_id && prod.color_id == detail.color_id)) { //Response.Write("<br/>Ban da mua " + ds.Count + " nay roi <br/>"); for (int i = 0; i < ds.Count; i++) { Product_Detail prd = ds[i]; prd.quantity = prd.quantity + quantity; } } else { detail.quantity = quantity; ds.Add(detail); } } Session["giohang"] = ds; Response.Redirect("Cart.aspx"); }
public List <Product> getListProduct(Product_Detail similar, int orderby, int color) { //Tao danh sach List <Product> ds = new List <Product>(); //Cau lenh truy van string conds = MakeConnection.createCondition(similar); string sqlSelect = "SELECT * FROM dbo.product left join dbo.category on category.category_id = product.category_id "; if (color == 1) { sqlSelect += "left join dbo.product_detail on product.product_id=product_detail.product_id "; } if (conds != "") { sqlSelect += "WHERE " + conds; } sqlSelect += " ORDER BY "; switch (orderby) { case 1: sqlSelect += "product.product_id ASC "; break; case 2: sqlSelect += "product.price ASC "; break; case 3: sqlSelect += "product.price DESC "; break; case 4: sqlSelect += "product.product_id DESC "; break; } //sqlSelect += " LIMIT 3 "; //Mo cong ket noi conn.Open(); //Thuc thi cau lenh SqlCommand cmd = new SqlCommand(sqlSelect, conn); //Doc du lieu tren table trong sql SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { Product p = new Product(); p.product_id = (int)rd["product_id"]; p.product_name = (string)rd["product_name"]; p.category_id = (int)rd["category_id"]; p.descriptions = (string)rd["descriptions"]; p.image = (string)rd["image"]; p.price = (int)rd["price"]; ds.Add(p); } //Dong bo quan ly ket noi conn.Close(); return(ds); }
public void EditarDetalle(int det, int pro, int col, int siz, int qua) { FAJA_MODELDataContext dc = new FAJA_MODELDataContext(); Product_Detail Producto = dc.Product_Detail.First(c => c.ProDet_PK == det); Producto.ProDet_FKk_Pro = pro; Producto.ProDet_FK_ProCol = col; Producto.ProDet_FK_ProSiz = siz; Producto.ProDet_Quantity = qua; dc.SubmitChanges(); }
public ActionResult Edit([Bind(Include = "productDetail_id,properties,propertiesDetail,product_id")] Product_Detail product_Detail) { if (ModelState.IsValid) { db.Entry(product_Detail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.product_id = new SelectList(db.Product, "product_id", "productName", product_Detail.product_id); return(View(product_Detail)); }
public static string createCondition(Product_Detail similar) { string conds = ""; if (similar != null) { int id = similar.product_id; if (id > 0) { conds += " product.product_id = " + id; } string product_name = similar.product_name; if (product_name != null && product_name != "") { if (conds != "") { conds += " AND "; } conds += " (product.product_name like '%" + product_name + "%') "; } int pc_id = similar.category_id; if (pc_id > 0) { if (conds != "") { conds += " AND "; } conds += " product.category_id = " + pc_id; } //string price = similar.price; //if (price != null&& price!="" ) //{ // if (conds != "") // { // conds += " AND "; // } // conds += " product.price = " + price; //} int color_id = similar.color_id; if (color_id > 0) { if (conds != "") { conds += " AND "; } conds += " product_detail.color_id = " + color_id; } } Console.Write(conds); return(conds); }
public void EditarDetalleCompra(int id) { FAJA_MODELDataContext dc = new FAJA_MODELDataContext(); Detail_Buy_Bill Compra = dc.Detail_Buy_Bill.First(c => c.DetBuyBil_PK == id); Compra.DetBuyBil_Status = "A"; dc.SubmitChanges(); Product_Detail Producto = dc.Product_Detail.First(c => c.ProDet_PK == Compra.DetBuyBil_FK_DetPro); Producto.ProDet_Quantity = Producto.ProDet_Quantity + Compra.DetBuyBil_Quantity; dc.SubmitChanges(); }
public async Task <IActionResult> Create([Bind("Id,Product_Name,Price,Brand_DetailId,Category_DetailId")] Product_Detail product_Detail) { if (ModelState.IsValid) { _context.Add(product_Detail); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Brand_DetailId"] = new SelectList(_context.Brand_Detail, "Id", "Brand_Name", product_Detail.Brand_DetailId); ViewData["Category_DetailId"] = new SelectList(_context.Category_Detail, "Id", "Product", product_Detail.Category_DetailId); return(View(product_Detail)); }
public double EliminarDetalleVenta(int pk) { double resultado = 0; FAJA_MODELDataContext dc = new FAJA_MODELDataContext(); Detail_Sale_Bill DetalleVenta = dc.Detail_Sale_Bill.First(c => c.DetBil_PK == pk); Product_Detail Detalle = dc.Product_Detail.First(c => c.ProDet_PK == DetalleVenta.DetBil_FK_ProDet); Product Producto = dc.Product.First(c => c.Pro_Pk == Detalle.ProDet_FKk_Pro); resultado = Convert.ToDouble(Producto.Pro_SalePrice * DetalleVenta.DetSalBil_Quantity - DetalleVenta.DetSalBil_Detail); dc.Detail_Sale_Bill.DeleteOnSubmit(DetalleVenta); dc.SubmitChanges(); return(resultado); }
public void EliminarDetalleCompra(int id) { FAJA_MODELDataContext dc = new FAJA_MODELDataContext(); Detail_Buy_Bill Compra = dc.Detail_Buy_Bill.First(c => c.DetBuyBil_PK == id); if (Compra.DetBuyBil_Status.Equals("A")) { Product_Detail Producto = dc.Product_Detail.First(c => c.ProDet_PK == Compra.DetBuyBil_FK_DetPro); Producto.ProDet_Quantity = Producto.ProDet_Quantity - Compra.DetBuyBil_Quantity; dc.SubmitChanges(); } Compra.DetBuyBil_Status = "I"; dc.SubmitChanges(); }
public void RegistrarDetalle(int pro, int col, int siz, int qua) { FAJA_MODELDataContext dc = new FAJA_MODELDataContext(); Product_Detail Producto = new Product_Detail(); Producto.ProDet_PK = IdentificadorDetalle(); Producto.ProDet_FKk_Pro = pro; Producto.ProDet_FK_ProCol = col; Producto.ProDet_FK_ProSiz = siz; Producto.ProDet_Quantity = qua; Producto.ProDet_Status = "A"; dc.Product_Detail.InsertOnSubmit(Producto); dc.SubmitChanges(); }
// GET: Product_Detail/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Product_Detail product_Detail = db.Product_Detail.Find(id); if (product_Detail == null) { return(HttpNotFound()); } return(View(product_Detail)); }
protected void hienthi() { //doi tuong truy van Product_Detail similar = new Product_Detail(); int orderby = 1; int color = 0; //int category_id = Int32.Parse(Request.QueryString["category_id"]); if (Request.QueryString["category_id"] != null) { similar.category_id = Int32.Parse(Request.QueryString["category_id"]); } if (Request.QueryString["color_id"] != null && Request.QueryString["color"] != null) { similar.color_id = Int32.Parse(Request.QueryString["color_id"]); color = 1; } if (Request.Form["product_name"] != null && Request.Form["product_name"] != "") { similar.product_name = Request.Form["product_name"]; //Response.Write(Request.Form["product_name"].ToString()); } if (Request.QueryString["orderby"] != null) { orderby = Int32.Parse(Request.QueryString["orderby"]); } List <Product> ds = data.getListProduct(similar, orderby, color); for (int i = 0; i < ds.Count(); i++) { Product p = new Product(); p = ds[i]; string tmp = ""; tmp += "<div class='product_item is_new'>"; tmp += "<div class='product_border'></div>"; tmp += "<div class='product_image d-flex flex-column align-items-center justify-content-center'><img style='width=115px;height:115px;' src='/Web/images/" + p.image + "' alt=''></div>"; tmp += "<div class='product_content'>"; tmp += "<div class='product_price'>" + p.price.ToString("#,##0").Replace(',', '.') + "</div>"; tmp += "<div class='product_name'><div><a href='/HomeXQ/product_detail.aspx?product_id=" + p.product_id + "&category_id=" + p.category_id + "' tabindex='0'>" + p.product_name + "</a></div></div>"; tmp += "</div>"; tmp += "<div class='product_fav'><i class='fas fa-heart'></i></div>"; tmp += "<ul class='product_marks'>"; //tmp +="<li class='product_mark product_discount'>-25%</li>"; tmp += "<li class='product_mark product_new'>new</li>"; tmp += "</ul>"; tmp += "</div>"; Response.Write(tmp); } }
// GET: Product_Detail/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Product_Detail product_Detail = db.Product_Detail.Find(id); if (product_Detail == null) { return(HttpNotFound()); } ViewBag.product_id = new SelectList(db.Product, "product_id", "productName", product_Detail.product_id); return(View(product_Detail)); }
public double RegistrarDetalleVenta(int idVenta, int detpro, double descuento, int cantidad) { FAJA_MODELDataContext dc = new FAJA_MODELDataContext(); Detail_Sale_Bill Venta = new Detail_Sale_Bill(); Venta.DetBil_FK_ProDet = detpro; Venta.DetBil_FK_BuyBil = idVenta; Venta.DetSalBil_Detail = descuento; Venta.DetSalBil_Quantity = cantidad; dc.Detail_Sale_Bill.InsertOnSubmit(Venta); dc.SubmitChanges(); Product_Detail Detalle = dc.Product_Detail.First(c => c.ProDet_PK == detpro); Product Producto = dc.Product.First(c => c.Pro_Pk == Detalle.ProDet_FKk_Pro); return(Producto.Pro_SalePrice * cantidad - descuento); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Product_Detail = await _context.Product_Detail.FindAsync(id); if (Product_Detail != null) { _context.Product_Detail.Remove(Product_Detail); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Product_Detail = await _context.Product_Detail .Include(p => p.Brand_Detail) .Include(p => p.Category_Detail).FirstOrDefaultAsync(m => m.Id == id); if (Product_Detail == null) { return(NotFound()); } return(Page()); }
public void EliminarVenta(int pk) { FAJA_MODELDataContext dc = new FAJA_MODELDataContext(); Sale_Bill Venta = dc.Sale_Bill.First(c => c.SalBil_Pk == pk); if (Venta.SalBil_Status.Equals("A")) { foreach (BOP_FAJAS_spListarDetalleVentasResult DBB in spListarDetalleVentas(pk)) { Product_Detail Producto = dc.Product_Detail.FirstOrDefault(c => c.ProDet_PK == DBB.DetBil_FK_ProDet); Producto.ProDet_Quantity += (int)DBB.DetSalBil_Quantity; dc.SubmitChanges(); } } Venta.SalBil_Status = "I"; dc.SubmitChanges(); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Product_Detail = await _context.Product_Detail .Include(p => p.Brand_Detail) .Include(p => p.Category_Detail).FirstOrDefaultAsync(m => m.Id == id); if (Product_Detail == null) { return(NotFound()); } ViewData["Brand_DetailId"] = new SelectList(_context.Brand_Detail, "Id", "Brand_Name"); ViewData["Category_DetailId"] = new SelectList(_context.Category_Detail, "Id", "Product"); return(Page()); }
protected void Page_Load(object sender, EventArgs e) { int product_detail_id = int.Parse(Request.QueryString["id"]); if (Session["giohang"] != null) { if (product_detail_id > 0) { List <Product_Detail> shopppingCart = Session["giohang"] as List <Product_Detail>; Product_Detail cardItem = shopppingCart.Single(p => p.product_detail_id == product_detail_id); shopppingCart.Remove(cardItem); Response.Redirect("cart.aspx"); } Response.Redirect("cart.aspx"); } else { Response.Write("hello" + product_detail_id); } }
protected void hienthi() { Product_Detail similar = new Product_Detail(); List <Product> ds = data.getListProduct(similar, 4, 0); for (int i = 0; i < ds.Count(); i++) { Product p = new Product(); p = ds[i]; string tmp = ""; tmp += "<div class=\"featured_slider_item\">"; tmp += "<div class=\"border_active\"></div>"; tmp += "<div class=\"product_item discount d-flex flex-column align-items-center justify-content-center text-center\">"; tmp += "<div class=\"product_image d-flex flex-column align-items-center justify-content-center\"><img style='width:115px;height:115px;' src=\"/Web/images/" + p.image + "\" alt=\"\" /></div>"; tmp += "<div class=\"product_content\">"; tmp += "<div class=\"product_price discount\"><span>" + p.price.ToString("#,##0").Replace(',', '.') + " đ</span></div>"; tmp += "<div class=\"product_name\"><div><a href=\"product.html\">" + p.product_name + "...</a></div></div>"; tmp += "<div class=\"product_extras\">"; tmp += "<div class=\"product_color\">"; tmp += "<input type=\"radio\" checked name=\"product_color\" style=\"background:#b19c83\">"; tmp += "<input type=\"radio\" name=\"product_color\" style=\"background:#000000\">"; tmp += "<input type=\"radio\" name=\"product_color\" style=\"background:#999999\">"; tmp += "</div>"; tmp += "<button class=\"product_cart_button\"><a href='/HomeXQ/product_detail.aspx?product_id=" + p.product_id + "&category_id=" + p.category_id + "' tabindex='0'>Xem chi tiết</a></button>"; tmp += "</div>"; tmp += "</div>"; tmp += "<div class=\"product_fav\"><i class=\"fas fa-heart\"></i></div>"; tmp += "<ul class=\"product_marks\">"; //tmp +="<li class=\"product_mark product_discount\">-25%</li>"; tmp += "<li class=\"product_mark product_new\">new</li>"; tmp += "</ul>"; tmp += "</div>"; tmp += "</div>"; tmp += ""; Response.Write(tmp); } }
public Product_Detail getProduct_detailByID(int id) { Product_Detail pd = null; //Cau lenh truy van string sqlSelect = "SELECT * FROM dbo.product_detail where product_detail.product_detail_id = '" + id + "'"; //string sqlSelect = "SELECT * FROM dbo.product_detail where product_detail.product_id = '" + product_id + "'"; //Mo cong ket noi conn.Open(); //Thuc thi cau lenh SqlCommand cmd = new SqlCommand(sqlSelect, conn); //Doc du lieu tren table trong sql SqlDataReader rd = cmd.ExecuteReader(); //doi tuong if (rd.Read()) { pd = new Product_Detail(); pd.quantity = (int)rd["quantity"]; } //Dong bo quan ly ket noi conn.Close(); return(pd); }
public override bool Equals(object obj) { Product_Detail p = (Product_Detail)obj; return(p.product_detail_id == product_detail_id); }