private void SavePreviousBusinessObject()
 {
     if (_lastSelectedBusinessObject != null && !_lastSelectedBusinessObject.Status.IsDeleted)
     {
         _lastSelectedBusinessObject.Save();
     }
 }
 private void GridSelectionChanged(object sender, EventArgs e)
 {
     if (_newBO != null)
     {
         if (_newBO.Status.IsDirty)
         {
             if (_newBO.IsValid())
             {
                 _newBO.Save();
             }
             else
             {
                 _newBO = null;
             }
         }
     }
     if (_lastSelectedBusinessObject == null || _readOnlyGridControl.SelectedBusinessObject != _lastSelectedBusinessObject)
     {
         if (!CheckRowSelectionCanChange())
         {
             return;
         }
         SavePreviousBusinessObject();
         SetSelectedBusinessObject();
     }
 }
示例#3
0
        /// <summary>
        /// Writes the inserted date value to the client.
        /// </summary>
        private void UpdateStopDateAndReturn()
        {
            string newDate = string.Empty;

            // validate required mappings
            if (TABLE_MAPPINGS.ContainsKey(Table) && BusinessObjectFactory.CanBuildBusinessObject(Table) && PriKey.HasValue)
            {
                int patientId = int.Parse(Session[SessionKey.PatientId].ToString());

                // create instance
                IBusinessObject biz = BusinessObjectFactory.BuildBusinessObject(Table);
                // load record and validate
                biz.Get(PriKey.Value);
                if (!biz.IsEmpty)
                {
                    // turn on validation of patient
                    biz.EnableSaveValidation(patientId);

                    // the date field representing the stop date
                    string dateField = TABLE_MAPPINGS[Table];
                    // check for date text field
                    string dateTextField = dateField + "Text";
                    if (biz.HasField(dateField))
                    {
                        // determine if updating stop date of nullifying
                        bool doStop = Checked;
                        if (doStop)
                        {
                            // set date fields
                            DateTime date = QueryDate.HasValue ? QueryDate.Value : DateTime.Today; // ?? use DateTime.Today for normalization
                            biz[dateField] = date;
                            if (biz.HasField(dateTextField))
                            {
                                biz[dateTextField] = date.ToShortDateString();
                            }
                            // set short date
                            newDate = date.ToShortDateString();
                        }
                        // nullify stop date fields
                        else
                        {
                            biz[dateField] = null;
                            if (biz.HasField(dateTextField))
                            {
                                biz[dateTextField] = null;
                            }
                            newDate = string.Empty;
                        }
                    }
                    // update
                    biz.Save();
                }
            }
            else
            {
                newDate = string.Empty;
            }
            // write the new short stop date
            Response.Write(newDate);
        }
