Пример #1
0
 public FzAttributeEntity(Boolean primaryKey, String attributeName, FzDataTypeEntity dataType, String description)
 {
     this._primaryKey = primaryKey;
     this._attributeName = attributeName;
     this._dataType = dataType;
     this._description = description;
 }
Пример #2
0
 //Copy Attribute
 public FzAttributeEntity(FzAttributeEntity newAttribute)
 {
     this._primaryKey = newAttribute.PrimaryKey;
     this._attributeName = newAttribute.AttributeName;
     this._dataType = newAttribute.DataType;
     this._description = newAttribute.Description;
 }
Пример #3
0
 public FzAttributeEntity()
 {
     this._primaryKey = false;
     this._attributeName = String.Empty;
     this._dataType = new FzDataTypeEntity();
     this._description = String.Empty;
 }
Пример #4
0
        public static Boolean CheckDataType(Object value, FzDataTypeEntity dataType)
        {
            try
            {
                switch (dataType.DataType)
                {
                    case "Int16": Int16 a = 0; return (Int16.TryParse(value.ToString(), out a));
                    case "Int32": Int32 b = 0; return (Int32.TryParse(value.ToString(), out b));
                    case "Int64": Int64 c = 0; return (Int64.TryParse(value.ToString(), out c));
                    case "Byte": Byte d = 0; return (Byte.TryParse(value.ToString(), out d));
                    case "String": return true;
                    case "DateTime": return true;//DateTime e = DateTime.Today; return (DateTime.TryParse(value.ToString(), out e));
                    case "Decimal": Decimal f = 0; return (Decimal.TryParse(value.ToString(), out f));
                    case "Single": Single g = 0; return (Single.TryParse(value.ToString(), out g));
                    case "Double": Double h = 0; return (Double.TryParse(value.ToString(), out h));
                    case "Boolean":
                        if (value.ToString().ToLower() == "true" || value.ToString().ToLower() == "false") return true;
                        else return false;//Boolean k = true; return (Boolean.TryParse(value.ToString(), out k));
                    case "Binary": return (IsBinaryType(value));
                    case "Currency": return (IsCurrencyType(value));
                    case "UserDefined": return (dataType.DomainValues.Contains(value.ToString()));
                }
            }
            catch (Exception ex)
            {
                return false;
            }

            return false;
        }
Пример #5
0
        public bool OpenFuzzyDatabase(FdbEntity fdb)
        {
            try
            {
                SqliteConnection connection = new SqliteConnection(fdb.ConnString);
                DataSet ds = new DataSet();

                ds.Tables.Add(connection.GetDataTable("SELECT * FROM SystemScheme", "system_scheme"));//Table [0]
                ds.Tables.Add(connection.GetDataTable("SELECT * FROM SystemRelation", "system_relation"));//Table [1]
                ds.Tables.Add(connection.GetDataTable("SELECT * FROM SystemAttribute", "system_attribute"));//Table [2]
                ds.Tables.Add(connection.GetDataTable("SELECT * FROM SystemQuery", "system_query"));//Table [3]

                ///Load Schemes////////////////////////////////////////////////////////////////////////////////////////
                foreach (DataRow row in ds.Tables["system_scheme"].Rows)
                {
                    String schemeName = row[1].ToString();
                    FzSchemeEntity tmpScheme = new FzSchemeEntity(schemeName);
                    DataTable tmpDt = new DataTable();
                    tmpDt = connection.GetDataTable("SELECT * FROM SystemAttribute Where SchemeID=" + Convert.ToInt16(row[0]));

                    if (tmpDt != null)
                    {
                        foreach (DataRow item in tmpDt.Rows)
                        {
                            Boolean primaryKey = Convert.ToBoolean(item[1]);
                            String attributeName = Convert.ToString(item[2]);
                            String typeName = Convert.ToString(item[3]);
                            String domain = Convert.ToString(item[4]);
                            String description = Convert.ToString(item[5]);

                            FzDataTypeEntity tmpDataType = new FzDataTypeEntity(typeName, domain);
                            FzAttributeEntity tmpAttribute = new FzAttributeEntity(primaryKey, attributeName, tmpDataType, description);

                            tmpScheme.Attributes.Add(tmpAttribute);
                        }

                        fdb.Schemes.Add(tmpScheme);
                    }
                }

                ///Load Relations//////////////////////////////////////////////////////////////////////////////////////////
                foreach (DataRow row in ds.Tables["system_relation"].Rows)
                {
                    String relationName = row[1].ToString();
                    int schemeID = Convert.ToInt16(row[2]);//To get scheme is referenced
                    String schemeName = connection.GetValueField("SELECT SchemeName FROM SystemScheme WHERE ID=" + schemeID).ToString();
                    DataTable tmpDt = new DataTable();
                    tmpDt = connection.GetDataTable("SELECT * FROM " + relationName);

                    FzRelationEntity tmpRelation = new FzRelationEntity(relationName);//Relation only content relation name, but scheme referenced and list tuples is null
                    tmpRelation.Scheme = FzSchemeDAL.GetSchemeByName(schemeName, fdb);//Assign scheme referenced to relation, but tuples is null

                    int nColumns = tmpRelation.Scheme.Attributes.Count;//Get number columns of per row

                    if (tmpDt != null)//
                    {
                        foreach (DataRow tupleRow in tmpDt.Rows)
                        {
                            List<Object> objs = new List<object>();

                            for (int i = 0; i < nColumns; i++)//Add values on per row from tupleRow[i]
                            {
                                //values += tupleRow[i].ToString();
                                objs.Add(tupleRow[i]);
                            }

                            FzTupleEntity tmpTuple = new FzTupleEntity() { ValuesOnPerRow = objs };
                            tmpRelation.Tuples.Add(tmpTuple);
                        }
                    }

                    fdb.Relations.Add(tmpRelation);
                }

                ///Load Queries////////////////////////////////////////////////////////////////////////////////////////////
                foreach (DataRow row in ds.Tables["system_query"].Rows)
                {
                    FzQueryEntity tmpQuery = new FzQueryEntity(row[1].ToString(), row[2].ToString());
                    fdb.Queries.Add(tmpQuery);
                }

                return true;
            }
            catch (SQLiteException ex)
            {
                throw new Exception("ERROR:\n" + ex.Message);
                //return false;
            }
        }
