Exemple #1
0
        // Updates the current row and then refreshes the grid
        private void SubmitBtn_Click(object sender, RoutedEventArgs e)
        {
            if (customersCBox.Text == "" || valuesCBox.Text == "" || commentTextBox.Text == "")
            {
                MessageBox.Show("Please, provide all the data", "Whoops...", MessageBoxButton.OK);
                return;
            }

            Readout updateReadout = (from m in db.Readouts
                                     where m.id == Id
                                     select m).Single();

            updateReadout.evaluatedCustomer = customersCBox.Text;
            updateReadout.value             = valuesCBox.Text;
            updateReadout.reviewDate        = DateTime.Now;
            updateReadout.comment           = commentTextBox.Text;

            db.SaveChanges();
            ReadoutsPage.datagrid.ItemsSource = db.Readouts.ToList();
            this.Hide();
        }
        //Inserts new readout into the database and then refreshes the grid
        private void SubmitBtn_Click(object sender, RoutedEventArgs e)
        {
            if (customersCBox.Text == "" || valuesCBox.Text == "" || commentTextBox.Text == "")
            {
                MessageBox.Show("Please, provide all the data", "Whoops...", MessageBoxButton.OK);
                return;
            }

            Readout newReadout = new Readout()
            {
                evaluatedCustomer = customersCBox.Text,
                reviewDate        = DateTime.Now,
                value             = valuesCBox.Text,
                comment           = commentTextBox.Text
            };

            db.Readouts.Add(newReadout);
            db.SaveChanges();
            ReadoutsPage.datagrid.ItemsSource = db.Readouts.ToList();
            this.Hide();
        }