private void btnSave_Click(object sender, RoutedEventArgs e) { try { if (!txtFullname.Text.Trim().Equals("")) { ContactManagement.Model.Contact contact = new ContactManagement.Model.Contact(); ContactManagement.Outlook.ContactManagement contactManagment = new ContactManagement.Outlook.ContactManagement(); contact.FullName = txtFullname.Text; contact.HomePhone = txtHomePhone.Text; contact.MobilePhone = txtMobilePhone.Text; contact.BusinessPhone = txtBusinessPhone.Text; contact.BusinessFax = txtBusinessFax.Text; contact.Address = txtAddress.Text; contact.Email = txtEmail.Text; contactManagment.AddNewContact(contact); // this.Close(); MessageBox.Show("Save Successful"); } } catch (Exception ex) { MessageBox.Show("Fail to save."); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString(); int i = username.IndexOf(@"\"); if (i != -1) { username = username.Substring(i + 1, username.Length - i - 1); } txtUsername.Text = username; AppConfig appConfig = new AppConfig(Constants.GetConfigFilePath()); contactManagement = new ContactManagement.ActiveDirectory.ContactManagement(Constants.GetADDomain()); contact = contactManagement.GetUserProfile(username); contact.Username = username; txtHomePhone.Text = contact.HomePhone; txtMobilePhone.Text = contact.MobilePhone; txtBusinessPhone.Text = contact.BusinessPhone; txtBusinessFax.Text = contact.BusinessFax; txtEmail.Text = contact.Email; txtAddress.Text = contact.Address; txtIPPhone.Text = contact.IPPhone; } catch (Exception ex) { MessageBox.Show(ex.Message); } }