Exemplo n.º 1
0
 public void Save(Expert expert)
 {
     Boolean insert = true;
     if (expert.Id != 0)
     {
         insert = false;
     }
     base.Save(expert);
     this._db.OpenConnection();
     MySqlCommand command = this._db.CreateCommand();
     if (insert)
     {
         command.CommandText = "INSERT INTO expert (user_id, company, address, postcode, telephone, city) VALUES " +
         "(?user_id, ?company, ?address, ?postcode, ?telephone, ?city)";
     }
     else
     {
         command.CommandText = "UPDATE expert SET user_id = ?user_id, company = ?company, address = ?address, postcode = ?postcode, telephone = ?telephone, city = ?city WHERE user_id = ?user_id";
     }
     command.Parameters.Add(new MySqlParameter("?user_id", MySqlDbType.Int32)).Value = expert.Id;
     command.Parameters.Add(new MySqlParameter("?company", MySqlDbType.String)).Value = expert.Company;
     command.Parameters.Add(new MySqlParameter("?address", MySqlDbType.String)).Value = expert.Address;
     command.Parameters.Add(new MySqlParameter("?postcode", MySqlDbType.String)).Value = expert.Postcode;
     command.Parameters.Add(new MySqlParameter("?telephone", MySqlDbType.String)).Value = expert.Telephone;
     command.Parameters.Add(new MySqlParameter("?city", MySqlDbType.String)).Value = expert.City;
     this._db.ExecuteCommand(command);
     this._db.CloseConnection();
 }
Exemplo n.º 2
0
 protected Expert ProcessRow(Expert expert, MySqlDataReader Reader)
 {
     base.ProcessRow(expert, Reader);
     //expert data
     expert.Company = Reader.GetString(8);
     expert.Address = Reader.GetString(9);
     expert.Postcode = Reader.GetString(10);
     expert.Telephone = Reader.GetString(11);
     expert.City = Reader.GetString(12);
     return expert;
 }
Exemplo n.º 3
0
        private void onExpertAddClicked(object sender, RoutedEventArgs e)
        {
            //Use this for input errors
            bool hasInputError = false;

            //Check first name
            if (textBoxExternVoornaam.Text.Equals(String.Empty))
            {
                textBoxExternVoornaam.BorderBrush = Brushes.Red;
                hasInputError = true;
            }
            else
            {
                textBoxExternVoornaam.BorderBrush = Brushes.Gray;
            }

            //Check surname
            if (textBoxExternAchternaam.Text.Equals(String.Empty))
            {
                textBoxExternAchternaam.BorderBrush = Brushes.Red;
                hasInputError = true;
            }
            else
            {
                textBoxExternAchternaam.BorderBrush = Brushes.Gray;
            }

            //Check email adress
            if (textBoxExternEmail.Text.Equals(String.Empty))
            {
                textBoxExternEmail.BorderBrush = Brushes.Red;
                hasInputError = true;
            }
            else
            {
                textBoxExternEmail.BorderBrush = Brushes.Gray;
            }
            if (!textBoxExternEmail.Text.IsValidEmailAddress())
            {
                textBoxExternEmail.BorderBrush = Brushes.Red;
                hasInputError = true;
            }
            else
            {
                textBoxExternEmail.BorderBrush = Brushes.Gray;
            }

            //Check company
            if (textBoxExternBedrijf.Text.Equals(String.Empty))
            {
                textBoxExternBedrijf.BorderBrush = Brushes.Red;
                hasInputError = true;
            }
            else
            {
                textBoxExternBedrijf.BorderBrush = Brushes.Gray;
            }

            //Check Adres
            if (textBoxExternAdres.Text.Equals(String.Empty))
            {
                textBoxExternAdres.BorderBrush = Brushes.Red;
                hasInputError = true;
            }
            else
            {
                textBoxExternAdres.BorderBrush = Brushes.Gray;
            }

            //Check Postcode
            if (textBoxExternPostcode.Text.Equals(String.Empty))
            {
                textBoxExternPostcode.BorderBrush = Brushes.Red;
                hasInputError = true;
            }
            else
            {
                textBoxExternPostcode.BorderBrush = Brushes.Gray;
            }

            //Check telephone
            if (textBoxExternTelefoonnummer.Text.Equals(String.Empty))
            {
                textBoxExternTelefoonnummer.BorderBrush = Brushes.Red;
                hasInputError = true;
            }
            else
            {
                textBoxExternTelefoonnummer.BorderBrush = Brushes.Gray;
            }

            //Check city
            if (textBoxExpertCity.Text.Equals(String.Empty))
            {
                textBoxExpertCity.BorderBrush = Brushes.Red;
                hasInputError = true;
            }
            else
            {
                textBoxExpertCity.BorderBrush = Brushes.Gray;
            }

            if (hasInputError == false)
            {
                //Create expert object and add values
                Expert newExpert = new Expert();
                newExpert.Firstname = textBoxExternVoornaam.Text;
                newExpert.Surname = textBoxExternAchternaam.Text;
                newExpert.Email = textBoxExternEmail.Text;
                newExpert.Company = textBoxExternBedrijf.Text;
                newExpert.Address = textBoxExternAdres.Text;
                newExpert.Postcode = textBoxExternPostcode.Text;
                newExpert.Telephone = textBoxExternTelefoonnummer.Text;
                newExpert.City = textBoxExpertCity.Text;

                if (blockedDayTimesExpert.SelectedItems != null)
                {
                    foreach (ListBoxItem selectedBlockdays in blockedDayTimesExpert.SelectedItems)
                    {
                        Blocked_timeslot thisTimeslot = new Blocked_timeslot();
                        thisTimeslot.Daytime_id = (int)selectedBlockdays.Tag;
                        thisTimeslot.Hardblock = true;
                        newExpert.BlockedTimeslots.Add(thisTimeslot);

                    }
                }

                if (softblockedDayTimesExpert.SelectedItems != null)
                {
                    foreach (ListBoxItem selectedBlockdays in softblockedDayTimesExpert.SelectedItems)
                    {
                        Blocked_timeslot thisTimeslot = new Blocked_timeslot();
                        thisTimeslot.Daytime_id = (int)selectedBlockdays.Tag;
                        thisTimeslot.Hardblock = true;
                        newExpert.BlockedTimeslots.Add(thisTimeslot);

                    }
                }
                //Send to the database
                _controller.ExpertMapper.Save(newExpert);
                MessageBox.Show("Expert toegevoegd");
                textBoxExternVoornaam.Text = "";
                textBoxExternAchternaam.Text = "";
                textBoxExternEmail.Text = "";
                textBoxExternBedrijf.Text = "";
                textBoxExternAdres.Text = "";
                textBoxExternPostcode.Text = "";
                textBoxExternTelefoonnummer.Text = "";
                textBoxExpertCity.Text = "";
            }
        }