// Sends the user back to the ClientManagement form. private void btnBackToMenu_Click(object sender, EventArgs e) { this.Hide(); frmClientManagement frmClientManagement = new frmClientManagement(admin); frmClientManagement.Show(); }
// This button takes the user to the client management menu private void button1_Click_1(object sender, EventArgs e) { this.Hide(); frmClientManagement frmClientManagement = new frmClientManagement(admin); frmClientManagement.Show(); }
// Sends order data to the database. private void btnConfirm_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you want to add this order?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { Order order = new Order(0, clientID, paymentMethod, DateTime.Now, false, price, admin, new Installation(), orderDetails); order.AddOrder(); this.Hide(); frmClientManagement frmClientManagement = new frmClientManagement(admin); frmClientManagement.Show(); } }
// Deletes the selected client. private void btnDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you want do delete this client", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { string clientID = cmbClient.SelectedValue.ToString(); Client.DeleteClient(clientID); this.Hide(); frmClientManagement frmClientManagement = new frmClientManagement(admin); frmClientManagement.Show(); } }
private void btnLogOut_Click_1(object sender, EventArgs e) { if (updateOrder) { this.Hide(); frmClientManagement frmClientManagement = new frmClientManagement(admin); frmClientManagement.Show(); } else { this.Hide(); frmTechnicalSupport frmTechnicalSupport = new frmTechnicalSupport(admin); frmTechnicalSupport.Show(); } }
// This button calls the datahandler class's addclient method through the Client class, and adds a new client to the database private void btnAddClient_Click(object sender, EventArgs e) { bool canAdd = false; bool nameValid = false; bool surnameValid = false; bool cityValid = false; bool streetValid = false; bool postalCodeValid = false; string name = txtName.Text; string surname = txtSurname.Text; DateTime dateOfBirth = dtpDateOfBirth.Value; string city = txtCity.Text; string street = txtStreet.Text; string postalCode = txtPostalCode.Text; string contractType = cmbContract.SelectedItem.ToString(); if (name == string.Empty) { nameValid = false; } else { nameValid = true; } if (surname == string.Empty) { surnameValid = false; } else { surnameValid = true; } if (city == string.Empty) { cityValid = false; } else { cityValid = true; } if (street == string.Empty) { streetValid = false; } else { streetValid = true; } if ((postalCode == string.Empty) || (postalCode.Length < 4)) { postalCodeValid = false; } else { postalCodeValid = true; } if (nameValid && surnameValid && cityValid && streetValid && postalCodeValid) { canAdd = true; } else { canAdd = false; } if (canAdd) { if (MessageBox.Show("Are you sure you want to add this person?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { Client client = new Client(Client.GenerateClientID(), name, surname, dateOfBirth, new Address(0, city, street, postalCode), Contract.GenerateContractID(contractType)); Client.AddClient(client); frmClientManagement frmClientManagement = new frmClientManagement(admin); frmClientManagement.Show(); this.Close(); } } else { if (helpMessageShow) { MessageBox.Show("Indicated fields are not correct!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); helpMessageShow = false; } } }
// Updates the client with the new values. private void btnUpdate_Click_1(object sender, EventArgs e) { bool canAdd = false; bool nameValid = false; bool surnameValid = false; bool cityValid = false; bool streetValid = false; bool postalCodeValid = false; string name = txtName.Text; string surname = txtSurname.Text; DateTime dateOfBirth = dtpDob.Value; string city = txtCity.Text; string street = txtStreet.Text; string postalCode = txtPostalCode.Text; if (name == string.Empty) { nameValid = false; } else { nameValid = true; } if (surname == string.Empty) { surnameValid = false; } else { surnameValid = true; } if (city == string.Empty) { cityValid = false; } else { cityValid = true; } if (street == string.Empty) { streetValid = false; } else { streetValid = true; } if ((postalCode == string.Empty) || (postalCode.Length < 4)) { postalCodeValid = false; } else { postalCodeValid = true; } if (nameValid && surnameValid && cityValid && streetValid && postalCodeValid) { canAdd = true; } else { canAdd = false; } if (canAdd) { if (MessageBox.Show("Are you sure you want to update this person?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { Client client = new Client(cmbClient.SelectedValue.ToString(), txtName.Text, txtSurname.Text, dtpDob.Value, new Address(addressID, txtCity.Text, txtStreet.Text, txtPostalCode.Text), txtContract.Text); client.UpdateClient(); frmClientManagement frmClientManagement = new frmClientManagement(admin); frmClientManagement.Show(); this.Hide(); } } else { if (helpMessageShow) { MessageBox.Show("Indicated fields are not correct!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); helpMessageShow = false; } } }