示例#4
0
        public void Test_ClickCancel_WhenNotIsNew_ShouldCancelEditsAndNotMarkForDelete()
        {
            //---------------Set up test pack-------------------
            IBusinessObject bo = _classDefMyBo.CreateNewBusinessObject();

            bo.Save();
            IDefaultBOEditorForm boEditorForm = GetControlFactory()
                                                .CreateBOEditorForm((BusinessObject)bo, "default", () => null);

            ShowFormIfNecessary(boEditorForm);
            EditControlValueOnForm(boEditorForm, "TestProp", "TestValue");
            EditControlValueOnForm(boEditorForm, "TestProp2", "TestValue2");
            bo.SetPropertyValue("TestProp", "TestValue");
            IButton cancelButton = boEditorForm.Buttons["Cancel"];

            //--------------Assert PreConditions----------------
            Assert.IsNotNull(cancelButton);
            Assert.IsTrue(bo.Status.IsDirty, "BO should be dirty prior to cancelling");
            //---------------Execute Test ----------------------
            cancelButton.PerformClick();
            //---------------Test Result -----------------------
            Assert.AreEqual(DialogResult.Cancel, boEditorForm.DialogResult);
            Assert.AreEqual(null, bo.GetPropertyValue("TestProp"));
            Assert.AreEqual(null, bo.GetPropertyValue("TestProp2"));
            Assert.IsFalse(bo.Status.IsDirty, "BO should not be dirty after cancelling");
            Assert.IsFalse(bo.Status.IsDeleted, "Saved BO should not be deleted on cancelling edits");
            Assert.IsNull(boEditorForm.PanelInfo.BusinessObject);
        }
        /// <summary>
        /// Deliberately adds BO to the grid's collection because current habanero model only
        /// adds BO to grid when it is saved.  This causes a problem when you call col.CreateBO(), since
        /// it adds the BO twice and throws a duplicate key exception.
        /// </summary>a
        private void NewButtonClicked(object sender, EventArgs e)
        {
            _newBO = null;
            IBusinessObject currentBO = CurrentBusinessObject;

            if (currentBO != null)
            {
                if (!currentBO.IsValid())
                {
                    _iboEditorControl.DisplayErrors();
                    return;
                }
                currentBO.Save();
            }

            IBusinessObjectCollection collection = _readOnlyGridControl.Grid.BusinessObjectCollection;

            _readOnlyGridControl.Grid.SelectionChanged -= GridSelectionChanged;
            _newBO = collection.CreateBusinessObject();
            // _readOnlyGridControl.Grid.GetBusinessObjectCollection().Add(businessObject);
            _readOnlyGridControl.SelectedBusinessObject = _newBO;
            CurrentBusinessObject = _newBO;
            UpdateControlEnabledState();
            //collection.Add(businessObject);
            _readOnlyGridControl.Grid.SelectionChanged += GridSelectionChanged;
            GridSelectionChanged(null, null);
            _iboEditorControl.Focus();
            _iboEditorControl.ClearErrors();
            _cancelButton.Enabled = true;
        }
示例#6
0
        private void DeleteButtonClicked(object sender, EventArgs e)
        {
            if (CurrentBusinessObject == null)
            {
                return;
            }

            IBusinessObject businessObject = CurrentBusinessObject;

            RemoveGridSelectionEvent();
            if (businessObject.Status.IsNew)
            {
                //RemoveGridSelectionEvent();
                ReadOnlyGridControl.SelectedBusinessObject = null;
                ReadOnlyGridControl.Grid.BusinessObjectCollection.Remove(businessObject);
                //AddGridSelectionEvent();
            }
            else
            {
                businessObject.MarkForDelete();
                businessObject.Save();
            }
            AddGridSelectionEvent();
            _lastSelectedBusinessObject = null;

            if (CurrentBusinessObject == null && ReadOnlyGridControl.Grid.Rows.Count > 0)
            {
                SelectLastRowInGrid();
            }
            UpdateControlEnabledState();
        }
        /// <summary>
        /// Deliberately adds BO to the grid's collection because current habanero model only
        /// adds BO to grid when it is saved.  This causes a problem when you call col.CreateBO(), since
        /// it adds the BO twice and throws a duplicate key exception.
        /// </summary>a
        private void NewButtonClicked(object sender, EventArgs e)
        {
            try
            {
                _newBO = null;
                IBusinessObject currentBO = CurrentBusinessObject;
                if (currentBO != null)
                {
                    if (!currentBO.Status.IsValid())
                    {
                        bool errors = _iboEditorControl.HasErrors;
                        return;
                    }
                    currentBO.Save();
                }

                IBusinessObjectCollection collection = _readOnlyGridControl.Grid.BusinessObjectCollection;
                _readOnlyGridControl.Grid.SelectionChanged -= GridSelectionChanged;
                _newBO = collection.CreateBusinessObject();
                // _readOnlyGridControl.Grid.GetBusinessObjectCollection().Add(businessObject);
                _readOnlyGridControl.SelectedBusinessObject = _newBO;
                CurrentBusinessObject = _newBO;
                UpdateControlEnabledState();
                //collection.Add(businessObject);
                _readOnlyGridControl.Grid.SelectionChanged += GridSelectionChanged;
                GridSelectionChanged(null, null);
                _iboEditorControl.Focus();
                //_iboEditorControl.ClearErrors();
                _cancelButton.Enabled = true;
            }
            catch (Exception ex)
            {
                GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error ");
            }
        }
