示例#1
0
        private void toolBaja_Click(object sender, EventArgs e)
        {
            DialogResult respuesta = MessageBox.Show("¿Quiere eliminar el subsidio?", "Confirmación", MessageBoxButtons.YesNo);
            if (respuesta == DialogResult.Yes)
            {
                string cdn = ConfigurationManager.ConnectionStrings["cdnNomina"].ConnectionString;
                int fila = dgvSubsidio.CurrentCell.RowIndex;
                int id = int.Parse(dgvSubsidio.Rows[fila].Cells[0].Value.ToString());
                cnx = new SqlConnection(cdn);
                cmd = new SqlCommand();
                cmd.Connection = cnx;
                sh = new TablaSubsidio.Core.SubsidioHelper();
                sh.Command = cmd;
                TablaSubsidio.Core.TablaSubsidio subsidio = new TablaSubsidio.Core.TablaSubsidio();
                subsidio.id = id;

                try
                {
                    cnx.Open();
                    sh.eliminaSubsidio(subsidio);
                    cnx.Close();
                    cnx.Dispose();
                    ListaSubsidio();
                }
                catch (Exception error)
                {
                    MessageBox.Show("Error: \r\n \r\n " + error.Message, "Error");
                }
            }
        }