private void cancelButton_Click(object sender, EventArgs e) { this.Hide(); CustomersForm customerForm = new CustomersForm(); customerForm.Show(); }
private void saveCustomerButton_Click(object sender, EventArgs e) { DatabaseConnection con = new DatabaseConnection(); string custNameValue, add1Value, add2Value, postalCodeValue, phoneValue, city; int cityId = 0; int countryId = 0; custNameValue = custNameTextBox.Text; add1Value = add1TextBox1.Text; add2Value = add2TextBox2.Text; postalCodeValue = postalCodeTxtBox.Text; phoneValue = phoneTextBox.Text; DateTime updateDate = DateTime.UtcNow; con.Open(); try { MySqlDataReader row; string query = "select countryId, cityId, city from city where city = '" + cityComboBox.Text + "'"; row = con.ExecuteReader(query); if (row.HasRows) { while (row.Read()) { cityId = Convert.ToInt32(row["cityId"]); countryId = Convert.ToInt32(row["countryId"]); city = row["city"].ToString(); } U069LrDataSetTableAdapters.customerTableAdapter customerTableAdapter = new U069LrDataSetTableAdapters.customerTableAdapter(); customerTableAdapter.UpdateQuery(custNameValue, updateDate, CurrentOnlineUser.currentOnlineUserName, TrackSelected.SelectedCustomerId); U069LrDataSetTableAdapters.addressTableAdapter addressTableAdapter = new U069LrDataSetTableAdapters.addressTableAdapter(); addressTableAdapter.UpdateQuery(add1Value, add2Value, cityId, postalCodeValue, phoneValue, updateDate, CurrentOnlineUser.currentOnlineUserName, TrackSelected.SelectedAddressId); } else { MessageBox.Show("Customer Record not Saved!", "Information"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Information"); } con.Close(); this.Hide(); CustomersForm customerForm = new CustomersForm(); customerForm.Show(); }