Example #1
0
        /// <summary>
        /// Basic Update Method
        /// </summary>
        /// <param name="contactId"></param>
        /// <param name="entity"></param>
        public void UpdateContact(int contactId, Contact entity)
        {
            var     contactManager  = new ContactManager(this);
            Contact originalContact = contactManager.GetContact(contactId);

            contactManager.Update(originalContact, entity);
        }
 public void UpdateContact(int contactId, Contact entity)
 {
     var contactManager = new ContactManager(this);
     var originalContact = new Contact();
     originalContact = contactManager.GetContact(contactId);
     contactManager.Update(originalContact, entity);
 }
        private void SaveContact()
        {
            contactManager = new ContactManager(this);
            contact = new DataClasses.Contact();
            var originalContact = new DataClasses.Contact();

            if (!String.IsNullOrEmpty(Request["ContactId"]))
            {
                originalContact = contactManager.GetContact(Convert.ToInt32(Request["ContactId"]));
                contact.CopyPropertiesFrom(originalContact);
            }
            else contact.UserId = User.Identity.UserId;

            contact.CompanyId = Company.CompanyId;
            contact.AddressComp = ucAddress.AddressComp;
            contact.AddressNumber = ucAddress.AddressNumber;
            contact.PostalCode = ucAddress.PostalCode;

            contact.CellPhone = txtCellPhone.Text;
            contact.Email = txtMail.Text;
            contact.Msn = txtMsn.Text;
            contact.Name = txtName.Text;
            contact.Observation = txtObservation.Text;
            contact.Phone = txtPhone.Text;
            contact.Phone2 = txtPhone2.Text;
            contact.Sector = txtSector.Text;
            contact.Skype = txtSkype.Text;


            if (!String.IsNullOrEmpty(Request["ContactId"]))
                contactManager.Update(originalContact, contact);
            else
            {
                contactManager.Insert(contact);

                if (Session["CustomerId"] != null)
                {
                    var customerContact = new CustomerContact();
                    customerContact.CompanyId = Company.CompanyId;
                    customerContact.CustomerId = Convert.ToInt32(Session["CustomerId"].ToString());
                    customerContact.ContactId = contact.ContactId;
                    contactManager.InsertCustomerContact(customerContact);
                }
                else
                {
                    var supplierContact = new SupplierContact();
                    supplierContact.CompanyId = Company.CompanyId;
                    supplierContact.SupplierId = Convert.ToInt32(Session["SupplierId"].ToString());
                    supplierContact.ContactId = contact.ContactId;
                    contactManager.InsertSupplierContact(supplierContact);
                }
            }
        }
        private void ShowContact()
        {
            contactManager = new ContactManager(this);
            contact = contactManager.GetContact(Convert.ToInt32(Request["ContactId"]));

            txtName.Text = contact.Name;
            txtCellPhone.Text = contact.CellPhone;
            txtMail.Text = contact.Email;
            txtMsn.Text = contact.Msn;
            txtObservation.Text = contact.Observation;
            txtPhone.Text = contact.Phone;
            txtPhone2.Text = contact.Phone2;
            txtSector.Text = contact.Sector;
            txtSkype.Text = contact.Skype;

            ucAddress.AddressComp = contact.AddressComp;
            ucAddress.AddressNumber = contact.AddressNumber;
            ucAddress.PostalCode = contact.PostalCode;
        }
        protected void txtContact_TextChanged(object sender, EventArgs e)
        {
            OnSelectingContact(this, new SelectingContactEventArgs() { ContactName = txtContact.Text });

            var contactManager = new ContactManager(this);
            contact = contactManager.GetContact(Page.Company.CompanyId, txtContact.Text);

            ShowContact(contact);
            //txtContact.Text = string.Empty;
        }