Example #1
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            String Name = ProdN.Text;
            int    Price;

            try { Price = Convert.ToInt32(ProdP.Text); }
            catch
            {
                this.Title = "Erorr";
                return;
            }

            if (ProdN.Text == "" || ProdP.Text == "")
            {
                this.Title = "Erorr";
                return;
            }
            Product_tbl a1 = new Product_tbl();

            a1.ProdName  = Name;
            a1.ProdPrice = Price;

            db.Product_tbl.Add(a1);
            db.SaveChanges();
            this.Title = "Employee Add";

            ProdN.Text = "";
            ProdP.Text = "";

            this.Title = "sucsses";
            UpdateDGV();
            updateCB();
        }
Example #2
0
        private void Update_Click(object sender, RoutedEventArgs e)
        {
            Product_tbl a1 = (Product_tbl)CB.SelectedItem;
            Product_tbl a2 = (from s in db.Product_tbl where s.ProdId == a1.ProdId select s).FirstOrDefault();

            a2.ProdName  = ProdN.Text;
            a2.ProdPrice = Convert.ToInt32(ProdP.Text);


            db.SaveChanges();
            updateCB();
            UpdateDGV();
        }
Example #3
0
        private void CB_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Product_tbl a1 = (Product_tbl)CB.SelectedItem;

            if (a1 == null)
            {
                ProdN.Text = "";
                ProdP.Text = "";

                return;
            }
            ProdN.Text = a1.ProdName;
            ProdP.Text = a1.ProdPrice.ToString();
        }