Exemple #1
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult result = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    // create writer
                    StreamWriter writer = new StreamWriter("Name2s.txt", true);
                    writer.WriteLine(FirstNameTextBox.Text + " " + LastNameTextBox.Text);

                    // close connections
                    writer.Close();

                    // reset the form fields
                    FirstNameTextBox.Clear();
                    LastNameTextBox.Clear();

                    FirstNameTextBox.Focus();
                }
                else
                {
                    FirstNameTextBox.Focus();
                    FirstNameTextBox.SelectAll();
                }
            } catch
            {
                Console.WriteLine("problems");
            }
        }
 private void ClearFormData()
 {
     FirstNameTextBox.Clear();
     LastNameTextBox.Clear();
     EmailAdrTextBox.Clear();
     ContactNumberTextBox.Clear();
 }
Exemple #3
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.OKCancel);

            if (result == DialogResult.OK)
            {
                // Step 1 - Open a stream
                StreamWriter writer = new StreamWriter("Names.txt", true);

                // Step 2 - Write to the buffer
                writer.WriteLine(FirstNameTextBox.Text + " " + LastNameTextBox.Text);

                // Step 3 - Close the file
                writer.Close();

                //Step 4 - Reset the Form
                FirstNameTextBox.Clear();
                LastNameTextBox.Clear();
                FirstNameTextBox.Focus();
            }
            else
            {
                FirstNameTextBox.Focus();
                FirstNameTextBox.SelectAll();
            }
        }
