private void ButtonAdd_Click(object sender, RoutedEventArgs e) { //instantiate the object int genreId = ComboGenre.SelectedIndex + 1; try { Book b = new Book(0, TbAuthor.Text, TbTitle.Text, genreId, decimal.Parse(TbPrice.Text), DateTime.Parse(TbPubDate.Text), TbDescription.Text); db.AddBooks(b); } catch (ArgumentException ex) { MessageBox.Show("the values are out of range" + ex.StackTrace); } catch (FormatException ex) { MessageBox.Show("not A valid Format" + ex.StackTrace); } refreshBookList(); LvBooks.Items.Refresh(); //clear the field of textboxes TbAuthor.Clear(); TbTitle.Clear(); ComboGenre.SelectedValue = false; TbPubDate.Clear(); TbDescription.Clear(); TbPrice.Clear(); }
public ActionResult DeleteConfirmed(int id) { TbPrice tbPrice = db.tbPrices.Find(id); db.tbPrices.Remove(tbPrice); db.SaveChanges(); return(RedirectToAction("Index")); }
private bool IsValid() { TbPrice.GetBindingExpression(TextBox.TextProperty).UpdateSource(); CbStatus.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource(); TbStock.GetBindingExpression(TextBox.TextProperty).UpdateSource(); return(!Validation.GetHasError(TbPrice) && !Validation.GetHasError(CbStatus) && !Validation.GetHasError(TbStock)); }
public ActionResult Edit([Bind(Include = "Id,Condition,PriceSet")] TbPrice tbPrice) { if (ModelState.IsValid) { db.Entry(tbPrice).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbPrice)); }
public ActionResult Create([Bind(Include = "Id,Condition,PriceSet")] TbPrice tbPrice) { if (ModelState.IsValid) { db.tbPrices.Add(tbPrice); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbPrice)); }
private bool IsValidProduct() { CbProduct.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource(); CbStatus.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource(); TbOriginStock.GetBindingExpression(TextBox.TextProperty).UpdateSource(); CbUnit.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource(); TbSupplyPrice.GetBindingExpression(TextBox.TextProperty).UpdateSource(); TbPrice.GetBindingExpression(TextBox.TextProperty).UpdateSource(); return(!Validation.GetHasError(CbProduct) && !Validation.GetHasError(CbStatus) && !Validation.GetHasError(TbOriginStock) && !Validation.GetHasError(CbUnit) && !Validation.GetHasError(TbSupplyPrice) && !Validation.GetHasError(TbPrice)); }
// GET: Prices/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TbPrice tbPrice = db.tbPrices.Find(id); if (tbPrice == null) { return(HttpNotFound()); } return(View(tbPrice)); }