Beispiel #1
0
 private void AcceptButton_Click(object sender, EventArgs e)
 {
     IsValidEmail(EmailText.Text);
     IsValidName(FirstNameTextBox.Text);
     IsValidName(SurnameText.Text);
     if (PhoneNumberText.Text.Length != 11)
     {
         MessageBox.Show("The length of your phone number must be 11 digits");
         PhoneNumberText.Clear();
     }
     if (FirstNameTextBox.Text != "" && SurnameText.Text != "" && EmailText.Text != "" && PhoneNumberText.Text != "")
     {
         if (CustomersSelectionFormcs.edit == false)
         {
             ReadInTextFile();
         }
         ListofCustomers.Add(new SnippetsBackend.Customers((FirstNameTextBox.Text), SurnameText.Text, EmailText.Text, PhoneNumberText.Text));
         //Add to textfile
         using (StreamWriter tw = new StreamWriter("ListofCustomers.txt", false))
         {
             foreach (SnippetsBackend.Customers s in ListofCustomers)
             {
                 tw.WriteLine(s.FirstName + "," + s.LastName + "," + s.Email + "," + s.PhoneNumber);
             }
             tw.Close();
         }
         MessageBox.Show("Customer has been added/edited");
         FirstNameTextBox.Clear();
         SurnameText.Clear();
         EmailText.Clear();
         PhoneNumberText.Clear();
         CustomerAppointments.Items.Clear();
     }
 }
Beispiel #2
0
 /// <summary>
 /// Очистка полей ввода
 /// </summary>
 private void ClearText()
 {
     NameText.Clear();
     SurnameText.Clear();
     PosText.Clear();
     BirthdayText.Clear();
     DepComboEdit.SelectedIndex = -1;
 }
Beispiel #3
0
 public void IsValidName(string name)
 {
     if (Regex.IsMatch(name, @"^[a-zA-Z]+$") == false)
     {
         MessageBox.Show("The First name and Last name must only contain letters");
         FirstNameTextBox.Clear();
         SurnameText.Clear();
     }
 }
Beispiel #4
0
        public void ReadInTextFile()
        {
            string[] oneline;
            string   RFirstName   = "";
            string   RLastName    = "";
            string   REmail       = "";
            string   RPhoneNumber = "";
            int      i            = 0;

            for (i = 0; i < ListofCustomers.Count; i++)
            {
                string customerstring = ListofCustomers[i].ToString();
                oneline = customerstring.Split(',');
                for (int x = 0; x < oneline.Length; x++)
                {
                    switch (x)
                    {
                    case 0:
                        RFirstName = oneline[x];
                        break;

                    case 1:
                        RLastName = oneline[x];
                        break;

                    case 2:
                        REmail = oneline[x];
                        break;

                    case 3:
                        RPhoneNumber = oneline[x];
                        break;
                    }
                }
                //If edit selected customer has been selected, check they do not have the same first name and last name
                if (RFirstName == FirstNameTextBox.Text && RLastName == SurnameText.Text)
                {
                    MessageBox.Show("This person already exists please enter a different firstname and lastname");
                    FirstNameTextBox.Clear();
                    SurnameText.Clear();
                }
                //If the edit customer button has been clicked
                if (CustomersSelectionFormcs.edit == true)
                {
                    string SelectedCustomerFirstName = CustomersSelectionFormcs.CustomerFirstName;
                    string SelectedCustomerLastName  = CustomersSelectionFormcs.CustomerLastName;
                    if (RFirstName == SelectedCustomerFirstName && RLastName == SelectedCustomerLastName)
                    {
                        FirstNameTextBox.Text = SelectedCustomerFirstName;
                        SurnameText.Text      = SelectedCustomerLastName;
                        EmailText.Text        = REmail;
                        PhoneNumberText.Text  = RPhoneNumber.ToString();
                    }
                }
            }
        }
Beispiel #5
0
        private void UpdateBTN_Click(object sender, EventArgs e)
        {
            connect.Open();
            SqlCommand command = new SqlCommand("update Customer set CustomerID='" + CustomerIDText.Text.ToString() + "',Name='" + NameText.Text.ToString() + "',Surname='" + SurnameText.Text.ToString() + "',Address='" + AddressText.Text.ToString() + "',Telephone='" + TelephoneText.Text.ToString() + "',Email='" + EmailText.Text.ToString() + "'where CustomerID=" + CustomerID + "", connect);

            command.ExecuteNonQuery();
            connect.Close();
            viewdetails();
            CustomerIDText.Clear();
            NameText.Clear();
            SurnameText.Clear();
            AddressText.Clear();
            TelephoneText.Clear();
            EmailText.Clear();
        }
