Beispiel #1
0
 private void ResetControls()
 {
     ProdId = 0; CatID = 0;
     DeleteTxt();
     cmbID.ItemsSource = null; cmbID2.ItemsSource = null;
     if (Classes.GlobalVar.CreateMFAction)
     {
         lblSPId.Visibility = Visibility.Hidden;
         cmbID.Visibility   = Visibility.Hidden;
         cmbID.IsEnabled    = false;
         DeleteTxt();
         if (ProductCategory.LoadComboBox(ref this.cmbID2))
         {
             this.Close();
         }
         chkActive.IsChecked = true;
         Products_.IsActive  = true;
     }
     else
     {
         lblSPId.Visibility = Visibility.Visible;
         cmbID.Visibility   = Visibility.Visible;
         cmbID.IsEnabled    = true;
         if (Products_.LoadComboBox(ref this.cmbID))
         {
             this.Close();
         }
     }
 }
Beispiel #2
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            Products_ products_ = db.Products_.Find(id);

            db.Products_.Remove(products_);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
 public ActionResult Edit([Bind(Include = "ProductId,Name,Price")] Products_ products_)
 {
     if (ModelState.IsValid)
     {
         db.Entry(products_).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(products_));
 }
Beispiel #4
0
 private void btmCreate_Click(object sender, RoutedEventArgs e)
 {
     if (!(AllComboBoxFilled()))
     {
         Products_.Create(ProdId, txtName.Text, System.Convert.ToDecimal(txtPrice.Text), txtDesc.Text, Products_.IsActive, System.Convert.ToDouble(txtIVU.Text), CatID, Convert.ToDecimal(txtCost.Text), GlobalVar.CreateMFAction);
         ResetControls();
     }
     else
     {
         MessageBox.Show("Not All fields were filled.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Beispiel #5
0
        // GET: Products_/Delete/5
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Products_ products_ = db.Products_.Find(id);

            if (products_ == null)
            {
                return(HttpNotFound());
            }
            return(View(products_));
        }
Beispiel #6
0
 private void cmbID_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         ProdId             = Convert.ToInt32(cmbID.SelectedValue.ToString());
         cmbID2.ItemsSource = null;
         if (ProductCategory.LoadComboBox(ref this.cmbID2))
         {
             this.Close();
         }
         Products_.LoadWindow(ProdId, ref txtName, ref txtPrice, ref txtDesc, ref txtIVU, ref cmbID2, ref chkActive, ref CatID, ref txtCost);
     }
     catch (Exception)
     {
         ProdId = 0;
     }
 }
Beispiel #7
0
        // GET: Products_/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Products_ products_ = db.Products_.Find(id);

            if (products_ == null)
            {
                return(HttpNotFound());
            }

            /*
             * var myValue = Request.QueryString["somesuch"];
             * var myOtherValue = Request["somesuch"];
             */

            return(View(products_));
        }
Beispiel #8
0
        //      public ActionResult Create([Bind(Include="ProductId,Name,Price")])
        // public ActionResult Create(string Name, decimal Price)
        public ActionResult Create(Products_ product)
        {
            if (string.IsNullOrEmpty(product.Name))
            {
                ModelState.AddModelError("Name,", "Name isa requiredfield.");
            }
            if (ModelState.IsValidField("Price") &&
                (product.Price < 0.01M) ||
                (product.Price > 1000M))
            {
                ModelState.AddModelError("Price", "PLease enter a valid price between 0.01 and 1000");
            }
            // at 11:10 in vid 15 this is commented in
            if (ModelState.IsValid)
            {
                product.ProductId = Guid.NewGuid();
                db.Products_.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            /*
             * this is weakly typed
             * var product = new Products_();
             * product.ProductId = Guid.NewGuid();
             * product.Name = Request["Name"];
             * product.Price = Decimal.Parse(Request["Price"]);
             */

            /*
             * at 11:10 in the video this is commented out
             *                      var product = new Products_();
             * product.ProductId = Guid.NewGuid();
             * product.Name = Name;
             * product.Price = Price;
             */

            // save these to database
            return(View(product));
        }