Esempio n. 1
0
        private void ConfirmBtn_Click(object sender, EventArgs e)
        {
            //Get all the data needed
            string name       = owner.name;
            string address    = owner.address;
            string make       = MakeTxt.Text;
            string model      = ModelTxt.Text;
            int    year       = Convert.ToInt32(YearTxt.Text);
            string license    = LicenseTxt.Text;
            bool   allEntered = false;

            //Ensure all data has data
            if (!(make.Equals("") || model.Equals("") || year.Equals("") || license.Equals("")))
            {
                allEntered = true;
            }

            if (allEntered)
            {
                //As long as everything is entered properly add it to the database
                DatabaseWorker dbw = new DatabaseWorker(connection, command);
                dbw.addNewCar(name, address, make, model, year, license);

                Close();
            }
            else //Otherwise show an error
            {
                MessageBox.Show("Not all items have a value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
Esempio n. 2
0
        private void addCustBtn_Click(object sender, EventArgs e)
        {
            //Get data from form into variables
            string name       = nameTxt.Text;
            string address    = addressTxt.Text;
            string make       = makeTxt.Text;
            string model      = modelTxt.Text;
            int    year       = Convert.ToInt32(yearInt.Value);
            string license    = licenseTxt.Text;
            bool   allEntered = false;

            //Make sure all data is entered
            if ((name.Equals("") || address.Equals("") || make.Equals("") || model.Equals("") || year.Equals("") ||
                 license.Equals("")))
            {
                allEntered = true;
            }

            if (!allEntered)
            {
                //If all data is entered add it to the database
                DatabaseWorker dbw = new DatabaseWorker(connection, command);
                dbw.addCustomer(name, address, make, model, year, license);

                Close();
            }
            else //Otherwise show an error and display it
            {
                MessageBox.Show("Not all items have a value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
Esempio n. 3
0
 public AddRepair(SqlConnection connection, SqlCommand command, DatabaseWorker dbw, Car currentCar)
 {
     this.connection = connection;
     this.command    = command;
     this.dbw        = dbw;
     this.currentCar = currentCar;
     InitializeComponent();
 }
Esempio n. 4
0
 public EditCustomer(SqlConnection connection, SqlCommand command, Customer customer)
 {
     this.connection = connection;
     this.command    = command;
     this.customer   = customer;
     dbw             = new DatabaseWorker(connection, command);
     InitializeComponent();
     load();
 }
Esempio n. 5
0
 public Home()
 {
     dbw = new DatabaseWorker(connection, command);
     InitializeComponent();
 }