Пример #1
0
        private void RetreiveMethod()
        {
            if (!PinText.Password.Equals(""))
            {
                if (PinText.Password.Equals(App.yale.Boxes.Box[itemIndex].pin))
                {
                    RetreivePhone();
                }
                else
                {
                    WrongBlock.Visibility = Visibility.Visible;
                    ForgotGrid.Visibility = Visibility.Visible;
                    PhoneBox.Focus(FocusState.Keyboard);
                    PinText.Password = "";
                }
            }

            else if (!PhoneBox.Text.Equals(""))
            {
                if (PhoneBox.Text.Equals(App.yale.Boxes.Box[itemIndex].owner.phone))
                {
                    RetreivePhone();
                }
                else
                {
                    WrongPhBlock.Visibility = Visibility.Visible;
                }
            }
        }
Пример #2
0
        private void PhoneCheckBtn_Click(object sender, EventArgs e)
        {
            string phone   = PhoneBox.Text;
            string dbPhone = "";
            string sql     = "SELECT USER_PHONE FROM TBL_USER WHERE USER_PHONE = " + "'" + phone + "'";

            dt = db.GetDBTable(sql);

            foreach (DataRow dr in dt.Rows)
            {
                dbPhone = dr["user_phone"].ToString();
            }

            if (phone == dbPhone)
            {
                MessageBox.Show("이미 가입된 핸드폰번호 입니다.");
                PhoneBox.Text = "";
                PhoneBox.Focus();
                return;
            }
            else
            {
                MessageBox.Show("사용 가능한 핸드폰번호 입니다.");
            }
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            int    employeeid = Convert.ToInt32(IdBox.Text);
            string name       = NameBox.Text;
            int    Phone      = Convert.ToInt32(PhoneBox.Text);
            string joinigdate = JoinBox.Text;
            string pass       = PassBox.Text;
            int    salary     = Convert.ToInt32(SalaryBox.Text);
            // string package = PackageBox.Text;
            // int due = Convert.ToInt32(DueBox.Text);
            string position = PsitionBox.Text;

            EmployeeDAO b = new EmployeeDAO();

            b.createEmployee(new EmployeeDTO(name, employeeid, pass, Phone, joinigdate, position, salary));
            loademployee();

            IdBox.Clear();
            PassBox.Clear();
            NameBox.Clear();
            PhoneBox.Clear();
            JoinBox.Clear();
            PsitionBox.Clear();
            SalaryBox.Clear();
        }
Пример #4
0
 private void PhoneBox_GotFocus(object sender, RoutedEventArgs e)
 {
     if (PhoneBox.Text.Equals("Phone"))
     {
         PhoneBox.Text = "";
     }
     PhoneBox.Focus(FocusState.Keyboard);
 }
 private void clearTextBoxes()
 {
     id = 0;
     UnameBox.Clear();
     mailBox.Clear();
     addressBox.Clear();
     PhoneBox.Clear();
 }
Пример #6
0
 private void PhoneBox_LostFocus(object sender, EventArgs e)
 {
     if (PhoneBox.Text.Length != 11)
     {
         MessageBox.Show("핸드폰 번호를 잘 못 입력하셨습니다.");
         PhoneBox.Text = "";
         PhoneBox.Focus();
     }
 }
Пример #7
0
 /*Clears all TextBoxes */
 protected void clearAllBoxes()
 {
     SurnameBox.Clear();
     NameBox.Clear();
     PhoneBox.Clear();
     MailBox.Clear();
     CityBox.Clear();
     AddressBox.Clear();
     NoteBox.Clear();
 }
Пример #8
0
 private void Cleared()
 {
     FirstNBox.Clear();
     LastNBox.Clear();
     MiddleNBox.Clear();
     PhoneBox.Clear();
     EmailBox.Clear();
     AddressBox1.Clear();
     AddressBox2.Clear();
     CityBox.Clear();
     StateBox.Clear();
     ZipBox.Clear();
     CountryBox.Clear();
 }
Пример #9
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     FirstNBox.Clear();
     LastNBox.Clear();
     MiddleNBox.Clear();
     PhoneBox.Clear();
     EmailBox.Clear();
     AddressBox1.Clear();
     AddressBox2.Clear();
     CityBox.Clear();
     StateBox.Clear();
     ZipBox.Clear();
     CountryBox.Clear();
 }