示例#8
0
        /// <summary>
        /// Handles the event of a row being committed to the database
        /// </summary>
        /// <param name="e">Attached arguments regarding the event</param>
        private void RowCommitted(DataRowChangeEventArgs e)
        {
            DataRow row = e.Row;

            try
            {
                IBusinessObject changedBo = GetBusinessObjectForRow(row);
                if (changedBo != null)
                {
                    try
                    {
                        DeregisterForBOEvents();
                        changedBo.Save();
                    }
                    finally
                    {
                        RegisterForBOEvents();
                    }
                    row.RowError = changedBo.Status.IsValidMessage;
                }
                else
                {
                    row.RowError = "";
                }
            }
            catch (Exception ex)
            {
                string message = "There was a problem saving. : " + ex.Message;
                row.RowError = message;
                GlobalRegistry.UIExceptionNotifier.Notify(ex, message, "Problem Saving");
            }
        }
示例#9
0
        /// <summary>
        /// Returns a saved valid business object of Type
        /// </summary>
        /// <returns></returns>
        public virtual IBusinessObject CreateSavedBusinessObject()
        {
            IBusinessObject bo = this.CreateBusinessObject();

            this.UpdateCompulsoryProperties(bo);
            bo.Save();
            return(bo);
        }
        void Entities_SavingChanges(object sender, EventArgs e)
        {
            var stateManager = ((BsoArchiveEntities)sender).ObjectStateManager;

            var updatedEntities =
                stateManager.GetObjectStateEntries(EntityState.Added | EntityState.Modified).Where(
                    entities => entities.IsRelationship == false);

            int userIdentity = 0;

            // look for created / modified dates
            foreach (ObjectStateEntry stateEntryEntity in updatedEntities)
            {
                if (!(stateEntryEntity.Entity is Adage.EF.Interfaces.IBusinessObject))
                {
                    return;
                }

                IBusinessObject businessObject = (Adage.EF.Interfaces.IBusinessObject)stateEntryEntity.Entity;

                if (businessObject.UniqueKey == "0" && stateEntryEntity.State == EntityState.Modified)
                {
                    stateManager.ChangeObjectState(stateEntryEntity.Entity, EntityState.Added);

                    foreach (System.Data.Common.FieldMetadata md in stateEntryEntity.CurrentValues.DataRecordInfo.FieldMetadata.Where(
                                 md => md.FieldType.TypeUsage.EdmType.Name.ToUpper() == "GUID"))
                    {
                        stateEntryEntity.CurrentValues.SetValue(md.Ordinal, Guid.NewGuid());
                    }
                }

                // update created on / by
                if (stateEntryEntity.State == EntityState.Added)
                {
                    SetDefaultValue(stateEntryEntity);
                    UpdateValue(stateEntryEntity, "CreatedOn", PrimitiveTypeKind.DateTime, DateTime.Now);
                    UpdateValue(stateEntryEntity, "CreatedBy", PrimitiveTypeKind.Int32, userIdentity);
                }

                // updated modified on / by
                UpdateValue(stateEntryEntity, "ModifiedOn", PrimitiveTypeKind.DateTime, DateTime.Now);
                UpdateValue(stateEntryEntity, "ModifiedBy", PrimitiveTypeKind.Int32, userIdentity);
            }

            // call Save on all business objects
            var changedEntities =
                stateManager.GetObjectStateEntries(EntityState.Added | EntityState.Modified | EntityState.Deleted).Where
                    (entities => entities.IsRelationship == false);

            foreach (ObjectStateEntry stateEntryEntity in changedEntities)
            {
                IBusinessObject businessObject = (Adage.EF.Interfaces.IBusinessObject)stateEntryEntity.Entity;
                businessObject.Save(this);
            }
        }
 private void SaveClickHandler(object sender, EventArgs e)
 {
     try
     {
         IBusinessObject currentBO = CurrentBusinessObject;
         currentBO.Save();
     }
     catch (Exception ex)
     {
         GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error ");
     }
 }
        private void DeleteButtonClicked(object sender, EventArgs e)
        {
            IBusinessObject businessObject = CurrentBusinessObject;

            businessObject.MarkForDelete();
            businessObject.Save();

            if (CurrentBusinessObject == null && _readOnlyGridControl.Grid.Rows.Count > 0)
            {
                SelectLastRowInGrid();
            }
        }
