private void btnDeletePT_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Would you like to delete this Product brand?", "Delete Product Brand", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { try { Product_Brand Brandtype = new Product_Brand(); Brandtype = db.Product_Brand.Find(tempID); db.Product_Brand.Remove(Brandtype); db.SaveChanges(); int BType = Convert.ToInt32(Brandtype.Product_Brand_ID); string prodType_Value = Convert.ToString(Brandtype); MessageBox.Show("Product brand Successfully Deleted"); this.Close(); } catch (Exception) { MessageBox.Show("Error: Product Brand was not deleted, currently in use"); } } }
public async Task <object> Edite(Product_Brand product_brand) { bool isValid = await _product_brandService.ModifyProduct_Brand(product_brand); _notification.SetNotificationMessage(isValid, Title, product_brand.UID); return(_notification); }
public ActionResult DemoSave() { int id = ConvertHelper.ConvertToInt(Request["id"], 0); var modelList = DBHelper.Db.Select<Product_Brand>(" select * from Product_Brand with(nolock) where IDPlus=" + id); Product_Brand model = new Product_Brand(); if (modelList != null && modelList.Count > 0) model = modelList.FirstOrDefault(); return View(model); }
public ReturnInfoModel SaveDemo(Product_Brand model) { ReturnInfoModel returninfo = new ReturnInfoModel(); if (model.IDPlus > 0) { if (DBHelper.Db.Update<Product_Brand>(model) == 0) { return ReturnInfo.Failure("修改失败"); } } else { if (DBHelper.Db.Insert <Product_Brand>(model) > 0) { return ReturnInfo.Failure("添加失败"); } } return ReturnInfo.Success(); }
private void btnAdd_Click(object sender, EventArgs e) { try { correct = true; Product_Brand prodB = new Product_Brand(); if (ValidateIfBrandExists(rtxtDescription.Text) == true) { MessageBox.Show("Product Brand exists"); } if (rtxtDescription.Text == "") { lblBrandDes.Visible = true; //essageBox.Show("Please Enter brand details"); correct = false; } if (correct == true) { prodB.Product_Brand_Name = rtxtDescription.Text; MessageBox.Show("Product Successfully Added"); db.Product_Brand.Add(prodB); db.SaveChanges(); int Product_Type_ID = prodB.Product_Brand_ID; string ProdT_value = Convert.ToString(prodB); //MessageBox.Show("Product Successfully Added"); this.Close(); } else { MessageBox.Show("Please enter valid details"); } } catch (NullReferenceException) { //MessageBox.Show("Product Type Not Added"); } }
public ActionResult DemoSave(Product_Brand model) { return Json(service.SaveDemo(model)); }