private void toolStripButton2_Click(object sender, EventArgs e)
        {
            DireccionGestor.setcloseshowuser();
            if (DireccionGestor.getorigen() == "" || DireccionGestor.getorigen() == null || DireccionGestor.getorigen() == "out")
            {
                UserAccessForm menu = new UserAccessForm();
                //menu.WindowState = FormWindowState.Normal;
                menu.Show();

                LoginClass save = new LoginClass();
                // this.Close();
            }
            else if (DireccionGestor.getorigen() == "buscador" || UsersShowForm.getstate() == "edit")
            {
                UsersShowForm menu = new UsersShowForm();
                //menu.WindowState = FormWindowState.Maximized;
                menu.Show();
                LoginClass save = new LoginClass();
                // this.Hide();
            }
            else if (DireccionGestor.getorigen() == "inicio")
            {
                DireccionGestor menu = new DireccionGestor();

                //menu.WindowState = FormWindowState.Maximized;
                menu.Show();
                LoginClass save = new LoginClass();
                // this.Hide();
            }

            this.Close();
        }
Exemplo n.º 2
0
 private void verUsuariosToolStripMenuItem_Click(object sender, EventArgs e)
 {
     showuser             = new UsersShowForm();
     showuser.WindowState = FormWindowState.Maximized;
     showuser.Show();
     this.Close();
 }
        private void savebuttonstrip_Click(object sender, EventArgs e)
        {
            int hour  = DateTime.Now.Hour;
            int min   = DateTime.Now.Minute;
            int sec   = DateTime.Now.Second;
            int day   = DateTime.Now.Day;
            int month = DateTime.Now.Month;
            int year  = DateTime.Now.Year;


            string fecha = day.ToString() + "/" + month.ToString() + "/" + year.ToString();
            string hora  = hour.ToString() + ":" + min.ToString() + ":" + sec.ToString();

            carga men = new carga();

            men.WindowState = FormWindowState.Normal;
            men.Show();
            LoginClass save = new LoginClass(dbserver, dbname, dbuser, dbpassword, dbport);

            if (UsersShowForm.getstate() == "edit")
            {
                if (nameBox.Text == "" || passwordbox.Text == "" || usercombo.Text == "" || askbox1.Text == "" || answerbox1.Text == "" || askbox2.Text == "" || answerbox2.Text == "" || askbox3.Text == "" || answerbox3.Text == "" || askbox4.Text == "" || answerbox4.Text == "" || askbox5.Text == "" || answerbox5.Text == "")
                {
                    men.Close();
                    if (nameBox.Text == "")
                    {
                        nameBox.BackColor = Color.Red;
                    }
                    else
                    {
                        nameBox.BackColor = Color.Green;
                    }
                    if (passwordbox.Text == "")
                    {
                        passwordbox.BackColor = Color.Red;
                    }
                    else
                    {
                        passwordbox.BackColor = Color.Green;
                    }
                    if (usercombo.Text == "")
                    {
                        usercombo.BackColor = Color.Red;
                    }
                    else
                    {
                        usercombo.BackColor = Color.Green;
                    }

                    if (askbox1.Text == "")
                    {
                        askbox1.BackColor = Color.Red;
                    }
                    else
                    {
                        askbox1.BackColor = Color.Green;
                    }
                    if (answerbox1.Text == "")
                    {
                        answerbox1.BackColor = Color.Red;
                    }
                    else
                    {
                        answerbox1.BackColor = Color.Green;
                    }

                    if (askbox2.Text == "")
                    {
                        askbox2.BackColor = Color.Red;
                    }
                    else
                    {
                        askbox2.BackColor = Color.Green;
                    }
                    if (answerbox2.Text == "")
                    {
                        answerbox2.BackColor = Color.Red;
                    }
                    else
                    {
                        answerbox2.BackColor = Color.Green;
                    }

                    if (askbox3.Text == "")
                    {
                        askbox3.BackColor = Color.Red;
                    }
                    else
                    {
                        askbox3.BackColor = Color.Green;
                    }
                    if (answerbox3.Text == "")
                    {
                        answerbox3.BackColor = Color.Red;
                    }
                    else
                    {
                        answerbox3.BackColor = Color.Green;
                    }

                    if (askbox4.Text == "")
                    {
                        askbox4.BackColor = Color.Red;
                    }
                    else
                    {
                        askbox4.BackColor = Color.Green;
                    }
                    if (answerbox4.Text == "")
                    {
                        answerbox4.BackColor = Color.Red;
                    }
                    else
                    {
                        answerbox4.BackColor = Color.Green;
                    }

                    if (askbox5.Text == "")
                    {
                        askbox5.BackColor = Color.Red;
                    }
                    else
                    {
                        askbox5.BackColor = Color.Green;
                    }
                    if (answerbox5.Text == "")
                    {
                        answerbox5.BackColor = Color.Red;
                    }
                    else
                    {
                        answerbox5.BackColor = Color.Green;
                    }

                    if (institucionbox.Text == "")
                    {
                        institucionbox.BackColor = Color.Red;
                    }
                    else
                    {
                        institucionbox.BackColor = Color.Green;
                    }
                    if (telefonobox.Text == "")
                    {
                        telefonobox.BackColor = Color.Red;
                    }
                    else
                    {
                        telefonobox.BackColor = Color.Green;
                    }
                    if (emailbox.Text == "")
                    {
                        emailbox.BackColor = Color.Red;
                    }
                    else
                    {
                        emailbox.BackColor = Color.Green;
                    }
                    MessageBox.Show("HAY DATOS IMPORTANTES VACIOS");
                }
                else
                {
                    string name        = nameBox.Text;
                    string password    = passwordbox.Text;
                    string usertipo    = usercombo.Text;
                    string ask1        = askbox1.Text;
                    string answer1     = answerbox1.Text;
                    string ask2        = askbox2.Text;
                    string answer2     = answerbox2.Text;
                    string ask3        = askbox3.Text;
                    string answer3     = answerbox3.Text;
                    string ask4        = askbox4.Text;
                    string answer4     = answerbox4.Text;
                    string ask5        = askbox5.Text;
                    string answer5     = answerbox5.Text;
                    string foto        = picturetextbox.Text;
                    string email       = emailbox.Text;
                    string telefono    = telefonobox.Text;
                    string institucion = institucionbox.Text;
                    string orden       = "UPDATE users_table SET USER_NAME= '" + name + "', USER_PASSWORD='******', USERTIPO='" + usertipo + "', QUESTION1='" + ask1 + "',ANSWER1='" + answer1 + "', QUESTION2='" + ask2 + "',ANSWER2='" + answer2 + "',QUESTION3='" + ask3 + "',ANSWER3='" + answer3 + "',QUESTION4='" + ask4 + "',ANSWER4='" + answer4 + "',QUESTION5='" + ask5 + "',ANSWER5='" + answer5 + "',PICTURE_ROUTE='" + picturetextbox.Text + "' ,INSTITUCION='" + institucion + "',TELEFONO='" + telefono + "',EMAIL='" + email + "' WHERE USER_NAME = '" + UsersShowForm.getdatum()[0] + "' AND USERTIPO = '" + UsersShowForm.getdatum()[1] + "' AND ID = '" + UsersShowForm.getdatum()[2] + "' AND FECHA_CREACION = '" + UsersShowForm.getdatum()[3] + "'; ";
                    save.ordensql(orden);
                    men.Close();
                    MessageBox.Show("USUARIO " + UsersShowForm.getdatum()[0] + " HA SIDO MODIFICADO");
                    if (UserAccessForm.getusername() != nameBox.Text)
                    {
                        UserAccessForm add = new UserAccessForm();
                        add.WindowState = FormWindowState.Maximized;
                        add.Show();
                        this.Close();
                    }
                    else
                    {
                        UsersShowForm add = new UsersShowForm();
                        add.WindowState = FormWindowState.Maximized;
                        add.Show();
                        this.Close();
                    }
                }
            }
            else
            {
                if (save.UserNoCopied(nameBox.Text) == true)
                {
                    men.Close();
                    MessageBox.Show("El usuario " + nameBox.Text + " ya existe");
                    if (MessageBox.Show("Agregar a otro usuario?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                    {
                        save = new LoginClass();

                        DireccionGestor menu = new DireccionGestor();
                        menu.WindowState = FormWindowState.Normal;
                        menu.Show();
                        this.Close();
                    }
                    else
                    {
                        save = new LoginClass();
                        UserAddForm menu = new UserAddForm();
                        menu.WindowState = FormWindowState.Normal;
                        menu.Show();
                        this.Close();
                    }
                }
                else if (save.UserNoCopied(nameBox.Text) == false)
                {
                    if (passwordbox.Text != passwordsecuritybox.Text)
                    {
                        men.Close();
                        MessageBox.Show("LAS CONTRASEÑAS NO COINCIDEN");
                    }

                    else
                    {
                        if (nameBox.Text == "" || passwordbox.Text == "" || passwordsecuritybox.Text == "" || askbox1.Text == "" || askbox2.Text == "" || askbox3.Text == "" || askbox4.Text == "" || askbox5.Text == "" || answerbox1.Text == "" || answerbox2.Text == "" || answerbox3.Text == "" || answerbox4.Text == "" || answerbox5.Text == "" || emailbox.Text == "" || telefonobox.Text == "" || institucionbox.Text == "")
                        {
                            men.Close();

                            MessageBox.Show("Hay datos importantes vacios, termine el formulario.");
                        }

                        else
                        {
                            if (DireccionGestor.getorigen() == "inicio")
                            {
                                //institucion, telefono, email
                                if (save.CreateNewUser(nameBox.Text, passwordbox.Text, picturetextbox.Text, askbox1.Text, askbox2.Text, askbox3.Text, askbox4.Text, askbox5.Text, answerbox1.Text, answerbox2.Text, answerbox3.Text, answerbox4.Text, answerbox5.Text, usercombo.Text, fecha, hora, institucionbox.Text, telefonobox.Text, emailbox.Text) == true)
                                {
                                    men.Close();
                                    MessageBox.Show("NUEVO USUARIO " + nameBox.Text + " HA SIDO CREADO EXITOSAMENTE.");
                                    if (MessageBox.Show("Agregar a otro usuario?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                                    {
                                        save = new LoginClass();

                                        DireccionGestor menu = new DireccionGestor();
                                        menu.WindowState = FormWindowState.Normal;
                                        menu.Show();
                                        this.Close();
                                    }
                                    else
                                    {
                                        save = new LoginClass();

                                        UserAddForm menu = new UserAddForm();
                                        menu.WindowState = FormWindowState.Normal;
                                        menu.Show();
                                        this.Close();
                                    }
                                }
                                else if (DireccionGestor.getorigen() == "buscador")
                                {
                                    men.Close();
                                    MessageBox.Show("NUEVO USUARIO " + nameBox.Text + " HA SIDO CREADO.");

                                    if (MessageBox.Show("Agregar a otro usuario?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                                    {
                                        save = new LoginClass();

                                        UsersShowForm menu = new UsersShowForm();
                                        menu.WindowState = FormWindowState.Normal;
                                        menu.Show();
                                        this.Close();
                                    }
                                    else
                                    {
                                        save = new LoginClass();

                                        UserAddForm menu = new UserAddForm();
                                        menu.WindowState = FormWindowState.Normal;
                                        menu.Show();
                                        this.Close();
                                    }
                                }

                                else
                                {
                                    men.Close();
                                    MessageBox.Show("NUEVO USUARIO " + nameBox.Text + " HA SIDO CREADO.");

                                    if (MessageBox.Show("Agregar a otro usuario?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                                    {
                                        save = new LoginClass();

                                        DireccionGestor menu = new DireccionGestor();
                                        menu.WindowState = FormWindowState.Normal;
                                        menu.Show();
                                        this.Close();
                                    }
                                    else
                                    {
                                        save = new LoginClass();

                                        UserAddForm menu = new UserAddForm();
                                        menu.WindowState = FormWindowState.Normal;
                                        menu.Show();
                                        this.Close();
                                    }
                                }
                            }
                            else if (DireccionGestor.getorigen() == "" || DireccionGestor.getorigen() == null || DireccionGestor.getorigen() == "out")
                            {
                                //institucion,telefono,email
                                if (save.CreateNewUser(nameBox.Text, passwordbox.Text, picturetextbox.Text, askbox1.Text, askbox2.Text, askbox3.Text, askbox4.Text, askbox5.Text, answerbox1.Text, answerbox2.Text, answerbox3.Text, answerbox4.Text, answerbox5.Text, usercombo.Text, fecha, hora, institucionbox.Text, telefonobox.Text, emailbox.Text) == true)
                                {
                                    men.Close();
                                    MessageBox.Show("NUEVO USUARIO " + nameBox.Text + " NO PUDO SER CREADO.");
                                    if (MessageBox.Show("Agregar a otro usuario?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                                    {
                                        save = new LoginClass();

                                        UserAccessForm menu = new UserAccessForm();
                                        menu.WindowState = FormWindowState.Normal;
                                        menu.Show();
                                        this.Close();
                                    }
                                    else
                                    {
                                        save = new LoginClass();

                                        UserAddForm menu = new UserAddForm();
                                        menu.WindowState = FormWindowState.Normal;
                                        menu.Show();
                                        this.Close();
                                    }
                                }

                                else
                                {
                                    men.Close();
                                    MessageBox.Show("NUEVO USUARIO " + nameBox.Text + " HA SIDO CREADO EXITOSAMENTE.");

                                    if (MessageBox.Show("Agregar a otro usuario?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                                    {
                                        save = new LoginClass();

                                        UserAccessForm menu = new UserAccessForm();
                                        menu.WindowState = FormWindowState.Normal;
                                        menu.Show();
                                        this.Close();
                                    }
                                    else
                                    {
                                        save = new LoginClass();

                                        UserAddForm menu = new UserAddForm();
                                        menu.WindowState = FormWindowState.Normal;
                                        menu.Show();
                                        this.Close();
                                    }
                                }
                            }
                        }
                    }
                }
            }


            save = new LoginClass();
        }
        private void savebuttonstrip_Click(object sender, EventArgs e)
        {
            if (passwordbox.Text == "" || answerbox1.Text == "" || answerbox2.Text == "" || answerbox3.Text == "" || answerbox4.Text == "" || answerbox5.Text == "")
            {
                if (passwordbox.Text == "")
                {
                    passwordbox.BackColor = Color.Red;
                }
                else
                {
                    passwordbox.BackColor = Color.Green;
                }
                if (answerbox1.Text == "")
                {
                    answerbox1.BackColor = Color.Red;
                }
                else
                {
                    answerbox1.BackColor = Color.Green;
                }
                if (answerbox2.Text == "")
                {
                    answerbox2.BackColor = Color.Red;
                }
                else
                {
                    answerbox2.BackColor = Color.Green;
                }
                if (answerbox3.Text == "")
                {
                    answerbox3.BackColor = Color.Red;
                }
                else
                {
                    answerbox3.BackColor = Color.Green;
                }
                if (answerbox4.Text == "")
                {
                    answerbox4.BackColor = Color.Red;
                }
                else
                {
                    answerbox4.BackColor = Color.Green;
                }
                if (answerbox5.Text == "")
                {
                    answerbox5.BackColor = Color.Red;
                }
                else
                {
                    answerbox5.BackColor = Color.Green;
                }
            }
            else
            {
                LoginClass log = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());

                if (log.setConectionsecurity(userlabel.Text, passwordbox.Text, answerbox1.Text, answerbox2.Text, answerbox3.Text, answerbox4.Text, answerbox5.Text) == true)
                {
                    count = 0;

                    UsersShowForm begin = new UsersShowForm();
                    begin.WindowState = FormWindowState.Normal;
                    begin.Show();
                    this.Close();
                }
                else
                {
                    problempanel.Show();
                    MessageBox.Show("ERROR AL INTRODUCIR DATOS");
                    if (count == 5)
                    {
                        MessageBox.Show("POR MOTIVOS DE SEGURIDAD SE CERRARA LA APLICACION");
                        this.Dispose();
                        Application.Exit();
                    }
                    count++;
                }
            }
        }