protected void aboutButton3_Click(object sender, EventArgs e)
 {
     WcfServiceReference.Service1Client sr = new WcfServiceReference.Service1Client();
     User user = sr.GetUserByUsername(Request.Cookies["Username"].Value);
     string r = ((Button)sender).ID;
     int t = sr.GetUserByUsername(r).Id;
     sr.CreateConnection(t, user.Id);
     Response.Redirect("Connections.aspx");
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

        WcfServiceReference.Service1Client sr = new WcfServiceReference.Service1Client();
            passion1.Items.Clear();
            passion2.Items.Clear();
            passion3.Items.Clear();
            foreach (string s in sr.GetAllPassions())
        {
            passion1.Items.Add(s);
            passion2.Items.Add(s);
            passion3.Items.Add(s);
        }
            for(int i = 1; i <= 31; i++)
            {
                daysDb.Items.Add(""+i);
            }
            for (int i = 1; i <= 12; i++)
            {
                monthDb.Items.Add(""+i);
            }
            for (int i = 1901; i <= 2016; i++)
            {
                yearDb.Items.Add(""+i);
            }

            string username = Request.Cookies["userName"].Value;
            User user = sr.GetUserByUsername(username);
            txtRealName.Text = user.Name;
            txtEmail.Text = user.Email;
            txtUsername.Text = user.Username;

            daysDb.SelectedIndex = user.Bday.Day-1;

            monthDb.SelectedIndex = user.Bday.Month-1;

            yearDb.SelectedIndex = user.Bday.Year-1901;

            passion1.SelectedIndex = user.Passion1-1;
            passion2.SelectedIndex = user.Passion2-1;
            passion3.SelectedIndex = user.Passion3-1;
        }
        txtUsername.Text = Request.Cookies["userName"].Value;
    }
 void newButton_Click(object sender, EventArgs e)
 {
     WcfServiceReference.Service1Client sr = new WcfServiceReference.Service1Client();
     User user = sr.GetUserByUsername(Request.Cookies["Username"].Value);
     string r = ((Button)sender).ID.Substring(1,((Button)sender).ID.Length-1);
     int t = sr.GetUserByUsername(r).Id;
     sr.InsertUserConnection(user.Id, t);
     Response.Redirect("Connections.aspx");
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Cookies["userName"] != null)
        {

                WcfServiceReference.Service1Client service = new WcfServiceReference.Service1Client();
                User currUser = service.GetUserByUsername(Request.Cookies["userName"].Value);
                //Finds where acceptance =0
                User[] results0 = service.GetAllConnections0(currUser);
                foreach (User r in results0)
                {
                    Panel panel = new Panel();
                    panel.Width = 600;
                    panel.Height = 180;
                    panel.BorderWidth = 10;
                    panel.HorizontalAlign = HorizontalAlign.Center;
                    //Username
                    Label label = new Label();
                    label.Width = 600;
                    label.Height = 10;
                    label.Text = r.Username;
                    panel.Controls.Add(label);
                    //Realname
                    Label label2 = new Label();
                    label2.Width = 600;
                    label2.Height = 10;
                    label2.Text = r.Name;
                    panel.Controls.Add(label2);
                    //Email
                    Label label3 = new Label();
                    label3.Width = 600;
                    label3.Height = 10;
                    label3.Text = r.Email;
                    panel.Controls.Add(label3);
                    //Name
                    Label label4 = new Label();
                    label4.Width = 600;
                    label4.Height = 10;
                    label4.Text = r.Passion1String + " | " + r.Passion2String + " | " + r.Passion3String + " ;";
                    panel.Controls.Add(label4);
                    //BirthDate
                    Label label5 = new Label();
                    label5.Width = 600;
                    label5.Height = 10;
                    label5.Text = r.Bday.ToString();
                    panel.Controls.Add(label4);

                    //more info
                    Button newButton2 = new Button();
                    newButton2.ID = "a" + r.Username;
                    newButton2.Width = 580;
                    newButton2.Height = 30;
                    newButton2.Text = "Click me for more information about this person.";
                    newButton2.Click += new EventHandler(aboutButton2_Click);
                    //pass the username through lamda for recognize the profile in the database;
                    panel.Controls.Add(newButton2);

                    Button newButton3 = new Button();
                    newButton3.ID = "" + r.Username;
                    newButton3.Width = 580;
                    newButton3.Height = 30;
                    newButton3.Text = "Accept request!";
                    newButton3.Click += new EventHandler(aboutButton3_Click);
                    //pass a variable through lambda for the accept id!
                    panel.Controls.Add(newButton3);

                    Panel_Controls.Controls.Add(panel);
                    //Panel_Controls.Controls.Add(panel);

                }

            User[] resultsPending =  service.GetAllPendingConnections(currUser);
            foreach (User r in resultsPending)
            {
                Panel panel = new Panel();
                panel.Width = 600;
                panel.Height = 180;
                panel.BorderWidth = 10;
                panel.HorizontalAlign = HorizontalAlign.Center;
                //Username
                Label label = new Label();
                label.Width = 600;
                label.Height = 10;
                label.Text = r.Username;
                panel.Controls.Add(label);
                //Realname
                Label label2 = new Label();
                label2.Width = 600;
                label2.Height = 10;
                label2.Text = r.Name;
                panel.Controls.Add(label2);
                //Email
                Label label3 = new Label();
                label3.Width = 600;
                label3.Height = 10;
                label3.Text = r.Email;
                panel.Controls.Add(label3);
                //Name
                Label label4 = new Label();
                label4.Width = 600;
                label4.Height = 10;
                label4.Text = r.Passion1String + " | " + r.Passion2String + " | " + r.Passion3String + " ;";
                panel.Controls.Add(label4);
                //BirthDate
                Label label5 = new Label();
                label5.Width = 600;
                label5.Height = 10;
                label5.Text = r.Bday.ToString();
                panel.Controls.Add(label4);

                //more info
                Button newButton2 = new Button();
                newButton2.ID = "a" + r.Username;
                newButton2.Width = 580;
                newButton2.Height = 30;
                newButton2.Text = "Click me for more information about this person.";
                newButton2.Click += new EventHandler(aboutButton2_Click);
                //pass the username through lamda for recognize the profile in the database;
                panel.Controls.Add(newButton2);

                Button newButton3 = new Button();
                newButton3.ID = "" + r.Username;
                newButton3.Width = 580;
                newButton3.Height = 30;
                newButton3.Text = "Cancel connection request !";
                newButton3.Click += new EventHandler(pendingButton_Click);
                //pass a variable through lambda for the accept id!
                panel.Controls.Add(newButton3);

                Panel_Controls.Controls.Add(panel);
                //Panel_Controls.Controls.Add(panel);

            }

            //Find where acceptance=1
            User[] results1 = service.GetAllConnections1(currUser);
                foreach (User r in results1)
                {
                    Panel panel = new Panel();
                    panel.Width = 600;
                    panel.Height = 180;
                    panel.BorderWidth = 10;
                    panel.HorizontalAlign = HorizontalAlign.Center;
                    //Username
                    Label label = new Label();
                    label.Width = 600;
                    label.Height = 10;
                    label.Text = r.Username;
                    panel.Controls.Add(label);
                    //Realname
                    Label label2 = new Label();
                    label2.Width = 600;
                    label2.Height = 10;
                    label2.Text = r.Name;
                    panel.Controls.Add(label2);
                    //Email
                    Label label3 = new Label();
                    label3.Width = 600;
                    label3.Height = 10;
                    label3.Text = r.Email;
                    panel.Controls.Add(label3);
                    //Name
                    Label label4 = new Label();
                    label4.Width = 600;
                    label4.Height = 10;
                    label4.Text = r.Passion1String + " | " + r.Passion2String + " | " + r.Passion3String + " ;";
                    panel.Controls.Add(label4);
                    //BirthDate
                    Label label5 = new Label();
                    label5.Width = 600;
                    label5.Height = 10;
                    label5.Text = r.Bday.ToString();
                    panel.Controls.Add(label4);

                    //more info
                    Button newButton2 = new Button();
                    newButton2.ID = "b" + r.Username;
                    newButton2.Width = 580;
                    newButton2.Height = 30;

                    newButton2.Text = "Click me for more information about this person.";
                    newButton2.Click += new EventHandler(aboutButton2_Click);
                    //pass the username through lamda for recognize the profile in the database;
                    panel.Controls.Add(newButton2);

                    Panel_Controls.Controls.Add(panel);

                }

        }
        else
        {
            Response.Redirect("Login.aspx");
        }
    }