Exemple #1
0
        //Formulario
        private void btnAtras_Click(object sender, EventArgs e)
        {
            FrmAdmin admin = new FrmAdmin();

            admin.lblUser.Text = lblUser.Text;
            this.Hide();
            admin.Closed += (s, args) => this.Close();
            admin.Show();
        }
        private void btnIniciarSesion_Click(object sender, EventArgs e)
        {
            int x = 0;
            int i = 0;

            OdbcConnection con = Connect();
            OdbcCommand    cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;

            cmd.CommandText = "execute SP_READ_USUARIO @username ='******',@contra ='" + txtContra.Text + "'";
            cmd.ExecuteNonQuery();
            DataTable       dt = new DataTable();
            OdbcDataAdapter da = new OdbcDataAdapter(cmd);

            da.Fill(dt);

            i = Convert.ToInt32(dt.Rows.Count.ToString());

            if (i != 0)
            {
                if (cmbIniciar.Text == "Afiliado")
                {
                    cmd.CommandText = "execute SP_READ_USUARIO_ROL @user='******',@contra='" + txtContra.Text + "'" + ",@rol = 'Afiliado'";
                    cmd.ExecuteNonQuery();
                    DataTable       dt2 = new DataTable();
                    OdbcDataAdapter da2 = new OdbcDataAdapter(cmd);
                    da.Fill(dt2);
                    x = Convert.ToInt32(dt2.Rows.Count.ToString());

                    if (x != 0)
                    {
                        this.Hide();
                        FrmAfiliado f2 = new FrmAfiliado();
                        f2.lblUser.Text = txtUser.Text;
                        f2.Closed      += (s, args) => this.Close();
                        f2.Show();
                    }
                    else
                    {
                        TBD1.AseConnection.messageBox("Su usuario no posee el rol seleccionado.");
                    }
                }
                else if (cmbIniciar.Text == "Administrador")
                {
                    cmd.CommandText = "execute SP_READ_USUARIO_ROL @user='******',@contra='" + txtContra.Text + "'" + ",@rol = 'Administrador'";
                    cmd.ExecuteNonQuery();
                    DataTable       dt2 = new DataTable();
                    OdbcDataAdapter da2 = new OdbcDataAdapter(cmd);
                    da.Fill(dt2);

                    x = Convert.ToInt32(dt2.Rows.Count.ToString());

                    if (x != 0)
                    {
                        this.Hide();
                        FrmAdmin f3 = new FrmAdmin();
                        f3.lblUser.Text = txtUser.Text;
                        f3.Closed      += (s, args) => this.Close();
                        f3.Show();
                    }
                    else
                    {
                        TBD1.AseConnection.messageBox("Su usuario no posee el rol seleccionado.");
                    }
                }
            }
            else if (i == 0)
            {
                TBD1.AseConnection.messageBox("Su usuario o contraseña no es correcta.");
            }

            /*
             * //Temporal
             * this.Hide();
             * FrmAfiliado f3 = new FrmAfiliado();
             * f3.lblUser.Text = "Admin";
             * f3.Closed += (s, args) => this.Close();
             * f3.Show();
             */
        }