private void ContenedorSecundario_FormClosed(object sender, FormClosedEventArgs e)
        {
            VentanaUser user = new VentanaUser();

            this.Hide();
            user.Show();
        }
Exemplo n.º 2
0
 private void Button1_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Desea cancelar? ", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
     {
         VentanaUser user = new VentanaUser();
         this.Hide();
         user.Show();
     }
 }
        private void Iniciar_Click(object sender, EventArgs e)
        {
            try
            {
                string CMD = string.Format("Select * FROM tblEmpleado WHERE username='******' AND password='******'", textBox1.Text.Trim(), textBox2.Text.Trim());

                DataSet ds = Class1.Ejecutar(CMD);

                Codigo = ds.Tables[0].Rows[0]["idEmpleado"].ToString().Trim();

                string cuenta = ds.Tables[0].Rows[0]["username"].ToString().Trim();
                string contra = ds.Tables[0].Rows[0]["password"].ToString().Trim();

                if (cuenta == textBox1.Text.Trim() && contra == textBox2.Text.Trim()) 
                {
                    if(Convert.ToBoolean(ds.Tables[0].Rows[0]["statusAdmin"])== true)
                    {
                        VentanaAdmin venAd = new VentanaAdmin();
                        this.Hide();
                        venAd.Show();
                    }
                    else
                    {
                        VentanaUser venUs = new VentanaUser();
                        this.Hide();
                        venUs.Show();
                    }
                }
            }

            catch (Exception)
            {
                MessageBox.Show("Usuario y/o contraseña incorrecta");

            }
        }