Exemplo n.º 1
0
        private void formBar_SVComboIndexChanged(object sender, EventArgs e)
        {
            string sqlclass = GetSqlClass(formBar.SVCombo.Text);

            Cursor = Cursors.WaitCursor;

            try
            {
                var asm = Assembly.LoadFrom("newtype.Database.dll");
                if (!SerialSqlManager.ContainsKey((ServerType)formBar.SVCombo.SelectedIndex))
                {
                    SerialSqlManager[(ServerType)formBar.SVCombo.SelectedIndex] = (ISqlManager)asm.CreateInstance($"newtype.Database.{sqlclass}");
                }

                CurrentSVIndex = formBar.SVCombo.SelectedIndex;

                if (sqlManager.isConnected)
                {
                    UpdateDataBaseComboItems();
                    return;
                }

                if (sqlManager.ConnectToServer())
                {
                    UpdateDataBaseComboItems();
                }
                else
                {
                    FormBar.DBcombo.Items.Clear();
                    tabGrid_settingClick(sender, e);
                }
            }
            finally { Cursor = Cursors.Default; }
        }
Exemplo n.º 2
0
        private void Controller_Load(object sender, EventArgs e)
        {
            // create Instance
            var xml = new XmlManager();

            formBar.isController = true;
            if (xml[new List <string> {
                        "serialize"
                    }, "False"].ToUpper().Equals("TRUE"))
            {
                formBar.isMultiMode = true;
            }
            Opacity = Convert.ToDouble(xml[new List <string> {
                                               "opacity"
                                           }, "0.6"]);

            ComboSetting("SQLServer", xml);
            ComboSetting("MySQL", xml);
            ComboSetting("PostgreSQL", xml);
            if (FormBar.SVCombo.Items.Count == 0)
            {
                formBar.SVCombo.Items.Add("SQLServer");
            }

            var defaultIndex = xml[new List <string> {
                                       "defaultSV"
                                   }, "0"];

            FormBar.SVCombo.SelectedIndex = Convert.ToInt32(defaultIndex);

            var sqlclass = GetSqlClass(FormBar.SVCombo.Text);

            SerialSqlManager.Add(
                (ServerType)CurrentSVIndex,
                (ISqlManager)Assembly
                .LoadFrom("newtype.Database.dll")
                .CreateInstance($"newtype.Database.{sqlclass}"));

            if (SerialSqlManager[(ServerType)CurrentSVIndex].ConnectToServer())
            {
                UpdateDataBaseComboItems();
            }
            else
            {
                tabGrid_settingClick(sender, e);
            }

            tabGrid.TabCollection.ForEach(t => t.Text = xml[new List <string> {
                                                                $"tab{t.Index}Text"
                                                            }, $"tab{t.Index}"]);
            tabGrid.TabCollection.ForEach(t => tabGrid.QueryCollection[t.Index].Text = xml[new List <string> {
                                                                                               $"tab{t.Index}Query"
                                                                                           }, ""]);

            FormBar.SVComboIndexChanged += formBar_SVComboIndexChanged;
        }