コード例 #1
0
 public void Remove(DataConnectionBase connection)
 {
     if (FConnections.Contains(connection))
     {
         FConnections.Remove(connection);
     }
 }
コード例 #2
0
ファイル: ReportSettings.cs プロジェクト: zwyl2001/FastReport
 internal void OnAfterDatabaseLogin(DataConnectionBase sender, AfterDatabaseLoginEventArgs e)
 {
     if (AfterDatabaseLogin != null)
     {
         AfterDatabaseLogin(sender, e);
     }
 }
コード例 #3
0
ファイル: DesignerSettings.cs プロジェクト: zixing131/LAEACC
        private void FindConnectorType()
        {
            FApplicationConnectionType = null;
            if (FApplicationConnection == null)
            {
                return;
            }

            // find appropriate connector
            List <ObjectInfo> registeredObjects = new List <ObjectInfo>();

            RegisteredObjects.Objects.EnumItems(registeredObjects);

            foreach (ObjectInfo info in registeredObjects)
            {
                if (info.Object != null && info.Object.IsSubclassOf(typeof(DataConnectionBase)))
                {
                    using (DataConnectionBase conn = Activator.CreateInstance(info.Object) as DataConnectionBase)
                        using (DbConnection dbConn = conn.GetConnection())
                        {
                            if (dbConn != null && dbConn.GetType() == FApplicationConnection.GetType())
                            {
                                FApplicationConnectionType = conn.GetType();
                                return;
                            }
                        }
                }
            }

            throw new Exception(FApplicationConnection.GetType().Name + " connection is not supported.");
        }
コード例 #4
0
 internal void OnDatabaseLogin(DataConnectionBase sender, DatabaseLoginEventArgs e)
 {
   if (Config.DesignerSettings.ApplicationConnection != null && 
     sender.GetType() == Config.DesignerSettings.ApplicationConnectionType)
   {
     e.ConnectionString = Config.DesignerSettings.ApplicationConnection.ConnectionString;
   }
   
   if (DatabaseLogin != null)
     DatabaseLogin(sender, e);
 }
コード例 #5
0
 private void cbxConnections_DrawItem(object sender, DrawItemEventArgs e)
 {
     e.DrawBackground();
     if (e.Index >= 0)
     {
         try
         {
             DataConnectionBase connection = cbxConnections.Items[e.Index] as DataConnectionBase;
             TextRenderer.DrawText(e.Graphics, connection.GetConnectionId(), e.Font, e.Bounds.Location, e.ForeColor);
         }
         catch
         {
         }
     }
 }
コード例 #6
0
 public void Deserialize(List <ConnectionEntry> connections)
 {
     foreach (ConnectionEntry ce in connections)
     {
         try
         {
             DataConnectionBase connection =
                 Activator.CreateInstance(ce.Type) as DataConnectionBase;
             connection.ConnectionString = ce.ConnectionString;
             FConnections.Add(connection);
         }
         catch
         {
         }
     }
 }
コード例 #7
0
 public void Deserialize(FRReader reader)
 {
     while (reader.NextItem())
     {
         try
         {
             DataConnectionBase connection = reader.Read() as DataConnectionBase;
             if (connection != null)
             {
                 FConnections.Add(connection);
             }
         }
         catch
         {
         }
     }
 }
コード例 #8
0
ファイル: ConnectionForm.cs プロジェクト: zixing131/LAEACC
        private void cbxConnections_SelectedIndexChanged(object sender, EventArgs e)
        {
            cbAlwaysUse.Checked = false;
            SuspendLayout();
            if (FConnectionEditor != null)
            {
                FConnectionEditor.Dispose();
            }
            if (!FEditMode)
            {
                if (FConnection != null)
                {
                    FConnection.Dispose();
                }
                FConnection = null;

                Type connectionType = (cbxConnections.SelectedItem as ObjectInfo).Object;
                FConnection = Activator.CreateInstance(connectionType) as DataConnectionBase;
            }

            FConnectionEditor = FConnection.GetEditor();
            if (FConnectionEditor != null)
            {
                FConnectionEditor.Parent   = this;
                FConnectionEditor.Location = new Point(0, gbSelect.Bottom);
                PerformAutoScale();
                FConnectionEditor.UpdateLayout();
                ClientSize = new Size(ClientSize.Width,
                                      FConnectionEditor.Bottom + cbLoginPrompt.Height + btnOk.Height + gbSelect.Top * 5);
            }
            else
            {
                ClientSize = new Size(ClientSize.Width,
                                      gbSelect.Bottom + cbLoginPrompt.Height + btnOk.Height + gbSelect.Top * 5);
            }

            ResumeLayout();
            Refresh();
            if (FConnection != null && FConnectionEditor != null)
            {
                FConnectionEditor.ConnectionString = FConnection.ConnectionString;
                cbLoginPrompt.Checked = FConnection.LoginPrompt;
            }
            btnTest.Enabled = FConnection != null && FConnection.IsSqlBased;
        }
