private void deleteBtn_Click(object sender, EventArgs e)
        {
            if (projectList.SelectedItem == null)
            {
                MessageBox.Show("Select a project in Project List.");
                return;
            }
            AccessSqlite sql    = new AccessSqlite();
            int          result = sql.deleteTable(projectList.SelectedItem.ToString());

            if (result == 0)
            {
                if (projectName != null && projectList.SelectedItem.ToString() == projectName)
                {
                    projectName      = null;
                    curProjText.Text = null;
                    ManageFile mf = new ManageFile();
                    mf.setCurrentProject("check.txt", null);
                }
                resetList();
                MessageBox.Show("Succeed in deleting the project.");
            }
            else
            {
                MessageBox.Show("Deleting the table failed.");
            }
        }
        private void resetList()
        {
            projectList.Items.Clear();
            AccessSqlite sql = new AccessSqlite();

            string[] rows = sql.getRows("sqlite_master", "name", "type = 'table'");
            if (rows == null)
            {
                return;
            }
            int i = 0;

            while (rows.Length > i)
            {
                projectList.Items.Add(rows[i]);
                i++;
            }
        }
Beispiel #3
0
        private void renewTreeView()
        {
            treeView.Nodes.Clear();
            AccessSqlite sql = new AccessSqlite();
            int          point;

            string[] rows = sql.getRows(project, "class", "name = '" + path + "'");
            int      i    = 0;

            try
            {
                if (rows == null || rows[0] == "")
                {
                    return;
                }
                while (rows.Length > i)
                {
                    treeView.Nodes.Add(rows[i]);
                    treeView.Nodes[i].BackColor = Color.DarkViolet;
                    treeView.Nodes[i].ForeColor = Color.White;
                    string[] row = sql.getRows(project, "field", "name = '" + path + "' and class = '" + rows[i] + "'");
                    if (row != null && row[0] != "" && row[0] != null)
                    {
                        point = row[0].IndexOf(",");
                        while (point != -1)
                        {
                            string temp   = row[0].Substring(0, point);
                            int    point2 = temp.IndexOf("-");
                            temp = temp.Substring(0, point2) + "(" + temp.Substring(point2 + 1) + ")";
                            treeView.Nodes[i].Nodes.Add(temp);
                            row[0] = row[0].Substring(point + 1);
                            point  = row[0].IndexOf(",");
                        }
                    }
                    i++;
                }
            }
            catch (Exception e)
            {
            }
        }
