Пример #1
0
 public EditFormProperties()
 {
     LoadingElapseTime = new ElapseTime();
     _ToolbarButtons   = new ToolbarButtons();
     _EditMode         = EditModeEnum.List;
     _VisibleToolbar   = true;
     _VisibleStatusbar = true;
     _IsLoadingRefresh = false;
     IsLoaded          = false;
 }
Пример #2
0
        private void Layers_CollectionChanged(object sender,
                                              NotifyCollectionChangedEventArgs e)
        {
            if (PreviousMode == Settings.Instance.Mode)
            {
                return;
            }

            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                Settings.Instance.Mode = EditModeEnum.Draw;
                PreviousMode           = EditModeEnum.Draw;
            }
        }
Пример #3
0
        /// <summary>
        /// Saves the changes done to the current record on the recordset.
        /// </summary>
        /// <remarks>If the recordset is not batch enabled this method saves the changes on the database.</remarks>
        public override void Update()
        {
            DataRow theRow = CurrentRow;

            if (theRow == null)
            {
                return;
            }
            if (newRow)
            {
                Tables[0].Rows.Add(theRow);
                index  = Tables[0].Rows.IndexOf(theRow);
                newRow = false;
                dbRow  = null;
            }
            int Action = -1;
            int Save   = 0;

            if (theRow.RowState != DataRowState.Unchanged)
            {
                if (theRow.RowState == DataRowState.Added)
                {
                    Save     = -1;
                    editMode = EditModeEnum.dbEditAdd;
                    //AIS-TODO: Check if data row is empty do not call database operation
                    if (CheckNullState(theRow))
                    {
                        return;
                    }
                }
                OnValidating(ref Save, ref Action);
                if (Action == 0)
                {
                    editMode = EditModeEnum.dbEditNone;
                    return;
                }
                if (!isBatchEnabled())
                {
                    UpdateWithNoEvents(theRow);
                }
            }
            editMode = EditModeEnum.dbEditNone;
        }
Пример #4
0
    public void SetEditMode(EditModeEnum aEditMode)
    {
        print("EditorManager - EditMode changed to " + aEditMode.ToString());
        this.editMode       = aEditMode;
        this.selectionState = SelectionStateEnum.DEFAULT;
        this.blockGhost     = null;
        switch (this.editMode)
        {
        case EditModeEnum.ADD:
            this.placeView.SetActive(true);
            break;

        case EditModeEnum.REMOVE:
            this.placeView.SetActive(false);
            // this.placeView.enabled = false;
            break;

        case EditModeEnum.SELECT:
            this.placeView.SetActive(false);
            // this.placeView.enabled = false;
            break;
        }
    }
Пример #5
0
 /// <summary>
 /// Sets the recordset on edit mode.
 /// </summary>
 public void Edit()
 {
     editMode = EditModeEnum.dbEditNone;
 }
Пример #6
0
 /// <summary>
 /// Creates a new record.
 /// </summary>
 public override void AddNew()
 {
     doAddNew();
     editMode = EditModeEnum.dbEditAdd;
 }
Пример #7
0
 public EmployeeDetailForm(EditModeEnum editMode)
 {
     InitializeComponent();
     _editMode = editMode;
 }
Пример #8
0
        /// <summary>
        /// Saves the changes done to the current record on the recordset.
        /// </summary>
        /// <remarks>If the recordset is not batch enabled this method saves the changes on the database.</remarks>
        public override void Update()
        {
            DataRow theRow = CurrentRow;
            if (theRow == null)
            {
                return;
            }
            if (newRow)
            {
                Tables[0].Rows.Add(theRow);
                index = Tables[0].Rows.IndexOf(theRow);
                newRow = false;
                dbRow = null;
            }
            int Action = -1;
            int Save = 0;

            if (theRow.RowState != DataRowState.Unchanged)
            {
                if (theRow.RowState == DataRowState.Added)
                {
                    Save = -1;
                    editMode = EditModeEnum.dbEditAdd;
                    //AIS-TODO: Check if data row is empty do not call database operation
                    if (CheckNullState(theRow))
                    {
                        return;
                    }
                }
                OnValidating(ref Save, ref Action);
                if (Action == 0)
                {
                    editMode = EditModeEnum.dbEditNone;
                    return;
                }
                if (!isBatchEnabled())
                {
                    UpdateWithNoEvents(theRow);
                }
            }
            editMode = EditModeEnum.dbEditNone;
        }
