/// <summary> /// Releases this System.Windows.Forms.DataGrid. /// </summary> protected override void Dispose(bool disposing) { if (disposing) { if (this.sqlDataAdapter != null) { this.sqlDataAdapter = null; } this.FK_TitleId = System.Data.SqlTypes.SqlInt32.Null; } base.Dispose(disposing); }
/// <summary> /// Load or reloads a subset of the table content. In order to successfully /// call this method, you need to call first the Initialize method. /// </summary> /// <param name="startRecord">The zero-based record number to start with.</param> /// <param name="maxRecords">The maximum number of records to retrieve.</param> public void RefreshData(int startRecord, int maxRecords) { this.CreateControl(); if (this.LastKnownConnectionType == Bob.DataClasses.ConnectionType.None) { throw new InvalidOperationException("You must call the 'Initialize' method before calling this method."); } switch (this.LastKnownConnectionType) { case Bob.DataClasses.ConnectionType.ConnectionString: this.sqlDataAdapter = new Bob.SqlDataAdapters.SqlDataAdapter_Customers(this.connectionString, this.FK_TitleId, "Customers"); break; case Bob.DataClasses.ConnectionType.SqlConnection: this.sqlDataAdapter = new Bob.SqlDataAdapters.SqlDataAdapter_Customers(this.sqlConnection, this.FK_TitleId, "Customers"); break; } this.dataSet = null; if (startRecord == -1 && maxRecords == -1) { this.sqlDataAdapter.FillDataSet(ref this.dataSet); } else { this.sqlDataAdapter.FillDataSet(ref this.dataSet, startRecord, maxRecords); } this.dataSet.Tables["Customers"].Columns["CustomerID"].Caption = "Customer Number"; this.dataSet.Tables["Customers"].Columns["CompanyName"].Caption = "Company Name"; this.dataSet.Tables["Customers"].Columns["ContactName"].Caption = "Customer/Contact Name"; this.dataSet.Tables["Customers"].Columns["TitleId"].Caption = "Title Id"; this.dataSet.Tables["Customers"].Columns["Address"].Caption = "Customer/Contact Address"; this.dataSet.Tables["Customers"].Columns["City"].Caption = "Customer/Contact City"; this.dataSet.Tables["Customers"].Columns["PostalCode"].Caption = "Customer/Contact Post Code"; this.dataSet.Tables["Customers"].Columns["Phone"].Caption = "Customer/Contact Phone"; this.dataSet.Tables["Customers"].Columns["Email"].Caption = "Email Address"; this.dataSet.Tables["Customers"].Columns["WebAddress"].Caption = "Web Address"; this.dataSet.Tables["Customers"].Columns["Fax"].Caption = "Customer/Contact Fax"; this.dataSet.Tables["Customers"].Columns["Active"].Caption = "Active"; this.bindingInProgress = true; this.DataSource = this.dataSet.Tables["Customers"].DefaultView; this.bindingInProgress = false; }