Ejemplo n.º 1
0
        /// <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_Pro_LngCategoryID = System.Data.SqlTypes.SqlInt32.Null;
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 2
0
        /// <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)
        {
            if (this.LastKnownConnectionType == OlymarsDemo.DataClasses.ConnectionType.None)
            {
                throw new InvalidOperationException("You must call the 'Initialize' method before calling this method.");
            }


            switch (this.LastKnownConnectionType)
            {
            case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                this.sqlDataAdapter = new OlymarsDemo.SqlDataAdapters.SqlDataAdapter_tblProduct(this.connectionString, this.FK_Pro_LngCategoryID, "tblProduct");
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                this.sqlDataAdapter = new OlymarsDemo.SqlDataAdapters.SqlDataAdapter_tblProduct(this.sqlConnection, this.FK_Pro_LngCategoryID, "tblProduct");
                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["tblProduct"].Columns["Pro_GuidID"].Caption        = "Pro_GuidID (update this label in the \"Olymars/ColumnLabel\" extended property of the \"Pro_GuidID\" column)";
            this.dataSet.Tables["tblProduct"].Columns["Pro_StrName"].Caption       = "Pro_StrName (update this label in the \"Olymars/ColumnLabel\" extended property of the \"Pro_StrName\" column)";
            this.dataSet.Tables["tblProduct"].Columns["Pro_CurPrice"].Caption      = "Pro_CurPrice (update this label in the \"Olymars/ColumnLabel\" extended property of the \"Pro_CurPrice\" column)";
            this.dataSet.Tables["tblProduct"].Columns["Pro_LngCategoryID"].Caption = "Pro_LngCategoryID (update this label in the \"Olymars/ColumnLabel\" extended property of the \"Pro_LngCategoryID\" column)";

            this.bindingInProgress = true;
            this.DataSource        = this.dataSet.Tables["tblProduct"].DefaultView;
            this.bindingInProgress = false;
        }