//Save btn private void btnsave1_Click(object sender, RoutedEventArgs e) { CustomerTbl c = new CustomerTbl() //Customer TBl { CustName = tbxCName.Text, // Name Enter by user CustPhone = tbxCphone.Text //Phone Enter by user }; db.CustomerTbls.Add(c); db.SaveChanges(); //Save details in cudtomer grid ShowItems(CustomersDg); //Show details }
private void CustomersDg_SelectionChanged(object sender, SelectionChangedEventArgs e) { CustomerTbl seletedCust = CustomersDg.SelectedItem as CustomerTbl; currentBasket = new Basket(); //check not noll if (seletedCust != null) { tbxCID.Text = seletedCust.CustId.ToString(); tbxCName1.Text = seletedCust.CustName; } }
//add to bill btn private void btnaddbil_Click(object sender, RoutedEventArgs e) { //get details CustomerTbl selectedCustomer = CustomersDg.SelectedItem as CustomerTbl; ItemTbl selectedItem = ItemsDG.SelectedItem as ItemTbl; if (selectedCustomer != null && selectedItem != null) { if (currentBasket == null) { currentBasket = new Basket(); currentBasket.Customer = selectedCustomer; } //add to basket currentBasket.ItemsToPurchase.Add(selectedItem); //update text with total tbxtotal.Text = string.Format("{0:C}", currentBasket.GetTotalInBasket()); //update display BillDG.ItemsSource = null; BillDG.ItemsSource = currentBasket.ItemsToPurchase; } //add to basket //update display //update db //int Grdtotal = 0; //BillTbl b = new BillTbl()//billtbl //{ // CustId=int.Parse(tbxCID.Text), // CustName= tbxCName1.Text, // Amount=int.Parse(tbxprice.Text), // }; //db.BillTbls.Add(b); //Grdtotal = Grdtotal + b.Amount; //tbxtotal.Text = "£" + Grdtotal; //db.SaveChanges(); //ShowItems(BillDG); }