示例#13
0
 /// <summary>
 /// Handles the Closing of the Popup form.
 /// By default this saves the Business Object that is currently selectedin the Popup  (if there is one)
 /// and Sets the Currently selected Business Object.ToString as the text of the TextBox
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected virtual void HandlePopUpFormClosedEvent(object sender, CancelEventArgs e)
 {
     if (this.EnableEditing)
     {
         IBusinessObject currentBusinessObject = GetSelectedBusinessObject();
         //TODO brett 27 May 2010: Check if dirty if dirty then
         // if valid Ask  have option of Save, CancelEdits, CancelClose.
         // if not valid ask if want to CancelEdits or CancelClose
         if ((currentBusinessObject != null) && currentBusinessObject.Status.IsValid())
         {
             currentBusinessObject.Save();
         }
     }
 }
示例#14
0
        /// <summary>
        /// Handles the Closing of the Popup form.
        /// By default this saves the Business Object that is currently selectedin the Popup  (if there is one)
        /// Reloads the Combo Box using <see cref="ReloadLookupValues"/>.
        /// and Sets the Currently selected Business Object as the selected Item for the ComboBox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void HandlePopUpFormClosedEvent(object sender, EventArgs e)
        {
            IBOGridAndEditorControl iboGridAndEditorControl = GetIBOGridAndEditorControl();
            IBusinessObject         currentBusinessObject   = iboGridAndEditorControl.CurrentBusinessObject;

            if ((currentBusinessObject != null) && currentBusinessObject.Status.IsValid())
            {
                currentBusinessObject.Save();
            }
            ReloadLookupValues();
            if (currentBusinessObject != null)
            {
                ExtendedComboBox.ComboBox.SelectedValue = currentBusinessObject.ID.GetAsValue().ToString();
            }
        }
示例#15
0
        private static void Save(IBusinessObject b, XmlServiceSettings settings)
        {
            if ((b is Procedure || b is OperatingRoomDetail) && !settings.EnableDuplicateRecords.Contains(b.TableName))
            {
                Dictionary <string, object> searchCriteria;

                if (b is Procedure)
                {
                    searchCriteria =
                        new Dictionary <string, object>()
                    {
                        { Procedure.PatientId, b[Procedure.PatientId] },
                        { Procedure.ProcSurgeon, b[Procedure.ProcSurgeon] },
                        { Procedure.ProcName, b[Procedure.ProcName] },
                        { Procedure.ProcDate, b[Procedure.ProcDate] },
                        { Procedure.ProcCPT_Code, b[Procedure.ProcCPT_Code] }
                    };
                }
                else
                {
                    searchCriteria =
                        new Dictionary <string, object>()
                    {
                        { OperatingRoomDetail.PatientId, b[OperatingRoomDetail.PatientId] },
                        { OperatingRoomDetail.OpDate, b[OperatingRoomDetail.OpDate] }
                    };
                }

                IEnumerable <IBusinessObject> existing = BusinessObject.GetByFields(b.TableName, searchCriteria);

                if (existing.Count() == 1)                 // if there's more than one, just insert
                {
                    IBusinessObject ex = existing.First();

                    foreach (string f in ex.FieldNames)
                    {
                        if (ExcludeField(b, f) || IsEmpty(b[f]))
                        {
                            b[f] = ex[f];
                        }
                    }
                }
            }

            b.Save();
        }
        private void DeleteButtonClicked(object sender, EventArgs e)
        {
            try
            {
                IBusinessObject businessObject = CurrentBusinessObject;
                businessObject.MarkForDelete();
                businessObject.Save();

                if (CurrentBusinessObject == null && _readOnlyGridControl.Grid.Rows.Count > 0)
                {
                    SelectLastRowInGrid();
                }
            }
            catch (Exception ex)
            {
                GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error ");
            }
        }
