Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int CurrentId = Convert.ToInt32(Context.User.Identity.Name);

        ProfPicture.ImageUrl = "~/Users/PictureHandler.ashx/?UserId=" + CurrentId.ToString();

        Users Users = new Users();

        Users.UserInformation Uinfo = Users.UserInfo(CurrentId);

        UserNameLabel.InnerText = Uinfo.FirstName + " " + Uinfo.LastName;

        Student = new Students(CurrentId, 1);

        PageTitle.Text = Student.FirstName + " " + Student.LastName;

        if (Session["School"] == null)
        {
            Response.Redirect("../UserPage.aspx");
        }

        else
        {
            SchoolName.InnerText = Student.School.GetSchool(Convert.ToInt32(Session["School"].ToString())).Info.SchoolName;
        }
    }
Ejemplo n.º 2
0
    public List <Users.UserInformation> OnlineUsers(int UserId)
    {
        List <Users.UserInformation> UserList = new List <Users.UserInformation>();

        using (var Con = new SqlConnection(GC.ConnectionString))
        {
            Con.Open();

            Query = "Select * from Online_Users inner Join Users on Online_Users.User_Id = Users.Id where Online_Users.User_Id != '" + UserId + "'";

            using (var Com = new SqlCommand(Query, Con))
            {
                Reader = Com.ExecuteReader();

                while (Reader.Read())
                {
                    Users User = new Users();
                    Users.UserInformation UserInfo = new Users.UserInformation();
                    UserInfo = User.UserInfo(Convert.ToInt32(Reader["User_id"].ToString()));

                    UserList.Add(UserInfo);
                }
            }
            Con.Close();
        }

        return(UserList);
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int CurrentId = Convert.ToInt32(Session["UserId"]);

        CurrentId = Convert.ToInt32(Context.User.Identity.Name);

        Chat chat = new Chat(Convert.ToInt32(Context.User.Identity.Name));

        chat.GetInbox();

        foreach (Chat ch in chat.GetChatData())
        {
            System.Diagnostics.Debug.WriteLine(ch.Message + "from" + ch.Sender.FirstName + ch.Sender.LastName);
        }

        foreach (string Role in Roles.GetRolesForUser(CurrentId.ToString()))
        {
            if (Role == "Students" || Role == "Teachers" || Role == "Administrators")
            {
                NewUserPrompt.Visible = false;

                System.Diagnostics.Debug.WriteLine(Role);
            }


            else
            {
                NewUserPrompt.Visible = true;
            }
        }


        foreach (string User in Roles.GetUsersInRole("Administrators"))
        {
            System.Diagnostics.Debug.WriteLine("Users:" + User);
        }

        Users Users = new Users();

        Users.UserInformation Uinfo = Users.UserInfo(CurrentId);

        this.Title = Uinfo.FirstName + " " + Uinfo.LastName;



        UserProfileNames.InnerText = Uinfo.UserName;

        Birthday.InnerText = Uinfo.DateOfBirth.ToString("MMMM,dd,yyyy");



        ProfilePicture2.ImageUrl = "~/Users/PictureHandler.ashx/?UserId=" + CurrentId.ToString();


        Salutation.InnerText = Uinfo.UserName;
    }
