private void Clear_Click(object sender, EventArgs e)
 {
     IDBox.Clear();
     NameBox.Clear();
     SurnameBox.Clear();
     CityBox.Clear();
     MaleRadio.Checked   = false;
     FemaleRadio.Checked = false;
 }
Exemple #2
0
 /*Clears all TextBoxes */
 protected void clearAllBoxes()
 {
     SurnameBox.Clear();
     NameBox.Clear();
     PhoneBox.Clear();
     MailBox.Clear();
     CityBox.Clear();
     AddressBox.Clear();
     NoteBox.Clear();
 }
Exemple #3
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();
 }
Exemple #4
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();
 }
        private void CreateAddress()
        {
            Student NewStudent = new Student();

            int.TryParse(StreetNumberBox.Text, out int StreetNumber);
            int.TryParse(ZipCodeBox.Text, out int ZipCode);

            NewStudent.SetAddress(StreetNumber, StreetNameBox.Text, StateBox.Text, CityBox.Text, ZipCode);

            StreetNumberBox.Clear();
            StreetNameBox.Clear();
            StateBox.Clear();
            CityBox.Clear();
            ZipCodeBox.Clear();

            //return NewAddress;
        }
Exemple #6
0
 private void button3_Click(object sender, EventArgs e)
 {
     ClientName.Clear();
     ClientSurname.Clear();
     ClientPatronymic.Clear();
     ClientPhone.Clear();
     HouseBox.Clear();
     StreetBox.Clear();
     CityBox.Clear();
     FlatBox.Clear();
     CategoryBox.Text     = "";
     ProductBox.Text      = "";
     ServiceType.Text     = "";
     numericUpDown1.Value = 1;
     CostBox.Clear();
     PreCost.Clear();
     dataGridView1.Rows.Clear();
     dateTimePicker2.Value = dateTimePicker1.Value;
 }
Exemple #7
0
        private void saveBtn(object sender, RoutedEventArgs e)
        {
            try
            {
                var suppModel = new supplier
                {
                    SupplierID  = int.Parse(SuppIdBox.Text),
                    FirstName   = FirstNameBox.Text,
                    LastName    = LastNameBox.Text,
                    Address     = AddressBox.Text,
                    City        = CityBox.Text,
                    PinCode     = int.Parse(PinCodeBox.Text),
                    PhoneNumber = int.Parse(PhoneNrBox.Text),
                    Email       = EmailBox.Text,
                    DateJoin    = DateJoinPicker.SelectedDate,
                    SupplierOf  = SuppBox.Text,
                };

                SuppIdBox.Clear();
                FirstNameBox.Clear();
                LastNameBox.Clear();
                AddressBox.Clear();
                CityBox.Clear();
                PinCodeBox.Clear();
                PhoneNrBox.Clear();
                EmailBox.Clear();
                SuppBox.Clear();

                dc.suppliers.InsertOnSubmit(suppModel);
                dc.SubmitChanges();

                MessageBox.Show("Supplier has been added");
                LoadData();
                LoadWindow();
            }
            catch
            {
                MessageBox.Show("u need to fill out all fields correct");
            }
        }
Exemple #8
0
 private void Clear_form()
 {
     modify               = false;
     SaveButton.Enabled   = false;
     DeleteButton.Enabled = false;
     FirstNameBox.Clear();
     MiddleNmeBox.Clear();
     LastNameBox.Clear();
     GenderBox.Clear();
     Address1Box.Clear();
     Address2Box.Clear();
     CityBox.Clear();
     StateBox.Clear();
     ZipCodeBox.Clear();
     EmailBox.Clear();
     PhoneNumberBox.Clear();
     ResultList.SelectedItems.Clear();
     DateReceivedPicker.Value = DateTime.Today;
     StartTimeBox.Clear();
     SaveTimeBox.Clear();
     BackNumBox.Clear();
 }
Exemple #9
0
        private void saveBtn(object sender, RoutedEventArgs e)
        {
            try
            {
                var empModel = new employee
                {
                    EmployeeID  = int.Parse(EmpIdBox.Text),
                    FirstName   = FirstNameBox.Text,
                    LastName    = LastNameBox.Text,
                    Address     = AddressBox.Text,
                    City        = CityBox.Text,
                    PinCode     = int.Parse(PinCodeBox.Text),
                    PhoneNumber = int.Parse(PhoneNrBox.Text),
                    Email       = EmailBox.Text,
                    JoinDate    = DateJoinPicker.SelectedDate
                };

                EmpIdBox.Clear();
                FirstNameBox.Clear();
                LastNameBox.Clear();
                AddressBox.Clear();
                CityBox.Clear();
                PinCodeBox.Clear();
                PhoneNrBox.Clear();
                EmailBox.Clear();

                dc.employees.InsertOnSubmit(empModel);
                dc.SubmitChanges();

                MessageBox.Show("Employee has been added");
                LoadData();
                LoadWindow();
            }
            catch
            {
                MessageBox.Show("Thats not a valid action");
            }
        }
Exemple #10
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");
             *      }
             *
             *  }
             * }
             */
        }
Exemple #11
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");
             * }
             */
        }