示例#17
0
        private void SaveButtonClicked(object sender, EventArgs e)
        {
            IBusinessObject currentBO = CurrentBusinessObject;

            if (currentBO != null)
            {
                CallApplyChangesOnPanelInfo();

                if (!currentBO.Status.IsValid())
                {
                    return;
                }

                currentBO.Save();
                RefreshGrid_IfStrategyAllows();
                UpdateControlEnabledState();
            }
        }
 private void GridSelectionChanged(object sender, EventArgs e)
 {
     if (this.SkipSaveOnSelectionChanged)
     {
         SetSelectedBusinessObject();
         return;
     }
     try
     {
         if (_newBO != null)
         {
             if (_newBO.Status.IsDirty)
             {
                 if (_newBO.Status.IsValid())
                 {
                     _newBO.Save();
                 }
                 else
                 {
                     _newBO = null;
                 }
             }
         }
         if (_lastSelectedBusinessObject == null || _readOnlyGridControl.SelectedBusinessObject != _lastSelectedBusinessObject)
         {
             if (!CheckRowSelectionCanChange())
             {
                 return;
             }
             SavePreviousBusinessObject();
             SetSelectedBusinessObject();
         }
     }
     catch (Exception ex)
     {
         GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error ");
     }
 }
示例#19
0
        /// <summary>
        /// Handles the event of a row being deleted
        /// </summary>
        /// <param name="sender">The object that notified of the event</param>
        /// <param name="e">Attached arguments regarding the event</param>
        private void RowDeletedHandler(object sender, DataRowChangeEventArgs e)
        {
            DataRow row = e.Row;

            try
            {
                IBusinessObject changedBo = GetBusinessObjectForRow(row);
                if (changedBo == null)
                {
                    return;
                }
                try
                {
                    string message;
                    if (changedBo.IsDeletable(out message))
                    {
                        DeregisterForBOEvents();
                        changedBo.MarkForDelete();
                        changedBo.Save();
                    }
                    else
                    {
                        row.RejectChanges();
                    }
                }
                finally
                {
                    RegisterForBOEvents();
                }
            }
            catch (Exception ex)
            {
                string message = "There was a problem saving. : " + ex.Message;
                row.RowError = message;
                GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error ");
            }
        }
        /// <summary>
        /// Updates the Patient assoication for the specificed Repeater, i.e., list of patient institutions
        /// </summary>
        /// <param name="patientId"></param>
        /// <param name="rptr"></param>
        private void UpdatePatientRptr(int patientId, Repeater rptr)
        {
            foreach (RepeaterItem item in rptr.Items)
            {
                ICaisisInputControl foreignKeyField = item.FindControl("ForeignKeyField") as ICaisisInputControl;
                ICaisisInputControl primaryKeyField = item.FindControl("PrimaryKeyField") as ICaisisInputControl;
                CheckBox            isAssociated    = item.FindControl("AssociateCheckBox") as CheckBox;
                if (isAssociated.Checked)
                {
                    // only add association if none exists
                    if (string.IsNullOrEmpty(primaryKeyField.Value))
                    {
                        IBusinessObject biz = BusinessObjectFactory.BuildBusinessObject(primaryKeyField.Table);
                        // set keys (i.e, InstitutionId + PatientId)
                        biz[foreignKeyField.Field] = int.Parse(foreignKeyField.Value);
                        biz[Patient.PatientId]     = patientId;
                        biz.Save();

                        primaryKeyField.Value = biz[biz.PrimaryKeyName].ToString();
                    }
                }
                else
                {
                    // remove if assocaition exists
                    if (!string.IsNullOrEmpty(primaryKeyField.Value))
                    {
                        IBusinessObject biz = BusinessObjectFactory.BuildBusinessObject(primaryKeyField.Table);
                        // delete by pri key (i.e., PatientInstitutionId)
                        int priKey = int.Parse(primaryKeyField.Value);
                        biz.Delete(priKey);

                        primaryKeyField.Value = biz[biz.PrimaryKeyName].ToString();
                    }
                }
            }
        }
 private static void CleanupObjectFromDatabase(IBusinessObject bo)
 {
     bo.MarkForDelete();
     bo.Save();
 }
