Exemplo n.º 1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        Boolean success = false;
        int     id      = 0;

        Label1.Text = "";


        System.Data.SqlClient.SqlConnection sc = new System.Data.SqlClient.SqlConnection();
        sc.ConnectionString = ConfigurationManager.ConnectionStrings["RoomMagnet"].ConnectionString;

        sc.Open();
        System.Data.SqlClient.SqlCommand match = new System.Data.SqlClient.SqlCommand();
        match.Connection = sc;

        match.CommandText = "select passwordhash from[db_owner].[AdminPassword] where Email = @Email " +
                            "union select passwordhash from[dbo].[HostPassword] where Email = @Email " +
                            "union select passwordhash from[dbo].[TenantPassword] where Email = @Email";



        match.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Email", tbEmail.Text));
        System.Data.SqlClient.SqlDataReader reader = match.ExecuteReader(); // create a reader

        if (reader.HasRows)
        {
            while (reader.Read())                                             // this will read the single record that matches the entered usename
            {
                string storedHash = reader["PasswordHash"].ToString();        // store the database password into this varable
                if (PasswordHash.ValidatePassword(Password.Text, storedHash)) // if the entered password matches what is stored, it will show success
                {
                    success = true;
                }
                else
                {
                    Label1.Text = "Invalid Account";
                }
            }
        }
        else
        {
            Label1.Text = "The user name does not exist";
        }

        sc.Close();

        if (success == true)
        {
            sc.Open();
            System.Data.SqlClient.SqlCommand matchID = new System.Data.SqlClient.SqlCommand();
            matchID.Connection = sc;
            //matchID.CommandText = "Select AdminID from [db_owner].[AdminPassword] where Email = @Email";
            matchID.CommandText = "select adminid from[db_owner].[AdminPassword] where Email = @Email " +
                                  "union select hostid from[dbo].[HostPassword] where Email = @Email " +
                                  "union select tenantid from[dbo].[TenantPassword] where Email = @Email";
            matchID.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Email", tbEmail.Text));
            id = (Int32)matchID.ExecuteScalar();
            Session["globalID"] = id;


            System.Data.SqlClient.SqlCommand type = new System.Data.SqlClient.SqlCommand();
            type.Connection = sc;

            type.CommandText = "select * from [dbo].[RMUser] where userid = " + id;



            SqlDataAdapter sda = new SqlDataAdapter(type);
            DataTable      dt  = new DataTable();
            sda.Fill(dt);

            if (dt.Rows.Count != 0)
            {
                Session["USERID"]    = dt.Rows[0]["UserID"].ToString();
                Session["USEREMAIL"] = dt.Rows[0]["Email"].ToString();
                Session["FRISTNAME"] = dt.Rows[0]["FirstName"].ToString();

                if (CheckBox1.Checked)
                {
                    Response.Cookies["UNAME"].Value = tbEmail.Text;


                    Response.Cookies["UNAME"].Expires = DateTime.Now.AddDays(15);
                }
                else
                {
                    Response.Cookies["UNAME"].Expires = DateTime.Now.AddDays(-1);
                }
                string Utype;
                Utype = dt.Rows[0]["UserType"].ToString().Trim();

                Session["USERTYPE"] = Utype.ToString();

                if (Utype == "t")
                {
                    Session["USERNAME"] = tbEmail.Text;
                    Response.Redirect("~/TenantDashboard.aspx");
                }
                if (Utype == "a")
                {
                    Session["USERNAME"] = tbEmail.Text;
                    Response.Redirect("~/AdminDashBoard.aspx");
                }
                if (Utype == "h")
                {
                    Session["USERNAME"] = tbEmail.Text;
                    Response.Redirect("~/HostDashBoard.aspx");
                }
            }
            else
            {
            }
        }
    }
 private CharProperty family(boolean singleLetter,
                             boolean maybeComplement)
 {
     next();
     String name;
     CharProperty node = null;
     int i;
     if (singleLetter) {
         int c = temp[_cursor];
         if (!Character.isSupplementaryCodePoint(c)) {
             name = String.valueOf((char)c);
         } else {
             name = new String(temp, _cursor, 1);
         }
         read();
     } else {
         i = _cursor;
         mark('}');
         while(read() != '}') {
         }
         mark('\u0000');
         int j = _cursor;
         if (j > patternLength)
             throw error(new String("Unclosed character family"));
         if (i + 1 >= j)
             throw error(new String("Empty character family"));
         name = new String(temp, i, j-i-1);
     }
     i = name.indexOf('=');
     if (i != -1) {
         // property construct \p{name=value}
         String value = name.substring(i + 1);
         name = name.substring(0, i).toLowerCase();
         if (new String("sc").equals(name) || new String("script").equals(name)) {
             node = unicodeScriptPropertyFor(value);
         } else if (new String("blk").equals(name) || new String("block").equals(name)) {
             node = unicodeBlockPropertyFor(value);
         } else if (new String("gc").equals(name) || new String("general_category").equals(name)) {
             node = charPropertyNodeFor(value);
         } else {
             throw error(new String("Unknown Unicode property {name=<" + name + ">, "
                          + "value=<" + value + ">}"));
         }
     } else {
         if (name.startsWith(new String("In"))) {
             // \p{inBlockName}
             node = unicodeBlockPropertyFor(name.substring(2));
         } else if (name.startsWith(new String("Is"))) {
             // \p{isGeneralCategory} and \p{isScriptName}
             name = name.substring(2);
             UnicodeProp uprop = UnicodeProp.forName(name);
             if (uprop != null)
                 node = new Utype(uprop);
             if (node == null)
                 node = CharPropertyNames.charPropertyFor(name);
             if (node == null)
                 node = unicodeScriptPropertyFor(name);
         } else {
             if (has(UNICODE_CHARACTER_CLASS)) {
                 UnicodeProp uprop = UnicodeProp.forPOSIXName(name);
                 if (uprop != null)
                     node = new Utype(uprop);
             }
             if (node == null)
                 node = charPropertyNodeFor(name);
         }
     }
     if (maybeComplement) {
         if (node is Category || node is Block)
             hasSupplementary = true;
         node = node.complement();
     }
     return node;
 }