Example #1
0
        private string GetValue(ReferenceEntity.UseField column, DataRow r)
        {
            string val = r[GetAlias(column)].ToString();

            if (string.IsNullOrEmpty(column.NODecPlaces))
            {
                return(val);
            }
            decimal dv;

            if (!decimal.TryParse(val, System.Globalization.NumberStyles.Any, null, out dv))
            {
                return(val);
            }
            string NODecPlacesString = r[GetAlias(column.NODecPlaces)].ToString();

            if (string.IsNullOrEmpty(NODecPlacesString))
            {
                return(val);
            }
            int NODecPlacesInt;

            if (!int.TryParse(NODecPlacesString, out NODecPlacesInt))
            {
                return(val);
            }
            val = dv.ToString("F" + NODecPlacesInt);
            return(val);
        }
Example #2
0
        string GetAlias(ReferenceEntity.UseField column)
        {
            string a = column.Entity.Alias + "_" + column.SqlName;

            if (a == "v_Date")
            {
                a = "pd_ShortName";
            }
            return(a);
        }
Example #3
0
        string GetSel(ReferenceEntity.UseField column)
        {
            string sel = column.Entity.Alias + "." + column.SqlName;

            if (sel == "v.Date")
            {
                sel = "pd.ShortName";
            }
            return(sel);
        }
Example #4
0
        bool ProcessGroup(ReferenceEntity.UseField g, int i, DataRow r, List <string> OldMasterGroup, out string GroupValue, out string GroupHeader)
        {
            string alias = GetAlias(g);

            GroupValue  = r[alias].ToString();
            GroupHeader = g.Entity.ReadableName;
            if (g.ReadableName != "Name")
            {
                GroupHeader += " " + g.ReadableName;
            }
            bool IsNewGroup = OldMasterGroup[i] != GroupValue;

            OldMasterGroup[i] = GroupValue;
            return(IsNewGroup);
        }
Example #5
0
        public static DataViewConfig Get(Guid DataViewTypeID)
        {
            if (DataViewConfigTypes == null)
            {
                DataViewConfigTypes = new Dictionary <Guid, DataViewConfig>();
            }
            if (DataViewConfigTypes.Keys.Contains(DataViewTypeID))
            {
                return(DataViewConfigTypes[DataViewTypeID]);
            }

            string p = System.Web.HttpContext.Current.Request.PhysicalApplicationPath;

            p = p + "Micajah.Common.config";
            DataSet ds = new System.Data.DataSet();

            ds.ReadXml(p);

            DataTable DataViewTable = ds.Tables["DataView"];

            DataRow [] rr = DataViewTable.Select("DataViewTypeID='" + DataViewTypeID + "'");
            if (rr == null || rr.Length < 1)
            {
                return(null);
            }

            string Name         = (string)rr[0]["Name"];
            Guid   BaseEntityID = new Guid((string)rr[0]["BaseEntityID"]);
            int    DataView_Id  = (int)rr[0]["DataView_Id"];

            DataTable ReferenceEntitiesTable = ds.Tables["ReferenceEntities"];

            rr = ReferenceEntitiesTable.Select("DataView_Id=" + DataView_Id);
            if (rr == null || rr.Length < 1)
            {
                return(null);
            }
            int ReferenceEntities_Id = (int)rr[0]["ReferenceEntities_Id"];

            DataTable ReferenceEntityTable = ds.Tables["ReferenceEntity"];

            rr = ReferenceEntityTable.Select("ReferenceEntities_Id=" + ReferenceEntities_Id);
            if (rr == null || rr.Length < 1)
            {
                return(null);
            }

            List <ReferenceEntity> rel = new List <ReferenceEntity>();

            foreach (DataRow r in rr)
            {
                ReferenceEntity re = new ReferenceEntity();
                re.EntityID       = new Guid((string)r["EntityID"]);
                re.OneToMany      = ReferenceEntityTable.Columns.Contains("ReferenceType") && (r["ReferenceType"] is string) && (string)r["ReferenceType"] == "OneToMany";
                re.ReferenceTable = ReferenceEntityTable.Columns.Contains("ReferenceTable") && (r["ReferenceTable"] is string)?(string)r["ReferenceTable"]:null;
                re.Alias          = r["Alias"] as string;

                DataRow[] RR = ds.Tables["entity"].Select("id='" + re.EntityID + "'");
                if (RR == null || RR.Length < 1)
                {
                    return(null);
                }
                DataRow EntityRow = RR[0];
                re.ReadableName = (string)EntityRow["name"];
                re.SqlName      = (string)EntityRow["tableName"];
                //re.SqlNameFieldName = (string)EntityRow[];

                int entity_Id = (int)EntityRow["entity_Id"];
                RR = ds.Tables["fields"].Select("entity_Id=" + entity_Id);
                if (RR == null || RR.Length < 1)
                {
                    return(null);
                }
                int fields_Id = (int)RR[0]["fields_Id"];


                int ReferenceEntity_Id = (int)r["ReferenceEntity_Id"];
                RR = ds.Tables["UseField"].Select("ReferenceEntity_Id=" + ReferenceEntity_Id);
                if (RR == null || RR.Length < 1)
                {
                    return(null);
                }
                bool SelectControlExist = ds.Tables["UseField"].Columns.Contains("SelectControl");

                re.UseFieldList = new List <ReferenceEntity.UseField>();
                DataRow[] FieldsRows;
                FieldsRows = ds.Tables["field"].Select("fields_Id=" + fields_Id + " AND name='Name'");
                if (FieldsRows != null && FieldsRows.Length > 0)
                {
                    re.SqlNameFieldName = FieldsRows[0]["columnName"].ToString();
                }

                foreach (DataRow R in RR)
                {
                    ReferenceEntity.UseField uf = new ReferenceEntity.UseField();
                    uf.Entity       = re;
                    uf.ReadableName = (string)R["Name"];
                    FieldsRows      = ds.Tables["field"].Select("fields_Id=" + fields_Id + " AND name='" + uf.ReadableName + "'");
                    if (FieldsRows == null || FieldsRows.Length < 1)
                    {
                        return(null);
                    }
                    uf.SqlName        = (string)FieldsRows[0]["columnName"];
                    uf.FullColumnName = re.SqlName + "." + uf.SqlName;
                    if (R.Table.Columns.Contains("NODecPlaces") && R["NODecPlaces"] is string)
                    {
                        uf.NODecPlaces = (string)R["NODecPlaces"];
                    }
                    if (SelectControlExist)
                    {
                        uf.SelectControl = R["SelectControl"] as string;
                    }
                    re.UseFieldList.Add(uf);
                }

                rel.Add(re);
            }

            DataViewConfig ret = new DataViewConfig(Name, BaseEntityID, DataViewTypeID);

            ret.ReferenceEntityList = rel;

            DataViewConfigTypes[DataViewTypeID] = ret;
            return(ret);
        }