Пример #10
0
        private void Reset()
        {
            string text = SearchBox.Text.Trim();

            View.DataSource = Program.Entities.Teachers
                              .Where(s => text.Length == 0 || s.Name.Contains(text))
                              .ToList();

            IdBox.Clear();
            NameBox.Clear();
            AddressBox.Clear();
            MaleButton.Checked = FemaleButton.Checked = false;
            DobBox.Value       = DateTime.Today;
            PhoneBox.Clear();
        }
Пример #11
0
        /*
         * Name, Phone number:
         * Those two parameters have to be filled to create a new contact
         *
         * Sets newContact object as null if values are incorrect
         */
        virtual protected void AddBtn_Click(object sender, EventArgs e)
        {
            /*Name and Phone Number fields have to be passed to create new contact*/
            bool isPhoneNumberEmpty = string.IsNullOrWhiteSpace(PhoneBox.Text);
            bool isNameEmpty        = string.IsNullOrWhiteSpace(NameBox.Text);


            if (isPhoneNumberEmpty == true || isNameEmpty == true)
            {
                newContact = null;
                MessageBox.Show("\"Name\" and \"Phone number\" fields have to be filled!");
                clearAllBoxes();
            }

            else if (!isNumeric(PhoneBox.Text))
            {
                MessageBox.Show("Type correct phone number!");
                newContact = null;
                PhoneBox.Clear();
            }

            else if (!isMailCorrect(MailBox.Text))
            {
                MessageBox.Show("Type correct Email Address!");
                newContact = null;
                MailBox.Clear();
            }

            else
            {
                People person = new People();

                person.Surname        = SurnameBox.Text;
                person.Name           = NameBox.Text;
                person.FullName       = SurnameBox.Text + " " + NameBox.Text;
                person.PhoneNumber    = PhoneBox.Text;
                person.EmailAddress   = MailBox.Text;
                person.City           = CityBox.Text;
                person.Address        = AddressBox.Text;
                person.AdditionalInfo = NoteBox.Text;

                newContact = person;

                clearAllBoxes();
                this.Close();
            }
        }
