Exemple #1
0
        private void tslAgregar_Click(object sender, EventArgs e)
        {
            frmLaboratoriosAE frm = new frmLaboratoriosAE(this);

            frm.Text = "Nuevo Laboratorio";
            DialogResult dr = frm.ShowDialog(this);

            if (dr == DialogResult.OK)
            {
                try
                {
                    Laboratorio laboratorio = frm.GetLaboratorio();
                    if (!_servicio.Existe(laboratorio))
                    {
                        _servicio.Guardar(laboratorio);
                        DataGridViewRow r = ConstruirFila();
                        SetearFila(r, laboratorio);
                        AñadirFila(r);
                        MessageBox.Show("Registro Agregado");
                    }
                    else
                    {
                        MessageBox.Show("Laboratorio repetido");
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }
        }
Exemple #2
0
 private void tslEditar_Click(object sender, EventArgs e)
 {
     if (dgvDatos.SelectedRows.Count > 0)
     {
         DataGridViewRow r           = dgvDatos.SelectedRows[0];
         Laboratorio     laboratorio = (Laboratorio)r.Tag;
         laboratorio = _servicio.GetLaboratorioPorId(laboratorio.LaboratorioId);
         frmLaboratoriosAE frm = new frmLaboratoriosAE();
         frm.Text = "Editar Laboratorio";
         frm.SetLaboratorio(laboratorio);
         DialogResult dr = frm.ShowDialog(this);
         if (dr == DialogResult.OK)
         {
             try
             {
                 laboratorio = frm.GetLaboratorio();
                 if (!_servicio.Existe(laboratorio))
                 {
                     _servicio.Guardar(laboratorio);
                     SetearFila(r, laboratorio);
                     MessageBox.Show("Registro Editado");
                 }
                 else
                 {
                     MessageBox.Show("Laboratorio Repetida");
                 }
             }
             catch (Exception exception)
             {
                 MessageBox.Show(exception.Message);
             }
         }
     }
 }