コード例 #1
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        lblMsg.Text = "";
        if (!(txtUsername.Text.Equals("") || txtPassword.Equals("")))
        {
            WcfServiceReference.Service1Client sr = new WcfServiceReference.Service1Client();
            if(sr.LoginUser(txtUsername.Text, txtPassword.Text))
            {
                Response.Cookies["userName"].Value = txtUsername.Text;
                Response.Cookies["userName"].Expires = DateTime.Now.AddDays(1);

                HttpCookie aCookie = new HttpCookie("lastVisit");
                aCookie.Value = DateTime.Now.ToString();
                aCookie.Expires = DateTime.Now.AddDays(1);
                Response.Cookies.Add(aCookie);
                //Response.Write(txtUsername.Text);
                Response.Redirect("Search.aspx");
                lblMsg.Text = "Logged in.";
            }
            else
            {
                lblMsg.Text = "Wrong username and/or password. Please try again.";
            }
        }
        else
        {
            lblMsg.Text = "Fields cannot be empty.";
        }
    }
コード例 #2
0
        public ActionResult GetAddService()
        {
            WcfServiceReference.Service1Client obj = new WcfServiceReference.Service1Client();

            //ServiceReference1.WebService1SoapClient obj = new ServiceReference1.WebService1SoapClient();
            ViewBag.result = obj.Add(12, 20);
            return(View());
        }
コード例 #3
0
 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");
 }
コード例 #4
0
    protected void RegisterButton_Click(object sender, EventArgs e)
    {
        bool error = false;
        lblMsg.Text = "";
        WcfServiceReference.Service1Client sr = new WcfServiceReference.Service1Client();

            if (passion1.SelectedIndex.Equals(passion2.SelectedIndex))
            {
                lblMsg.Text = "a"+ passion1.SelectedIndex + " " + passion2.SelectedIndex + " " + passion3.SelectedIndex;
                error = true;
            }
            if (passion2.SelectedIndex.Equals(passion3.SelectedIndex))
            {
                lblMsg.Text = "b"+ passion1.SelectedIndex + " " + passion2.SelectedIndex + " " + passion3.SelectedIndex;
                error = true;
            }
            if (passion1.SelectedIndex.Equals(passion3.SelectedIndex))
            {
                lblMsg.Text ="c"+ passion1.SelectedIndex + " " + passion2.SelectedIndex + " " + passion3.SelectedIndex;
                //lblMsg.Text = "Similar passions selected 1 and 3.";
                error = true;
            }

            if (error == false && !sr.EmailExists(txtEmail.Text) && !sr.UsernameExists(txtUsername.Text))
            {
                string day = Request.Form.Get("days");
                string month = Request.Form.Get("months");
                string year = Request.Form.Get("years");
                string bday = string.Format("{0}/{1}/{2}", day, month, year);
                int isAdvisor = 0;
                if (isAdvisorChk.Checked) { isAdvisor = 1; }
                DateTime birthdate = DateTime.Parse(bday, new System.Globalization.CultureInfo("fr-FR", true));
                sr.RegisterUser(txtUsername.Text, txtPassword.Text, txtEmail.Text, txtRealName.Text, passion1.SelectedIndex+1, passion2.SelectedIndex+1, passion3.SelectedIndex+1, birthdate, isAdvisor);
                if (isAdvisor == 1)
                {
                    lblMsg.Text = "Advisor registered";
                }
                else
                {
                lblMsg.Text = "User registered";
                }
                txtUsername.Text = "";
                txtPassword.Text = "";
                txtRePassword.Text = "";
                txtRealName.Text = "";
                txtEmail.Text = "";
            }
            else if (sr.EmailExists(txtEmail.Text) || sr.UsernameExists(txtUsername.Text))
            {
                lblMsg.Text = "Email or username already registered!";
            }
            else
            {
                lblMsg.Text = "Make sure all the fields are completed.";
            }
    }