コード例 #9
0
        private void btnQueryBuilder_Click(object sender, EventArgs e)
        {
            using (DataConnectionBase conn = Activator.CreateInstance(FTable.Connection.GetType()) as DataConnectionBase)
            {
                conn.Assign(FTable.Connection);
                if (Config.DesignerSettings.ApplicationConnection != null)
                {
                    conn.ConnectionString = Config.DesignerSettings.ApplicationConnection.ConnectionString;
                }

                QueryBuilder qb = new QueryBuilder(conn);
                qb.UseJoin = true;
                if (qb.DesignQuery() == DialogResult.OK)
                {
                    tbSql.Text = qb.GetSql();
                }
            }
        }
コード例 #10
0
 public void Add(DataConnectionBase connection)
 {
     for (int i = 0; i < FConnections.Count; i++)
     {
         try
         {
             if (FConnections[i].GetConnectionId() == connection.GetConnectionId())
             {
                 FConnections.RemoveAt(i);
                 break;
             }
         }
         catch
         {
         }
     }
     FConnections.Insert(0, connection);
 }
コード例 #11
0
ファイル: DataBase.cs プロジェクト: zixing131/LAEACC
        public DataBase(DataConnectionBase db)
        {
            dataBase = db;
            try
            {
                dataBase.CreateAllTables(false);
            }
            catch
            {
            }

            foreach (TableDataSource tds in dataBase.Tables)
            {
                Table tbl = new Table(tds);
                tbl.Name = tbl.Name;
                tableList.TableList.Add(tbl);
            }
            tableList.TableList.Sort(CompareTable);
        }
コード例 #12
0
ファイル: DataTreeHelper.cs プロジェクト: zixing131/LAEACC
        public static void CreateDataTree(Dictionary dictionary, DataConnectionBase connection,
                                          TreeNodeCollection root)
        {
            foreach (TableDataSource data in connection.Tables)
            {
                AddDataSource(dictionary, data, root, false, false, true);
                TreeNode node = root[root.Count - 1];

                // add dummy child node for the table which has no schema, to allow expand the node and get schema
                if (data.Columns.Count == 0)
                {
                    node.Nodes.Add("dummy");
                }

                // fix the node text if table is not a query: display the TableName instead of Alias
                if (String.IsNullOrEmpty(data.SelectCommand))
                {
                    node.Text = data.TableName.Replace("\"", "");
                }
            }
        }
コード例 #13
0
 private void btnCreateNewDatasource_Click(object sender, EventArgs e)
 {
     using (DataWizardForm form = new DataWizardForm(FReport))
     {
         if (form.ShowDialog() == DialogResult.OK)
         {
             tvDataSources.CreateNodes(FReport.Dictionary);
             DataConnectionBase connection = form.Connection;
             string             tableName  = "";
             foreach (DataSourceBase table in connection.Tables)
             {
                 if (table.Enabled)
                 {
                     tableName = table.Alias;
                     break;
                 }
             }
             if (tableName != "")
             {
                 tvDataSources.SelectedItem = tableName;
             }
         }
     }
 }
コード例 #14
0
 public QueryBuilder(DataConnectionBase dcb)
 {
     core = new Core(new QueryDesigner(), new DataBase(dcb));
 }
コード例 #15
0
ファイル: DesignerEvents.cs プロジェクト: zixing131/LAEACC
 internal FilterConnectionTablesEventArgs(DataConnectionBase connection, string tableName)
 {
     FConnection = connection;
     FTableName  = tableName;
 }