Esempio n. 1
0
        //Loads a customer
        private void btnLoad_Click(object sender, RoutedEventArgs e)
        {
            //Pulls customer details from database using customer reference number entered

            data.DBConnect();
            Customer c = data.SetCustomer(Int32.Parse(txtEditCustP.Text));

            if (c.CustomerRef == 0)
            {
                MessageBox.Show("Failed to find that customer. Please retry");
            }
            else
            {
                //Creates a new booking window and assigns the values from the customer query to labels on new booking window
                BookingWindow bw = new BookingWindow(c, data);
                bw.lblCustName.Content    = c.Name;
                bw.lblCustAddress.Content = c.Address;

                //Opens the new booking window and hides current window
                bw.Show();
                this.Hide();
            }
        }
Esempio n. 2
0
        //Creates a new booking, using the customer details added
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (!(txtCustName.Text == "" && txtCustAddress.Text == ""))
            {
                //Creates new instance of booking window and assigns customer details rom textboxes to labels for reference.
                BookingWindow bw = new BookingWindow(c, data);
                c.Name    = txtCustName.Text;
                c.Address = txtCustAddress.Text;
                bw.lblCustName.Content    = txtCustName.Text;
                bw.lblCustAddress.Content = txtCustAddress.Text;

                //Inserts the customer details into database
                data.DBConnect();
                data.InsertCustomer(c.Name, c.Address);

                //Displays booking window and hides current window
                bw.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Please insert new customer details to create a booking.");
            }
        }