Ejemplo n.º 4
0
    public List <Notifications> PopulateNotifications(int num)
    {
        DefaultNotificationsNumber = num;
        List <Notifications> MyNotis = new List <Notifications>();
        Notifications        Note;

        using (var con = new SqlConnection(GC.ConnectionString))
        {
            con.Open();

            string Query = "select top 15 * from Notifications inner join users on Notifications.user_id=users.id where Target_Group=1 order by notifications.id desc";


            using (var com = new SqlCommand(Query, con))
            {
                SqlDataReader MyReader = com.ExecuteReader();

                while (MyReader.Read())
                {
                    Note = new Notifications();

                    Note.id = Convert.ToInt32(MyReader[0].ToString());

                    Note.Message = MyReader["Notification"].ToString();

                    Users Sender = new Users();

                    Users.UserInformation SenderInfo = Sender.UserInfo(Convert.ToInt32(MyReader["User_id"].ToString()));

                    Note.Sender = SenderInfo;

                    MyNotis.Add(Note);
                }

                com.Dispose();
            }

            con.Close();
        }

        return(MyNotis);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        int CurrentId     = Convert.ToInt32(Context.User.Identity.Name);
        int SelectorIndex = 0;


        User = new Users();

        Users.UserInformation Uinfo = User.UserInfo(CurrentId);

        foreach (string Role in Roles.GetRolesForUser(CurrentId.ToString()))
        {
            HtmlGenericControl li = null;

            if (Role == "Students")
            {
                List <Schools> SchoolSAttended = new List <Schools>();
                SchoolSAttended = User.GetSchools(CurrentId);

                foreach (Schools School in SchoolSAttended)
                {
                    li = new HtmlGenericControl("li");

                    HtmlAnchor Anch = new HtmlAnchor();

                    Anch.InnerText = School.Info.SchoolName;
                    Anch.ID        = School.Info.SchoolId.ToString();

                    li.Controls.Add(Anch);

                    Anch.ServerClick += new EventHandler(SchoolSelected);

                    PageSelector.Controls.AddAt(SelectorIndex, li);

                    SelectorIndex++;
                }
            }

            else if (Role == "Teachers")
            {
                li = new HtmlGenericControl("<li><a href=" + "Teachers/Teachers_Home_Default.aspx" + ">" + Role + "</a></li>");
            }
            else if (Role == "Administrators")
            {
                li = new HtmlGenericControl("<li><a href=#>" + Role + "</a></li>");
            }

            try
            {
                PageSelector.Controls.AddAt(SelectorIndex, li);
                SelectorIndex++;
            }
            catch
            {
            }
        }


        UserNameLabel.InnerText = Uinfo.FirstName + " " + Uinfo.LastName;


        ProfPicture.ImageUrl = "~/Users/PictureHandler.ashx/?UserId=" + CurrentId.ToString();
    }
Ejemplo n.º 6
0
    //User data captured here
    protected void SubmitInfo_ServerClick(object sender, EventArgs e)
    {
        //try
        //{

        Users = new Users();

        Users.UserInformation UserInfo = new Users.UserInformation();

        Bitmap Bm = null;

        UserInfo.FirstName = FirstNameBox.Value;
        UserInfo.LastName  = LastNameBox.Value;
        UserInfo.OtherName = MiddleNameBox.Value;
        UserInfo.UserName  = UserNameBox.Value;
        UserInfo.Email     = EmailBox.Value;


        if (ProfilePictureUpload.HasFile)
        {
            Bm = new Bitmap(ProfilePictureUpload.PostedFile.InputStream);
        }

        else
        {
            Bm = null;
        }

        UserInfo.ProfilePicture = Bm;

        if (BirthDaySelection.Value != null)
        {
            UserInfo.DateOfBirth = (DateTime)BirthDaySelection.Value;
        }
        else
        {
            UserInfo.DateOfBirth = DateTime.Today;
        }

        UserInfo.PhoneNumber = PhoneNumberBox.Value;

        AlertContainer.Visible = true;


        if (Users.NewUser(UserInfo, PasswordBox.Value, RptPasswordBox.Value).Code == 0)
        {
            if (Session["UserId"] == null)
            {
                Session.Add("UserId", Users.CurrentId);
            }
            else
            {
                Session["UserId"] = Users.CurrentId;
            }

            CreateUserFile(UserInfo.FirstName + " " + UserInfo.LastName + "[" + UserInfo.UserName + "]");


            UploadImage(ProfilePictureUpload, ProfileUserPath, UserInfo.UserName, ".jpg");

            // Response.Redirect("UserPage.aspx");

            FormsAuthentication.RedirectFromLoginPage(Users.CurrentId.ToString(), true);

            AlertContainer.Attributes["class"] = "alert alert-success";
            AlertMessage.InnerText             = "User Account has been Created Succesfully";
        }

        else
        {
            AlertContainer.Attributes["class"] = "alert alert-danger";
            AlertMessage.InnerText             = Users.NewUser(UserInfo, PasswordBox.Value, RptPasswordBox.Value).MessageData;

            System.Diagnostics.Debug.WriteLine(Users.NewUser(UserInfo, PasswordBox.Value, RptPasswordBox.Value).MessageData);
        }

        //}
        //catch
        //{

        //}
    }