Beispiel #6
0
        private void DeleteBTN_Click(object sender, EventArgs e)
        {
            connect.Open();
            SqlCommand komut = new SqlCommand("Delete From Customer Where CustomerID=(" + sira + ")", connect);

            komut.ExecuteNonQuery();
            connect.Close();
            viewdetails();

            viewdetails();
            CustomerIDText.Clear();
            NameText.Clear();
            SurnameText.Clear();
            AddressText.Clear();
            TelephoneText.Clear();
            EmailText.Clear();
        }
Beispiel #7
0
 private void AcceptButton_Click(object sender, EventArgs e)
 {
     IsValidEmail(EmailText.Text);
     IsValidName(FirstNameTextBox.Text);
     IsValidName(SurnameText.Text);
     if (PhoneNumberText.Text.Length != 11)
     {
         MessageBox.Show("The length of your phone number must be 11 digits");
         PhoneNumberText.Clear();
     }
     if (FirstNameTextBox.Text != "" && SurnameText.Text != "" && EmailText.Text != "" && PhoneNumberText.Text != "" && HourlyRateText.Text != "")
     {
         if (StylistSelectionForm.edit == false)
         {
             ReadInTextFile();
         }
         ListofStylists.Add(new SnippetsBackend.Stylist((FirstNameTextBox.Text), SurnameText.Text, EmailText.Text, PhoneNumberText.Text, double.Parse(HourlyRateText.Text)));
         //Add to textfile
         using (StreamWriter tw = new StreamWriter("ListofStylists.txt", false))
         {
             foreach (SnippetsBackend.Stylist s in ListofStylists)
             {
                 tw.WriteLine(s.FirstName + "," + s.LastName + "," + s.Email + "," + s.PhoneNumber + "," + s.HourlyRate);
             }
             tw.Close();
         }
         MessageBox.Show("Stylist has been added/edited");
         FirstNameTextBox.Clear();
         SurnameText.Clear();
         EmailText.Clear();
         PhoneNumberText.Clear();
         HourlyRateText.Clear();
         StylistTransactions.Items.Clear();
     }
     else if (FirstNameTextBox.Text == "" || SurnameText.Text == "" || EmailText.Text == "" || PhoneNumberText.Text == "" || HourlyRateText.Text == "")
     {
         MessageBox.Show("Please fill in all the textboxes");
     }
 }
Beispiel #8
0
        public void ReadInTextFile()
        {
            string[] oneline;
            string   RFirstName   = "";
            string   RLastName    = "";
            string   REmail       = "";
            string   RPhoneNumber = "";
            double   RHourlyRate  = 0;
            int      i            = 0;

            for (i = 0; i < ListofStylists.Count; i++)
            {
                string splitstylist = ListofStylists[i].ToString();
                oneline = splitstylist.Split(',');
                for (int x = 0; x < oneline.Length; x++)
                {
                    switch (x)
                    {
                    case 0:
                        RFirstName = oneline[x];
                        break;

                    case 1:
                        RLastName = oneline[x];
                        break;

                    case 2:
                        REmail = oneline[x];
                        break;

                    case 3:
                        RPhoneNumber = oneline[x];
                        break;

                    case 4:
                        RHourlyRate = double.Parse(oneline[x]);
                        break;
                    }
                }
                //If edit selected stylist has been selected, check they do not have the same first name and last name
                if (RFirstName == FirstNameTextBox.Text && RLastName == SurnameText.Text)
                {
                    MessageBox.Show("This person already exists please enter a different firstname and lastname");
                    FirstNameTextBox.Clear();
                    SurnameText.Clear();
                }
                if (StylistSelectionForm.edit == true)
                {
                    string SelectedStylistFirstName = StylistSelectionForm.StylistFirstName;
                    string SelectedStylistLastName  = StylistSelectionForm.StylistLastName;
                    if (RFirstName == SelectedStylistFirstName && RLastName == SelectedStylistLastName)
                    {
                        FirstNameTextBox.Text = SelectedStylistFirstName;
                        SurnameText.Text      = SelectedStylistLastName;
                        EmailText.Text        = REmail;
                        PhoneNumberText.Text  = RPhoneNumber.ToString();
                        HourlyRateText.Text   = RHourlyRate.ToString();
                    }
                }
            }
        }