Пример #1
0
        private void Back_Click(object sender, EventArgs e)
        {
            frmsecretariacs sec = new frmsecretariacs(secres);

            sec.Show();
            this.Close();
        }
Пример #2
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            switch (cbxuser.Text)
            {
            case "Asesor":
                cn.Open();
                SqlCommand     comando = new SqlCommand("SELECT * FROM Asesor WHERE correo='" + txtuser.Text + "'AND Contraseña='" + txtpassword.Text + "'", cn);
                SqlDataAdapter da      = new SqlDataAdapter(comando);
                DataTable      dt      = new DataTable();
                da.Fill(dt);
                if (dt.Rows.Count == 1)
                {
                    MessageBox.Show("Bienvenido " + dt.Rows[0][2]);

                    String nom;
                    string ids;
                    ids = Convert.ToString(dt.Rows[0][6]);
                    nom = Convert.ToString(dt.Rows[0][2]);
                    frmasesor ase = new frmasesor(nom, ids);
                    ase.Show();
                    this.Close();
                }
                else
                {
                    SqlCommand     comandoS = new SqlCommand("SELECT * FROM Asesor WHERE correo='" + txtuser.Text + "'", cn);
                    SqlDataAdapter daS      = new SqlDataAdapter(comandoS);
                    DataTable      dtS      = new DataTable();
                    daS.Fill(dtS);

                    try
                    {
                        if (dtS.Rows[0][4].Equals(txtuser.Text) && !dtS.Rows[0][7].Equals(txtpassword.Text))
                        {
                            MessageBox.Show("Contraseña ingresada incorrectamente");
                        }
                    }catch (Exception k)
                    {
                        MessageBox.Show("El usuario no existe");
                    }
                }

                cn.Close();



                break;

            case "Practicante":
                cn.Open();
                SqlCommand     comando1 = new SqlCommand("SELECT * FROM Practicante WHERE Correo='" + txtuser.Text + "'AND Contraseña='" + txtpassword.Text + "'", cn);
                SqlDataAdapter da1      = new SqlDataAdapter(comando1);
                DataTable      dt1      = new DataTable();
                da1.Fill(dt1);
                if (dt1.Rows.Count == 1)
                {
                    MessageBox.Show("Bienvenido " + dt1.Rows[0][1]);
                    String nom;
                    nom = Convert.ToString(dt1.Rows[0][1]);
                    frmprac prac = new frmprac(nom, Convert.ToInt32(dt1.Rows[0][0]));
                    prac.Show();
                    this.Close();
                }
                else
                {
                    SqlCommand     comandoS = new SqlCommand("SELECT * FROM Practicante WHERE correo='" + txtuser.Text + "'", cn);
                    SqlDataAdapter daS      = new SqlDataAdapter(comandoS);
                    DataTable      dtS      = new DataTable();
                    daS.Fill(dtS);

                    try
                    {
                        if (dtS.Rows[0][3].Equals(txtuser.Text) && !dtS.Rows[0][6].Equals(txtpassword.Text))
                        {
                            MessageBox.Show("Contraseña ingresada incorrectamente");
                        }
                    }
                    catch (Exception k)
                    {
                        MessageBox.Show("Usuario no existe");
                    }
                }

                cn.Close();


                break;

            case "Secretaria":
                cn.Open();
                SqlCommand     comando2 = new SqlCommand("SELECT * FROM Secretaria WHERE Correo='" + txtuser.Text + "'AND Contraseña='" + txtpassword.Text + "'", cn);
                SqlDataAdapter da2      = new SqlDataAdapter(comando2);
                DataTable      dt2      = new DataTable();
                da2.Fill(dt2);
                if (dt2.Rows.Count == 1)
                {
                    MessageBox.Show("Bienvenida " + dt2.Rows[0][1]);
                    String nom;
                    nom = Convert.ToString(dt2.Rows[0][2]);
                    frmsecretariacs sec = new frmsecretariacs(nom);
                    sec.Show();
                    this.Close();
                }
                else
                {
                    SqlCommand     comandoS = new SqlCommand("SELECT * FROM Secretaria WHERE Correo='" + txtuser.Text + "'", cn);
                    SqlDataAdapter daS      = new SqlDataAdapter(comandoS);
                    DataTable      dtS      = new DataTable();
                    daS.Fill(dtS);

                    try
                    {
                        if (dtS.Rows[0][4].Equals(txtuser.Text) && !dtS.Rows[0][5].Equals(txtpassword.Text))
                        {
                            MessageBox.Show("Contraseña ingresada incorrectamente");
                        }
                    }
                    catch (Exception k)
                    {
                        MessageBox.Show("Usuario no existe");
                    }
                }

                cn.Close();


                break;
            }
        }