Ejemplo n.º 1
0
        /// <summary>
        /// Load or reloads a subset of the chosen resultset returned by the stored procedure.
        /// 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.");
            }

            this.param = new Params.spS_xSearchCustomer();

            switch (this.LastKnownConnectionType)
            {
            case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                this.param.SetUpConnection(this.connectionString);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                this.param.SetUpConnection(this.sqlConnection);
                break;
            }

            this.param.CommandTimeOut = this.commandTimeOut;


            if (!this.param_LastName.IsNull)
            {
                this.param.Param_LastName = this.param_LastName;
            }

            if (!this.param_FirstName.IsNull)
            {
                this.param.Param_FirstName = this.param_FirstName;
            }

            System.Data.DataSet DS = null;

            SPs.spS_xSearchCustomer SP = new SPs.spS_xSearchCustomer();
            if (SP.Execute(ref this.param, ref DS, startRecord, maxRecords))
            {
                this.DataSource = DS.Tables[this.tableName].DefaultView;
                if (this.primaryKey.Length != 0)
                {
                    this.DataKeyField = this.primaryKey;
                }
                if (this.doDataBindAfterRefreshData)
                {
                    this.DataBind();
                }
                SP.Dispose();
            }

            else
            {
                SP.Dispose();
                throw new OlymarsDemo.DataClasses.CustomException(this.param, "WebDataGridCustom_spS_xSearchCustomer", "RefreshData");
            }
        }