Пример #12
0
        /// <summary>
        /// Clears all fields and sets necessary enables/disables to
        /// prepare for new customer entry into database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NewCustomerButton_Click(object sender, EventArgs e)
        {
            FirstNameBox.Clear();
            LastNameBox.Clear();
            AddressBox.Clear();
            CityBox.Clear();
            StateBox.Clear();
            ZipBox.Clear();
            PhoneBox.Clear();
            EmailBox.Clear();
            CustomerSelectBox.Enabled = false;
            CancelButton.Enabled      = true;
            SaveButton.Enabled        = true;
            return;

            /*
             * // When add customer button is first clicked, display message and disable box.
             * if (CustomerSelectBox.Enabled == true)
             * {
             *  MessageBox.Show("To add a customer, fill in the fields and click Add Customer again", "Add Customer");
             *  CustomerSelectBox.Enabled = false;
             *  return;
             * }
             *
             * // Once form is in "add customer" mode, add customer normally.
             * else
             * {
             *  bool valid = true; // Boolean will be set to false if any tests fail, used to check if customer should be saved.
             *  if (FirstNameBox.Text == "" || Regex.IsMatch(FirstNameBox.Text, name))
             *  {
             *      MessageBox.Show("Please enter your first name", "First name is a required field");
             *      FirstNameBox.Focus();
             *      valid = false;
             *  }
             *  if (LastNameBox.Text == "" || Regex.IsMatch(LastNameBox.Text, name))
             *  {
             *      MessageBox.Show("Please enter your last name", "Last name is a required field");
             *      LastNameBox.Focus();
             *      valid = false;
             *  }
             *  if (AddressBox.Text == "" || Regex.IsMatch(AddressBox.Text, address))
             *  {
             *      MessageBox.Show("Please enter your address", "Address is a required field");
             *      AddressBox.Focus();
             *      valid = false;
             *  }
             *  if (CityBox.Text == "" || Regex.IsMatch(CityBox.Text, name))
             *  {
             *      MessageBox.Show("Please enter your city", "City is a required field");
             *      CityBox.Focus();
             *      valid = false;
             *  }
             *  if (StateBox.Text == "" || Regex.IsMatch(StateBox.Text, name))
             *  {
             *      MessageBox.Show("Please enter your state", "State is a required field");
             *      StateBox.Focus();
             *      valid = false;
             *  }
             *  if (ZipBox.Text == "" || Regex.IsMatch(ZipBox.Text, zip))
             *  {
             *      MessageBox.Show("Please enter your zip code", "Zip Code is a required field");
             *      ZipBox.Focus();
             *      valid = false;
             *  }
             *  if (PhoneBox.Text == "" || Regex.IsMatch(PhoneBox.Text, phone))
             *  {
             *      MessageBox.Show("Please enter your phone number", "Phone number is a required field");
             *      PhoneBox.Focus();
             *      valid = false;
             *  }
             *  if (EmailBox.Text == "" || Regex.IsMatch(EmailBox.Text, email))
             *  {
             *      MessageBox.Show("Please enter your email address", "Email is a required field");
             *      EmailBox.Focus();
             *      valid = false;
             *  }
             *
             *  // If no issues, add customer to text file and ComboBox.
             *  if (valid)
             *  {
             *      Customer tempCustomer = new Customer(FirstNameBox.Text, LastNameBox.Text, AddressBox.Text, CityBox.Text, StateBox.Text, ZipBox.Text, PhoneBox.Text, EmailBox.Text);
             *      customers.Add(tempCustomer);
             *
             *      // Close reader and inFile even if exception is thrown.
             *      // SRC:https://stackoverflow.com/questions/86766/how-to-properly-handle-exceptions-when-performing-file-io
             *      try
             *      {
             *          using (FileStream outFile = new FileStream("customers.txt", FileMode.Append, FileAccess.Write))
             *          using (StreamWriter writer = new StreamWriter(outFile))
             *          {
             *              // Write info to file.
             *              writer.WriteLine($"{FirstNameBox.Text},{LastNameBox.Text},{AddressBox.Text},{CityBox.Text},{StateBox.Text},{ZipBox.Text},{PhoneBox.Text},{EmailBox.Text}");
             *              // Clear Text Boxes.
             *              FirstNameBox.Clear();
             *              LastNameBox.Clear();
             *              AddressBox.Clear();
             *              CityBox.Clear();
             *              StateBox.Clear();
             *              ZipBox.Clear();
             *              PhoneBox.Clear();
             *              EmailBox.Clear();
             *              CustomerSelectBox.Items.Add(tempCustomer);
             *              CustomerSelectBox.Enabled = true;
             *          }
             *      }
             *      catch (FileNotFoundException)
             *      {
             *          MessageBox.Show("File 'customers.txt' not found to write.", "File Write Error");
             *      }
             *      // Catch generic I/O exceptions.
             *      catch (IOException ex)
             *      {
             *          MessageBox.Show(ex.ToString(), "Error");
             *      }
             *
             *  }
             * }
             */
        }
