Exemplo n.º 1
0
        private void listarYModificarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AdminMantenimiento newMDIChild = new AdminMantenimiento();

            // Set the Parent Form of the Child window.
            newMDIChild.MdiParent = this;
            // Display the new form.
            newMDIChild.Show();
        }
Exemplo n.º 2
0
        //ADD A NEW PERSONAL
        //IF THE ADD IS CORRECT INSERT THIS PERSON IN ADMIN TABLE
        private void btnADD_Click(object sender, EventArgs e)
        {
            //comprobamos si vamos ha actualizar o a insertar un nuevo administrador
            if (update == "")
            {
                //Recorremos todos los TextBox para comprobar que ninguno esta vacio.
                int contarTxt = 0;
                foreach (Control _textbox in this.Controls)
                {
                    if (_textbox is TextBox && _textbox.Text == string.Empty)
                    {
                        contarTxt = contarTxt + 1;
                    }
                }
                //Cargamos el personal y miramos si este dni existe
                List <Personal> listPersonal = new List <Personal>();
                int             exist        = 0;
                listPersonal = control.getAllPersonal();
                foreach (var item in listPersonal)
                {
                    if (item.MyNif.Equals(txtDni.Text))
                    {
                        exist = 1;
                    }
                }

                if (exist != 1)
                {
                    //comprobamos si habia alguno vacio
                    if (contarTxt > 0)
                    {
                        MessageBox.Show("Campos Vacios");
                    }
                    else
                    {
                        Personal personal = new Personal();
                        personal = new Personal(txtDni.Text, txtName.Text, txtApellidos.Text, txtMail.Text);
                        int result = control.AddPersonal(personal);
                        if (result == 1)
                        {
                            Administrador admin   = new Administrador(txtDni.Text, txtSS.Text, comboBox1.Text);
                            int           result2 = control.addAdmin(admin);
                            if (result2 == 1)
                            {
                                MessageBox.Show("Añadido");
                                AdminMantenimiento newMDIChild = new AdminMantenimiento();
                                // Set the Parent Form of the Child window.
                                newMDIChild.MdiParent = SuperAdmin.ActiveForm;
                                // Display the new form.
                                newMDIChild.Show();
                                Close();
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("este DNI O NIF ya existe");
                }
            }
            else
            {
                Personal      personal = new Personal(txtDni.Text, txtName.Text, txtApellidos.Text, txtMail.Text);
                Administrador admin    = new Administrador(txtDni.Text, txtSS.Text, comboBox1.Text);
                int           result   = control.updatePersona(personal);
                result = control.updateAdmin(admin);
                if (result == 1)
                {
                    MessageBox.Show("Actualizado");
                    AdminMantenimiento newMDIChild = new AdminMantenimiento();
                    // Set the Parent Form of the Child window.
                    newMDIChild.MdiParent = SuperAdmin.ActiveForm;
                    // Display the new form.
                    newMDIChild.Show();
                    Close();
                }
            }
        }