Пример #9
0
 /// <summary>
 /// Deletes the current record or a group of records.
 /// </summary>
 /// <param name="deleteBehavior">AffectEnum value indicating if the deletion applies to the current group or a group.</param>
 public void Delete(int deleteBehavior)
 {
     Exception exceptionToThrow = null;
     EventStatusEnum status = EventStatusEnum.adStatusOK;
     string[] errors = null;
     OnWillChangeRecord(EventReasonEnum.adRsnDelete, ref status, 1);
     if (status != EventStatusEnum.adStatusCancel)
     {
         try
         {
             if (!isBatchEnabled() || editMode != EditModeEnum.adEditNone)
             {
                 editMode = EditModeEnum.adEditDelete;
             }
             DataRow deletingRow;
             switch (deleteBehavior)
             {
                 case (int)AffectEnum.adAffectCurrent:
                     deletingRow = UsingView ? currentView[index].Row : Tables[0].Rows[index];
                     break;
                 case (int)AffectEnum.adAffectGroup:
                     deletingRow = UsingView ? currentView[index].Row : Tables[0].Rows[index];
                     break;
                 default:
                     throw new ArgumentException("Value not allowed to delete.");
             }
             deletingRow.Delete();
             Update();
         }
         catch (Exception e)
         {
             if (!isBatchEnabled() || editMode != EditModeEnum.adEditNone)
             {
                 editMode = EditModeEnum.adEditInProgress;
             }
             errors = new string[] { e.Message };
             exceptionToThrow = e;
         }
         if (exceptionToThrow != null)
         {
             throw exceptionToThrow;
         }
         OnRecordChangeComplete(EventReasonEnum.adRsnDelete, ref status, 1, errors);
     }
 }
Пример #10
0
 public EditModel(uint id, EditModeEnum editMode)
 {
     ID       = id;
     EditMode = editMode;
 }
Пример #11
0
 /// <summary>
 /// Array access by index
 /// </summary>
 /// <param name="columnIndex">index value</param>
 /// <returns>object</returns>
 public override Object this[int columnIndex]
 {
     get
     {
         return base[columnIndex];
     }
     set
     {
         base[columnIndex] = value;
         if (!isBatchEnabled() || editMode != EditModeEnum.adEditNone)
         {
             editMode = EditModeEnum.adEditInProgress;
         }
         firstChange = firstChange ? false : firstChange;
     }
 }
Пример #12
0
 /// <summary>
 /// Saves the current content of the ADORecordsetHelper to the database.
 /// </summary>
 /// <param name="reportMove">Bool flag that indicates if this operation will notify others process raising an event or not.</param>
 private void Update(bool reportMove)
 {
     Exception exceptionToThrow = null;
     EventStatusEnum status = EventStatusEnum.adStatusOK;
     string[] errors = null;
     OnWillChangeRecordset(EventReasonEnum.adRsnMove, ref status);
     if (status != EventStatusEnum.adStatusCancel)
     {
         DataRow theRow = CurrentRow;
         if (newRow)
         {
             newRow = false;
         }
         if (theRow.RowState != DataRowState.Unchanged)
         {
             if (!isBatchEnabled())
             {
                 if (UsingView)
                 {
                     dbvRow.EndEdit();
                     index = findBookmarkIndex(dbvRow.Row);
                 }
                 status = EventStatusEnum.adStatusOK;
                 OnWillChangeRecord(EventReasonEnum.adRsnUpdate, ref status, 1);
                 if (status != EventStatusEnum.adStatusCancel)
                 {
                     try
                     {
                         UpdateWithNoEvents(theRow);
                         editMode = EditModeEnum.adEditNone;
                     }
                     catch (Exception e)
                     {
                         errors = new string[] { e.Message };
                         exceptionToThrow = e;
                     }
                     OnRecordChangeComplete(EventReasonEnum.adRsnUpdate, ref status, 1, errors);
                 }
             }
         }
         OnRecordsetChangeComplete(EventReasonEnum.adRsnMove, ref status, errors);
         if (exceptionToThrow != null)
         {
             throw exceptionToThrow;
         }
         if (reportMove)
         {
             Move(0, EventReasonEnum.adRsnMove, EventStatusEnum.adStatusOK);
         }
     }
 }
