private void btnNew_Click(object sender, EventArgs e) { FormCustomerData frm = new FormCustomerData(); frm.Show(); this.Close(); }
private void Edit() { Customer customer = new Customer(); customer.Name = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); customer.CPF = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); customer.Cell_Phone = dataGridView1.SelectedRows[0].Cells[3].Value.ToString(); customer.Address = dataGridView1.SelectedRows[0].Cells[4].Value.ToString(); customer.Address_Number = dataGridView1.SelectedRows[0].Cells[5].Value.ToString(); customer.Observation = dataGridView1.SelectedRows[0].Cells[6].Value.ToString(); FormCustomerData frm = new FormCustomerData() { Edit = true }; frm.FillForm(customer.Name, customer.CPF, customer.Cell_Phone, customer.Address, customer.Address_Number, customer.Observation); if (frm.ShowDialog() != DialogResult.None) { var id = Int32.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()); Db db = new Db(); SqlCommand deleteCommand = new SqlCommand("delete from customer where id = @id"); deleteCommand.Parameters.AddWithValue("@id", id); db.executeQuery(deleteCommand); } }
private void Fill() { Customer customer = new Customer(); customer.Name = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); customer.CPF = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); customer.Cell_Phone = dataGridView1.SelectedRows[0].Cells[3].Value.ToString(); customer.Address = dataGridView1.SelectedRows[0].Cells[4].Value.ToString(); customer.Address_Number = dataGridView1.SelectedRows[0].Cells[5].Value.ToString(); customer.Observation = dataGridView1.SelectedRows[0].Cells[6].Value.ToString(); FormCustomerData frm = new FormCustomerData(); frm.FillForm(customer.Name, customer.CPF, customer.Cell_Phone, customer.Address, customer.Address_Number, customer.Observation); frm.Show(); }