Пример #1
0
        private void btnClient_Click(object sender, RoutedEventArgs e)
        {
            string email         = EmailTxtBox.Text;
            string twitterHandle = TwitterHandleTxtBox.Text;
            string facebookEmail = FacebookEmailTxtBox.Text;
            User   newC          = null;

            try
            {
                newC = new User
                {
                    FirstName = FirstNameTxtBox.Text,
                    LastName  = LastNameTxtBox.Text,
                };
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Please enter both a first and last name for the client.");
            }
            db.Users.InsertOnSubmit(newC);
            if (email != null)
            {
                db.Emails.InsertOnSubmit(new Email {
                    EmailAddress = email, User = newC
                });
            }
            if (facebookEmail != null)
            {
                db.SocialMedias.InsertOnSubmit(new SocialMedia {
                    User = newC, SMHandle = facebookEmail, SMtyKey = 2
                });
            }
            if (twitterHandle != null)
            {
                db.SocialMedias.InsertOnSubmit(new SocialMedia {
                    User = newC, SMHandle = twitterHandle, SMtyKey = 1
                });
            }
            db.SubmitChanges();
            if (email != null || facebookEmail != null || twitterHandle != null)
            {
                try
                {
                    db.SubmitChanges();
                    MessageBox.Show("Submission successful");
                }
                catch (Exception ex)
                {
                    StreamWriter w = new StreamWriter("errorLog");
                    w.Write(ex.Message + "\n" + "Client Submit" + DateTime.Now + "\n\n");
                    MessageBox.Show("AN ERROR HAS OCCURED WHEN SUBMITTING THE CLIENT", "Database Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Please enter data in at least one box");
            }
        }
Пример #2
0
        private void LoginBTN_Click(object sender, RoutedEventArgs e)
        {
            string EMailAdd  = AddressTXT.Text;
            string EmailPass = EMailPB.Password;

            if (!isAuth)
            {
                temp.authorize(TwitterPB.Password.ToString().Trim());
                db.Twitters.InsertOnSubmit(new Twitter()
                {
                    AToken     = temp.getAuthTokenAsString(),
                    ASecret    = temp.getAuthSecretAsString(),
                    UserId     = temp.getUserID(),
                    ScreenName = temp.getUserHandle()
                });
                db.SubmitChanges();
                TwitterPB.Password  = "";
                TwitterPB.IsEnabled = false;
            }
        }