Exemple #4
0
 private void LoginButton_Click(object sender, EventArgs e)
 {
     if (registration == true)
     {
         if (LoginTextBox.Text != "" && PasswordTextBox.Text != "" && LastNameTextBox.Text != "" && EmailTextBox.Text != "" && RobotCheckBox.Checked == true && GenderComboBox.SelectedItem != null && BirthDateTimePicker.Value != null)
         {
             Users.Add(new User(LoginTextBox.Text, LastNameTextBox.Text, PasswordTextBox.Text, EmailTextBox.Text, GenderComboBox.SelectedItem, Convert.ToString(BirthDateTimePicker.Value)));
             folderBrowserDialog1.ShowDialog();
             File.AppendAllText(folderBrowserDialog1.SelectedPath + "\\Data.txt", $"Имя: {LoginTextBox.Text}, Фамилия: {LastNameTextBox.Text}, Электронная почта: {PasswordTextBox.Text}, Пароль: {EmailTextBox.Text}, Пол: {GenderComboBox.SelectedItem}, Дата рождения: {BirthDateTimePicker.Value}.\n");
             LoginTextBox.Clear();
             PasswordTextBox.Clear();
             LastNameTextBox.Clear();
             EmailTextBox.Clear();
             RobotCheckBox.Checked       = false;
             GenderComboBox.SelectedItem = "";
             BirthDateTimePicker.Value   = DateTime.Now;
         }
     }
     else
     {
         for (int i = 0; i < Users.Count; i++)
         {
             if (LoginTextBox.Text == User.GetInfo(Users[i], 0) && PasswordTextBox.Text == User.GetInfo(Users[i], 3))
             {
                 Sign sign = new Sign(User.GetInfo(Users[i], 0));
                 sign.TextLabel.Text = "Авторизация прошла успешно!";
                 sign.Show();
                 return;
             }
         }
         Sign form2 = new Sign();
         form2.TextLabel.Text = "Неправильный логин или пароль";
         form2.Show();
     }
 }
        private void ModifyToggleButtonClick(object sender, RoutedEventArgs e)
        {
            ToggleButton currentModifyToggleButton = (ToggleButton)sender;

            if (currentModifyToggleButton != lastModifyToggleButton && lastModifyToggleButton != null)
            {
                lastModifyToggleButton.IsChecked = false;
            }

            lastModifyToggleButton = (bool)currentModifyToggleButton.IsChecked ? currentModifyToggleButton : null;

            if (lastModifyToggleButton != null)
            {
                authorToModify          = (Author)AuthorsDataGrid.SelectedItem;
                AddButtonImage.Source   = new BitmapImage(new Uri(@"Assets/Icons/modify.png", UriKind.Relative));
                AddButtonTextBlock.Text = "Modyfikuj";
                FirstNameTextBox.Text   = authorToModify.FirstName;
                LastNameTextBox.Text    = authorToModify.LastName;
            }
            else
            {
                authorToModify          = null;
                AddButtonImage.Source   = new BitmapImage(new Uri(@"Assets/Icons/add.png", UriKind.Relative));
                AddButtonTextBlock.Text = "Dodaj";
                FirstNameTextBox.Clear();
                LastNameTextBox.Clear();
            }
        }
        private void newWorkerSubmit_Click(object sender, EventArgs e)
        {
            string newUserBannerId    = BannerTextBox.Text;
            string newUserFirstName   = FirstNameTextBox.Text;
            string newUserLastName    = LastNameTextBox.Text;
            string newUserPhoneNumber = PhoneNumberTextBox.Text;
            string newUserEmail       = EmailTextBox.Text;
            string newUserUserType    = UserTypeTextBox.Text;
            string newUserNotes       = NotesTextBox.Text;
            string newUserStatus      = StatusTextBox.Text;

            User newUser = new User(newUserBannerId, newUserFirstName, newUserLastName, newUserPhoneNumber, newUserEmail, newUserUserType, newUserNotes, newUserStatus);

            newUser.insert();

            BannerTextBox.Clear();
            FirstNameTextBox.Clear();
            LastNameTextBox.Clear();
            PhoneNumberTextBox.Clear();
            EmailTextBox.Clear();
            UserTypeTextBox.Clear();
            NotesTextBox.Clear();
            StatusTextBox.Clear();

            NewWorkerNotificationLabel.Text = "User added to database";
        }
 private void AddContactButtonClick(object sender, RoutedEventArgs e)
 {
     try
     {
         var contact = new Contact
         {
             Email     = EmailTextBox.Text,
             FirstName = FirstNameTextBox.Text,
             LastName  = LastNameTextBox.Text
         };
         MessageService.AddContact(contact);
         StatusBlock.Alert($"Contact {contact.Email} created successfully", StatusBlock.Success);
         EmailTextBox.Clear();
         FirstNameTextBox.Clear();
         LastNameTextBox.Clear();
     }
     catch (ItemAllreadyExistsException ex)
     {
         StatusBlock.Alert(ex.Message, StatusBlock.Danger);
     }
     catch (FormatException ex)
     {
         StatusBlock.Alert(ex.Message, StatusBlock.Warning);
     }
     catch (DbEntityValidationException)
     {
         StatusBlock.Alert("Validation failed for one of the fields", StatusBlock.Danger);
     }
     catch (Exception)
     {
         StatusBlock.Alert("Error while saving to database", StatusBlock.Danger);
     }
 }
        private void ResetForm()
        {
            FirstNameTextBox.Clear();
            LastNameTextBox.Clear();
            EmailAddressTextBox.Clear();
            ContactNumberTextBox.Clear();

            // clear Contact ComboBox List Items
            ContactComboBox.Items.Clear();
        }
Exemple #9
0
 /// <summary>
 /// Clears this instance.
 /// </summary>
 public void Clear()
 {
     ErrorMessageTextBlock.Visibility = Visibility.Collapsed;
     FirstNameTextBox.Clear();
     LastNameTextBox.Clear();
     EmailTextBox.Clear();
     PasswordBox.Clear();
     ConfirmPasswordBox.Clear();
     ZipCodeTextBox.Clear();
 }
        /// <summary>
        /// Handles the Click event of the NoButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        private void NoButton_Click(object sender, RoutedEventArgs e)
        {
            FirstNameTextBox.Clear();
            LastNameTextBox.Clear();
            EmailTextBox.Clear();
            PasswordBox.Clear();
            ConfirmPasswordBox.Clear();
            ZipCodeTextBox.Clear();
            GetEmailCheckBox.IsChecked = null;

            this.NavigationService.GoBack();
        }
