private void Savebtn_Click(object sender, EventArgs e) { DialogResult AddCustomer = MessageBox.Show("Are You Sure You Wish To ADD This Customer?", "Add Customer", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (AddCustomer == DialogResult.Yes) { dataset.Clear(); MySqlConnection con = new MySqlConnection(); con.ConnectionString = LoginForm.constring; MySqlDataAdapter dataadapter = new MySqlDataAdapter(); con.Open(); MySqlCommand command = con.CreateCommand(); MySqlCommand commandaddress = con.CreateCommand(); commandaddress.CommandText = "INSERT INTO address (address_line1, address_line2, address_city, address_county, address_postcode) VALUES "+"('"+Addl1txt.Text+"','"+Addl2txt.Text+"','"+Towntxt.Text+"','"+Countytxt.Text+"','"+Postcodetxt.Text+"');"; commandaddress.ExecuteNonQuery(); MySqlCommand commandfindaddid = con.CreateCommand(); command.CommandText = "SELECT * FROM address WHERE address_line1='"+Addl1txt.Text+"' AND address_postcode='" + Postcodetxt.Text + "'"; dataadapter.SelectCommand = command; dataadapter.Fill(dataset, "address"); DataRow dr = dataset.Tables["address"].Rows[0]; command.CommandText = "INSERT INTO customer (address_id, customer_forename, customer_surname, customer_email, customer_phone) VALUES" + "(" + dr[0].ToString()+ ",'" + Forenametxt.Text + "','" + Surnametxt.Text + "','" + Emailtxt.Text + "'," + Phonetxt.Text + ");"; command.ExecuteNonQuery(); MessageBox.Show("The Customer Has Been Added Successfully."); con.Close(); dataset.Clear(); ManageAccounts ManageAccounts = new ManageAccounts(); ManageAccounts.Show(); this.Close(); } }
private void ManageAccountsbtn_Click(object sender, EventArgs e) { ManageAccounts ManageAccounts = new ManageAccounts(); ManageAccounts.Show(); this.Dispose(false); }