Exemplo n.º 1
0
 private void CTMenuQuery_DeleteQueries_Click(object sender, EventArgs e)
 {
     try
     {
         fdbEntity.Queries.Clear();
         ShowTreeList();
         ShowTreeListNode();
         treeList1.ExpandAll();
         currentQuery = null;
         CloseCurrentQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 2
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;
            }
        }
Exemplo n.º 3
0
        private void treeList1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            childCurrentNode = e.Node;
            String name = childCurrentNode.Name;

            if (childCurrentNode.Parent == childRelationNode)
            {
                currentRelation = FzRelationBLL.GetRelationByName(name, fdbEntity);
                ShowColumnsAttribute(currentRelation);
                ShowTuples(currentRelation);
            }
            if (childCurrentNode.Parent == childSchemeNode)
            {
                currentScheme = FzSchemeBLL.GetSchemeByName(name, fdbEntity);
                OpenScheme(currentScheme);
            }
            if (childCurrentNode.Parent == childQueryNode)
            {
                currentQuery = FzQueryBLL.GetQueryByName(name, fdbEntity);
                OpenQuery(name);
                txtQuery.Focus();
            }
        }
Exemplo n.º 4
0
        private void SaveQuery()
        {
            try
            {
                if (txtQuery.Text != "")
                {
                    String queryName = xtraTabDatabase.TabPages[2].Text.Substring(5);
                    String queryText = txtQuery.Text;

                    frmQueryEditor frm = new frmQueryEditor(fdbEntity.Queries) { TxtQueryName = queryName, TxtQueryText = queryText };
                    frm.ShowDialog();

                    //After form close
                    fdbEntity.Queries = frm.Queries;
                    DBValues.queriesName = FzQueryBLL.ListOfQueryName(fdbEntity);
                    ShowTreeList();
                    ShowTreeListNode();
                    treeList1.ExpandAll();

                    currentQuery = null;
                    OpenQuery(frm.QueryName);
                }
                else
                {
                    xtraTabDatabase.SelectedTabPageIndex = 2;
                    txtQuery.Focus();
                    MessageBox.Show("Please input some text to save!");
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
        private void OpenQuery(String queryName)
        {
            if (queryName != null)
            {
                currentQuery = FzQueryBLL.GetQueryByName(queryName, fdbEntity);

                xtraTabDatabase.TabPages[2].Text = "Query " + queryName;
                xtraTabDatabase.SelectedTabPage = xtraTabDatabase.TabPages[2];
                txtQuery.Text = currentQuery.QueryString;
            }
        }
Exemplo n.º 6
0
 private void iDeleteQuery_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     currentQuery = null;
     QueryEditor();
     //CloseCurrentQuery();
 }
Exemplo n.º 7
0
        /// <summary>
        /// Delete tree node on treeList and also delete Object in db
        /// </summary>
        private void DeleteTreeNode(String deleteNodeName, FzSchemeEntity schemeEntity, FzRelationEntity relationEntity, FzQueryEntity queryEntity)
        {
            if (schemeEntity != null)
            {
                TreeNode deletedNode = childSchemeNode.Nodes[deleteNodeName];
                deletedNode.Remove();
                fdbEntity.Schemes.Remove(schemeEntity);
                schemeEntity = null;

                if (childSchemeNode.Nodes.Count == 0)
                {
                    childSchemeNode.ImageIndex = childSchemeNode.SelectedImageIndex = 2;
                }
            }

            if (relationEntity != null)
            {
                TreeNode deletedNode = childRelationNode.Nodes[deleteNodeName];
                deletedNode.Remove();
                fdbEntity.Relations.Remove(relationEntity);
                relationEntity = null;

                if (childRelationNode.Nodes.Count == 0)
                {
                    childRelationNode.ImageIndex = childRelationNode.SelectedImageIndex = 2;
                }
            }

            if (queryEntity != null)
            {
                TreeNode deletedNode = childQueryNode.Nodes[deleteNodeName];
                deletedNode.Remove();
                fdbEntity.Queries.Remove(queryEntity);
                queryEntity = null;

                if (childQueryNode.Nodes.Count == 0)
                {
                    childQueryNode.ImageIndex = childQueryNode.SelectedImageIndex = 2;//folder close
                }
            }
        }