Exemple #11
0
 //Method to sync textboxes with datagrid cells
 private void StudentOverviewDataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         FirstNameTextBox.Text = StudentOverviewDataGrid[0, e.RowIndex].Value.ToString();
         LastNameTextBox.Text  = StudentOverviewDataGrid[1, e.RowIndex].Value.ToString();
         StudyTextBox.Text     = StudentOverviewDataGrid[2, e.RowIndex].Value.ToString();
     }
     catch
     {
         FirstNameTextBox.Clear();
         LastNameTextBox.Clear();
         StudyTextBox.Clear();
     }
 }
        // Clear UI infput fields
        private void ClearUI()
        {
            IDTextBox.Clear();
            UserNameTextBox.Clear();
            PasswordTextBox.Clear();
            FirstNameTextBox.Clear();
            LastNameTextBox.Clear();
            EmailTextBox.Clear();
            var date = new DateTime();

            date = DateTime.Today;
            StartDateDatePickerTextBox.Text = date.ToShortDateString();
            UserTypeComboBox.Text           = "Staff";
            ProtectedUserCheckBox.IsChecked = false;
            UserInactiveCheckBox.IsChecked  = false;
        }
Exemple #13
0
 //When called it will update the buttons
 private void UpdateButtons()
 {
     if (peopleList.Count == 0)
     {
         RemoveButton.Enabled   = false;
         ClearAllButton.Enabled = false;
         MaleButton.Checked     = false;
         FemaleButton.Checked   = false;
         FirstNameTextBox.Clear();
         LastNameTextBox.Clear();
         SearchTextBox.Clear();
     }
     else
     {
         RemoveButton.Enabled   = true;
         ClearAllButton.Enabled = true;
     }
 }
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            myUserToModify.SetFirstName(FirstNameTextBox.Text);
            myUserToModify.SetLastName(LastNameTextBox.Text);
            myUserToModify.SetPhoneNumber(PhoneNumberTextBox.Text);
            myUserToModify.SetEmailAddress(EmailTextBox.Text);
            myUserToModify.SetUserType(UserTypeTextBox.Text);
            myUserToModify.SetNotes(NotesTextBox.Text);
            myUserToModify.SetStatus(StatusTextBox.Text);

            myUserToModify.update();

            FirstNameTextBox.Clear();
            LastNameTextBox.Clear();
            PhoneNumberTextBox.Clear();
            EmailTextBox.Clear();
            UserTypeTextBox.Clear();
            NotesTextBox.Clear();
            StatusTextBox.Clear();

            NewWorkerNotificationLabel.Text = "User updated";
        }
        private void AddButtonClick(object sender, RoutedEventArgs e)
        {
            AddButton.IsEnabled        = false;
            FirstNameTextBox.IsEnabled = false;
            LastNameTextBox.IsEnabled  = false;

            if (lastModifyToggleButton != null)
            {
                ModifyAction();
            }
            else
            {
                AddAction();
            }

            FirstNameTextBox.Clear();
            LastNameTextBox.Clear();

            AuthorsDataGrid.DataContext = dB.GetAuthors();

            AddButton.IsEnabled        = true;
            FirstNameTextBox.IsEnabled = true;
            LastNameTextBox.IsEnabled  = true;
        }
