public ActionResult DeleteConfirmed(int id) { try { Product_Master product_Master = db.Product_Master.Find(id); db.Product_Master.Remove(product_Master); db.SaveChanges(); return(RedirectToAction("Index")); } catch (System.Data.Entity.Infrastructure.DbUpdateException ue) { Console.WriteLine(ue.InnerException); // return View("~/Views/Shared/Error.cshtml"); return(View("ActiveRecordException")); // throw; } catch (Exception e) { Console.WriteLine(e.InnerException); // ViewBag.Message = "Foreign key violation"; return(View("Error")); // throw; } }
public JsonResult PriceGST(int ProductID) { decimal GSTRate = 0; decimal Rate = 0; decimal[] GSTRateArray = new decimal[2]; Product_Master productRow = db.Product_Master.Single(x => x.Id == ProductID); GSTRate = productRow.GST_rate; Rate = productRow.Rate; GSTRateArray[0] = Rate; GSTRateArray[1] = GSTRate; return(Json(GSTRateArray)); }
private void GetData() { var objC = from objV in dbJalagam.Product_Masters where objV.Id == Convert.ToInt32(Request.QueryString["Id"]) select objV; Product_Master objK = objC.SingleOrDefault(); ddlBatteryType.Text = Convert.ToString(objK.BatteryType); txtColor.Text = Convert.ToString(objK.Color); txtPName.Text = Convert.ToString(objK.Price); txtDesc.Text = Convert.ToString(objK.Description); txtProductCode.Text = Convert.ToString(objK.Prodcut_Code); txtPName.Text = Convert.ToString(objK.ProductName); txtTags.Text = Convert.ToString(objK.Tags); txtPrice.Text = Convert.ToString(objK.Price); }
private void GetData() { var objC = from objV in dbJalagam.Product_Masters where objV.Id == Convert.ToInt32(litPId.Text) select objV; Product_Master objK = objC.SingleOrDefault(); lblBatteryType.Text = Convert.ToString(objK.BatteryType); lblColor.Text = Convert.ToString(objK.Color); //lblPrice.Text = Convert.ToString(objK.Price); lblDescription.Text = Convert.ToString(objK.Description); lblProductCode.Text = Convert.ToString(objK.Prodcut_Code); lblProductName.Text = Convert.ToString(objK.ProductName); lblTags.Text = Convert.ToString(objK.Tags); imgProductImage.ImageUrl = "Load-Image.aspx?DisplayPhoto=" + Convert.ToInt32(litPId.Text); }
public ActionResult Edit([Bind(Include = "Id,Product_name,Category,Rate,GST_rate")] Product_Master product_Master) { try { if (ModelState.IsValid) { db.Entry(product_Master).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(product_Master)); } catch (Exception e) { Console.WriteLine(e.InnerException); return(View("Error")); // throw; } }
// GET: Product_Master/Edit/5 public ActionResult Edit(int?id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Product_Master product_Master = db.Product_Master.Find(id); if (product_Master == null) { return(HttpNotFound()); } return(View(product_Master)); } catch (Exception e) { Console.WriteLine(e.InnerException); return(View("Error")); // throw; } }
private void Save() { Product_Master objK = new Product_Master(); // objU.UserEmailId = Context.User.Identity.Name.ToString(); objK.Prodcut_Code = Convert.ToString(txtProductCode.Text); objK.Price = Convert.ToString(txtPrice.Text); objK.ProductName = Convert.ToString(txtPName.Text); objK.BatteryType = Convert.ToString(ddlBatteryType.SelectedItem.Text); objK.Color = Convert.ToString(txtColor.Text); objK.Description = Convert.ToString(txtDesc.Text); objK.Tags = Convert.ToString(txtTags.Text); objK.CreateDate = DateTime.Now; objK.CreatedBy = Context.User.Identity.Name.ToString(); if (fupDisplayImage.HasFile) { using (System.IO.BinaryReader reader = new System.IO.BinaryReader(fupDisplayImage.PostedFile.InputStream)) { objK.DisplayImage = reader.ReadBytes(fupDisplayImage.PostedFile.ContentLength); } } else { objK.DisplayImage = null; } dbJalagam.Product_Masters.InsertOnSubmit(objK); dbJalagam.SubmitChanges(); SaveAlbum(Convert.ToInt16(objK.Id)); clsPublic.ClearControls(Page.Controls); lblMsg.Text = "<div><i class='fa fa-check fa-2x'></i>" + "Submitted Successfully" + "</div>"; }
public ActionResult Create([Bind(Include = "Id,Product_name,Category,Rate,GST_rate")] Product_Master product_Master) { try { if (ModelState.IsValid) { product_Master.Product_name = product_Master.Product_name.Trim(); product_Master.Category = product_Master.Category.Trim(); db.Product_Master.Add(product_Master); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(product_Master)); } catch (Exception e) { Console.WriteLine(e.InnerException); return(View("Error")); // throw; } }
public IHttpActionResult AddProduct(Products P) { var DB = new AngularDemoEntities(); try { if (P != null) { byte[] ImageFile = null; if (!string.IsNullOrEmpty(P.ProductImage)) { ImageFile = Convert.FromBase64String(P.ProductImage.Split(',')[1]); } Product_Master Obj_P = new Product_Master { CategoryID = P.CategoryID, InStock = P.InStock, ProductImage = ImageFile, ProductName = P.ProductName, ProductPrice = P.ProductPrice, ProductQuantity = P.ProductQuantity, ProductDescription = P.ProductDescription }; DB.Product_Master.Add(Obj_P); DB.SaveChanges(); return(Ok("success")); } else { return(NotFound()); } } catch (Exception ex) { throw ex.InnerException; } }
protected void Page_Load(object sender, EventArgs e) { if (Convert.ToString(Request.QueryString["GId"]) != null) { Response.Buffer = true; Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); { var obj = (from objImg in dbJalagam.Photo_Gallery_Image_Dets where objImg.GalleryId == Convert.ToInt16(Request["GId"]) select objImg).Take(1); Photo_Gallery_Image_Det objI; objI = obj.SingleOrDefault(); if (objI != null) { if (Convert.ToString(objI.Photo).Length != 0) { Byte[] bytImage = (Byte[])objI.Photo.ToArray(); Response.BinaryWrite(bytImage); } } } } if (Convert.ToString(Request.QueryString["PhotoGalleryPhoto"]) != null) { Response.Buffer = true; Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); { var objA = from objImg in dbJalagam.Photo_Gallery_Image_Dets where objImg.PhotoId == Convert.ToInt16(Request["PhotoGalleryPhoto"]) select objImg; Photo_Gallery_Image_Det objC = objA.FirstOrDefault(); if (objC != null) { if (Convert.ToString(objC.Photo).Length != 0) { Byte[] bytImage = (Byte[])objC.Photo.ToArray(); Response.BinaryWrite(bytImage); } } } } if (Convert.ToString(Request.QueryString["DisplayPhoto"]) != null) { Response.Buffer = true; Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); { var objA = from objImg in dbJalagam.Product_Masters where objImg.Id == Convert.ToInt16(Request["DisplayPhoto"]) select objImg; Product_Master objC = objA.FirstOrDefault(); if (objC != null) { if (Convert.ToString(objC.DisplayImage).Length != 0) { Byte[] bytImage = (Byte[])objC.DisplayImage.ToArray(); Response.BinaryWrite(bytImage); } } } } if (Convert.ToString(Request.QueryString["DisplayPhotoAcc"]) != null) { Response.Buffer = true; Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); { var objA = from objImg in dbJalagam.Accessories_Masters where objImg.Id == Convert.ToInt16(Request["DisplayPhotoAcc"]) select objImg; Accessories_Master objC = objA.FirstOrDefault(); if (objC != null) { if (Convert.ToString(objC.DisplayImage).Length != 0) { Byte[] bytImage = (Byte[])objC.DisplayImage.ToArray(); Response.BinaryWrite(bytImage); } } } } // to get all ad images //if (Convert.ToString(Request.QueryString["AdId"]) != null) //{ // Response.Buffer = true; // Response.Charset = ""; // Response.Cache.SetCacheability(HttpCacheability.NoCache); // { // var obj = from objImg in dbEmup.UserAdsImagesDets // where objImg.UserAdId == Convert.ToInt16(Request["AdId"]) // select objImg; // UserAdsImagesDet objI; // objI = obj.SingleOrDefault(); // if (objI != null) // { // if (Convert.ToString(objI.Image).Length != 0) // { // Byte[] bytImage = (Byte[])objI.Image.ToArray(); // Response.BinaryWrite(bytImage); // } // } // } //} Response.Flush(); Response.End(); }