Пример #6
0
 public static Boolean CheckDataType(Object value, FzDataTypeEntity dataType)
 {
     return FzDataTypeDAL.CheckDataType(value, dataType);
 }
Пример #7
0
        ///mean also save its attributes
        private void SaveCurrentScheme(String schemeName)
        {
            if (FzSchemeBLL.IsInherited(currentScheme, fdbEntity.Relations))//Or check the readOnly on GridView
            {
                MessageBox.Show("Current Scheme is opened and \ninherited by some relations!");
                return;
            }

            xtraTabDatabase.TabPages[0].Text = "Scheme " + schemeName;
            xtraTabDatabase.SelectedTabPage = xtraTabDatabase.TabPages[0]; ;
            currentScheme.Attributes.Clear();
            GridViewDesign.CurrentCell = GridViewDesign.Rows[GridViewDesign.Rows.Count - 1].Cells[0];

            for (int i = 0; i < GridViewDesign.Rows.Count - 1; i++)// The end row is new row
            {
                Boolean primaryKey = Convert.ToBoolean(GridViewDesign.Rows[i].Cells[0].Value);
                String attributeName = GridViewDesign.Rows[i].Cells[1].Value.ToString();
                String typeName = GridViewDesign.Rows[i].Cells[2].Value.ToString();
                String description = (GridViewDesign.Rows[i].Cells[4].Value == null ? "" : GridViewDesign.Rows[i].Cells[4].Value.ToString());
                String domain = (GridViewDesign.Rows[i].Cells[3].Value.ToString());

                FzDataTypeEntity dataType = new FzDataTypeEntity(typeName, domain);
                FzAttributeEntity attribute = new FzAttributeEntity(primaryKey, attributeName, dataType, description);

                currentScheme.Attributes.Add(attribute);
            }

            if (GridViewDesign.Rows[GridViewDesign.Rows.Count - 2].Cells[1].Value.ToString() != "µ")
                AddMembership();

            MessageBox.Show("Current Scheme is saved OK!");
        }
Пример #8
0
        private void AddMembership()
        {
            MessageBox.Show("The default membership attribute \nwill be added automatically to this scheme", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Boolean primaryKey = false;
            String attributeName = "µ";
            String typeName = "Double";
            String description = "";
            String domain = "[5.0 x 10^-324  ...  1.7 x 10^308]";

            FzDataTypeEntity dataType = new FzDataTypeEntity(typeName, domain);
            FzAttributeEntity attribute = new FzAttributeEntity(primaryKey, attributeName, dataType, description);
            currentScheme.Attributes.Add(attribute);
        }