Пример #13
0
        /// <summary>
        /// Clicking button checks if all fields have plausible entires (not empty or wrong format). Then
        /// updates currently selected customer with new information. Uses email as unique identifier, but
        /// does not check if email already exists. (Not sure how...)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveButton_Click(object sender, EventArgs e)
        {
            bool valid = true; // Boolean will be set to false if any tests fail, used to check if customer should be saved.

            if (FirstNameBox.Text == "" || !Regex.IsMatch(FirstNameBox.Text, name))
            {
                MessageBox.Show("Please enter your first name", "First name is a required field");
                FirstNameBox.Focus();
                valid = false;
            }
            if (LastNameBox.Text == "" || !Regex.IsMatch(LastNameBox.Text, name))
            {
                MessageBox.Show("Please enter your last name", "Last name is a required field");
                LastNameBox.Focus();
                valid = false;
            }
            if (AddressBox.Text == "" || !Regex.IsMatch(AddressBox.Text, address))
            {
                MessageBox.Show("Please enter your address", "Address is a required field");
                AddressBox.Focus();
                valid = false;
            }
            if (CityBox.Text == "" || !Regex.IsMatch(CityBox.Text, city))
            {
                MessageBox.Show("Please enter your city", "City is a required field");
                CityBox.Focus();
                valid = false;
            }
            if (StateBox.Text == "" || !Regex.IsMatch(StateBox.Text, name))
            {
                MessageBox.Show("Please enter your state", "State is a required field");
                StateBox.Focus();
                valid = false;
            }
            if (ZipBox.Text == "" || !Regex.IsMatch(ZipBox.Text, zip))
            {
                MessageBox.Show("Please enter your zip code", "Zip Code is a required field");
                ZipBox.Focus();
                valid = false;
            }
            if (PhoneBox.Text == "" || !Regex.IsMatch(PhoneBox.Text, phone))
            {
                MessageBox.Show("Please enter your phone number", "Phone number is a required field");
                PhoneBox.Focus();
                valid = false;
            }
            if (EmailBox.Text == "" || !Regex.IsMatch(EmailBox.Text, email))
            {
                MessageBox.Show("Please enter your email address", "Email is a required field");
                EmailBox.Focus();
                valid = false;
            }

            // If invalid entry, do not save.
            if (!valid)
            {
                return;
            }

            // Else
            string          ConnectionString = "server=localhost;user=root;database=book store;password="******"Insert into customer values" +
                                  $"('null','{FirstNameBox.Text}'," +
                                  $"'{LastNameBox.Text}'," +
                                  $"'{AddressBox.Text}'," +
                                  $"'{CityBox.Text}'," +
                                  $"'{StateBox.Text}'," +
                                  $"'{ZipBox.Text}'," +
                                  $"'{PhoneBox.Text}'," +
                                  $"'{EmailBox.Text}')";

                cmd.Connection = DBConnect;
                cmd.ExecuteNonQuery();
                DBConnect.Close();

                FirstNameBox.Clear();
                LastNameBox.Clear();
                AddressBox.Clear();
                CityBox.Clear();
                StateBox.Clear();
                ZipBox.Clear();
                PhoneBox.Clear();
                EmailBox.Clear();

                // Call function to update the combobox with new customer added.
                CustomerSelectBox_Click(sender, e);

                CustomerSelectBox.Enabled = true;
                SaveButton.Enabled        = false;
                MessageBox.Show("Customer added to database.");
                return;
            }
            // Else update the currently selected customer with textbox info

            // Extract first and last name into string array.
            string[] custName = new string[2];
            custName = CustomerSelectBox.Text.Split();

            cmd.CommandText = $"Update customer set" +
                              $" first='{FirstNameBox.Text}'," +
                              $"last='{LastNameBox.Text}'," +
                              $"address='{AddressBox.Text}'," +
                              $"city='{CityBox.Text}'," +
                              $"state='{StateBox.Text}'," +
                              $"zip='{ZipBox.Text}'," +
                              $"phone='{PhoneBox.Text}'," +
                              $"email='{EmailBox.Text}'" +
                              $" where first='{custName[0]}' AND last ='{custName[1]}'";
            cmd.Connection = DBConnect;
            cmd.ExecuteNonQuery();
            DBConnect.Close();
            MessageBox.Show("Customer successfully updated.");
            return;



            /*
             * SaveButton.Enabled = false;     // Disable the save button again until new customer is selected from the comboBox.
             *
             * // Rewrite the entire file, omitting the line with the email of the customer that is being updated, since email is unique.
             * // SRC: https://stackoverflow.com/questions/10371630/c-sharp-text-file-search-for-specific-word-and-delete-whole-line-of-text-that-co
             * Customer tempCustomer = (Customer)(CustomerSelectBox.SelectedItem);
             * var oldLines = File.ReadAllLines("customers.txt");
             * var newLines = oldLines.Where(line => !line.Contains(tempCustomer.email));
             * File.WriteAllLines("customers.txt", newLines);
             *
             * customers.Remove((Customer)CustomerSelectBox.SelectedItem);  // Remove old customer info from customer list.
             *
             * // Add new info to list.
             * tempCustomer = new Customer(FirstNameBox.Text, LastNameBox.Text, AddressBox.Text, CityBox.Text, StateBox.Text, ZipBox.Text, PhoneBox.Text, EmailBox.Text);
             * customers.Add(tempCustomer);
             *
             * // Close reader and inFile even if exception is thrown.
             * // SRC:https://stackoverflow.com/questions/86766/how-to-properly-handle-exceptions-when-performing-file-io
             * try
             * {
             *  using (FileStream outFile = new FileStream("customers.txt", FileMode.Append, FileAccess.Write))
             *  using (StreamWriter writer = new StreamWriter(outFile))
             *  {
             *      // Write info to file.
             *      writer.WriteLine($"{FirstNameBox.Text},{LastNameBox.Text},{AddressBox.Text},{CityBox.Text},{StateBox.Text},{ZipBox.Text},{PhoneBox.Text},{EmailBox.Text}");
             *  }
             *
             *  // Clear Text Boxes.
             *  FirstNameBox.Clear();
             *  LastNameBox.Clear();
             *  AddressBox.Clear();
             *  CityBox.Clear();
             *  StateBox.Clear();
             *  ZipBox.Clear();
             *  PhoneBox.Clear();
             *  EmailBox.Clear();
             *
             *  // Update comboBox with new info.
             *  CustomerSelectBox.Items.Remove(CustomerSelectBox.SelectedItem);
             *  CustomerSelectBox.Items.Add(tempCustomer);
             * }
             * catch (FileNotFoundException)
             * {
             *  MessageBox.Show("File 'customers.txt' not found to write.", "File Write Error");
             * }
             * // Catch generic I/O exceptions.
             * catch (IOException ex)
             * {
             *  MessageBox.Show(ex.ToString(), "Error");
             * }
             */
        }
