public DataTable DeleteCustomer(InfowayCustomer customer) { DataTable customerTable = new DataTable("Customers"); int result = 0; using (MySqlConnection CN = new MySqlConnection(ConfigurationManager.ConnectionStrings["InfowayMySqlConStr"].ConnectionString)) { CN.Open(); MySqlCommand CMD = new MySqlCommand(); CMD.Connection = CN; CMD.CommandType = CommandType.StoredProcedure; CMD.CommandText = "DeleteInfowayCustomers"; CMD.Parameters.AddWithValue("p_CustomerId", customer.CustomerId); result = CMD.ExecuteNonQuery(); CN.Close(); } if (result > 0) { return(GetAllCustomers()); } else { throw new Exception("Insert Optioration failed! Please retry!"); } }
private void btnModify_Click(object sender, EventArgs e) { InfowayCustomer customer = new InfowayCustomer() { CustomerId = int.Parse(txtCustomerId.Text), ContactName = txtContactName.Text, City = txtCity.Text }; try { customerDal.UpdateCustomer(customer); customersTable = customerDal.GetAllCustomers(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }