Example #1
0
        protected override void AfterChange(DataColumn dc, DataRow dr)
        {
            appDB.ddTableRow dtr = (appDB.ddTableRow)dr;
            switch (dc.ColumnName)
            {
            case "isDynamic":
                if (dtr.isDynamic)
                {
                    dtr.DBTableName = "ddEntity";
                    dtr.tblType     = "atriumDB";
                }
                else
                {
                    dtr.DBTableName = dtr.TableName;
                }
                dtr.EndEdit();
                break;

            case "TableName":
                if (!dtr.isDynamic)
                {
                    dtr.DBTableName = dtr.TableName;
                }
                break;
            }
        }
Example #2
0
        public void DynBeforeUpdate(BEManager be, DataRow dr, appDB.ddTableRow ruleDefinition, Dictionary <string, appDB.ddFieldRow> ruleColumnMap)
        {
            if (ruleDefinition == null)
            {
                return;
            }

            FileManager fm = GetFMFromBE(be);

            foreach (appDB.ddRuleRow ddr in ruleDefinition.GetddRuleRows())
            {
                //for "beforeupdate" event
                if (ddr.EventId == 2 && ddr.Enabled)
                {
                    //check rules
                    RunRule(null, dr, null, fm, null, ddr);
                }
                if (ddr.EventId == 10 && ddr.Enabled)
                {
                    //check rules
                    //needs to run for column
                    //need columnmap
                    DataColumn       dc  = dr.Table.Columns[ddr.ddFieldRow.DBFieldName];
                    appDB.ddFieldRow dfr = ruleColumnMap[dc.ColumnName];
                    RunRule(dc, dr, ruleColumnMap, fm, dfr, ddr);
                }
                if (ddr.EventId == 5 && ddr.Enabled && dr.RowState == DataRowState.Added)
                {
                    //check rules
                    RunRule(null, dr, null, fm, null, ddr);
                }
            }
        }
Example #3
0
        public void DynAfterDelete(BEManager be, DataRow dr, appDB.ddTableRow ruleDefinition)
        {
            if (ruleDefinition == null)
            {
                return;
            }

            //never used as the record is effectively gone
        }
Example #4
0
        public void DynBeforeAdd(BEManager be, DataRow dr, appDB.ddTableRow ruleDefinition)
        {
            if (ruleDefinition == null)
            {
                return;
            }

            //rarely or never used
        }
Example #5
0
 public void DynDefaultValues(FileManager fm, DataRow dr, appDB.ddTableRow myDefinition)
 {
     //check for defined fields that have a systemdefault value
     foreach (appDB.ddFieldRow dfr in myDefinition.GetddFieldRows())
     {
         if (!dfr.IsDefaultSystemValueNull())
         {
             dr[dfr.DBFieldName] = fm.GetDefaultValue(dfr.DefaultSystemValue);
         }
     }
 }
Example #6
0
        protected override void AfterAdd(DataRow dr)
        {
            appDB.ddTableRow dtr        = (appDB.ddTableRow)dr;
            string           ObjectName = this.myddTableDT.TableName;

            dtr.TableId              = this.myA.PKIDGet(ObjectName, 1);
            dtr.TableName            = "New Table";
            dtr.isLookup             = false;
            dtr.isDBTable            = false;
            dtr.AllowInRelatedFields = true;
            dtr.isDynamic            = false;
            dtr.ShowInTOC            = false;
        }
Example #7
0
        public void LoadACS(string form)
        {
            int acsid = System.Convert.ToInt32(form.Replace("acs-", ""));

            Atmng      = FM.AtMng;
            myACSeries = Atmng.acMng.DB.ACSeries.FindByACSeriesId(acsid);

            appDB.ddTableRow[] dtrs = (appDB.ddTableRow[])Atmng.DB.ddTable.Select("DefaultFormID=" + acsid.ToString());

            myPrimaryTable     = dtrs[0];
            secReadOnly        = Atmng.SecurityManager.CanUpdate(FM.CurrentFileId, MyFeatureID()) == atSecurity.SecurityManager.LevelPermissions.No;
            tsScreenTitle.Text = myACSeries["Desc" + Atmng.AppMan.Language].ToString();


            Init(myACSeries);

            FileTreeView.BuildMenu(FM, tsActions, myACSeries.StepCode);
        }
Example #8
0
        public void DynBeforeDelete(BEManager be, DataRow dr, appDB.ddTableRow ruleDefinition)
        {
            if (ruleDefinition == null)
            {
                return;
            }

            FileManager fm = GetFMFromBE(be);

            //find rules for field
            foreach (appDB.ddRuleRow ddr in ruleDefinition.GetddRuleRows())
            {
                //for "beforedelete" event
                if (ddr.EventId == 3 && ddr.Enabled)
                {
                    //check rules
                    RunRule(null, dr, null, fm, null, ddr);
                }
            }
        }
Example #9
0
        public void DynAfterUpdate(BEManager be, DataRow dr, appDB.ddTableRow ruleDefinition)
        {
            if (ruleDefinition == null)
            {
                return;
            }

            //rarely used except for toc  xml which is obsolete
            FileManager fm = GetFMFromBE(be);

            //find rules for field
            foreach (appDB.ddRuleRow ddr in ruleDefinition.GetddRuleRows())
            {
                //for "afterupdate" event
                if (ddr.EventId == 8 && ddr.Enabled)
                {
                    //check rules
                    RunRule(null, dr, null, fm, null, ddr);
                }
            }
        }
