private void btnAdd_Click(object sender, EventArgs e) { WayToPay wayToPay = new WayToPay(); if (isEdit == false) { var result = MessageBox.Show("¿Desea registrar forma de pago?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { wayToPay.Description = textDescripcion.Text; WorkWayToPay.addWayToPay(wayToPay); loadWayToPays(); clear(); } } if (isEdit == true) { var result = MessageBox.Show("¿Desea guardar los cambios?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { wayToPay.Id = Convert.ToInt32(idWayToPay); wayToPay.Description = textDescripcion.Text; WorkWayToPay.updateWayToPay(wayToPay); loadWayToPays(); MessageBox.Show("Cambios actualizados correctamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); clear(); isEdit = false; } } }
private void btnEliminar_Click(object sender, EventArgs e) { if (dataGridViewWayToPay.SelectedRows.Count > 0) { var result = MessageBox.Show("¿Desea eliminar forma de pago?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { idWayToPay = dataGridViewWayToPay.CurrentRow.Cells["Id"].Value.ToString(); WorkWayToPay.deleteWayToPay(idWayToPay); MessageBox.Show("Se elimino correctamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); loadWayToPays(); } } else { MessageBox.Show("Seleccione una fila!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void loadWayToPays() { dataGridViewWayToPay.DataSource = WorkWayToPay.getAllWayToPays(); }