示例#22
0
        /// <summary>
        /// Updates the metadta attibutes and attribute values
        /// </summary>
        protected virtual void Update()
        {
            GridView grid = GetMetadataGrid();

            if (grid == null)
            {
                return;
            }
            foreach (var dirtyRow in dirtyRows)
            {
                // the "dirty" grid row
                GridViewRow row      = dirtyRow.Key;
                int         rowIndex = row.RowIndex;
                // lookup of key fields in row
                var rowDataKeys = grid.DataKeys[rowIndex].Values;
                // a list of controls which are "dirty" in row
                var dirtyControls = dirtyRow.Value;
                // a list of "dirty" controls which represent an attribute value
                var dirtyAttributes = dirtyControls.Where(c => c.Table == attributeValueTableName);
                // a list of "dirty" contorls which represents a dirty metdata item
                var dirtyMetadataItemFields = dirtyControls.Where(c => c.Table == metadataItemTableName);

                IBusinessObject metadataItemBiz = BusinessObjectFactory.BuildBusinessObject(metadataItemTableName);
                int             metadataItemKey = (int)rowDataKeys[metadataItemBiz.PrimaryKeyName];

                // for each row, only updates values(attribuet values) which have changed, not all attribute values
                foreach (ICaisisInputControl dirtyAttributeValue in dirtyAttributes)
                {
                    string attributeName = dirtyAttributeValue.Field;
                    // only update if there is an attribute by this name
                    if (AttributeToHiddenField.ContainsKey(attributeName))
                    {
                        IBusinessObject attributeBiz     = BusinessObjectFactory.BuildBusinessObject(BIZ_ATTRIBUTE_TABLE.TableName);
                        int?            attributeId      = null;
                        int?            attributeValueId = null;

                        // get the table attribute id
                        ICaisisInputControl attributeIdField = AttributeToHiddenField[attributeName];

                        // CREATE/LOAD: Attribute (i.e., "FieldLabel" -> MetadataFieldAttribute)

                        // if attribute exists, set value
                        if (!string.IsNullOrEmpty(attributeIdField.Value))
                        {
                            attributeId = int.Parse(attributeIdField.Value);
                        }
                        // otherwise insert attribute
                        else
                        {
                            // set required attribute name
                            attributeBiz[attributeFieldName] = attributeName;
                            attributeBiz.Save();

                            // update hidden attribute id field
                            attributeId            = (int)attributeBiz[attributeBiz.PrimaryKeyName];
                            attributeIdField.Value = attributeId.Value.ToString();
                        }

                        // INSERT/UPDATE: Attribute Value (i.e., "FieldLabel" + "My Field" -> MetadataFieldAttributeValue)

                        // the field representing the AttributeValueId
                        ICaisisInputControl attributeValueIdField = GetTableAttributeValueIdControl(row, attributeName);
                        // the field representing the input control containing the AttributeValue
                        ICaisisInputControl attributeValueControl = GetTableAttributeValueControl(row, attributeName);
                        // the disease mapping to the attribute value
                        ICaisisInputControl diseaseAttributeValueId = GetDiseaseAttributeValueId(row, attributeName);

                        // validate fields exists
                        if (attributeValueIdField != null && attributeValueControl != null)
                        {
                            IBusinessObject attributeValueBiz = BusinessObjectFactory.BuildBusinessObject(attributeValueTableName);
                            bool            isDiseaseSpecific = QueryDiseaseId.HasValue && diseaseAttributeValueId != null;
                            // load attribute value, if isn't disease specific or disease specific has a value
                            if (!string.IsNullOrEmpty(attributeValueIdField.Value) && (!isDiseaseSpecific || !string.IsNullOrEmpty(diseaseAttributeValueId.Value)))
                            {
                                attributeValueId = int.Parse(attributeValueIdField.Value);
                                attributeValueBiz.Get(attributeValueId.Value);
                            }
                            // set required foreign keys for insert
                            else
                            {
                                // set required attribute id key (i.e., AttributeId)
                                attributeValueBiz[attributeBiz.PrimaryKeyName] = attributeId;
                                // set required metadata id (i.e., FieldId)
                                attributeValueBiz[metadataItemBiz.PrimaryKeyName] = metadataItemKey;
                            }

                            // get attribute value (i.e., "ControlType" = "CaisisTextBox")
                            string attributeValue = GetInputControlValue(attributeValueControl);

                            // update table attribute value

                            // validate (no empty values allowed)
                            if (string.IsNullOrEmpty(attributeValue))
                            {
                                // delete empty values
                                if (attributeValueId.HasValue)
                                {
                                    // delete atttibute value
                                    attributeValueBiz.Delete(attributeValueId.Value);
                                    attributeValueId            = null;
                                    attributeValueIdField.Value = string.Empty;
                                    // delete disease specific mapping
                                    if (isDiseaseSpecific && !string.IsNullOrEmpty(diseaseAttributeValueId.Value))
                                    {
                                        DiseaseAttributeValue dav = new DiseaseAttributeValue();
                                        dav.Delete(int.Parse(diseaseAttributeValueId.Value));
                                        diseaseAttributeValueId.Value = string.Empty;
                                    }
                                }
                                continue;
                            }
                            else
                            {
                                attributeValueBiz[attributeValueFieldName] = attributeValue;
                                attributeValueBiz.Save();
                                // update hidden field
                                attributeValueId            = (int)attributeValueBiz[attributeValueBiz.PrimaryKeyName];
                                attributeValueIdField.Value = attributeValueId.ToString();

                                // handle disease specific mapping
                                if (isDiseaseSpecific)
                                {
                                    var diseaseAttributeValue = new DiseaseAttributeValue();
                                    var diseaseAttributeId    = GetMetadataDiseaseAttributeId();
                                    // load existing mapping
                                    if (!string.IsNullOrEmpty(diseaseAttributeValueId.Value))
                                    {
                                        diseaseAttributeValue.Get(int.Parse(diseaseAttributeValueId.Value));
                                    }
                                    // new
                                    else
                                    {
                                        diseaseAttributeValue[DiseaseAttributeValue.DiseaseId]          = QueryDiseaseId.Value;
                                        diseaseAttributeValue[DiseaseAttributeValue.DiseaseAttributeId] = diseaseAttributeId.Value;
                                    }
                                    diseaseAttributeValue[DiseaseAttributeValue.DiseaseAttributeValue_Field] = attributeValueIdField.Value;

                                    diseaseAttributeValue.Save();
                                    diseaseAttributeValueId.Value = diseaseAttributeValue[diseaseAttributeValue.PrimaryKeyName].ToString();
                                }
                            }
                        }
                    }
                }
                // update metadata item (i.e., MetadataField)
                if (dirtyMetadataItemFields.Count() > 0)
                {
                    // load by pri key (i.e., FieldId)
                    metadataItemBiz.Get(metadataItemKey);
                    // update fields which have changed (i.e., FieldOrder, FieldSupress)
                    foreach (ICaisisInputControl input in dirtyMetadataItemFields)
                    {
                        metadataItemBiz[input.Field] = GetInputControlValue(input);
                    }
                    // save record
                    metadataItemBiz.Save();
                }
            }
            // after update rebuilds lists
            PopulateAttributeValues();
        }
        private void SaveClickHandler(object sender, EventArgs e)
        {
            IBusinessObject currentBO = CurrentBusinessObject;

            currentBO.Save();
        }