Пример #13
0
 /// <summary>
 /// Cancels a pending batch update.
 /// </summary>
 public override void CancelBatch()
 {
     bool wasNewRow = newRow;
     EventStatusEnum status = EventStatusEnum.adStatusOK;
     string[] errors = null;
     OnWillChangeRecord(wasNewRow ? EventReasonEnum.adRsnUndoAddNew : EventReasonEnum.adRsnUndoUpdate, ref status, 1);
     if (status != EventStatusEnum.adStatusCancel)
     {
         try
         {
             base.CancelBatch();
             index = -1;
             editMode = EditModeEnum.adEditNone;
         }
         catch (Exception e)
         {
             errors = new string[] { e.Message };
         }
         OnRecordChangeComplete(wasNewRow ? EventReasonEnum.adRsnUndoAddNew : EventReasonEnum.adRsnUndoUpdate, ref status, 1, errors);
     }
 }
Пример #14
0
 /// <summary>
 /// Writes all pending batch updates to disk.
 /// </summary>
 public void UpdateBatch()
 {
     Exception exceptionToThrow = null;
     if (UsingView)
     {
         dbvRow.EndEdit();
         index = findBookmarkIndex(dbvRow.Row);
     }
     if (isBatchEnabled())
     {
         DbConnection connection = GetConnection(connectionString);
         using (DbDataAdapter dbAdapter = CreateAdapter(connection, true))
         {
             DataTable changes = UsingView ? currentView.Table.GetChanges() : Tables[0].GetChanges();
             if (changes != null)
             {
                 EventStatusEnum status = EventStatusEnum.adStatusOK;
                 string[] errors = null;
                 OnWillChangeRecord(EventReasonEnum.adRsnUpdate, ref status, 1);
                 if (status != EventStatusEnum.adStatusCancel)
                 {
                     try
                     {
                         dbAdapter.Update(isClone ? currentView.Table.DataSet : this);
                         editMode = EditModeEnum.adEditNone;
                     }
                     catch (Exception e)
                     {
                         errors = new string[] { e.Message };
                         exceptionToThrow = e;
                     }
                     OnRecordChangeComplete(EventReasonEnum.adRsnUpdate, ref status, 1, errors);
                     if (exceptionToThrow != null)
                     {
                         throw exceptionToThrow;
                     }
                 }
             }
         }
     }
 }
Пример #15
0
 public EditModel(EditModeEnum editMode)
 {
     EditMode = editMode;
 }
Пример #16
0
 void Awake()
 {
     this.selectionState = SelectionStateEnum.DEFAULT;
     this.editMode       = EditModeEnum.ADD;
 }
Пример #17
0
 /// <summary>
 /// Creates a new record.
 /// </summary>
 public override void AddNew()
 {
     doAddNew();
     editMode = EditModeEnum.dbEditAdd;
 }
Пример #18
0
 public EditMode(EditModeEnum mode = 0)
 {
     Mode = mode;
 }
Пример #19
0
 /// <summary>
 /// Sets the recordset on edit mode.
 /// </summary>
 public void Edit()
 {
     editMode = EditModeEnum.dbEditNone;
 }
Пример #20
0
 public void setCurrentEditMode(EditModeEnum newMode)
 {
     currentEditMode = newMode;
     destroyPreviews();
 }
Пример #21
0
 /// <summary>
 /// Creates a new record for an updatable Recordset.
 /// </summary>
 public override void AddNew()
 {
     //Validations. AddNew is not allowed for Recordset with ReadOnly LockType
     if (LockType == LockTypeEnum.adLockReadOnly)
     {
         throw new NotSupportedException("AddNew is not supported for RecordSets with a LockType " + LockType);
     }
     EventStatusEnum status = EventStatusEnum.adStatusOK;
     OnWillMove(EventReasonEnum.adRsnMove, ref status);
     string[] errors = null;
     if (status != EventStatusEnum.adStatusCancel)
     {
         OnWillChangeRecord(EventReasonEnum.adRsnAddNew, ref status, 1);
         if (status != EventStatusEnum.adStatusCancel)
         {
             try
             {
                 if (!isBatchEnabled() || editMode != EditModeEnum.adEditNone)
                 {
                     editMode = EditModeEnum.adEditAdd;
                 }
                 base.AddNew();
                 if (!UsingView)
                 {
                     Tables[0].Rows.Add(dbRow);
                     base.newRow = false;
                     MoveLast();
                 }
             }
             catch (Exception e)
             {
                 errors = new string[] { e.Message };
                 status = EventStatusEnum.adStatusErrorsOccurred;
             }
             OnRecordChangeComplete(EventReasonEnum.adRsnAddNew, ref status, 1, errors);
         }
         OnMoveComplete(EventReasonEnum.adRsnMove, ref status, errors);
     }
 }