コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: ranganathsb/DotNet
        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();
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            TbPrice tbPrice = db.tbPrices.Find(id);

            db.tbPrices.Remove(tbPrice);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
 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));
 }
コード例 #5
0
        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));
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        // 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));
        }