protected void SaveRecord(bool newRecord)
        {
            // new record / exiting record //

            object oldEntity  = null;
            object oldAddress = null;

            if (newRecord)
            {
                Entity             = new CRM_Venue();
                Entity.CRM_Address = new CRM_Address();
                db.CRM_Venues.InsertOnSubmit(Entity);
            }

            Entity.Name       = txtName.Text;
            Entity.Capacity   = Convert.ToInt32(txtCapacity.Text);
            Entity.IsInternal = chkIsInternal.Checked;
            ucAddress.Save(Entity.CRM_Address);
            db.SubmitChanges();

            if (oldEntity != null)
            {
                CRM.Code.History.History.RecordLinqUpdate(AdminUser, oldEntity, Entity);
                CRM.Code.History.History.RecordLinqUpdate(AdminUser, oldAddress, Entity.CRM_Address);
                db.SubmitChanges();
            }
            else
            {
                CRM.Code.History.History.RecordLinqInsert(AdminUser, Entity);
                CRM.Code.History.History.RecordLinqInsert(AdminUser, Entity.CRM_Address);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            RunSecurity(CRM.Code.Models.Admin.AllowedSections.NotSet);
            Entity = db.CRM_Venues.SingleOrDefault(c => c.ID.ToString() == Request.QueryString["id"]);

            btnSubmitChanges.Visible = PermissionManager.CanUpdate;
            if (!PermissionManager.CanAdd && Entity == null)
            {
                Response.Redirect("list.aspx");
            }

            // buttons //

            btnSubmit.EventHandler        = btnSubmit_Click;
            btnSubmitChanges.EventHandler = btnSubmitChanges_Click;
            btnDelete.EventHandler        = btnDelete_Click;

            // Security //

            btnSubmitChanges.Visible = PermissionManager.CanUpdate;
            btnDelete.Visible        = PermissionManager.CanDelete;
            if (!PermissionManager.CanAdd && Entity == null)
            {
                Response.Redirect("list.aspx");
            }

            // confirmations //

            confirmationDelete.StandardDeleteHidden("venue", btnRealDelete_Click);

            // process //
            CRMContext = Entity;

            if (!IsPostBack)
            {
                if (Entity != null)
                {
                    PopulateFields();
                }
            }
        }