Esempio n. 1
0
 /// <summary>
 /// set current record to the specified record index
 /// </summary>
 /// <param name="idx"></param>
 internal void SetCurrentRecordByIdx(int idx)
 {
     if (idx >= 0)
     {
         Dataview.setCurrRecByIdx(idx, false, true, false, DataView.SET_DISPLAYLINE_BY_DV);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// update dataview after fetch of the record
        /// </summary>
        /// <param name="curRecId"></param>
        internal ReturnResultBase UpdateAfterFetch(int curRecId)
        {
            UpdateIncludes();

            if (Dataview.getSize() == 0)
            {
                if (Task.getMode() == Constants.TASK_MODE_CREATE)
                {
                    Dataview.addRecord(false, false);
                }
                else
                {
                    Dataview.addFirstRecord();
                }
            }

            if (Form != null)
            {
                Form.SetTableItemsCount(false);
            }

            SetCurrentRecord(curRecId);
            ReturnResultBase result = UpdateEmptyDataview();

            ComputeRecord();
            Task.SetRefreshType(Constants.TASK_REFRESH_TABLE);
            return(result);
        }
Esempio n. 3
0
 /// <summary>
 /// update arrays of table children controls
 /// </summary>
 private void UpdateTableChildrenArraysSize()
 {
     if (Form != null)
     {
         Form.UpdateTableChildrenArraysSize(Dataview.getSize());
     }
 }
Esempio n. 4
0
        internal void SetupDataview(bool reverse)
        {
            //do invalidate if needed
            //backup current record or copy values of virtuals

            Dataview.InsertAt = reverse ? (char)InsertMode.Before : (char)InsertMode.After;
            Dataview.setEmptyDataview(false);
        }
Esempio n. 5
0
        /// <summary>
        //  make sure that a new record created by the server is in 'insert' mode
        //  and mark it as a 'computed' record
        //  the same we doing for RecordsTable.cs method fillData()
        /// </summary>
        internal void SetInsertModeToCurrentRecord()
        {
            Debug.Assert(Task.getMode() == Constants.TASK_MODE_CREATE);

            Record record = Dataview.getCurrRec();

            record.setMode(DataModificationTypes.Insert);
            Dataview.currRecCompute(false);
        }
Esempio n. 6
0
        /// <summary>
        /// Gets the DC values object, whose identifier is 'id', from the data view.
        /// </summary>
        /// <param name="id">The identifier of the DC values object.</param>
        /// <returns>Returns the DC values, whose identifier is 'id', if found.
        /// If 'id' is not found - the method returns null</returns>
        internal DcValues GetDcValues(DataControlRangeDataCollection dcValuesRange)
        {
            int id;

            if (DataviewManager.TryGetDcValuesIsByRange(dcValuesRange, out id))
            {
                return(Dataview.getDcValues(id));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// compute record if it is new
        /// </summary>
        private void ComputeRecord()
        {
            Record record = Dataview.getCurrRec();

            if (record != null && record.getMode() == DataModificationTypes.Insert)
            {
                record.setComputed(false);
                Dataview.currRecCompute(false);
            }
            else if (Task.DataviewManager.HasLocalData)
            {
                Dataview.currRecCompute(false);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// remove record
        /// </summary>
        /// <param name="useFirstRecord"></param>
        /// <returns></returns>
        internal IRecord GetRecord(bool useFirstRecord)
        {
            IRecord record;

            if (useFirstRecord)
            {
                record = Dataview.getRecByIdx(0);
                DataviewManager.ClientIdGenerator.GenerateId();
            }
            else
            {
                record = CreateRecord();
                InsertRecord(record);
            }
            return(record);
        }
Esempio n. 9
0
        /// <summary>
        /// set current record to the specified record id
        /// </summary>
        /// <param name="id"></param>
        internal void SetCurrentRecord(int id)
        {
            int idx = Dataview.getRecIdx(id);

            if (idx != -1)
            {
                SetCurrentRecordByIdx(idx);
            }
            else
            {
                if (Dataview.getSize() > 0)
                {
                    SetCurrentRecordByIdx(0);
                }
            }
        }
Esempio n. 10
0
        public DataPicker(String Query, String DefaultFilter, TextBox textbox, Boolean Icon)
        {
            InitializeComponent();

            this.Query         = Query;
            this.HasIcon       = HasChildren;
            this.DefaultFilter = DefaultFilter;

            Dataview.ReadOnly              = true;
            Dataview.RowHeadersVisible     = false;
            Dataview.AllowUserToAddRows    = false;
            Dataview.AllowUserToResizeRows = false;
            Dataview.Refresh();
            Dataview.Dock = DockStyle.Fill;
            pb_icon.Image = new Bitmap(Properties.Settings.Default.path_icons + "/" + "ain_saw_lv1_ultimate01.jpg");

            Dataview.DataSource = sql.fetch_table(Query);
            Dataview.Size       = this.Size;
        }
Esempio n. 11
0
        /// <summary>
        /// update after modifications
        /// </summary>
        /// <param name="success"></param>
        internal void UpdateDataviewAfterModification(bool success)
        {
            IRecordsTable modRecordTbl = Dataview.ModifiedRecordsTab;
            Record        record       = this.GetModifiedRecord();

            if (success)
            {
                record.clearMode();
                record.clearFlagsHistory();
                record.clearFlagsForRealOnly(Record.FLAG_MODIFIED_ATLEAST_ONCE);
                Task.setTransactionFailed(false);
            }
            // remove all records
            modRecordTbl.RemoveAll();

            // if not success then call RecoveryRetryToLocalTask
            if (!success)
            {
                Dataview.HandleLocalDataError();
            }
        }
Esempio n. 12
0
        internal void RemoveRecord(IRecord record)
        {
            Record currRec = ((Record)record).getPrevRec();

            if (currRec == null)
            {
                currRec = ((Record)record).getNextRec();
            }

            if (currRec != null)
            {
                SetCurrentRecord(currRec.getId());
            }
            else
            {
                Dataview.reset();
            }
            Dataview.RemoveRecord((Record)record);
            TaskViews.ClearRecord(record);
            UpdateTableChildrenArraysSize();
        }
Esempio n. 13
0
        internal ReturnResultBase UpdateEmptyDataview()
        {
            ReturnResultBase result = new ReturnResult();

            if (PositionCache.Count == 0 && ((DataView)Task.DataView).HasMainTable)
            {
                Dataview.MoveToEmptyDataviewIfAllowed();

                if (!Dataview.isEmptyDataview())
                {
                    if (Task.checkProp(PropInterface.PROP_TYPE_ALLOW_CREATE, true))
                    {
                        // change to create mode
                        if (Task.getMode() != Constants.TASK_MODE_CREATE)
                        {
                            Task.setOriginalTaskMode(Constants.TASK_MODE_CREATE);
                            Task.setMode(Constants.TASK_MODE_CREATE);
                            Dataview.getCurrRec().setMode(DataModificationTypes.Insert);
                            Dataview.getCurrRec().setNewRec();
                            //ComputeRecord();
                        }

                        // MG_ACT_CRELINE may be disabled .i.e. PROP_TYPE_ALLOW_CREATE expression can be changed
                        (Task).enableCreateActs(true);
                    }
                    // exit from the ownerTask
                    else
                    {
                        result = new ReturnResult(MsgInterface.RT_STR_NO_RECS_IN_RNG);
                        //ClientManager.Instance.EventsManager.handleInternalEvent(Task, InternalInterface.MG_ACT_EXIT);
                    }
                }
            }
            else
            {
                Dataview.setEmptyDataview(false);
            }
            return(result);
        }
Esempio n. 14
0
        /// <summary>
        /// Returns a table object based on data in sys_table / sys_table_field / sys_table_field_lang tables for the given tableName.  Returns an empty definition if not found.
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="dm"></param>
        /// <param name="languageID"></param>
        /// <param name="loadFriendlyNamesForAllLanguages"></param>
        /// <returns></returns>
        public static ITable Map(string tableName, DataManager dm, int languageID, bool loadFriendlyNamesForAllLanguages)
        {
            string       cacheName = "FieldMappingTableCache";
            string       cacheKey  = tableName + languageID;
            CacheManager cache     = CacheManager.Get(cacheName);
            var          fmt       = (ITable)(cache[cacheKey]);

            if (fmt != null)
            {
                // already exists, just return it
                return(fmt);
            }
            else
            {
                fmt           = new Table();
                fmt.TableName = tableName;

                DataTable dt = dm.Read(@"
select
	st.sys_table_id,
	st.table_name,
	st.audits_created,
	st.audits_modified,
	st.audits_owned,
	st.is_readonly as table_is_readonly,
	stf.sys_table_field_id,
    stf.field_ordinal,
	stf.field_name,
	stf.field_purpose,
	stf.field_type,
	stf.default_value,
	stf.is_primary_key,
	stf.is_foreign_key,
	stf.is_nullable,
	stf.is_autoincrement,
	stf.gui_hint,
	stf.is_readonly as field_is_readonly,
	stf.min_length,
	stf.max_length,
	stf.numeric_precision,
	stf.numeric_scale,
	stf.group_name,
    stfl.sys_lang_id,
    coalesce(stfl.title, stf.field_name) as friendly_field_name,
    stfl.description as friendly_field_description,
	stf.foreign_key_dataview_name,
    st2.table_name as foreign_key_table_name,
    stf2.field_name as foreign_key_table_field_name
from
	sys_table st inner join sys_table_field stf
		on st.sys_table_id = stf.sys_table_id
    left join sys_table_field_lang stfl
        on stf.sys_table_field_id = stfl.sys_table_field_id
        and coalesce(stfl.sys_lang_id, 0) = coalesce(:langid, stfl.sys_lang_id, 0)
	left join sys_table_field stf2
		on stf.foreign_key_table_field_id = stf2.sys_table_field_id
    left join sys_table st2
        on stf2.sys_table_id = st2.sys_table_id
where
	st.table_name = :tablename 
order by
	stf.field_ordinal
", new DataParameters(":tablename", tableName, ":langid", (loadFriendlyNamesForAllLanguages ? null : (int?)languageID), DbType.Int32));

                if (dt.Rows.Count == 0)
                {
                    return(fmt);
                }
                else
                {
                    // set table-level properties
                    fmt.TableName       = dt.Rows[0]["table_name"].ToString().ToLower();
                    fmt.AuditsCreated   = dt.Rows[0]["audits_created"].ToString().ToUpper() == "Y";
                    fmt.AuditsModified  = dt.Rows[0]["audits_modified"].ToString().ToUpper() == "Y";
                    fmt.AuditsOwned     = dt.Rows[0]["audits_owned"].ToString().ToUpper() == "Y";
                    fmt.IsReadOnly      = dt.Rows[0]["table_is_readonly"].ToString().ToUpper() == "Y";
                    fmt.TableID         = Toolkit.ToInt32(dt.Rows[0]["sys_table_id"], -1);
                    fmt.UniqueKeyFields = determineAlternateKeyFields(dm, fmt.TableID);


                    string prevFieldName = null;
                    Field  fm            = null;
                    // read field-level properties, add each row as a field mapping
                    foreach (DataRow dr in dt.Rows)
                    {
                        var fieldName = dr["field_name"].ToString();

                        var langID = Toolkit.ToInt32(dr["sys_lang_id"], -1);

                        if (prevFieldName != fieldName)
                        {
                            fm                = new Field();
                            fm.Table          = fmt;
                            fm.TableFieldID   = Toolkit.ToInt32(dr["sys_table_field_id"], -1);
                            fm.TableName      = fmt.TableName;
                            fm.TableFieldName = dr["field_name"].ToString();
                            fm.FieldPurpose   = dr["field_purpose"].ToString();
                            fm.DataTypeString = dr["field_type"].ToString();
                            fm.DataType       = Dataview.ParseDataType(dr["field_type"].ToString());
                            fm.DefaultValue   = (dr["default_value"] == DBNull.Value ? "{DBNull.Value}" : dr["default_value"].ToString());
                            //fm.DefaultValue = (dr["default_value"] == DBNull.Value ? "{DBNull.Value}" : dr["default_value"].ToString());
                            fm.IsPrimaryKey = dr["is_primary_key"].ToString().ToUpper() == "Y";
                            if (fm.IsPrimaryKey)
                            {
                                fmt.PrimaryKeyFieldName = fm.TableFieldName;
                            }

                            if (langID == languageID)
                            {
                                fm.FriendlyFieldName   = dr["friendly_field_name"].ToString();
                                fm.FriendlyDescription = dr["friendly_field_description"].ToString();
                            }

                            fm.IsForeignKey             = dr["is_foreign_key"].ToString().ToUpper() == "Y";
                            fm.ForeignKeyTableName      = dr["foreign_key_table_name"].ToString();
                            fm.ForeignKeyTableFieldName = dr["foreign_key_table_field_name"].ToString();

                            fm.ForeignKeyDataviewName  = dr["foreign_key_dataview_name"].ToString();
                            fm.ForeignKeyDataviewParam = Dataview.DetermineForeignKeyDataviewParams(dm, fm.ForeignKeyDataviewName);

                            fm.IsNullable         = dr["is_nullable"].ToString().ToUpper() == "Y";
                            fm.GuiHint            = dr["gui_hint"].ToString();
                            fm.IsReadOnly         = dr["field_is_readonly"].ToString().ToUpper() == "Y";
                            fm.IsReadOnlyOnInsert = dr["field_is_readonly"].ToString().ToUpper() == "I";
                            fm.IsAutoIncrement    = dr["is_autoincrement"].ToString().ToUpper() == "Y";

                            // readonly is driven by many things. it can be marked as readonly,
                            // it could be marked as autoincrement
                            if (!fm.IsReadOnly && fm.IsAutoIncrement)
                            {
                                fm.IsReadOnly = true;
                            }


                            fm.MinimumLength = Toolkit.ToInt32(dr["min_length"], 0);
                            fm.MaximumLength = Toolkit.ToInt32(dr["max_length"], 0);
                            fm.Precision     = Toolkit.ToInt32(dr["numeric_precision"], 0);
                            fm.Scale         = Toolkit.ToInt32(dr["numeric_scale"], 0);
                            fm.GroupName     = dr["group_name"].ToString();

                            fmt.Mappings.Add(fm);
                            if (fm.IsForeignKey)
                            {
                                fmt.ForeignKeys.Add(fm);
                            }

                            prevFieldName = fieldName;
                        }

                        if (langID > -1)
                        {
                            fm.DataviewFriendlyFieldNames.Add(langID, dr["friendly_field_name"].ToString());
                        }
                    }

                    // get all trigger(s) associated with this table


                    // certain table-level triggers are required for the system to operate properly...
                    addSystemLevelTableDataTriggers(fmt);

                    // and certain table-level triggers are optional and can be configured by the end user...
                    addAdHocTableDataTriggers(fmt, dm);
                }
            }
            cache[cacheKey] = fmt;
            return(fmt);
        }
Esempio n. 15
0
 internal void InsertRecord(IRecord record)
 {
     Dataview.InsertSingleRecord((Record)record);
     UpdateTableChildrenArraysSize();
 }
Esempio n. 16
0
 /// <summary>
 /// update include first/include last according to the Position cache
 /// </summary>
 internal void UpdateIncludes()
 {
     Dataview.SetIncludesFirst(PositionCache.IncludesFirst);
     Dataview.SetIncludesLast(PositionCache.IncludesLast);
 }
Esempio n. 17
0
 /// <summary>
 /// Adds the dcValues object to the data view's DC values collection.
 /// </summary>
 /// <param name="dcValues">Object to be added to the data view.</param>
 internal void AddDcValues(DcValues dcValues, DataControlRangeDataCollection dcValuesRange)
 {
     Dataview.AddDcValues(dcValues);
     DataviewManager.MapDcValues(dcValuesRange, dcValues.getId());
 }
Esempio n. 18
0
 /// <summary>
 /// update db view size
 /// </summary>
 internal void UpdateDBViewSize()
 {
     Dataview.DBViewSize = Dataview.getSize();
 }
Esempio n. 19
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 internal IRecord GetFirstRecord()
 {
     return(Dataview.getRecByIdx(0));
 }
Esempio n. 20
0
 /// <summary>
 /// get modified record
 /// </summary>
 /// <returns></returns>
 internal Record GetModifiedRecord()
 {
     return(Dataview.GetModifiedRecord());
 }
Esempio n. 21
0
 /// <summary>
 /// reset is the first time the d.v is load
 /// </summary>
 internal void ResetFirstDv()
 {
     Dataview.ResetFirstDv();
 }
Esempio n. 22
0
 /// <summary>
 /// return the current record
 /// </summary>
 /// <returns></returns>
 internal IRecord GetCurrentRecord()
 {
     return(Dataview.getCurrRec());
 }
Esempio n. 23
0
 /// <summary>
 /// invalidate dataview
 /// </summary>
 internal void Invalidate()
 {
     Dataview.clear();
     DataviewManager.Reset();
 }
Esempio n. 24
0
 internal void UpdateTopIndex(int topIndex)
 {
     Dataview.setTopRecIdx(topIndex);
 }