public static BitmapImage CreateQRCode(Contactperson contact)
        {
            if (contact != null)
            {
                var sb = new StringBuilder();
                sb.AppendLine("BEGIN:VCARD");
                sb.AppendLine("N:" + contact.Name + ";");
                sb.AppendLine("ORG:" + contact.Company);
                sb.AppendLine("TITLE:" + contact.JobRole.Name);
                sb.AppendLine("EMAIL:" + contact.Email);
                sb.AppendLine("END:VCARD");

                var writer = new BarcodeWriter
                {
                    Format  = BarcodeFormat.QR_CODE,
                    Options = new QrCodeEncodingOptions {
                        Width = 100, Height = 100
                    }
                };

                var bitmap = writer.Write(sb.ToString());

                BitmapImage bmp = ConvertBitmapToBitmapImage(bitmap);

                return(bmp);
            }
            else
            {
                return(new BitmapImage());
            }
        }
Exemplo n.º 2
0
 //Een constructor om de properties te initialiseren
 public CPersonenVM()
 {
     Persons = Contactperson.GetContactpersons();
     ContactpersonTypes = ContactpersonType.GetContactpersonTypes();
     SelectedContactperson = Persons[0];
     Contactperson = new Contactperson();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Verwijder het binnenkomende contactpersoon object. Return true als de operatie gelukt is, en false als die mislukt is. Deze waarde wordt in de aanroepende klasse gebruikt om te achterhalen of de operatie gelukt is. Bij een fout wordt de error in detail weggeschreven naar een apart bestand.
        /// </summary>
        /// <param name="Contactperson"></param>
        /// <returns></returns>
        public bool DeleteContactperson(Contactperson Contactperson)
        {
            try
            {
                conn.Open();
                string         query           = @"DELETE FROM contactperson WHERE id = @contactpersonID;";
                MySqlCommand   cmd             = new MySqlCommand(query, conn);
                MySqlParameter contactpersonID = new MySqlParameter("@contactpersonID", MySqlDbType.Int32);
                contactpersonID.Value = Contactperson.id;

                cmd.Parameters.Add(contactpersonID);
                cmd.ExecuteNonQuery();
                return(true);
            }
            catch (Exception ex)
            {
                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine("Message : " + ex.Message + Environment.NewLine + ex.StackTrace
                                     + Environment.NewLine + "Date : " + DateTime.Now.ToString() + Environment.NewLine);
                }
                return(false);
            }
            finally
            {
                conn.Close();
            }
        }