Пример #14
0
        /// <summary>
        /// Отправление данных.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SendButton_Click(object sender, RoutedEventArgs e)
        {
            if (client != null)
            {
                if (client.Connected)
                {
                    string path;

                    try
                    {
                        path = FileNameTextBox.Text;

                        if (FirstLastNameBox.Text != string.Empty &&
                            UniversityBox.Text != string.Empty &&
                            PhoneBox.Text != string.Empty &&
                            path != string.Empty)                                                                   // условия для запуска обработки и отправки данных
                        {
                            UserInfo user = new UserInfo(FirstLastNameBox.Text, UniversityBox.Text, PhoneBox.Text); // получение и подготовка данных

                            if (File.Exists(path))
                            {
                                PrepareData(user, path);

                                byte[] info        = Encoding.ASCII.GetBytes(packetSerialize.Length.ToString());
                                bool   isConnected = Send(info); // отправка информации о размере (или об отключении)

                                if (isConnected)
                                {
                                    if (client.Connected)
                                    {
                                        isConnected = Send(packetSerialize);

                                        if (isConnected)
                                        {
                                            WriteStatus("\nОжидание ответа...");

                                            Task receiveTask = Task.Factory.StartNew(Receive);

                                            FirstLastNameBox.IsEnabled = false;
                                            FirstLastNameBox.Clear();
                                            UniversityBox.IsEnabled = false;
                                            UniversityBox.Clear();
                                            PhoneBox.IsEnabled = false;
                                            PhoneBox.Clear();
                                            FileNameTextBox.Clear();
                                            browseButton.IsEnabled = false;
                                            SendButton.IsEnabled   = false;
                                            MyPic.Visibility       = Visibility.Hidden;
                                            MyPic.Visibility       = Visibility.Hidden;
                                        }
                                    }
                                    else
                                    {
                                        WriteStatus("\n\nСоединение было разорвано!");
                                        ConnectButton.Content = "Подключиться";

                                        Shutdown();
                                    }
                                }
                            }
                            else
                            {
                                _ = MessageBox.Show("Текущий путь до файла не корректен, либо файл отсуствует!", "Ошибка!");
                            }
                        }
                        else
                        {
                            _ = MessageBox.Show("Заполните все поля ввода данных!", "Ошибка!");
                        }
                    }
                    catch (Exception)
                    {
                        _ = MessageBox.Show("Неизвестная ошибка!", "Ошибка!");
                    }
                }
                else // отсутствие подключения
                {
                    _ = MessageBox.Show("Проблема с соединением. Попробуйте переподключиться.", "Ошибка!");
                    ConnectButton.Content = "Подключиться";
                }
            }
            else
            {
                _ = MessageBox.Show("Сначала необходимо подключиться!", "Ошибка!");
            }
        }
Пример #15
0
 private void RealeaseBtn_Click(object sender, EventArgs e)
 {
     PhoneBox.Clear();
     CallManager.OnUserRelease(call.Session);
 }