Exemple #16
0
        public void SubmitButton_Click(object sender, EventArgs e)
        {
            try
            {
                string gender;
                if (FemaleradioButton1.Checked)
                {
                    gender = FemaleradioButton1.Text;
                }
                else
                {
                    gender = MaleradioButton2.Text;
                }
                Passport pass  = new Passport(FirstNameTextBox.Text, LastNameTextBox.Text, CountryOfBirthTextBox.Text, NationalityTextBoox.Text);
                Address  adr   = new Address(StreetTextBox.Text, CityTextBox.Text, StateTextBox.Text, ZipTextBox.Text);
                Person   adam1 = new Passenger(int.Parse(IDNumberTextBox.Text), FirstNameTextBox.Text, LastNameTextBox.Text, gender, PhoneNumberTextBox.Text, adr, pass);
                foreach (Person p in TravelAgency.people)
                {
                    if (adam1.isEqual(p))
                    {
                        throw new DuplicateDataExcception("Sorry! This Passenger already exists");
                    }
                }

                string s = " ";

                if (FirstNameTextBox.Text == s || LastNameTextBox.Text == s)
                {
                    throw new InvalidName("Invalid Name");
                }

                if (PhoneNumberTextBox.Text == s)
                {
                    throw new InvalidPhoneNumber("Invalid PhoneNumber");
                }

                if (StreetTextBox.Text == s || CityTextBox.Text == s || StateTextBox.Text == s || ZipTextBox.Text == s)
                {
                    throw new InvalidAddress("Invalid Address");
                }

                if (CountryOfBirthTextBox.Text == s)
                {
                    throw new InvalidDataException("Invalid Country of Birth");
                }

                if (NationalityTextBoox.Text == s)
                {
                    throw new InvalidDataException("Invalid Nationality");
                }

                if (IDNumberTextBox.Text == s)
                {
                    throw new InvalidDataException("Invalid ID");
                }

                if (PassportNumberTextBox.Text == s)
                {
                    throw new InvalidDataException("Invalid Passport Number");
                }

                if (!FemaleradioButton1.Checked && !MaleradioButton2.Checked)
                {
                    throw new InvalidDataException("Invalid Gender");
                }

                TravelAgency.people.Add(adam1);
                MessageBox.Show("Passenger " + FirstNameTextBox.Text + " " + LastNameTextBox.Text + " was added");
                IDNumberTextBox.Clear();
                FirstNameTextBox.Clear();
                LastNameTextBox.Clear();
                PhoneNumberTextBox.Clear();
                StreetTextBox.Clear();
                CityTextBox.Clear();
                StateTextBox.Clear();
                ZipTextBox.Clear();
                CountryOfBirthTextBox.Clear();
                NationalityTextBoox.Clear();
                FemaleradioButton1.Checked = false;
                MaleradioButton2.Checked   = false;
                PassportTextBox.Clear();
            }
            catch (InvalidName)
            {
                MessageBox.Show("Invalid Name");
            }
            catch (InvalidPhoneNumber)
            {
                MessageBox.Show("invalid Phone Number");
            }
            catch (DuplicateDataExcception ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (OverflowException oe)
            {
                MessageBox.Show(oe.Message);
            }
            catch (Exception q)
            {
                MessageBox.Show(q.Message);
            }
        }
 /// <summary>
 /// Enter a value into the 'Last Name' field
 /// </summary>
 /// <param name="lastName">The value to enter</param>
 public void EnterLastName(string lastName)
 {
     LastNameTextBox.Clear();
     LastNameTextBox.SendKeys(lastName);
 }
Exemple #18
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            try
            {
                string gender;
                if (FemaleradioButton1.Checked)
                {
                    gender = FemaleradioButton1.Text;
                }
                else
                {
                    gender = MaleradioButton2.Text;
                }
                Address    addr  = new Address(StreetTextBox.Text, CityTextBox.Text, StateTextBox.Text, ZipTextBox.Text);
                CreditCard cc    = new CreditCard(int.Parse(CardNumbertextBox1.Text), int.Parse(PintextBox1.Text), DateTime.Parse(ExpirationDatedateTimePicker1.Text));
                Customer   cust1 = new Customer(FirstNameTextBox.Text, LastNameTextBox.Text, gender, addr, PhoneNumberTextBox.Text, int.Parse(IDNumberTextBox.Text), cc);

                foreach (Person p in TravelAgency.people)
                {
                    if (cust1.isEqual(p))
                    {
                        throw new DuplicateDataExcception("Sorry! This Customer already exists!");
                    }
                }
                string s = " ";
                if (FirstNameTextBox.Text == s || LastNameTextBox.Text == s)
                {
                    throw new InvalidName("Invalid Name");
                }

                if (PhoneNumberTextBox.Text == s)
                {
                    throw new InvalidPhoneNumber("Invalid PhoneNumber");
                }

                if (StreetTextBox.Text == s || CityTextBox.Text == s || StateTextBox.Text == s || ZipTextBox.Text == s)
                {
                    throw new InvalidAddress("Invalid Address");
                }

                if (IDNumberTextBox.Text == s)
                {
                    throw new InvalidDataException("Invalid ID");
                }

                if (CardNumbertextBox1.Text == s || PintextBox1.Text == s)
                {
                    throw new InvalidDataException("invalid card");
                }

                if (!FemaleradioButton1.Checked && !MaleradioButton2.Checked)
                {
                    throw new InvalidDataException("Invalid Gender");
                }

                TravelAgency.people.Add(cust1);
                MessageBox.Show("Customer " + FirstNameTextBox.Text + " " + LastNameTextBox.Text + " was added");
                FirstNameTextBox.Clear();
                LastNameTextBox.Clear();
                PhoneNumberTextBox.Clear();
                StreetTextBox.Clear();
                CityTextBox.Clear();
                StateTextBox.Clear();
                ZipTextBox.Clear();
                IDNumberTextBox.Clear();
                FemaleradioButton1.Checked = false;
                MaleradioButton2.Checked   = false;
                PintextBox1.Clear();
                ExpirationDatedateTimePicker1.ResetText();
                CardNumbertextBox1.Clear();
            }
            catch (InvalidName)
            {
                MessageBox.Show("Invalid Name");
            }
            catch (InvalidPhoneNumber)
            {
                MessageBox.Show("Invalid phone Number");
            }
            catch (DuplicateDataExcception ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (OverflowException oe)
            {
                MessageBox.Show(oe.Message);
            }
            catch (Exception q)
            {
                MessageBox.Show(q.Message);
            }
        }
Exemple #19
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            try //throw this exception if this passenger already exists
            {
                string gender;
                if (FemaleradioButton1.Checked)
                {
                    gender = FemaleradioButton1.Text;
                }
                else
                {
                    gender = MaleradioButton2.Text;
                }

                Address     addr  = new Address(StreetTextBox.Text, CityTextBox.Text, StateTextBox.Text, ZipTextBox.Text);
                TravelAgent trav1 = new TravelAgent(FirstNameTextBox.Text, LastNameTextBox.Text, gender, addr, PhoneNumberTextBox.Text, int.Parse(IDNumberTextBox.Text), double.Parse(EarningstextBox1.Text), SsnTextBox.Text);
                trav1.countofEmployees++;
                foreach (Person p in TravelAgency.people)
                {
                    if (trav1.isEqual(p))
                    {
                        throw new DuplicateDataExcception("Sorry! This Passenger already exists!");
                    }
                }
                string s = " ";

                if (FirstNameTextBox.Text == s || LastNameTextBox.Text == s)
                {
                    throw new InvalidName("Invalid Name");
                }

                if (PhoneNumberTextBox.Text == s)
                {
                    throw new InvalidPhoneNumber("Invalid PhoneNumber");
                }

                if (StreetTextBox.Text == s || CityTextBox.Text == s || StateTextBox.Text == s || ZipTextBox.Text == s)
                {
                    throw new InvalidAddress("Invalid Address");
                }

                if (IDNumberTextBox.Text == s)
                {
                    throw new InvalidDataException("Invalid ID");
                }

                if (SsnTextBox.Text == s)
                {
                    throw new InvalidDataException("Invalid Passport Number");
                }

                if (!FemaleradioButton1.Checked && !MaleradioButton2.Checked)
                {
                    throw new InvalidDataException("Invalid Gender");
                }
                TravelAgency.people.Add(trav1);
                MessageBox.Show("Travel Agent " + FirstNameTextBox.Text + " " + LastNameTextBox.Text + " was added");
                FirstNameTextBox.Clear();
                LastNameTextBox.Clear();
                PhoneNumberTextBox.Clear();
                StreetTextBox.Clear();
                SsnTextBox.Clear();
                CityTextBox.Clear();
                StateTextBox.Clear();
                ZipTextBox.Clear();
                FemaleradioButton1.Checked = false;
                MaleradioButton2.Checked   = false;
                IDNumberTextBox.Clear();
                EarningstextBox1.Clear();
            }
            catch (InvalidName)
            {
                MessageBox.Show("Invalid Name");
            }
            catch (InvalidPhoneNumber)
            {
                MessageBox.Show("Invalid phone Number");
            }
            catch (DuplicateDataExcception ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (OverflowException oe)
            {
                MessageBox.Show(oe.Message);
            }
            catch (FormatException f)
            {
                MessageBox.Show(f.Message);
            }
            catch (Exception q)
            {
                MessageBox.Show(q.Message);
            }
        }
Exemple #20
0
 private void LastNameTextBox_Click(object sender, EventArgs e)
 {
     LastNameTextBox.Clear();
 }