Exemplo n.º 4
0
        public void SaveContactperson()
        {
            try
            {
                string sql = "INSERT INTO Contactpersonen(Name, FirstName, Gender, Birthdate, Company, Street,City,Phone,Cellphone,Email,ContactpersoontypeID,Number) ";
                sql += "VALUES (@Name,@FirstName,@Gender,@Birthdate,@Company,@Street,@City,@Phone,@Cellphone,@Email,@JobRole,@Number)";
                DbParameter parName      = Database.AddParameter("@Name", SelectedContactperson.Name);
                DbParameter parFirstName = Database.AddParameter("@FirstName", SelectedContactperson.FirstName);
                DbParameter parGender    = Database.AddParameter("@Gender", SelectedContactperson.Gender);
                DbParameter parBirthdate = Database.AddParameter("@Birthdate", SelectedContactperson.BirthDate);
                DbParameter parCompany   = Database.AddParameter("@Company", SelectedContactperson.Company);
                DbParameter parStreet    = Database.AddParameter("@Street", SelectedContactperson.Street);
                DbParameter parCity      = Database.AddParameter("@City", SelectedContactperson.City);
                DbParameter parPhone     = Database.AddParameter("@Phone", SelectedContactperson.Phone);
                DbParameter parCellphone = Database.AddParameter("@Cellphone", SelectedContactperson.Cellphone);
                DbParameter parEmail     = Database.AddParameter("@Email", SelectedContactperson.Email);
                DbParameter parNumber    = Database.AddParameter("@Number", SelectedContactperson.Number);
                DbParameter parJobRole   = Database.AddParameter("@JobRole", SelectedContactperson.JobRole.ID);

                Database.ModifyData(sql, parName, parFirstName, parGender, parBirthdate, parCompany, parStreet, parCity, parPhone, parCellphone, parEmail, parNumber, parJobRole);
                ContactpersonList.Add(SelectedContactperson);
                ContactpersonList = Contactperson.GetContactpersons();
                MessageBox.Show("Contactpersoon werd succesvol toegevoegd");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
        public async Task <IActionResult> EditContactperson([FromBody] Contactperson contact)
        {
            var contactToChange = await _context.Contactpersons.SingleAsync(x => x.Id == contact.Id);

            if (contactToChange.Role != contact.Role)
            {
                contactToChange.Role = contact.Role;
            }
            if (contactToChange.Mail != contact.Mail)
            {
                contactToChange.Mail = contact.Mail;
            }
            if (contactToChange.Name != contact.Name)
            {
                contactToChange.Name     = contact.Name;
                contactToChange.Initials = getInitials(contact.Name);
            }
            if (contactToChange.Telephone != contact.Telephone)
            {
                contactToChange.Telephone = contact.Telephone;
            }
            if (contactToChange.SecTelephone != contact.SecTelephone)
            {
                contactToChange.SecTelephone = contact.SecTelephone;
            }

            await _context.SaveChangesAsync();

            return(Ok());
        }
Exemplo n.º 6
0
        public async Task <IActionResult> AddContactperson([FromBody] Contactperson contactperson)
        {
            contactperson.Initials = getInitials(contactperson.Name);
            contactperson.Masked   = false;
            await _context.Contactpersons.AddAsync(contactperson);

            await _context.SaveChangesAsync();

            return(Ok());
        }
 public ContactPersonenViewModel()
 {
     ContactList = Contactperson.GetContactPersons();
     TypeList = ContactpersonType.GetTypes();
     AddControls = "Visible";
     EditControls = "Hidden";
     CloseVis = "Hidden";
     WindowHeight = 600;
     FormContact = new Contactperson();
     ContactTypeAdd = new ContactpersonType();
 }
Exemplo n.º 8
0
 public void NewContactperson()
 {
     try
     {
         Contactperson NewPerson = new Contactperson();
         SelectedContactperson = NewPerson;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 9
0
        public async Task <IActionResult> ChangeResponsibleContactperson([FromBody] Contactperson contact)
        {
            if (await _context.Contactpersons.AnyAsync(x => x.Responsible == true && x.CustomerId == contact.CustomerId))
            {
                var prevResponsibleContact = await _context.Contactpersons.FirstOrDefaultAsync(x => x.Responsible == true && x.CustomerId == contact.CustomerId);

                prevResponsibleContact.Responsible = false;
                await _context.SaveChangesAsync();
            }

            var contactToChange = await _context.Contactpersons.SingleOrDefaultAsync(x => x.Id == contact.Id);

            contactToChange.Responsible = true;
            await _context.SaveChangesAsync();

            return(Ok());
        }
Exemplo n.º 10
0
 // Maakt het scherm klaar voor zowel het toevoegen als bewerken
 private void prepareScreen(ref List <User> UserList, ref List <Company> CompanyList)
 {
     buttonContactpersonConfirm.Text = Manage;
     foreach (var item in CompanyList)
     {
         CompanyNames.Add(item.id, item.name);
     }
     comboBoxContactpersonCompanyID.DataSource    = new BindingSource(CompanyNames, null);
     comboBoxContactpersonCompanyID.ValueMember   = "Key";
     comboBoxContactpersonCompanyID.DisplayMember = "Value";
     foreach (var item in UserList)
     {
         UserNames.Add(item.id, item.lastname + ", " + item.firstname[0] + ". " + item.insertion);
     }
     comboBoxContactpersonHHSContact.DataSource    = new BindingSource(UserNames, null);
     comboBoxContactpersonHHSContact.ValueMember   = "Key";
     comboBoxContactpersonHHSContact.DisplayMember = "Value";
     if (Manage.Equals("Toevoegen"))
     {
         Controls.Remove(buttonContactpersonDelete);
     }
     else
     {
         foreach (var item in ContactpersonList)
         {
             if (item.id.ToString() == ListViewActors.SubItems[0].Text)
             {
                 ContactpersonToEdit = item;
                 textBoxContactpersonFirstName.Text            = item.firstname;
                 textBoxContactpersonInsertion.Text            = item.insertion;
                 textBoxContactpersonLastName.Text             = item.lastname;
                 textBoxContactpersonEmail.Text                = item.email;
                 textBoxContactpersonPhonenumber.Text          = item.phonenumber.ToString();
                 comboBoxContactpersonCompanyID.SelectedValue  = item.company_id;
                 textBoxContactpersonFunction.Text             = item.function;
                 comboBoxContactpersonNextTime.Text            = item.next_time.ToString();
                 comboBoxContactpersonRating.Text              = item.rating.ToString();
                 textBoxContactpersonComment.Text              = item.comment;
                 comboBoxContactpersonHHSContact.SelectedValue = item.contact_hhs;
             }
         }
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Voeg een nieuwe contactpersoon toe aan de database. Return true als de toevoeging succesvol is, false als er iets verkeerd is gegaan. Deze boolean waarde wordt in de de klasse waar deze methode is aangeroepen gebruikt om te controleren of de methode geslaagd is. Bij een fout wordt de error in detail weggeschreven naar een apart bestand.
        /// </summary>
        /// <param name="Contactperson">De nieuwe contactpersoon die toegevoegd gaat worden.</param>
        /// <returns></returns>
        public bool InsertContactperson(Contactperson Contactperson)
        {
            try
            {
                conn.Open();
                string       query = @"INSERT INTO contactperson (firstname, insertion, lastname, email, phonenumber, company_id, function, next_time, rating, created, last_updated, contact_hhs, created_by) VALUES (@contactpersonFirstName, @contactpersonInsertion, @contactpersonLastname, @contactpersonEmail, @contactpersonPhonenumber, @contactpersonCompanyID, @contactpersonFunction, @contactpersonNextTime, @contactpersonRating, @contactpersonCreated, @contactpersonLastUpdated, @contactpersonHHSContact, @contactpersonCreatedBy)";
                MySqlCommand cmd   = new MySqlCommand(query, conn);

                cmd.Parameters.AddWithValue("@contactpersonFirstName", Contactperson.firstname);
                cmd.Parameters.AddWithValue("@contactpersonInsertion", Contactperson.insertion);
                cmd.Parameters.AddWithValue("@contactpersonLastname", Contactperson.lastname);
                cmd.Parameters.AddWithValue("@contactpersonEmail", Contactperson.email);
                cmd.Parameters.AddWithValue("@contactpersonPhonenumber", Contactperson.phonenumber);
                cmd.Parameters.AddWithValue("@contactpersonCompanyID", Contactperson.company_id);
                cmd.Parameters.AddWithValue("@contactpersonFunction", Contactperson.function);
                cmd.Parameters.AddWithValue("@contactpersonNextTime", Contactperson.next_time);
                cmd.Parameters.AddWithValue("@contactpersonRating", Contactperson.rating);
                cmd.Parameters.AddWithValue("@contactpersonCreated", DateTime.Now);
                cmd.Parameters.AddWithValue("@contactpersonLastUpdated", DateTime.Now);
                cmd.Parameters.AddWithValue("@contactpersonHHSContact", Contactperson.contact_hhs);
                cmd.Parameters.AddWithValue("@contactpersonCreatedBy", Contactperson.created_by);

                cmd.ExecuteNonQuery();
                PrimaryKey = (int)cmd.LastInsertedId;
                return(true);
            }
            catch (Exception ex)
            {
                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine("Message : " + ex.Message + Environment.NewLine + ex.StackTrace
                                     + Environment.NewLine + "Date : " + DateTime.Now.ToString() + Environment.NewLine);
                }
                return(false);
            }
            finally
            {
                conn.Close();
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Wijzig de gegevens van een contactpersoon. Return true als de operatie gelukt is, en false als die mislukt is. Deze waarde wordt in de aanroepende klasse gebruikt om te achterhalen of de operatie gelukt is. Bij een fout wordt de error in detail weggeschreven naar een apart bestand.
        /// </summary>
        /// <param name="Contactperson"></param>
        /// <returns></returns>
        public bool UpdateContactperson(Contactperson Contactperson)
        {
            try
            {
                conn.Open();
                string       query = "UPDATE contactperson SET firstname = @contactpersonFirstName, insertion = @contactpersonInsertion, lastname = @contactpersonLastName, email = @contactpersonEmail, phonenumber = @contactpersonPhonenumber, company_id = @contactpersonCompanyID, function = @contactpersonFunction, next_time = @contactpersonNextTime, rating = @contactpersonRating, comment = @contactpersonComment, last_updated = @contactpersonLastUpdated, contact_hhs = @contactpersonHHSContact WHERE id = @contactpersonID";
                MySqlCommand cmd   = new MySqlCommand(query, conn);

                cmd.Parameters.AddWithValue("@contactpersonID", Contactperson.id);
                cmd.Parameters.AddWithValue("@contactpersonFirstName", Contactperson.firstname);
                cmd.Parameters.AddWithValue("@contactpersonInsertion", Contactperson.insertion);
                cmd.Parameters.AddWithValue("@contactpersonLastName", Contactperson.lastname);
                cmd.Parameters.AddWithValue("@contactpersonEmail", Contactperson.email);
                cmd.Parameters.AddWithValue("@contactpersonPhonenumber", Contactperson.phonenumber);
                cmd.Parameters.AddWithValue("@contactpersonCompanyID", Contactperson.company_id);
                cmd.Parameters.AddWithValue("@contactpersonFunction", Contactperson.function);
                cmd.Parameters.AddWithValue("@contactpersonNextTime", Contactperson.next_time);
                cmd.Parameters.AddWithValue("@contactpersonRating", Contactperson.rating);
                cmd.Parameters.AddWithValue("@contactpersonComment", Contactperson.comment);
                cmd.Parameters.AddWithValue("@contactpersonLastUpdated", DateTime.Now);
                cmd.Parameters.AddWithValue("@contactpersonHHSContact", Contactperson.contact_hhs);

                cmd.ExecuteNonQuery();
                return(true);
            }
            catch (MySqlException ex)
            {
                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine("Message : " + ex.Message + Environment.NewLine + ex.StackTrace
                                     + Environment.NewLine + "Date : " + DateTime.Now.ToString() + Environment.NewLine);
                }
                return(false);
            }
            finally
            {
                conn.Close();
            }
        }
Exemplo n.º 13
0
        void contact_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            Contactperson person = sender as Contactperson;

            if (person.IsValid())
            {
                if (person.ID != null)//if id is null, contact is not inserted, so insert that if valid, else update if valid
                {
                    try
                    {
                        if (!person.Update())
                        {
                            throw new Exception("Could not update contact");
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        MessageBox.Show("Kon contact niet updaten naar de database");
                    }
                }
                else
                {
                    try
                    {
                        if (!person.Insert())
                        {
                            throw new Exception("Could not insert contact");
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        MessageBox.Show("Kon contact niet in de database steken");
                    }
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Haal alle contactpersonen op uit de database en sla ze op in een lijst. Return vervolgens deze lijst. Bij een fout wordt de error in detail weggeschreven naar een apart bestand.
        /// </summary>
        /// <returns></returns>
        public List <Contactperson> GetContactpersonList()
        {
            List <Contactperson> ContactpersonList = new List <Contactperson>();
            string contactpersonInsertion          = "";
            string contactpersonComment            = "";

            try
            {
                conn.Open();
                string          query  = @"SELECT * FROM contactperson";
                MySqlCommand    cmd    = new MySqlCommand(query, conn);
                MySqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Contactperson Contactperson            = new Contactperson();
                    Company       Company                  = new Company();
                    User          User                     = new User();
                    int           contactpersonID          = reader.GetInt32("id");
                    string        contactpersonFirstName   = reader.GetString("firstname");
                    string        contactpersonLastName    = reader.GetString("lastname");
                    string        contactpersonEmail       = reader.GetString("email");
                    string        contactpersonPhonenumber = reader.GetString("phonenumber");
                    int           contactpersonCompanyID   = reader.GetInt32("company_id");
                    string        contactpersonFunction    = reader.GetString("function");
                    string        contactpersonNextTime    = reader.GetString("next_time");
                    string        contactpersonRating      = reader.GetString("rating");
                    DateTime      contactpersonCreated     = reader.GetDateTime("created");
                    DateTime      contactpersonLastUpdated = reader.GetDateTime("last_updated");
                    int           contactpersonHHSContact  = reader.GetInt32("contact_hhs");
                    int           contactpersonCreatedBy   = reader.GetInt32("created_by");

                    //  check if insertion is not NULL
                    if (!reader.IsDBNull(2))
                    {
                        contactpersonInsertion = reader.GetString("insertion");
                    }
                    //  check if comment is not NULL
                    if (!reader.IsDBNull(10))
                    {
                        contactpersonComment = reader.GetString("comment");
                    }

                    Contactperson.id           = contactpersonID;
                    Contactperson.firstname    = contactpersonFirstName;
                    Contactperson.insertion    = contactpersonInsertion;
                    Contactperson.lastname     = contactpersonLastName;
                    Contactperson.email        = contactpersonEmail;
                    Contactperson.phonenumber  = contactpersonPhonenumber;
                    Contactperson.company_id   = contactpersonCompanyID;
                    Contactperson.function     = contactpersonFunction;
                    Contactperson.next_time    = contactpersonNextTime;
                    Contactperson.rating       = contactpersonRating;
                    Contactperson.comment      = contactpersonComment;
                    Contactperson.created      = contactpersonCreated;
                    Contactperson.last_updated = contactpersonLastUpdated;
                    Contactperson.contact_hhs  = contactpersonHHSContact;
                    Contactperson.created_by   = contactpersonCreatedBy;

                    // Voeg de record van de contactpersoon toe aan de lijst
                    ContactpersonList.Add(Contactperson);
                }
            }
            catch (Exception ex)
            {
                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine("Message : " + ex.Message + Environment.NewLine + ex.StackTrace
                                     + Environment.NewLine + "Date : " + DateTime.Now.ToString() + Environment.NewLine);
                }
            }
            finally
            {
                conn.Close();
            }
            return(ContactpersonList);
        }
Exemplo n.º 15
0
 //De method om op te slaan
 private void AddContactperson()
 {
     int affected = Contactperson.AddContactperson(Contactperson);
       if (affected == 1)
       {
       Persons.Add(Contactperson);
      // Persons = Contactperson.GetContactpersons();
       int LastIndex = Persons.Count - 1;
       SelectedContactperson = Persons[LastIndex];
       }
 }
Exemplo n.º 16
0
 private void CloseClickAll()
 {
     MenuHeightAdd = 0;
     MenuZoekHeight = 0;
     FunctieMenuHeight = 0;
     CloseVis = "Hidden";
     FormContact = new Contactperson();
     ListIndex = 0;
     WindowHeight = 700;
 }
Exemplo n.º 17
0
        // Voert de uiteindelijke actie uit voor het toevoegen of bewerken
        private void buttonContactpersonConfirm_Click(object sender, EventArgs e)
        {
            bool existContactperson = false;

            if (textBoxContactpersonFirstName.Text.Any(char.IsDigit) || textBoxContactpersonInsertion.Text.Any(char.IsDigit) || textBoxContactpersonLastName.Text.Any(char.IsDigit) || !textBoxContactpersonPhonenumber.Text.All(char.IsDigit) || textBoxContactpersonFunction.Text.Any(char.IsDigit) || textBoxContactpersonFirstName.Text.IndexOfAny(letters) > 0 || textBoxContactpersonLastName.Text.IndexOfAny(letters) > 0 || textBoxContactpersonInsertion.Text.IndexOfAny(letters) > 0 || textBoxContactpersonFunction.Text.IndexOfAny(letters) > 0 || textBoxContactpersonFirstName.Text.Equals("") || textBoxContactpersonLastName.Text.Equals("") || textBoxContactpersonEmail.Text.Equals("") || textBoxContactpersonEmail.Text.IndexOf('@') == (-1) || textBoxContactpersonEmail.Text.IndexOf('.') == -1 || textBoxContactpersonPhonenumber.Text.Equals("") || textBoxContactpersonPhonenumber.Text.Length != 10 || comboBoxContactpersonCompanyID.Text.Equals("") || textBoxContactpersonFunction.Text.Equals("") || comboBoxContactpersonNextTime.Text.Equals("") || comboBoxContactpersonRating.Text.Equals("") || comboBoxContactpersonHHSContact.Text.Equals(""))
            {
                MessageBox.Show("Vul alle velden correct in aub (met uitsluiting van tussenvoegsel en commentaar)");
            }
            else
            // Add functionality
            if (Manage.Equals("Toevoegen"))
            {
                Console.WriteLine("buttonContactpersonConfirm_Click is clicked");
                foreach (var item in ContactpersonList)
                {
                    if (item.phonenumber.Equals(textBoxContactpersonPhonenumber.Text) || item.email.Equals(textBoxContactpersonEmail.Text))
                    {
                        existContactperson = true;
                        MessageBox.Show("E-mail of telefoonnummer bestaat al");
                    }
                }
                if (existContactperson == false)
                {
                    Contactperson Contactperson = new Contactperson {
                        firstname = textBoxContactpersonFirstName.Text, insertion = textBoxContactpersonInsertion.Text, lastname = textBoxContactpersonLastName.Text, email = textBoxContactpersonEmail.Text, phonenumber = textBoxContactpersonPhonenumber.Text, company_id = Int32.Parse(comboBoxContactpersonCompanyID.SelectedValue.ToString()), function = textBoxContactpersonFunction.Text, next_time = comboBoxContactpersonNextTime.SelectedItem.ToString(), rating = comboBoxContactpersonRating.SelectedItem.ToString(), comment = textBoxContactpersonComment.Text, contact_hhs = Int32.Parse(comboBoxContactpersonHHSContact.SelectedValue.ToString()), created_by = ActivePerson.id
                    };
                    bool Transaction = ContactpersonDB.InsertContactperson(Contactperson);
                    if (Transaction == true)
                    {
                        Contactperson ContactpersonInserted = new Contactperson {
                            id = ContactpersonDB.PrimaryKey, firstname = textBoxContactpersonFirstName.Text, insertion = textBoxContactpersonInsertion.Text, lastname = textBoxContactpersonLastName.Text, email = textBoxContactpersonEmail.Text, phonenumber = textBoxContactpersonPhonenumber.Text, company_id = Int32.Parse(comboBoxContactpersonCompanyID.SelectedValue.ToString()), function = textBoxContactpersonFunction.Text, next_time = comboBoxContactpersonNextTime.SelectedItem.ToString(), rating = comboBoxContactpersonRating.SelectedItem.ToString(), comment = textBoxContactpersonComment.Text, contact_hhs = Int32.Parse(comboBoxContactpersonHHSContact.SelectedValue.ToString()), created_by = ActivePerson.id
                        };
                        ContactpersonList.Add(ContactpersonInserted);
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Het toevoegen is mislukt!");
                    }
                }
            }
            // Edit functionality
            else
            {
                foreach (var item in ContactpersonList)
                {
                    if (item.id != ContactpersonToEdit.id)
                    {
                        if (item.phonenumber.Equals(textBoxContactpersonPhonenumber.Text) || item.email.Equals(textBoxContactpersonEmail.Text))
                        {
                            existContactperson = true;
                            MessageBox.Show("E-mail of telefoonnummer bestaat al");
                        }
                    }
                }
                if (existContactperson == false)
                {
                    ContactpersonToEdit.firstname   = textBoxContactpersonFirstName.Text;
                    ContactpersonToEdit.insertion   = textBoxContactpersonInsertion.Text;
                    ContactpersonToEdit.lastname    = textBoxContactpersonLastName.Text;
                    ContactpersonToEdit.email       = textBoxContactpersonEmail.Text;
                    ContactpersonToEdit.phonenumber = textBoxContactpersonPhonenumber.Text;
                    ContactpersonToEdit.company_id  = Int32.Parse(comboBoxContactpersonCompanyID.SelectedValue.ToString());
                    ContactpersonToEdit.function    = textBoxContactpersonFunction.Text;
                    ContactpersonToEdit.next_time   = comboBoxContactpersonNextTime.SelectedItem.ToString();
                    ContactpersonToEdit.rating      = comboBoxContactpersonRating.SelectedItem.ToString();
                    ContactpersonToEdit.comment     = textBoxContactpersonComment.Text;
                    ContactpersonToEdit.contact_hhs = Int32.Parse(comboBoxContactpersonHHSContact.SelectedValue.ToString());

                    bool Transaction = ContactpersonDB.UpdateContactperson(ContactpersonToEdit);
                    if (Transaction == true)
                    {
                        foreach (var item in ContactpersonList)
                        {
                            if (ContactpersonToEdit.id == item.id)
                            {
                                item.firstname   = ContactpersonToEdit.firstname;
                                item.insertion   = ContactpersonToEdit.insertion;
                                item.lastname    = ContactpersonToEdit.lastname;
                                item.email       = ContactpersonToEdit.email;
                                item.phonenumber = ContactpersonToEdit.phonenumber;
                                item.company_id  = ContactpersonToEdit.company_id;
                                item.function    = ContactpersonToEdit.function;
                                item.next_time   = ContactpersonToEdit.next_time;
                                item.rating      = ContactpersonToEdit.rating;
                                item.comment     = ContactpersonToEdit.comment;
                                item.contact_hhs = ContactpersonToEdit.contact_hhs;
                            }
                        }
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Het wijzigen is mislukt!");
                    }
                }
            }
        }
Exemplo n.º 18
0
 public ContactpersonVM()
 {
     _contactpersonList     = Contactperson.GetContactpersons();
     _contactpersonTypeList = ContactpersonType.GetContactpersonTypes();
     SelectedContactperson  = new Contactperson();
 }