protected void wdgContacts_ItemCommand(object sender, Infragistics.Web.UI.GridControls.HandleCommandEventArgs e)
        {
            ClaimContact claimContact = null;

            int contactID = 0;
            int claimID   = SessionHelper.getClaimID();

            if (e.CommandName == "DoImport")
            {
                try {
                    contactID              = Convert.ToInt32(e.CommandArgument);
                    claimContact           = new ClaimContact();
                    claimContact.ClaimID   = claimID;
                    claimContact.ContactID = contactID;

                    ClaimContactManager.Save(claimContact);

                    lblImportContactMessage.Text     = "Contact was imported successfully.";
                    lblImportContactMessage.CssClass = "ok";
                }
                catch (Exception ex) {
                    Core.EmailHelper.emailError(ex);
                    lblImportContactMessage.Text     = "Contact was not imported.";
                    lblImportContactMessage.CssClass = "error";
                }
            }
        }
        protected void gvContacts_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Contact contact = null;
            int     id      = 0;

            if (e.CommandName == "DoEdit")
            {
                id = Convert.ToInt32(e.CommandArgument);

                ViewState["ContactID"] = id.ToString();

                contact = ContactManager.Get(id);

                if (contact != null)
                {
                    showContactPanel();

                    bindContactTypes();

                    bindStates();

                    fillForm(contact);
                }
            }
            else if (e.CommandName == "DoRemove")
            {
                id = Convert.ToInt32(e.CommandArgument);

                ClaimContactManager.Delete(id);

                bindData(this.claimID);
            }
        }
        public void bindData(int claimID)
        {
            clientID = Core.SessionHelper.getClientId();

            List <ClaimContact> contacts = ClaimContactManager.GetAll(claimID);

            showContactGrid();

            gvContacts.DataSource = contacts;
            gvContacts.DataBind();
        }
        protected void saveContact()
        {
            bool isNewContact = false;
            int  contactID    = Convert.ToInt32(ViewState["ContactID"]);

            Contact      contact      = null;
            ClaimContact claimContact = null;

            lblMessage.Text = string.Empty;

            if (contactID == 0)
            {
                // new contact
                contact = new Contact();

                contact.ClientID = Core.SessionHelper.getClientId();

                isNewContact = true;
            }
            else
            {
                contact = ContactManager.Get(contactID);
            }

            contact.FirstName   = txtFirstName.Text;
            contact.LastName    = txtLastName.Text;
            contact.ContactName = txtFirstName.Text + " " + txtLastName.Text;

            contact.Phone          = txtContactPhone.Text;
            contact.Email          = txtContactEmail.Text;
            contact.Phone          = txtContactPhone.Text;
            contact.Mobile         = txtMobilePhone.Text;
            contact.ContactTitle   = txtContactTile.Text;
            contact.DepartmentName = txtDepartmentName.Text;
            contact.IsPrimary      = cbxPrimary.Checked;
            contact.Fax            = txtContactFax.Text;
            contact.CompanyName    = txtCompanyName.Text.Trim();

            if (ddlContactType.SelectedIndex > 0)
            {
                contact.CategoryID = Convert.ToInt32(ddlContactType.SelectedValue);
            }
            else
            {
                contact.CategoryID = null;
            }

            contact.Address1 = txtAddress1.Text;
            contact.Address2 = txtAddress2.Text;

            if (ddlState.SelectedIndex > 0)
            {
                contact.StateID = Convert.ToInt32(ddlState.SelectedValue);
            }

            if (ddlCity.SelectedIndex > 0)
            {
                contact.CityID = Convert.ToInt32(ddlCity.SelectedValue);
            }

            if (ddlLossZip.SelectedIndex > 0)
            {
                contact.ZipCodeID = Convert.ToInt32(ddlLossZip.SelectedValue);
            }



            try {
                if (isNewContact)
                {
                    using (TransactionScope scope = new TransactionScope()) {
                        // save contact to contact table
                        contact = ContactManager.Save(contact);

                        claimContact = new ClaimContact();

                        claimContact.ClaimID   = this.claimID;
                        claimContact.ContactID = contact.ContactID;

                        // save contact reference for claim
                        claimContact = ClaimContactManager.Save(claimContact);

                        // complete transaction
                        scope.Complete();
                    }
                }
                else
                {
                    // save contact to contact table
                    contact = ContactManager.Save(contact);
                }

                lblMessage.Text     = "Contact saved successfully.";
                lblMessage.CssClass = "ok";
            }
            catch (Exception ex) {
                lblMessage.Text     = "Contact not saved.";
                lblMessage.CssClass = "error";

                Core.EmailHelper.emailError(ex);
            }
            finally {
                bindData(this.claimID);
            }
        }