private void sellButton_Click(object sender, EventArgs e) { if (emailTextBox.Text != "" && vinTextBox.Text != "" && IsValidEmail(emailTextBox.Text)) { string message; string mesajEmail = ""; DBConnection.Connect(); if (DBConnection.IsConnected() != false) { MySqlDataReader dataReader = DBConnection.Command("select marca,Model from masini where VIN ='" + vinTextBox.Text + "';").ExecuteReader(); if (dataReader.Read()) { message = dataReader["marca"] + " " + dataReader["Model"]; mesajEmail = string.Format("Congratulations, you bought yourself a {0}", message); dataReader.Close(); string attempt = RemoveRecord.removeCarByVIN(vinTextBox.Text); if (attempt.Equals("Successful")) { MailMessage mail = new MailMessage("*****@*****.**", emailTextBox.Text, "CarSamsar Acquisition", mesajEmail); SmtpClient client = new SmtpClient("smtp.gmail.com") { Port = 587, Credentials = new System.Net.NetworkCredential("*****@*****.**", "proiect1234"), EnableSsl = true }; client.Send(mail); MessageBox.Show("Car SOLD !", "Success", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } else { MessageBox.Show("VIN not found !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } dataReader.Close(); } else { MessageBox.Show("Can't connect to DataBase !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Please check the fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void remove_car_Click_1(object sender, EventArgs e) { string attempt = RemoveRecord.removeCarByVIN(VIN_textbox.Text); if (attempt.Equals("Successful")) { MessageBox.Show("Car successfully deleted from database.", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Information); VIN_textbox.Clear(); Logs.addCarLog("admin", " RemoveCar ", "Successful ", "VIN: " + VIN_textbox.Text); } else if (attempt.Equals("Failed")) { MessageBox.Show("Could not perform operation. VIN could not be found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); VIN_textbox.Clear(); Logs.addCarLog("admin", " RemoveCar ", "Failed ", "VIN: " + VIN_textbox.Text + " could not be found"); } }