Beispiel #1
0
        private void salirToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            principal frm = new principal();

            frm.Show();
            this.Hide();
        }
Beispiel #2
0
        private void Entrar_Click(object sender, EventArgs e)
        {
            if (password.Text == "")
            {
                MessageBox.Show("Favor de ingresar su password...");
                password.Focus();
            }
            else
            {
                IPHostEntry host;
                localIP = "";
                host    = Dns.GetHostEntry(Dns.GetHostName());
                foreach (IPAddress ip in host.AddressList)
                {
                    if (ip.AddressFamily.ToString() == "InterNetwork")
                    {
                        localIP = ip.ToString();
                    }
                }

                //  MessageBox.Show("Tú IP Local Es: " + localIP);
            }

            try
            {
                dbcom obj = new dbcom();
                //  obj.sql("SET GLOBAL max_connections = 300;");
                // MySqlDataReader reader = obj.Estructura("SELECT nombre, numero, password FROM usuarios where string.trim(numero) = 1150;");
                MySqlDataReader reader = obj.Estructura("SELECT usuario, password, numero,clave FROM usuarios ;");
                // String a = this.textBox1.Text.ToUpper();
                // String b = this.textBox2.Text.ToUpper();
                while (reader.Read())
                {
                    usuario         = reader[0].ToString().ToUpper();
                    passwordusuario = reader[1].ToString().ToUpper();
                    claveusuario    = passwordusuario = reader[3].ToString().ToUpper();

                    if (numeroempleado == reader[2].ToString().ToUpper() && password.Text == reader[1].ToString().ToUpper())
                    {
                        obj.sql(" UPDATE usuarios SET usuarioip = '" +
                                localIP
                                + "' WHERE clave = '" +
                                claveusuario
                                + "';");
                        principal frm = new principal();
                        frm.Show();
                        this.Hide();
                        break;
                        //      MainForm.ActiveForm.MainMenuStrip.Visible = true;
                        //MainForm.ActiveForm.MainMenuStrip.Items.RemoveAt(1);
                        //MainForm.indice_usuario = 0;
                        //       MainForm.ActiveForm.Tag = reader[0];
                        //       this.Close();
                    }
                }
                reader.Close();
                //  MessageBox.Show("El password no se encontro...");
            }
            catch (Exception)
            {
                MessageBox.Show("No existen usuarios...");
            }
        }