public JsonResult creatRecord(string para01, string para02, string para03) { var b_id = para01; int num; int.TryParse(para02, out num); var date = Convert.ToDateTime(para03); SALES_LOT sALES_LOT = new SALES_LOT(); PRODUCT pRODUCT = db.PRODUCT.Find(b_id); sALES_LOT.PRODUCT = pRODUCT; PRODUCT_ATTRIBUTE pRODUCT_ATTRIBUTE = db.PRODUCT_ATTRIBUTE.Find(pRODUCT.PRODUCT_ID); sALES_LOT.BATCH_ID = b_id; sALES_LOT.PRODUCT.PRODUCT_ID = pRODUCT.PRODUCT_ID; sALES_LOT.PRODUCT.PRODUCT_ATTRIBUTE.PRODUCT_NAME = pRODUCT_ATTRIBUTE.PRODUCT_NAME; sALES_LOT.LOT_NUMBER = num; sALES_LOT.MONEY = num * pRODUCT_ATTRIBUTE.SELL_PRICE * pRODUCT.DISCOUNT; sALES_LOT.LOT_DATE = date; db.SALES_LOT.Add(sALES_LOT); db.SaveChanges(); var list = db.SALES_LOT.Select(n => new { BATCH_ID = n.BATCH_ID, PRODUCT_ID = n.PRODUCT.PRODUCT_ID, PRODUCT_NAME = n.PRODUCT.PRODUCT_ATTRIBUTE.PRODUCT_NAME, LOT_NUMBER = n.LOT_NUMBER, MONEY = n.MONEY, LOT_DATE = n.LOT_DATE }); return(Json(new { code = 0, msg = "", count = 1000, data = list }, JsonRequestBehavior.AllowGet)); }
public ActionResult edit(HttpPostedFileBase hinhanh, PRODUCT sp, string gr_groupid) { PRODUCT spedit = db.PRODUCTs.Find(sp.product_id); if (hinhanh != null) { var filename = Path.GetFileName(hinhanh.FileName); var path = Path.Combine(Server.MapPath("~/images"), filename); hinhanh.SaveAs(path); spedit.image = hinhanh.FileName; } if (gr_groupid == "Man") { spedit.gr_groupid = 1; } else { spedit.gr_groupid = 2; } spedit.product_Name = sp.product_Name; spedit.Description = sp.Description; db.SaveChanges(); return(Redirect("Index")); }
public ActionResult AddNewProduct(Models.Product productLocal) { string fileName = Path.GetFileNameWithoutExtension(productLocal.ImageFile.FileName); string extension = Path.GetExtension(productLocal.ImageFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; productLocal.ProductImg = "~/Image/" + fileName; fileName = Path.Combine(Server.MapPath("~/Image/"), fileName); productLocal.ImageFile.SaveAs(fileName); PRODUCT prodDal = new PRODUCT(); prodDal.ProductName = productLocal.ProductName; prodDal.ProductDescription = productLocal.ProductDescription; prodDal.ProductPrice = productLocal.ProductPrice; prodDal.ProductImg = productLocal.ProductImg; if (operations.AddNewProduct(prodDal)) { ViewBag.prodMessage = "Product details added successfully"; } else { ViewBag.prodMessage = "Failed to add product details"; } ModelState.Clear(); return(View()); }
public ProductResponse SaveProduct(ProductRequest request) { ProductItem item = request.Product; var response = new ProductResponse(); using (var db = new ProductEntities()) { var model = new PRODUCT { NAME = item.Name, QUANTITY = item.Quantity, SALE_AMOUNT = item.SaleAmount }; if (item.Id == null) { db.PRODUCTS.Add(model); } else { model.ID = (int)item.Id; db.Entry(model).State = System.Data.Entity.EntityState.Modified; } db.SaveChanges(); } return(response); }
public ProductResponse Delete(ProductRequest request) { ProductItem item = request.Product; var response = new ProductResponse(); using (var db = new ProductEntities()) { var model = new PRODUCT { ID = (int)item.Id }; var entry = db.Entry(model); if (entry.State == System.Data.Entity.EntityState.Detached) { db.PRODUCTS.Attach(model); } db.PRODUCTS.Remove(model); db.SaveChanges(); } return(response); }
public static int addProduct(PRODUCT p) { using (DAL.Charity_DBEntities db = new DAL.Charity_DBEntities()) { db.Products.Add(Converters.ProductConverter.convertToDal(p)); try { db.SaveChanges(); } catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { System.Diagnostics.Debug.WriteLine( "Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } System.Diagnostics.Debug.WriteLine("no"); } return(db.Products.ToArray().Last().ProductCode); } }
protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.Session == null || HttpContext.Current.Session["admin"] == null) { Response.Redirect("~/LoginP.aspx"); } int id = 0; if (string.IsNullOrEmpty(Request.QueryString["id"]) || !Int32.TryParse(Request.QueryString["id"], out id)) { Response.Redirect("~/MenuP.aspx"); } p = db.PRODUCTs.FirstOrDefault(pr => pr.id_product == id); if (p == null) { Response.Redirect("~/MenuP.aspx"); } Page.Header.Title = string.Format("Fast food - {0}", p.title); if (IsPostBack == false) { TitleTextBox.Text = p.title; CategoryDropDownList.Text = p.category; PriceTextBox.Text = p.price.ToString(); DescriptionTextArea.Text = p.description; ProductImage.ImageUrl = string.Format("~/pictures/products/{0}", p.picture); AvailableCheckBox.Checked = p.available; } }
public HttpResponseMessage deleteProduct([FromBody] PRODUCT p) { Result <PRODUCT> ru = new Result <PRODUCT>(); int result = 0; try { result = DB_Product.deleteProduct(p); if (result == 1) { ru.code = "3020"; ru.success = "true"; ru.message = "删除成功!"; } else { ru.code = "3021"; ru.success = "false"; ru.message = "删除失败"; } } catch (Exception e) { ru.code = "3022"; ru.success = "false"; ru.message = e.Message; } ru.systemTime = Conn.GetTimeStamp(); ru.data = null; return(Conn.toJson(ru)); }
public IHttpActionResult AddProduct(AddProductViewModel p) { using (MobileStoreServiceEntities data = new MobileStoreServiceEntities()) { PRODUCT pro = new PRODUCT(); pro.MODEL = p.Name; pro.MANUFACTURE_ID = (int)getIdMan(p.NSX, data); pro.PRICE = p.Price; pro.QUANTITY = 100; pro.MODEL_ID = "MSP_01"; pro.DELETED = 0; data.PRODUCTs.Add(pro); data.SaveChanges(); PRODUCT_CATEGORY pc = new PRODUCT_CATEGORY(); PRODUCT newPro = data.PRODUCTs.ToList()[data.PRODUCTs.Count() - 1]; pc.PRODUCT_ID = newPro.PRODUCT_ID; pc.CATEGORY_ID = getIdCat(p.Category, data); data.PRODUCT_CATEGORY.Add(pc); data.SaveChanges(); } return(Ok()); }
public ActionResult ProductEdit(int?id) { if (Session["login"] is null) { return(RedirectToAction("Login")); } int idRole = ((USER)Session["login"]).IdRole; if (idRole != 1 && idRole != 2) { return(RedirectToAction("Index")); } PRODUCT product = new PRODUCT(); if (id != null) { using (THUONGMAIDIENTUEntities db = new THUONGMAIDIENTUEntities()) { product = db.PRODUCTs.Where(x => x.IdProduct == id).FirstOrDefault(); if (product.IdUser != ((USER)Session["login"]).IdUser && idRole != 1) { return(RedirectToAction("Product")); } if (product is null) { return(HttpNotFound()); } } } return(View(product)); }
public HttpResponseMessage queryProduct([FromBody] PRODUCT p) { Result <PRODUCT> ru = new Result <PRODUCT>(); List <PRODUCT> lproduct = new List <PRODUCT>(); try { lproduct = DB_Product.getProduct(p.uid); if (lproduct.Count > 0) { ru.code = "3030"; ru.success = "true"; ru.message = "获取成功!"; } else { ru.code = "3031"; ru.success = "false"; ru.message = "无数据"; } } catch (Exception e) { ru.code = "3032"; ru.success = "false"; ru.message = e.Message; } ru.systemTime = Conn.GetTimeStamp(); ru.data = lproduct; return(Conn.toJson(ru)); }
private void mlDownProduct_Click(object sender, EventArgs e) { if (listBoxClothesOnMannequin.SelectedIndex == -1) { return; } if (listBoxClothesOnMannequin.SelectedIndex == listBoxClothesOnMannequin.Items.Count - 1) { return; } int newSelItem = listBoxClothesOnMannequin.SelectedIndex + 1; PRODUCT curItem = listSelectedProduct[listBoxClothesOnMannequin.SelectedIndex]; listSelectedProduct[listBoxClothesOnMannequin.SelectedIndex] = listSelectedProduct[newSelItem]; listSelectedProduct[newSelItem] = curItem; Image curImg = clothes[listBoxClothesOnMannequin.SelectedIndex]; clothes[listBoxClothesOnMannequin.SelectedIndex] = clothes[newSelItem]; clothes[newSelItem] = curImg; UpdateMannequinList(); DrawClothesOnMannequin(clothes); listBoxClothesOnMannequin.SetSelected(newSelItem, true); }
public bool Update(PRODUCT entity) { try { var pro = db.PRODUCT.Find(entity.ID); pro.Name = entity.Name; pro.Metatitle = entity.Metatitle; pro.Description = entity.Description; pro.Price = entity.Price; pro.PromotionPrice = entity.Price; pro.Quantity = entity.Quantity; pro.ModifiedDate = entity.ModifiedDate; pro.Image = entity.Image; pro.MoreImages = entity.MoreImages; pro.Detail = entity.Detail; pro.CreatedDate = DateTime.Now; pro.MetaDescriptions = entity.MetaDescriptions; pro.MetaKeywords = entity.MetaKeywords; pro.CreatedBy = entity.CreatedBy; pro.ModifiedBy = entity.ModifiedBy; pro.Warranty = entity.Warranty; pro.TopHot = entity.TopHot; pro.Like = entity.Like; pro.ViewCount = entity.ViewCount; pro.Status = entity.Status; db.SaveChanges(); return(true); } catch (Exception) { //logging return(false); } }
PRODUCT getInput() { var r = new PRODUCT() { ID = ID, NAME = NAME, DESCRIPTION = DESCRIPTION, CODE = CODE, IMPORTANCE = 0, QUANTITY = QUANTITY, QUANTITY_MIN = QUANTITY_MIN, TYPE = TYPE, TAX_PERCE = TAX_PERCE, MONEY_PURCHASE = MONEY_PURCHASE, MONEY_SELLING_1 = MONEY_SELLING_1, MONEY_SELLING_2 = MONEY_SELLING_1, MONEY_SELLING_3 = MONEY_SELLING_1, MONEY_SELLING_4 = MONEY_SELLING_1, MONEY_SELLING_5 = MONEY_SELLING_1, MONEY_SELLING_MIN = MONEY_SELLING_MIN, DATE_PRODUCTION = DATE_PRODUCTION, DATE_PURCHASE = DATE_PURCHASE, DATE_EXPIRATION = DATE_EXPIRATION, PICTURE = PICTURE_PRODUCT, }; return(r); }
// Xóa giỏ hàng public ActionResult XoaGioHang(int id) { // Kiểm tra giỏ hàng đã tồn tại chưa if (Session["Cart"] == null) { return(RedirectToAction("Index", "Home")); } // Kiểm tra sản phẩm có tồn tại trong CSDL hay không PRODUCT product = db.PRODUCTs.FirstOrDefault(s => s.PRODUCT_ID == id); if (product == null) { // Trang đường dẫn không hợp lệ Response.StatusCode = 404; return(null); } // Lấy list giỏ hàng từ session List <ItemGioHang> lstGioHang = LayGioHang(); ItemGioHang check = lstGioHang.SingleOrDefault(s => s.MaSP == id); if (check == null) { return(RedirectToAction("Index", "Home")); } // Xóa item trong giỏ hàng lstGioHang.Remove(check); return(RedirectToAction("Index")); }
private void btnAdd_Click(object sender, EventArgs e) { try { product = new PRODUCT(); if (idSupply != -1) { product.title = tbName.Text; product.category = tbCategory.Text; product.size = Convert.ToInt32(tbSize.Text); product.color = tbColor.Text; product.photo = ImgConverter.ImageToString(pictureBoxPhoto.Image); product.price = Convert.ToInt32(tbPrice.Text); product.count = Convert.ToInt32(tbCount.Text); product.id_supply = idSupply; } productsControlS.Add(product); Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Create(PRODUCT model) { model.Is_Deleted = false; db.PRODUCTs.Add(model); db.SaveChanges(); }
public ActionResult Create([Bind(Include = "PRODUCT_NAME,PRODUCT_DESCRIPTION,PRICE,CATEGORY_ID")] PRODUCT pRODUCT, HttpPostedFileBase Product_Image) { if (ModelState.IsValid) { if (Product_Image != null) { pRODUCT.PRODUCT_IMAGE = new byte[Product_Image.ContentLength]; Product_Image.InputStream.Read(pRODUCT.PRODUCT_IMAGE, 0, Product_Image.ContentLength); } db.PRODUCTS.Add(pRODUCT); try { db.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } return(RedirectToAction("Index")); } ViewBag.CATEGORY_ID = new SelectList(db.CATEGORIES, "ID", "CATEGORY_NAME", pRODUCT.CATEGORY_ID); return(View(pRODUCT)); }
public ActionResult Create([Bind(Include = "ProdID,CatID,ProdName,Price")] PRODUCT pRODUCT) { if (ModelState.IsValid) { var user = @Session["userName"]; var id = pRODUCT.ProdID; var price = pRODUCT.Price; var cat = pRODUCT.CatID; CART c = new CART(); c.USERNAME = user.ToString(); c.ProdID = id; c.Price = price; c.Cat = cat; db.CARTs.Add(c); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CatID = new SelectList(db.CATEGORies, "CatID", "CatName", pRODUCT.CatID); return(View("Index", "CARTs")); }
public void Can_Remove_Line() { // Arrange - create some test products PRODUCT p1 = new PRODUCT { ProductId = 1, Name = "P1" }; PRODUCT p2 = new PRODUCT { ProductId = 2, Name = "P2" }; PRODUCT p3 = new PRODUCT { ProductId = 3, Name = "P3" }; // Arrange - create a new cart CART target = new CART(); // Arrange - add some products to the cart target.AddItem(p1, 1); target.AddItem(p2, 3); target.AddItem(p3, 5); target.AddItem(p2, 1); // Act target.RemoveLine(p2); // Assert Assert.AreEqual(target.Lines.Where(c => c.Product == p1).Count(), 1); Assert.AreEqual(target.Lines.Where(c => c.Product == p2).Count(), 0); Assert.AreEqual(target.Lines.Where(c => c.Product == p3).Count(), 1); Assert.AreEqual(target.Lines.Count(), 2); }
public ActionResult ProductDetail(int id) { PRODUCT product = new PRODUCT(); product = dbContext.PRODUCT.Where(i => i.ID == id).FirstOrDefault(); return(View(product)); }
public ActionResult Empleado2(String idBorrar) { ViewBag.Message = "Lista de productos"; ViewBag.Message2 = "Lista de ofertas"; ViewBag.listaoferta = bd.OFFER.ToList(); String id = (String.Format("{0,-" + bd.PRODUCT.ToList().First().ID_PRODUCT.Length + "}", idBorrar)); PRODUCT producto = bd.PRODUCT.Find(id); int cantidad = 0; for (int i = 0; i < ((List <PRODUCT>)Session["Productos"]).Count; i++) { if (id == ((List <PRODUCT>)Session["Productos"])[i].ID_PRODUCT) { ((List <PRODUCT>)Session["Productos"]).Remove(((List <PRODUCT>)Session["Productos"])[i]); } } foreach (var item in (List <ProductosCantidad>)Session["Productos_cantidad"]) { if (item.idproducto == idBorrar) { cantidad = item.cantidad; } } Session["Monto Total"] = (decimal)Session["Monto Total"] - producto.UNIT_PRICE * cantidad; return(View("Empleado")); }
public ActionResult Empleado3() { ViewBag.Message = "Lista de productos"; ViewBag.Message2 = "Lista de ofertas"; ViewBag.listaoferta = bd.OFFER.ToList(); foreach (var item in (List <ProductosCantidad>)Session["Productos_cantidad"]) { PRODUCT producto = new PRODUCT(); for (int i = 0; i < ((List <PRODUCT>)Session["Productos"]).Count; i++) { String id = (String.Format("{0,-" + bd.PRODUCT.ToList().First().ID_PRODUCT.Length + "}", item.idproducto)); if (id == ((List <PRODUCT>)Session["Productos"])[i].ID_PRODUCT) { producto = ((List <PRODUCT>)Session["Productos"])[i]; } } bd.DETAIL.Add(new DETAIL { ID_PRODUCT = item.idproducto, ID_SALE = "001", QUANTITY = item.cantidad, SALE_PRICE = producto.UNIT_COST * item.cantidad, DISCOUNT = 0 }); } return(View("Empleado")); }
public ActionResult Productadd(ProductModel productmodel) { var productdao = new ProductDao(); var product = new PRODUCT(); ViewBag.ListBrand = productdao.ListBrand(); ViewBag.ListCategory = productdao.ListCategory(); if (ModelState.IsValid)//kiem tra xem form co rong hay khong { product.productName = productmodel.productName; product.product_Code = productmodel.product_Code; product.productQuantity = productmodel.productQuantity; product.brandId = productmodel.brandId; product.catId = productmodel.catId; product.product_Desc = productmodel.product_Desc; product.images = productmodel.images; product.types = productmodel.types; product.price = productmodel.price; product.procduct_Soldout = "0"; product.product_Remain = product.productQuantity; long id = productdao.Productdadd(product); if (id < 0) { ModelState.AddModelError("", "Thêm thất bại"); return(RedirectToAction("Productadd", "Product")); } else { ViewData["success"] = "Thêm sản phẩm thành công"; } } return(View()); }
private void gridControl1_Click(object sender, EventArgs e) { if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[0]) != null) { if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[0]).ToString() != "") { PRODUCT objproduct = new PRODUCT(); if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[0]) != null) { string test = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[0]).ToString(); objproduct = new PRODUCTController().PRODUCT_Get(test.ToString()); if (objproduct.Product_Name.Trim() != gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[1]).ToString()) { gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[1], gridView2.GetRowCellDisplayText(GlobalRowSelect, "Product_Name")); gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[2], gridView2.GetRowCellDisplayText(GlobalRowSelect, "Stock_ID")); gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[3], new UNITController().UNIT_Get(objproduct.Unit).Unit_ID); gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[4], "1"); gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[5], double.Parse(gridView2.GetRowCellDisplayText(GlobalRowSelect, "Org_Price"))); gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[6], objproduct.VAT_ID); gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[8], objproduct.Discount); } gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[7], double.Parse(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[4]).ToString()) * double.Parse(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[5]).ToString())); } } } }
public ActionResult Edit(ProductModel productmodel, int id) { var dao = new ProductDao(); var product = new PRODUCT(); ViewBag.ListBrand = dao.ListBrand(); ViewBag.ListCategory = dao.ListCategory(); ViewBag.types = product.types; if (ModelState.IsValid)//kiem tra xem form co rong hay khong { product.productName = productmodel.productName; product.product_Code = productmodel.product_Code; product.productQuantity = productmodel.productQuantity; product.brandId = productmodel.brandId; product.catId = productmodel.catId; product.product_Desc = productmodel.product_Desc; product.images = productmodel.images; product.types = productmodel.types; product.price = productmodel.price; product.procduct_Soldout = "0"; product.product_Remain = product.productQuantity; var result = dao.UpdateProduct(product, id); if (result) { //ViewData["success"] = "Sửa thương hiệu thành công"; return(RedirectToAction("Productlist")); } else { ModelState.AddModelError("", "Sửa thương hiệu thất bại"); } } return(View()); }
public ActionResult EnterProduct(ProductModel productmodel, int id) { string soluong = Request.Form["product_more_quantity"]; var dao = new ProductDao(); var product = new PRODUCT(); var warehouse = new WAREHOUSE(); if (soluong == "") { ViewData["error"] = "Hãy nhập số lượng sản phẩm "; } else { product.product_Remain = (Convert.ToInt32(productmodel.product_Remain) + Convert.ToInt32(soluong)).ToString(); warehouse.product_more_quantity = soluong; warehouse.productId = id; warehouse.sl_Ngaynhap = DateTime.Now; var result = dao.EnterProduct(product, id); if (result) { ViewData["success"] = "Nhập thêm hàng thành công"; dao.InsertWareHose(warehouse, id); } else { ViewData["error"] = "Nhập thêm hàng thất bại"; } } return(View()); }
public void Load_Data(PRODUCT objproduct) { //MemoryStream fs1 = new MemoryStream(objproduct.Photo, true); //if (fs1.Length != 1) //{ // pictureEdit1.Image = Image.FromStream(fs1); // pictureEdit1.Refresh(); //} this.objproduct = objproduct; gridLookUpNganh.EditValue = new PRODUCT_GROUPController().PRODUCT_GROUP_Get(objproduct.Product_Group_ID).ID_NGANH; cboloaihang.SelectedIndex = objproduct.Product_Type_ID; lookkho.EditValue = objproduct.Provider_ID; lookphanloai.Properties.DataSource = new PRODUCT_GROUPController().PRODUCT_GROUP_GetByNganh(new PRODUCT_GROUPController().PRODUCT_GROUP_Get(objproduct.Product_Group_ID).ID_NGANH); lookphanloai.EditValue = objproduct.Product_Group_ID; txtMa.Text = objproduct.Product_ID; txtbarcode.Text = objproduct.Barcode; txtten.Text = objproduct.Product_Name; lookdonvi.EditValue = objproduct.Unit; txtxuatxu.Text = objproduct.Origin; caltoithieu.Text = objproduct.MinStock.ToString(); calhientai.Text = "0"; looknhacungcap.EditValue = objproduct.Customer_ID; calcgiamua.Text = objproduct.Org_Price.ToString(); calcgiasi.Text = objproduct.Sale_Price.ToString(); calcgiale.Text = objproduct.Retail_Price.ToString(); }
public ActionResult GetOnlyProducto(string Id) { try { PRODUCT em = new PRODUCT(); if (!string.IsNullOrEmpty(Id)) { using (ADMIN_PORTAL.Models.UTNIMASEntities db = new ADMIN_PORTAL.Models.UTNIMASEntities()) { em = db.PRODUCTS.Find(int.Parse(Id)); } Productoz e3 = new Productoz { PRODUCTO_ID = em.PRODUCTO_ID, NOMBRE_PRODUCTO = em.NOMBRE_PRODUCTO, ID_PRECIO = em.ID_PRECIO.ToString(), DESCRIP_PRODUCTO = em.DESCRIP_PRODUCTO, FOTO_PRODUCTO = em.FOTO_PRODUCTO.ToString(), EMPRESA_ID = em.EMPRESA_ID.ToString() }; return(Json(new { Success = true, data = e3, status = 200 }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = true, data = "Error", status = 200 }, JsonRequestBehavior.AllowGet)); } catch (Exception) { throw; } }
// Create public int Create(PRODUCT productModel) { productModel.Is_Deleted = false; db.PRODUCTs.Add(productModel); db.SaveChanges(); return(productModel.Id_Product); }
public ActionResult Create(PRODUCT product) { if (ModelState.IsValid) { db.PRODUCTS.AddObject(product); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.SUPPLIER_ID = new SelectList(db.SUPPLIERS, "ID", "NAME", product.SUPPLIER_ID); return View(product); }
public ActionResult Product_New(PRODUCT newProduct) { try { BLTServiceCaller serviceCaller = BLTServiceCaller.Instance; var request = new RestRequest(Method.POST); request.Resource = "/Products"; request.RequestFormat = DataFormat.Xml; request.AddHeader("Content-Type", "application/xml"); //Use extended serializer BLTWebSerializer serializer = new BLTWebSerializer(); request.AddParameter("application/xml", serializer.Serialize<PRODUCT>(newProduct), ParameterType.RequestBody); PRODUCT createdProd = serviceCaller.Execute<PRODUCT>(request); //now activate it for use //request = new RestRequest(); //request.Resource = "/Products/{entityID}/Activate?ActiveDate={date}"; //request.RootElement = "PRODUCT"; //request.AddParameter("entityID", createdProd.ID, ParameterType.UrlSegment); //PRODUCT activatedProd = serviceCaller.Execute<PRODUCT>(request); return RedirectToAction("../Parts/Index"); } catch (Exception e) { return View(e.ToString()); } }
public ActionResult Product_Edit(int id, PRODUCT editedProduct) { BLTServiceCaller serviceCaller = BLTServiceCaller.Instance; var request = new RestRequest(Method.POST); request.Resource = "/Products/{entityID}"; request.RequestFormat = DataFormat.Xml; request.AddParameter("entityID", id, ParameterType.UrlSegment); request.AddHeader("X-HTTP-Method-Override", "PUT"); //Use extended serializer BLTWebSerializer serializer = new BLTWebSerializer(); request.AddParameter("application/xml", serializer.Serialize<PRODUCT>(editedProduct), ParameterType.RequestBody); PRODUCT updatedProduct = serviceCaller.Execute<PRODUCT>(request); //update the AI and go back to the AI index return RedirectToAction("Index"); }
public ActionResult Edit(PRODUCT product) { if (ModelState.IsValid) { db.PRODUCTS.Attach(product); db.ObjectStateManager.ChangeObjectState(product, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.SUPPLIER_ID = new SelectList(db.SUPPLIERS, "ID", "NAME", product.SUPPLIER_ID); return View(product); }