Beispiel #4
0
        private void setDirectory()
        {
            AccessSqlite sql = new AccessSqlite();
            ManageFile   mf  = new ManageFile();

            string[] rows = sql.getRows(projectName, "name", null);
            int      i    = 0;

            try
            {
                while (rows.Length > i)
                {
                    string row = rows[i].Replace(".", @"\");
                    mf.createDirectory(projectName + @"\" + row);
                    i++;
                }
            }
            catch (Exception e)
            {
            }
        }
Beispiel #5
0
        private void renewTreeView()
        {
            treeView.Nodes.Clear();
            AccessSqlite sql = new AccessSqlite();

            string[] rows = sql.getRows(project, "name", null);
            int      i    = 0;

            if (rows == null)
            {
                return;
            }
            while (rows.Length > i)
            {
                if (nodeList == null)
                {
                    nodeList = new Node(rows[i]);
                }
                else
                {
                    addNode(rows[i]);
                }
                int point = rows[i].LastIndexOf(".");
                while (point != -1)
                {
                    rows[i] = rows[i].Substring(0, point);
                    addNode(rows[i]);
                    point = rows[i].LastIndexOf(".");
                }
                i++;
            }

            tempNode = nodeList;
            while (tempNode != null)
            {
                string pPath = tempNode.getPath();
                int    point = pPath.LastIndexOf(".");
                if (point != -1)
                {
                    pPath = pPath.Substring(0, point);
                }
                else
                {
                    pPath = "";
                }
                Node tempNode2 = nodeList;
                while (tempNode2 != null)
                {
                    if (string.Compare(tempNode2.getPath(), pPath) == 0)
                    {
                        tempNode2.getNode().Nodes.Add(tempNode.getNode());
                        break;
                    }
                    tempNode2 = tempNode2.getNext();
                }
                tempNode = tempNode.getNext();
            }

            tempNode = nodeList;
            while (tempNode != null)
            {
                if (string.Compare(tempNode.getNode().Text, tempNode.getPath()) == 0)
                {
                    treeView.Nodes.Add(tempNode.getNode());
                }
                tempNode = tempNode.getNext();
            }
        }
Beispiel #6
0
        private void setClassFile()
        {
            AccessSqlite sql = new AccessSqlite();
            ManageFile   mf  = new ManageFile();
            string       path;
            int          point;

            string[] rows = sql.getRowsDistinct(projectName, "name", null);
            int      i    = 0;
            int      j    = 0;

            try
            {
                while (rows.Length > i)
                {
                    path = rows[i].Replace(".", @"\");
                    string[] crows = sql.getRows(projectName, "class", "name = '" + rows[i] + "'");
                    j = 0;
                    try
                    {
                        while (crows.Length > j)
                        {
                            if (crows[j] == "")
                            {
                                j++;
                                continue;
                            }
                            if (mf.checkFile(path, crows[j]))
                            {
                                // field check
                                j++;
                                continue;
                            }
                            string curDir;
                            point = rows[i].LastIndexOf(".");
                            if (point != -1)
                            {
                                curDir = rows[i].Substring(point + 1);
                            }
                            else
                            {
                                curDir = rows[i];
                            }
                            int result = mf.createFile(projectName + @"\" + path, curDir, crows[j]);
                            if (result == 0)
                            {
                                try
                                {
                                    string[] frow = sql.getRows(projectName, "field", "name = '" + rows[i] + "' and class = '" + crows[j] + "'");
                                    if (frow[0] == "")
                                    {
                                        j++;
                                        continue;
                                    }
                                    mf.createField(projectName + @"\" + path, curDir, crows[j], frow[0]);
                                }
                                catch (Exception e)
                                {
                                }
                            }
                            j++;
                        }
                    }
                    catch (Exception e)
                    {
                    }
                    i++;
                }
            }
            catch (Exception e)
            {
            }
        }
Beispiel #7
0
        private void doBtn_Click(object sender, EventArgs e)
        {
            AccessSqlite sql    = new AccessSqlite();
            ManageFile   mf     = new ManageFile();
            int          result = -2;
            string       path;

            if (categoryCombo.SelectedItem == null)
            {
                MessageBox.Show("Select a Category for this work.");
                return;
            }
            else if (workAtText.Text == "")
            {
                string msg = "";
                if (categoryCombo.SelectedItem.ToString() == "Class")
                {
                    msg = "Click a Namespace in View for this work.";
                }
                else if (categoryCombo.SelectedItem.ToString() == "Field")
                {
                    msg = "Click a Class in View for this work.";
                }
                MessageBox.Show(msg);
                return;
            }
            else if (nameText.Text == "")
            {
                MessageBox.Show("Input a name in Name Textbox for this work.");
                return;
            }
            else if (CheckCharacter.checkNamespace(nameText.Text) != 0)
            {
                return;
            }
            else if (workCombo.SelectedItem == null)
            {
                MessageBox.Show("Select a work in Work Combo box for this work.");
                return;
            }
            else if (categoryCombo.SelectedItem.ToString() == "Namespace" && workCombo.SelectedItem.ToString() == "Create")
            {
                result = sql.insertNamespace(projectName, nameText.Text);
                if (result == 0)
                {
                    namespaceTree = new SetNamespaceTreeView(namespaceTreeView, fileName, projectName);
                    namespaceTree.expandNode(nameText.Text);
                    path = nameText.Text.Replace(".", @"\");
                    mf.createDirectory(projectName + @"\" + path);
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Namespace is duplicated.");
                    return;
                }
                else
                {
                    MessageBox.Show("Creating new Namespace failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Class" && workCombo.SelectedItem.ToString() == "Create")
            {
                result = sql.insertClass(projectName, namespaceTree.getPath(), nameText.Text);
                if (result == 0)
                {
                    path = namespaceTree.getPath().Replace(".", @"\");
                    int    point = namespaceTree.getPath().LastIndexOf(".");
                    string curDir;
                    if (point != -1)
                    {
                        curDir = namespaceTree.getPath().Substring(point + 1);
                    }
                    else
                    {
                        curDir = namespaceTree.getPath();
                    }
                    mf.createFile(projectName + @"\" + path, curDir, nameText.Text);
                    classTree = new SetClassTreeView(classTreeView, fileName, projectName, namespaceTree.getPath());
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Class is duplicated.");
                    return;
                }
                else
                {
                    MessageBox.Show("Creating new Class failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Field" && workCombo.SelectedItem.ToString() == "Create")
            {
                if (classTree.getClassName() != null)
                {
                    lastClassName = classTree.getClassName();
                }
                string type = null;
                if (typeCombo.SelectedItem == null)
                {
                    MessageBox.Show("Select a field type for this work.");
                    return;
                }
                else
                {
                    type = typeCombo.SelectedItem.ToString();
                }
                result = sql.insertField(projectName, namespaceTree.getPath(), lastClassName, nameText.Text, type);
                if (result == 0)
                {
                    path = namespaceTree.getPath().Replace(".", @"\");
                    int    point = namespaceTree.getPath().LastIndexOf(".");
                    string curDir;
                    if (point != -1)
                    {
                        curDir = namespaceTree.getPath().Substring(point + 1);
                    }
                    else
                    {
                        curDir = namespaceTree.getPath();
                    }
                    mf.addField(projectName + @"\" + path, lastClassName, nameText.Text, type);
                    classTree = new SetClassTreeView(classTreeView, fileName, projectName, namespaceTree.getPath());
                    classTree.expandNode(lastClassName);
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Field is duplicated.");
                    return;
                }
                else
                {
                    MessageBox.Show("Creating new Field failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Namespace" && workCombo.SelectedItem.ToString() == "Delete")
            {
                WarningForm warningForm = new WarningForm();
                warningForm.ShowDialog();
                if (!warningForm.getCheckOK())
                {
                    return;
                }
                result = sql.deleteNamespace(projectName, nameText.Text);
                if (result == 0)
                {
                    namespaceTree = new SetNamespaceTreeView(namespaceTreeView, fileName, projectName);
                    namespaceTree.expandNode(nameText.Text);
                    path = nameText.Text;
                    path = path.Replace(".", @"\");
                    mf.deleteDirectory(projectName + @"\" + path);
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Namespace dose not exist.");
                    return;
                }
                else
                {
                    MessageBox.Show("Deleting the Namespace failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Class" && workCombo.SelectedItem.ToString() == "Delete")
            {
                result = sql.deleteClass(projectName, workAtText.Text, nameText.Text);
                if (result == 0)
                {
                    classTree = new SetClassTreeView(classTreeView, fileName, projectName, namespaceTree.getPath());
                    path      = namespaceTree.getPath().Replace(".", @"\");
                    mf.deleteFile(projectName + @"\" + path, nameText.Text);
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Class dose not exist.");
                    return;
                }
                else
                {
                    MessageBox.Show("Deleting the Class failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Field" && workCombo.SelectedItem.ToString() == "Delete")
            {
                if (classTree.getClassName() != null)
                {
                    lastClassName = classTree.getClassName();
                }
                result = sql.deleteField(projectName, namespaceTree.getPath(), lastClassName, nameText.Text);
                if (result == 0)
                {
                    path = namespaceTree.getPath().Replace(".", @"\");
                    int    point = namespaceTree.getPath().LastIndexOf(".");
                    string curDir;
                    if (point != -1)
                    {
                        curDir = namespaceTree.getPath().Substring(point + 1);
                    }
                    else
                    {
                        curDir = namespaceTree.getPath();
                    }
                    mf.deleteField(projectName + @"\" + path, lastClassName, nameText.Text);
                    classTree = new SetClassTreeView(classTreeView, fileName, projectName, namespaceTree.getPath());
                    classTree.expandNode(lastClassName);
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Field dose not exist.");
                    return;
                }
                else
                {
                    MessageBox.Show("Deleting the Field failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Namespace" && workCombo.SelectedItem.ToString() == "Modify")
            {
                if (namespaceTree.getPath() == null)
                {
                    MessageBox.Show("Click a namespace in View for this work.");
                    return;
                }
                else if (namespaceTree.getPath() == nameText.Text)
                {
                    MessageBox.Show("Input changed name in Name Textbox for this work.");
                    return;
                }
                else if (nameText.Text.LastIndexOf(".") != -1)
                {
                    int    point = nameText.Text.LastIndexOf(".");
                    string temp  = nameText.Text.Substring(0, point);
                    if (namespaceTree.getParentPath() == null || namespaceTree.getParentPath() != temp)
                    {
                        MessageBox.Show("Invalid namespace. Try again appropriately.");
                        return;
                    }
                }
                else if (namespaceTree.getPath().LastIndexOf(".") != -1)
                {
                    MessageBox.Show("Invalid namespace. Try again appropriately.");
                    return;
                }
                result = sql.changeNamespace(projectName, namespaceTree.getPath(), nameText.Text);
                if (result == 0)
                {
                    string oldPath = namespaceTree.getPath().Replace(".", @"\");
                    string newPath = nameText.Text.Replace(".", @"\");
                    mf.modifyDirectory(projectName + @"\" + oldPath, projectName + @"\" + newPath);
                    namespaceTree = new SetNamespaceTreeView(namespaceTreeView, fileName, projectName);
                    namespaceTree.expandNode(nameText.Text);
                    nameText.Text = null;
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Namespace is duplicated.");
                    return;
                }
                else
                {
                    MessageBox.Show("Changing the Namespace failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Class" && workCombo.SelectedItem.ToString() == "Modify")
            {
                if (classTree.getClassName() == null)
                {
                    MessageBox.Show("Click a class in View for this work.");
                    return;
                }
                else if (classTree.getClassName() == nameText.Text)
                {
                    MessageBox.Show("Input changed name in Name Textbox for this work.");
                    return;
                }
                result = sql.changeClass(projectName, workAtText.Text, classTree.getClassName(), nameText.Text);
                if (result == 0)
                {
                    path = workAtText.Text.Replace(".", @"\");
                    mf.modifyFile(projectName + @"\" + path, classTree.getClassName(), nameText.Text);
                    classTree     = new SetClassTreeView(classTreeView, fileName, projectName, namespaceTree.getPath());
                    nameText.Text = null;
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Class is duplicated.");
                    return;
                }
                else
                {
                    MessageBox.Show("Changing the Class failed.");
                    return;
                }
            }
            else if (categoryCombo.SelectedItem.ToString() == "Field" && workCombo.SelectedItem.ToString() == "Modify")
            {
                if (classTree.getClassName() != null)
                {
                    lastClassName = classTree.getClassName();
                }
                if (classTree.getFieldName() == null)
                {
                    MessageBox.Show("Click a Field in View for this work.");
                    return;
                }
                else if (typeCombo.SelectedItem == null)
                {
                    MessageBox.Show("Select a field type in Type for this work.");
                    return;
                }
                result = sql.changeField(projectName, namespaceTree.getPath(), classTree.getClassName(), classTree.getFieldName(), nameText.Text, typeCombo.SelectedItem.ToString());
                if (result == 0)
                {
                    path = namespaceTree.getPath().Replace(".", @"\");
                    int    point = namespaceTree.getPath().LastIndexOf(".");
                    string curDir;
                    if (point != -1)
                    {
                        curDir = namespaceTree.getPath().Substring(point + 1);
                    }
                    else
                    {
                        curDir = namespaceTree.getPath();
                    }
                    mf.modifyField(projectName + @"\" + path, classTree.getClassName(), classTree.getFieldName(), nameText.Text, typeCombo.SelectedItem.ToString());
                    classTree = new SetClassTreeView(classTreeView, fileName, projectName, namespaceTree.getPath());
                    classTree.expandNode(lastClassName);
                    nameText.Text = null;
                }
                else if (result == -1)
                {
                    MessageBox.Show("The Field is duplicated.");
                    return;
                }
                else if (result == -3)
                {
                    MessageBox.Show("Input changed value.");
                    return;
                }
                else
                {
                    MessageBox.Show("Changing the Field failed.");
                    return;
                }
            }
            nameText.Focus();
        }
Beispiel #8
0
        private void OKBtn_Click(object sender, EventArgs e)
        {
            AccessSqlite sql = new AccessSqlite();

            if (work == 0)
            {
                if (inputText.Text == "")
                {
                    MessageBox.Show("Input a name in Name Textbox for this work.");
                    return;
                }
                else if (CheckCharacter.checkString(inputText.Text) != 0)
                {
                    return;
                }
                else
                {
                    int result = sql.createTable(inputText.Text, null);
                    if (result == 0)
                    {
                        this.Close();
                    }
                    else if (result == -1)
                    {
                        MessageBox.Show("The project name is duplicated.");
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Creating the table failed.");
                        return;
                    }
                }
            }
            else
            {
                if (inputText.Text == "")
                {
                    MessageBox.Show("Input a name in Name Textbox for this work.");
                    return;
                }
                else if (CheckCharacter.checkString(inputText.Text) != 0)
                {
                    return;
                }
                else
                {
                    int result = sql.changeTable(beforeName, inputText.Text);
                    if (result == 0)
                    {
                        afterName = inputText.Text;
                        this.Close();
                    }
                    else if (result == -1)
                    {
                        MessageBox.Show("The project name is duplicated.");
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Changing the table failed.");
                        return;
                    }
                }
            }
        }