Example #10
0
        public string CreateSQLView(appDB.ddTableRow dtr)
        {
            string sql = "DROP VIEW dbo.vdde" + dtr.TableName + Environment.NewLine;

            sql += "CREATE VIEW dbo.vdde" + dtr.TableName + Environment.NewLine + "AS SELECT " + Environment.NewLine;

            foreach (appDB.ddFieldRow dfr in dtr.GetddFieldRows())
            {
                if (dfr.AllowInRelatedFields)
                {
                    sql += dfr.DBFieldName + " AS " + dfr.FieldName + ", " + Environment.NewLine;
                }
            }
            sql += "entryUser,entryDate,updateUser,updateDate " + Environment.NewLine;
            sql += "FROM dbo.[ddEntity] " + Environment.NewLine;
            sql += "WHERE tableid=" + dtr.TableId.ToString() + Environment.NewLine;
            sql += "GO" + Environment.NewLine;
            sql += "GRANT SELECT ON dbo.vdde" + dtr.TableName + " TO LAWMATEINTERNAL";

            return(sql);
        }
Example #11
0
        public void DynAfterAdd(BEManager be, DataRow dr, appDB.ddTableRow ruleDefinition)
        {
            if (ruleDefinition == null)
            {
                return;
            }

            FileManager fm = GetFMFromBE(be);

            //set defaults
            myA.GetddField().DynDefaultValues(fm, dr, ruleDefinition);

            foreach (appDB.ddRuleRow ddr in ruleDefinition.GetddRuleRows())
            {
                //for "beforeupdate" event
                if (ddr.EventId == 4 && ddr.Enabled)
                {
                    //check rules
                    RunRule(null, dr, null, fm, null, ddr);
                }
            }
        }
Example #12
0
        public void Populate(appDB.ddTableRow drTable)
        {
            DataTable dtTyped = null;

            try
            {
                atLogic.BEManager mngr = myA.GetFile(0).GetBEMngrForTable(drTable.DBTableName);
                dtTyped = mngr.MyDS.Tables[drTable.DBTableName];
            }
            catch (Exception x)
            {
                //ignore
            }

            DataTable dtViews = myA.GetGeneralRec("select * from information_schema.columns where table_schema='dbo' and table_name='v" + drTable.DBTableName + "' ");
            DataTable dtTable = myA.GetGeneralRec("select * from information_schema.columns where table_schema='dbo' and table_name='" + drTable.DBTableName + "' ");

            if (dtTable.Rows.Count == 0)
            {
                drTable.isDBTable = false;
            }
            else
            {
                drTable.isDBTable = true;
            }

            if (dtTyped != null)
            {
                foreach (DataColumn dc in dtTyped.Columns)
                {
                    appDB.ddFieldRow drField;
                    if (myA.DB.ddField.Select("Tableid=" + drTable.TableId.ToString() + " and DBFieldName='" + dc.ColumnName + "'").Length == 0)
                    {
                        drField             = (appDB.ddFieldRow)Add(drTable);
                        drField.FieldName   = dc.ColumnName;
                        drField.DBFieldName = dc.ColumnName;
                        if (drTable.isDynamic)
                        {
                            drField.AllowInRelatedFields = false;
                        }
                    }
                    else
                    {
                        drField = (appDB.ddFieldRow)myA.DB.ddField.Select("Tableid=" + drTable.TableId.ToString() + " and DBFieldName='" + dc.ColumnName + "'")[0];
                    }
                    drField.isMissing = true;
                    drField.DataType  = dc.DataType.Name;

                    if (drField.IsLeftEngNull())
                    {
                        drField.LeftEng = SplitCamelCase(drField.FieldName);
                        drField.LeftFre = SplitCamelCase(drField.FieldName);
                    }

                    if (dtViews.Select("Column_name='" + dc.ColumnName + "'", "").Length == 0)
                    {
                        drField.isVirtualColumn = true;
                    }
                    else
                    {
                        drField.isMissing       = false;
                        drField.isVirtualColumn = false;
                    }

                    if (!drField.isVirtualColumn && dtTable.Select("Column_name='" + dc.ColumnName + "'", "").Length == 0)
                    {
                        drField.isFromView = true;
                    }
                    else
                    {
                        drField.isMissing  = false;
                        drField.isFromView = false;
                    }
                }

                //check for "obsolete" columns
                foreach (appDB.ddFieldRow drf in drTable.GetddFieldRows())
                {
                    if (!dtTyped.Columns.Contains(drf.DBFieldName))
                    {
                        drf.AllowInRelatedFields = false;
                        drf.DescEng = "OBSOLETE";
                    }
                }
            }
            else
            {
                foreach (DataRow dr in dtViews.Rows)
                {
                    if (myA.DB.ddField.Select("Tableid=" + drTable.TableId.ToString() + " and DBFieldName='" + dr["Column_name"].ToString() + "'").Length == 0)
                    {
                        appDB.ddFieldRow drField = (appDB.ddFieldRow)Add(drTable);
                        drField.FieldName = dr["Column_name"].ToString();

                        if (dtTable.Select("Column_name='" + drField.FieldName + "'", "").Length == 0)
                        {
                            drField.isFromView = true;
                            drField.isMissing  = false;
                        }
                    }
                }
            }
        }