示例#1
0
        private void GenerateCSharpClassesWithCollection()
        {
            try
            {
                var tb = tab.SelectedTab;
                if (tb != null && tb.Controls.Count > 0)
                {
                    DoWait(true);
                    var qrCurrent = tb.Controls.Find("qr", true)[0] as Controls.QueryResultCtl;
                    var items     = qrCurrent.GetText().Split(';').Select(o => o.NullTrimer()).ToList();

                    if (items.NotEmpty())
                    {
                        if (compName.IsEmpty())
                        {
                            compName = ControlMod.InputBox("", "Company name");
                        }
                        if (nameSpace.IsEmpty())
                        {
                            nameSpace = ControlMod.InputBox("", "Namespace");
                        }

                        var __s = string.Empty;

                        foreach (var item in items)
                        {
                            var customClassName = ControlMod.InputBox("", "Class name", item);
                            var data            = OracleHelper.GetDatatable(String.Format(@"SELECT * FROM {0} WHERE 0=1", item.ToString()));
                            ClassGenerater.GetCSharpClass(data, item, true, true, compName, nameSpace, customClassName);
                            __s += ClassGenerater.GetCSharpSelectFunctions(data, item, customClassName);
                        }

                        qrCurrent.SetText(__s);
                        qrCurrent.HidePanel2();
                    }
                }
            }
            catch (Exception ex)
            {
                ex.PromptMsg();
            }

            DoWait(false);
        }
示例#2
0
        private void GenerateCSharpQueryfunctions()
        {
            try
            {
                var tb = tab.SelectedTab;
                if (tb != null && tb.Controls.Count > 0)
                {
                    DoWait(true);
                    var qrCurrent = tb.Controls.Find("qr", true)[0] as Controls.QueryResultCtl;
                    var items     = lstObjects.SelectedItems.Cast <string>().ToList();

                    if (items.IsEmpty())
                    {
                        items = qrCurrent.GetText().Split(';').Select(o => o.NullTrimer()).ToList();
                    }

                    if (items.NotEmpty())
                    {
                        var __s = string.Empty;

                        foreach (var item in items)
                        {
                            var data = OracleHelper.GetDatatable(String.Format(@"SELECT * FROM {0} WHERE 0=1", item.ToString()));
                            __s += ClassGenerater.GetCSharpSelectFunctions(data, item.ToString(), string.Empty);
                        }

                        qrCurrent.SetText(__s);
                        qrCurrent.HidePanel2();
                    }
                }
            }
            catch (Exception ex)
            {
                ex.PromptMsg();
            }

            DoWait(false);
        }
示例#3
0
        private void schemaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var newTab = tab.TabPages[tab.TabPages.Count - 1];

            FillTab(newTab);
            tab.SelectedTab = newTab;

            var qr = newTab.Controls.Find("qr", true)[0] as QueryResultCtl;

            if (sender.Equals(schemaToolStripMenuItem))//Schema
            {
                qr.SetText(@"SELECT column_name, data_type, data_length
                                FROM USER_TAB_COLUMNS
                                WHERE table_name = '" + lstObjects.SelectedItem.ToString() + @"'
                                ORDER BY column_name");
                qr.ExecQuery();
            }
            else if (sender.Equals(openWithAllFieldsToolStripMenuItem))// Open with all fields
            {
                var fields = OracleHelper.GetDatatable(@"SELECT column_name
                                FROM USER_TAB_COLUMNS
                                WHERE table_name = '" + lstObjects.SelectedItem.ToString() + @"'");
                if (fields.NotEmpty())
                {
                    var sCols = fields.Rows.Cast <DataRow>().Select(o => o[0]).Aggregate((f1, f2) => f1 + ", " + f2);
                    qr.SetText(String.Format(@"SELECT {0} FROM {1}  WHERE ROWNUM <= {2}", sCols, lstObjects.SelectedItem.ToString(), numRowLimit.Text));
                    qr.ExecQuery();
                }
            }
            else if (sender.Equals(generateCClassToolStripMenuItem) || sender.Equals(generateCClassWCFToolStripMenuItem))// Generate C# class
            {
                var data = OracleHelper.GetDatatable(String.Format(@"SELECT * FROM {0} WHERE 0=1", lstObjects.SelectedItem.ToString()));
                var __s  = ClassGenerater.GetCSharpClass(data, lstObjects.SelectedItem.ToString(), sender.Equals(generateCClassWCFToolStripMenuItem), false, string.Empty, string.Empty, string.Empty);
                qr.SetText(__s);
                qr.HidePanel2();
            }
            else if (sender.Equals(generateClassWithCollectionToolStripMenuItem))// Generate C# class
            {
                if (lstObjects.SelectedItems.NotEmpty())
                {
                    if (compName.IsEmpty())
                    {
                        compName = ControlMod.InputBox("", "Company name");
                    }
                    if (nameSpace.IsEmpty())
                    {
                        nameSpace = ControlMod.InputBox("", "Namespace");
                    }

                    var __s = string.Empty;

                    foreach (var item in lstObjects.SelectedItems)
                    {
                        var customClassName = ControlMod.InputBox("", "Class name", item.ToString());
                        var data            = OracleHelper.GetDatatable(String.Format(@"SELECT * FROM {0} WHERE 0=1", item.ToString()));
                        ClassGenerater.GetCSharpClass(data, item.ToString(), true, true, compName, nameSpace, customClassName);
                        __s += ClassGenerater.GetCSharpSelectFunctions(data, item.ToString(), customClassName);
                    }

                    qr.SetText(__s);
                    qr.HidePanel2();
                }
                else
                {
                    GenerateCSharpClassesWithCollection();
                }
            }
            else if (sender.Equals(generateCSharpQueryfunctionsToolStripMenuItem))
            {
                GenerateCSharpQueryfunctions();
            }
        }