コード例 #5
0
    protected void UpdateButton_Click(object sender, EventArgs e)
    {
        bool error = false;
        lblMsg.Text = "";
        WcfServiceReference.Service1Client sr = new WcfServiceReference.Service1Client();

        if (passion1.SelectedIndex.Equals(passion2.SelectedIndex))
        {
            lblMsg.Text = "a" + passion1.SelectedIndex + " " + passion2.SelectedIndex + " " + passion3.SelectedIndex;
            error = true;
        }
        if (passion2.SelectedIndex.Equals(passion3.SelectedIndex))
        {
            lblMsg.Text = "b" + passion1.SelectedIndex + " " + passion2.SelectedIndex + " " + passion3.SelectedIndex;
            error = true;
        }
        if (passion1.SelectedIndex.Equals(passion3.SelectedIndex))
        {
            lblMsg.Text = "c" + passion1.SelectedIndex + " " + passion2.SelectedIndex + " " + passion3.SelectedIndex;
            //lblMsg.Text = "Similar passions selected 1 and 3.";
            error = true;
        }

        if (error == false)
        {
            int day=1, month=1, year=1992;

            day = Int32.Parse(daysDb.SelectedValue);
            month = Int32.Parse(monthDb.SelectedValue);
            year = Int32.Parse(yearDb.SelectedValue);
            //string bday = string.Format("{0}/{1}/{2}", day, month,year);
            //DateTime birthdate = DateTime.Parse(bday, new System.Globalization.CultureInfo("fr-FR", true));
            DateTime birthdate = new DateTime(year, month, day);

            sr.UpdateUser(txtUsername.Text, txtPassword.Text, txtEmail.Text, txtRealName.Text, passion1.SelectedIndex+1 , passion2.SelectedIndex+1 , passion3.SelectedIndex+1 , birthdate);
            lblMsg.Text = "Updated!";
            txtUsername.Text = "";
            txtPassword.Text = "";
            txtRePassword.Text = "";
            txtRealName.Text = "";
            txtEmail.Text = "";
        }

        else
        {
            lblMsg.Text = "Make sure all the fields are completed.";
        }
        //sr.RegisterUser(txtUsername.Text, txtUsername.Text, "Email",2, 5, 6);
    }
コード例 #6
0
    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;
    }
コード例 #7
0
    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);
            }
        }
    }
コード例 #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        /*
        DateTime dt = DateTime.Today;
        TimeSpan span = DateTime.Now-dt;
        Response.Write(span.Minutes);
        */

        isSearching = false;
        if (Request.Cookies["userName"] != null)
        {
            theCookie = Request.Cookies.Get("userName");
            String value = theCookie.Value;
            //if (!IsPostBack)
            //{
                WcfServiceReference.Service1Client sr = new WcfServiceReference.Service1Client();
                passion1.Items.Clear();
                passion2.Items.Clear();
                passion3.Items.Clear();

                passion1.Items.Add("None");
                passion2.Items.Add("None");
                passion3.Items.Add("None");
                foreach (string s in sr.GetAllPassions())
                {
                    passion1.Items.Add(s);
                    passion2.Items.Add(s);
                    passion3.Items.Add(s);
                }
               CreateButtons();
            //}
        }
        else
        {
            Response.Redirect("Login.aspx");
        }
    }
コード例 #9
0
 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");
 }
コード例 #10
0
    private void CreateButtons()
    {
        HttpCookie theCookie = Request.Cookies.Get("userName");
        String value = theCookie.Value;
        WcfServiceReference.Service1Client sr = new WcfServiceReference.Service1Client();
        if (isSearching)
        {
            results = sr.GetAllResults(passion1.SelectedIndex, passion2.SelectedIndex, passion3.SelectedIndex, value);
        }
        else
        {
            results = sr.GetAllUsers(value);
        }
        foreach (User r in results)
        {
            for (int i = 0; i < 3; i++)
            {
                r.Passion1String = sr.GetPassionById(r.Passion1);
                r.Passion2String = sr.GetPassionById(r.Passion2);
                r.Passion3String = sr.GetPassionById(r.Passion3);

            }
            Panel panel = new Panel();
            panel.Width = 1000;
            panel.Height = 180;
            panel.BorderWidth = 10;
            panel.HorizontalAlign = HorizontalAlign.Left;
            //Username
            Label label = new Label();
            label.Width = 1000;
            label.Height = 10;
            label.Text = r.Username;
            panel.Controls.Add(label);
            //Realname
            Label label2 = new Label();
            label2.Width = 1000;
            label2.Height = 10;
            label2.Text = r.Name;
            panel.Controls.Add(label2);
            //Email
            Label label3 = new Label();
            label3.Width = 1000;
            label3.Height = 10;
            label3.Text = r.Email;
            panel.Controls.Add(label3);
            //Name
            Label label4 = new Label();
            label4.Width = 1000;
            label4.Height = 10;
            label4.Text = r.Passion1String + " | " + r.Passion2String + " | " + r.Passion3String + " ;";
            panel.Controls.Add(label4);

            Button newButton = new Button();
            newButton.Click += new EventHandler(newButton_Click);
            newButton.ID = "a" + r.Username;
            newButton.Width = 980;
            newButton.Height = 30;
            newButton.Text = "Add connection.";
            panel.Controls.Add(newButton);
            //more info
            Button newButton2 = new Button();
            newButton2.Click += new EventHandler(newButton2_Click);
            newButton2.ID = "b" + r.Username;
            newButton2.Width = 980;
            newButton2.Height = 30;

            newButton2.Text = "Click me for more information about this person.";
            panel.Controls.Add(newButton2);

            Panel_Controls.Controls.Add(panel);
        }
    }
コード例 #11
0
    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");
        }
    }