Ejemplo n.º 1
0
        private void toolStripButton_createCollection_Click(object sender, EventArgs e)
        {
            if (this.treeView_dbInfo.SelectedNode == null)
            {
                return;
            }
            DateTime timeStart = DateTime.Now;

            Support.Constructor.CreateModel cm = new Support.Constructor.CreateModel();
            string nodeTag = this.treeView_dbInfo.SelectedNode.Tag.ToString();

            if (nodeTag == "database")
            {
                canCtrl_S = false;
                this.textBox_codeZone.Clear();
                foreach (TreeNode tn_type in this.treeView_dbInfo.SelectedNode.Nodes)
                {
                    string tableType = tn_type.Tag.ToString().Substring(0, 1).ToUpper();
                    tableType = tableType != "V" ? "U" : "V";
                    this.textBox_codeZone.AppendText(tableType != "V" ? "Creating user table models...\r\n" : "Creating user view models...\r\n");
                    for (int i = 0; i < tn_type.Nodes.Count; i++)
                    {
                        TreeNode tn = tn_type.Nodes[i];
                        (new Support.Constructor.CreateCSFile()).Write(cm.GenerateCollection(tn.Text.Split('(')[0]), Settings.Default.CreateFilePath + "\\Model", tn.Text.Split('(')[0] + "Collection.cs");
                        this.textBox_codeZone.AppendText("  [" + i.ToString("000") + "] " + "Successfully created model file: " + Settings.Default.CreateFilePath + "\\Model\\" + tn.Text.Split('(')[0] + "Collection.cs\r\n");
                    }
                    this.textBox_codeZone.AppendText("Done.\r\n");
                }
            }
            else if (nodeTag == "tables" || nodeTag == "views")
            {
                canCtrl_S = false;
                string tableType = nodeTag.Substring(0, 1).ToUpper();
                tableType = tableType != "V" ? "U" : "V";
                this.textBox_codeZone.Clear();
                this.textBox_codeZone.AppendText(tableType != "V" ? "Creating user table models...\r\n" : "Creating user view models...\r\n");
                for (int i = 0; i < this.treeView_dbInfo.SelectedNode.Nodes.Count; i++)
                {
                    TreeNode tn = this.treeView_dbInfo.SelectedNode.Nodes[i];
                    (new Support.Constructor.CreateCSFile()).Write(cm.GenerateCollection(tn.Text.Split('(')[0]), Settings.Default.CreateFilePath + "\\Model", tn.Text.Split('(')[0] + "Collection.cs");
                    this.textBox_codeZone.AppendText("  [" + i.ToString("000") + "] " + "Successfully created model file: " + Settings.Default.CreateFilePath + "\\Model\\" + tn.Text.Split('(')[0] + "Collection.cs\r\n");
                }
                this.textBox_codeZone.AppendText("Done.\r\n");
            }
            else if (nodeTag == "table")
            {
                canCtrl_S = true;
                string tableType = this.treeView_dbInfo.SelectedNode.Parent.Tag.ToString().Substring(0, 1).ToUpper();
                tableType = tableType != "V" ? "U" : "V";
                this.textBox_codeZone.Text = cm.GenerateCollection(this.treeView_dbInfo.SelectedNode.Text.Split('(')[0]);
                if (this.toolStripButton_createFile.Tag.ToString() == "1")
                {
                    SaveFile(Settings.Default.CreateFilePath + "\\Model", this.treeView_dbInfo.SelectedNode.Text.Split('(')[0] + "Collection.cs");
                }
            }
            currentOperate = "collection";
            this.toolStripStatusLabel_statusInfo.Text = "Time spend " + Time.TimeSpend.Spend(timeStart);
        }
Ejemplo n.º 2
0
        private void toolStripButton_createQueryModel_Click(object sender, EventArgs e)
        {
            if (this.treeView_dbInfo.SelectedNode == null)
            {
                return;
            }
            else if (!File.Exists(Settings.Default.CreateFilePath + "\\SQL\\Query.xml"))
            {
                toolStripButton_CreateXml_Click(sender, e);
            }
            canCtrl_S = true;
            DateTime timeStart = DateTime.Now;

            Support.Constructor.CreateModel cm = new Support.Constructor.CreateModel();
            this.textBox_codeZone.Text = cm.GenerateQueryXmlModel(Settings.Default.CreateFilePath + "\\SQL\\Query.xml");
            if (this.toolStripButton_createFile.Tag.ToString() == "1")
            {
                SaveFile(Settings.Default.CreateFilePath + "\\Model", "Query.cs");
            }
            currentOperate = "xmlModel";

            this.toolStripStatusLabel_statusInfo.Text = "Time spend " + Time.TimeSpend.Spend(timeStart);
        }