Пример #1
0
        private void QRgenerate_Click(object sender, EventArgs e)
        {
            PagePortal pagePor = new PagePortal();

            QRCoder.QRCodeGenerator generateQR = new QRCoder.QRCodeGenerator();
            var QRdata = generateQR.CreateQrCode(QRcontent.Text, QRCoder.QRCodeGenerator.ECCLevel.H);
            var QRcode = new QRCoder.QRCode(QRdata);
            var image  = QRcode.GetGraphic(150);

            QRcodeImage.Image = image;
        }
        private async void BtnGoogleP_Click(object sender, RoutedEventArgs e)
        {
            SociaLogin SL = new SociaLogin();

            SL.ShowDialog();
            tokenResponse = SL.access.Access_token;
            string userinfoRequestURI = "https://www.googleapis.com/plus/v1/people/me";

            try
            {
                // sends the request
                HttpWebRequest userinfoRequest = (HttpWebRequest)WebRequest.Create(userinfoRequestURI);
                userinfoRequest.Method = "GET";
                userinfoRequest.Headers.Add(string.Format("Authorization: Bearer {0}", SL.access.Access_token));
                userinfoRequest.ContentType = "application/x-www-form-urlencoded";
                userinfoRequest.Accept      = "Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";

                WebResponse userinfoResponse = await userinfoRequest.GetResponseAsync();

                using (StreamReader userinfoResponseReader = new StreamReader(userinfoResponse.GetResponseStream()))
                {
                    // reads response body
                    string userinfoResponseText = await userinfoResponseReader.ReadToEndAsync();

                    var node = JsonConvert.DeserializeXNode(userinfoResponseText, "Profile");
                    ProfileXML = node.ToString();

                    XmlSerializer serializer = new XmlSerializer(typeof(Profile));
                    XmlReader     reader     = XmlReader.Create(new StringReader(ProfileXML));
                    user = (Profile)serializer.Deserialize(reader);

                    GPname  = user.displayName;
                    GPemail = user.emails.myemail;

                    PagePortal pagepor = new PagePortal();
                    this.NavigationService.Navigate(pagepor);
                    pagepor.getGooglePlusUser(GPname);
                    //HP.ShowDialog();
                    //this.Hide();
                    //Por.Show();
                }
            }
            catch (System.NullReferenceException)
            {
                MessageBox.Show("Google+ Log In Error");
            }
        }
 private void BtnLogin_Click(object sender, RoutedEventArgs e)
 {
     if (textEmail.Text.Length == 0)
     {
         MessageBox.Show("Error: Enter Your Email");
         textEmail.Focus();
     }
     else if (!Regex.IsMatch(textEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"))
     {
         MessageBox.Show("Error: Enter Valid Email");
         textEmail.Select(0, textEmail.Text.Length);
         textEmail.Focus();
     }
     else
     {
         string        email    = textEmail.Text;
         string        password = passwordbox.Password;
         SqlConnection con      = new SqlConnection("Data Source=.;Initial Catalog=PatientDB;Integrated Security=True");
         con.Open();
         SqlCommand cmd = new SqlCommand("Select * from Registration where Email='" + email + "'  and password='******'", con);
         cmd.CommandType = CommandType.Text;
         SqlDataAdapter adapter = new SqlDataAdapter();
         adapter.SelectCommand = cmd;
         DataSet dataSet = new DataSet();
         adapter.Fill(dataSet);
         if (dataSet.Tables[0].Rows.Count > 0)
         {
             var    DBtable      = dataSet.Tables[0].Rows[0];
             string username     = DBtable["FirstName"].ToString() + " " + DBtable["LastName"].ToString();
             string fulluserinfo = DBtable["FirstName"].ToString() + " " + DBtable["LastName"].ToString() + "\r\n" + DBtable["Email"].ToString() + "\r\n" + DBtable["Gender"].ToString() + "\r\n" + DBtable["Birthday"].ToString() + "\r\n" + DBtable["PhoneNo"].ToString() + "\r\n" + DBtable["Address1"].ToString() + "\r\n" + DBtable["Address2"].ToString() + "\r\n" + DBtable["Postcode"].ToString() + "\r\n" + DBtable["State"].ToString();
             MessageBox.Show("Welcome " + username);
             PagePortal pagepor = new PagePortal();
             pagepor.getGooglePlusUser(username);
             pagepor.getuserinfo(fulluserinfo);
             this.NavigationService.Navigate(pagepor);
         }
         else
         {
             MessageBox.Show("Error: Email or Password incorrect");
         }
         con.Close();
     }
 }
        private void Btnregister_Click(object sender, RoutedEventArgs e)
        {
            if (emailR.Text.Length == 0)
            {
                MessageBox.Show("Error: Enter Your Email");
                emailR.Text = "";
                emailR.Focus();
            }
            else if (!Regex.IsMatch(emailR.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"))
            {
                MessageBox.Show("Error: Enter a valid email");
                emailR.Text = "";
                emailR.Select(0, emailR.Text.Length);
                emailR.Focus();
            }
            else
            {
                string firstname = Fname.Text;
                string lastname  = Lname.Text;
                string email     = emailR.Text;
                string Genders   = gender.Text;
                string phoneNum  = phoneNo.Text;
                string birthdayU = birthday.Text;
                string password  = password1.Password;
                if (password1.Password.Length == 0)
                {
                    MessageBox.Show("Error: Enter password");
                    password1.Focus();
                }
                else if (confirmPassword.Password.Length == 0)
                {
                    MessageBox.Show("Error: Enter Confirm password");
                    confirmPassword.Focus();
                }
                else if (password1.Password != confirmPassword.Password)
                {
                    MessageBox.Show("Error: Confirm password must be same as password.");
                    confirmPassword.Focus();
                }
                else
                {
                    string        addressL  = address1.Text;
                    string        addressLL = address2.Text;
                    string        location  = state.Text;
                    string        locID     = postcode.Text;
                    SqlConnection con       = new SqlConnection("Data Source=.;Initial Catalog=PatientDB;Integrated Security=True");
                    con.Open();
                    SqlCommand cmd = new SqlCommand("Insert into Registration (FirstName,LastName,Email,Password,Gender,Birthday,PhoneNo,Address1,Address2,Postcode,State) values('" + firstname + "','" + lastname + "','" + email + "','" + password + "','" + Genders + "','" + birthdayU + "','" + phoneNum + "','" + addressL + "','" + addressLL + "','" + locID + "','" + location + "')", con);
                    cmd.CommandType = CommandType.Text;
                    cmd.ExecuteNonQuery();
                    con.Close();
                    MessageBox.Show("You have Registered successfully");
                    PagePortal pagepor = new PagePortal();

                    pagepor.getuserinfo(firstname + " " + lastname + "\r\n" + email + "\r\n" + Genders + "\r\n" + birthdayU + "\r\n" + phoneNum + "\r\n" + addressL + "\r\n" + addressLL + "\r\n" + locID + "\r\n" + location);
                    pagepor.getGooglePlusUser(firstname + " " + lastname);
                    this.NavigationService.Navigate(pagepor);
                    Reset();
                }
            }
        }