Example #1
0
        private void NuevoToolStripButton_Click(object sender, EventArgs e)
        {
            InterpretesAEForm frm = new InterpretesAEForm();

            frm.Text = "Nuevo Intérprete";
            DialogResult dr = frm.ShowDialog(this);

            if (dr == DialogResult.OK)
            {
                try
                {
                    Interprete interprete = frm.GetInterprete();

                    if (!servicio.Existe(interprete))
                    {
                        servicio.Agregar(interprete);
                        DataGridViewRow r = ConstruirFila();
                        SetearFila(r, interprete);
                        AgregarFila(r);
                        MessageBox.Show("Registro agregado", "Mensaje",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Registro Duplicado \nAlta Denegada", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #2
0
        private void EditarToolStripButton_Click(object sender, EventArgs e)
        {
            if (DatosDataGridView.SelectedRows.Count > 0)
            {
                DataGridViewRow   r             = DatosDataGridView.SelectedRows[0];
                Interprete        interprete    = (Interprete)r.Tag;
                Interprete        interpreteAux = (Interprete)interprete.Clone();
                InterpretesAEForm frm           = new InterpretesAEForm();
                frm.Text = "Editar Intérprete";
                frm.SetInterprete(interprete);
                DialogResult dr = frm.ShowDialog(this);
                if (dr == DialogResult.OK)
                {
                    try
                    {
                        interprete = frm.GetInterprete();

                        if (!servicio.Existe(interprete))
                        {
                            servicio.Agregar(interprete);
                            SetearFila(r, interprete);
                            MessageBox.Show("Registro agregado", "Mensaje",
                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            SetearFila(r, interpreteAux);

                            MessageBox.Show("Registro Duplicado \nAlta Denegada", "Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.Message, "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }