Пример #1
0
        private void btnGuargar_Click(object sender, EventArgs e)
        {
            bool paso = Utilidades.ValidarForm(this, MyErrorProvider);

            if (paso == true)
            {
                paso = this.Detalle.Count() > 0;
            }

            if (paso == false)
            {
                MyErrorProvider.SetError(DetalleDataGridView1, "Debe agregar algun telefono");
                TelefonoMaskedTextBox.Focus();
            }

            if (paso == true)
            {
                Personas persona = LlenaClase();
                MessageBox.Show("Se lleno la clase");
                if (persona.PersonaId > 0)
                {
                    if (PersonasBLL.Modificar(persona) == true)
                    {
                        if (Detalle.Count != 0)
                        {
                            foreach (var item in Detalle)
                            {
                                PersonasBLL.EliminarDetalle(item.Id);
                            }
                        }
                        MessageBox.Show("Modificado Correctamente!!!");
                    }
                    else
                    {
                        MessageBox.Show("Error al intentar modificar el registro!!!");
                    }
                }
                else
                {
                    if (PersonasBLL.Guardar(persona) == true)
                    {
                        MessageBox.Show("Guardado Correctamente!!!");
                    }
                    else
                    {
                        MessageBox.Show("Error al intentar guardar el registro!!!");
                    }
                }
            }
        }