Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //UserDetailsLabel.Visible = false;
        //UpdateUserDetailsTable.Visible = false;

        InterestsCBL.Visible = false;
        AddButton.Visible = false;
        SaveChangesLabel.Visible = false;

        dbOps = DBOperations.Instance;
        links = Links.Instance;
        general = General.Instance;
        gui = GUIVariables.Instance;
        engine = ProcessingEngine.Instance;
        categories = Categories.Instance;

        if (string.IsNullOrEmpty(Request.QueryString["UID"]))
        {

        }
        else
        {
            queryStringUID = Request.QueryString["UID"].Trim().ToLower();
        }

        if (string.IsNullOrEmpty(queryStringUID))
        {
            UserDetailsLabel.Visible = false;
            UpdateUserDetailsTable.Visible = false;

            SubmittedLB.Visible = false;
            CommentedLB.Visible = false;
        }
        else
        {
            UserDetailsLabel.Visible = true;
            UpdateUserDetailsTable.Visible = false;

            string userDetails = string.Empty;
            StringBuilder returnSB = new StringBuilder();

            string date = string.Empty;
            string eMail = string.Empty;
            string about = string.Empty;

            string queryString = "SELECT Date, EMail, About FROM getputs.user where UID='" + queryStringUID + "';";
            MySqlDataReader retList = dbOps.ExecuteReader(queryString);

            if (retList != null && retList.HasRows)
            {
                while (retList.Read())
                {
                    date = Convert.ToString(retList["Date"]);
                    eMail = Convert.ToString(retList["EMail"]);
                    about = Convert.ToString(retList["About"]);

                    date = general.GetFormattedDate(date);

                    returnSB.AppendLine(gui.GrayFontStart + "User: "******"Created: " + gui.GrayFontEnd + date);
                    returnSB.AppendLine(gui.LineBreak);
                    //  //  Keep E-Mail Private.
                    //  returnSB.AppendLine(gui.GrayFontStart + "EMail: " + gui.GrayFontEnd + eMail);
                    //  returnSB.AppendLine(gui.LineBreak);
                    returnSB.AppendLine(gui.GrayFontStart + "About: " + gui.GrayFontEnd + about);

                    userDetails = returnSB.ToString();
                }
                retList.Close();
            }

            if (string.IsNullOrEmpty(userDetails))
            {
                userDetails = gui.RedFontStart + "No such user found." + gui.RedFontEnd;

                SubmittedLB.Visible = false;
                CommentedLB.Visible = false;
                SavedLB.Visible = false;
                RatedLB.Visible = false;
            }

            UserDetailsLabel.Text = userDetails;
        }

        if (Request.Cookies["getputsCookie"] != null)
        {
            HttpCookie getputsCookie = Request.Cookies["getputsCookie"];
            loggedUID = dbOps.Decrypt(getputsCookie["UID"].ToString().Trim());

            if (string.IsNullOrEmpty(loggedUID))
            {
                UpdateUserDetailsTable.Visible = false;
            }
            else if (loggedUID.Equals(queryStringUID))
            {
                UserDetailsLabel.Visible = false;
                UpdateUserDetailsTable.Visible = true;

                InterestsCBL.Visible = true;
                AddButton.Visible = true;
                SaveChangesLabel.Visible = true;

                if (!IsPostBack)
                {
                    GetPreferredCategories(loggedUID);

                    StringBuilder returnSB = new StringBuilder();

                    string date = string.Empty;
                    string eMail = string.Empty;
                    string about = string.Empty;

                    string queryString = "SELECT Date, EMail, About FROM getputs.user where UID='" + loggedUID + "';";
                    MySqlDataReader retList = dbOps.ExecuteReader(queryString);

                    if (retList != null && retList.HasRows)
                    {
                        while (retList.Read())
                        {
                            date = Convert.ToString(retList["Date"]);
                            eMail = Convert.ToString(retList["EMail"]);
                            about = Convert.ToString(retList["About"]);

                            date = general.GetFormattedDate(date);

                            UserLabelR.Text = loggedUID;
                            CreatedLabelR.Text = date;

                            AboutTB.Text = about;
                            EMailTB.Text = eMail;

                        }
                        retList.Close();
                    }
                }
            }
        }

        //  Whether to show the SavedLB or not.
        if (!string.IsNullOrEmpty(queryStringUID) && !string.IsNullOrEmpty(loggedUID))
        {
            if (queryStringUID.Equals(loggedUID))
            {
                SavedLB.Visible = true;
                RatedLB.Visible = true;
            }
            else
            {
                SavedLB.Visible = false;
                RatedLB.Visible = false;
            }
        }
        else
        {
            SavedLB.Visible = false;
            RatedLB.Visible = false;
        }
    }