Example #1
0
        public Tables.tblOrderItem_Record GetOne_tblOrderItem_Record(Guid id)
        {
            Params.spS_tblOrderItem param = new Params.spS_tblOrderItem(true);

            param.SetUpConnection(string.Empty);

            param.Param_Oit_GuidID = id;

            using (SPs.spS_tblOrderItem sp = new SPs.spS_tblOrderItem(true)) {
                System.Data.SqlClient.SqlDataReader sqlDataReader = null;
                sp.Execute(ref param, out sqlDataReader);
                param.Dispose();

                if (sqlDataReader.Read())
                {
                    Tables.tblOrderItem_Record record = new Tables.tblOrderItem_Record();

                    record.Col_Oit_GuidID.UseNull = sqlDataReader.IsDBNull(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidID.ColumnIndex);
                    if (!record.Col_Oit_GuidID.UseNull)
                    {
                        record.Col_Oit_GuidID.Value = sqlDataReader.GetSqlGuid(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidID.ColumnIndex).Value;
                    }

                    record.Col_Oit_GuidOrderID.UseNull = sqlDataReader.IsDBNull(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidOrderID.ColumnIndex);
                    if (!record.Col_Oit_GuidOrderID.UseNull)
                    {
                        record.Col_Oit_GuidOrderID.Value = sqlDataReader.GetSqlGuid(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidOrderID.ColumnIndex).Value;
                    }

                    record.Col_Oit_GuidProductID.UseNull = sqlDataReader.IsDBNull(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidProductID.ColumnIndex);
                    if (!record.Col_Oit_GuidProductID.UseNull)
                    {
                        record.Col_Oit_GuidProductID.Value = sqlDataReader.GetSqlGuid(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidProductID.ColumnIndex).Value;
                    }

                    record.Col_Oit_LngAmount.UseNull = sqlDataReader.IsDBNull(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_LngAmount.ColumnIndex);
                    if (!record.Col_Oit_LngAmount.UseNull)
                    {
                        record.Col_Oit_LngAmount.Value = sqlDataReader.GetSqlInt32(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_LngAmount.ColumnIndex).Value;
                    }


                    sqlDataReader.Close();
                    sp.Connection.Close();

                    return(record);
                }
                else
                {
                    sqlDataReader.Close();
                    sp.Connection.Close();

                    return(null);
                }
            }
        }
Example #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.");
            }

            this.param = new Params.spS_tblOrderItem(true);

            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;
            }

            if (!this.FK_Oit_GuidOrderID.IsNull)
            {
                this.param.Param_Oit_GuidOrderID = this.FK_Oit_GuidOrderID;
            }

            if (!this.FK_Oit_GuidProductID.IsNull)
            {
                this.param.Param_Oit_GuidProductID = this.FK_Oit_GuidProductID;
            }

            System.Data.DataSet DS = null;

            SPs.spS_tblOrderItem SP = new SPs.spS_tblOrderItem(false);
            if (SP.Execute(ref this.param, ref DS, startRecord, maxRecords))
            {
                this.DataSource   = DS.Tables["spS_tblOrderItem"].DefaultView;
                this.DataKeyField = "Oit_GuidID";
                if (this.doDataBindAfterRefreshData)
                {
                    this.DataBind();
                }

                SP.Dispose();
            }

            else
            {
                SP.Dispose();
                throw new OlymarsDemo.DataClasses.CustomException(this.param, "WebDataGrid_tblOrderItem : System.Web.UI.WebControls.DataGrid", "RefreshData");
            }
        }
        /// <summary>
        /// Load or reloads a subset of the chosen resultset returned by the stored procedure.
        /// You can specify which record you want to be checked by default.
        /// </summary>
        /// <param name="PrimaryKey">Primary key of the record you want to be selected by default.</param>
        /// <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(object PrimaryKey, int startRecord, int maxRecords)
        {
            this.CreateControl();

            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_tblOrderItem();

            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_Oit_GuidID.IsNull)
            {
                this.param.Param_Oit_GuidID = this.param_Oit_GuidID;
            }


            if (!this.param_Oit_GuidOrderID.IsNull)
            {
                this.param.Param_Oit_GuidOrderID = this.param_Oit_GuidOrderID;
            }


            if (!this.param_Oit_GuidProductID.IsNull)
            {
                this.param.Param_Oit_GuidProductID = this.param_Oit_GuidProductID;
            }


            System.Data.DataSet DS = null;

            SPs.spS_tblOrderItem SP = new SPs.spS_tblOrderItem();
            if (SP.Execute(ref this.param, ref DS, startRecord, maxRecords))
            {
                this.BeginUpdate();
                this.bindingInProgress = true;
                this.DataSource        = DS.Tables[this.tableName].DefaultView;
                this.ValueMember       = this.valueMember;
                this.DisplayMember     = this.displayMember;
                this.bindingInProgress = false;

                if (PrimaryKey != null)
                {
                    this.SelectedValue = PrimaryKey;
                }
                else
                {
                    base.OnSelectedIndexChanged(EventArgs.Empty);
                }

                this.EndUpdate();
                SP.Dispose();
            }

            else
            {
                SP.Dispose();
                throw new OlymarsDemo.DataClasses.CustomException(this.param, "WinComboBoxCustom_spS_tblOrderItem", "RefreshData");
            }
        }
        /// <summary>
        /// Load or reloads a subset of the chosen resultset returned by the stored procedure.
        /// You can specify which record you want to be checked by default.
        /// </summary>
        /// <param name="ArrayOf_PrimaryKeys">Primary keys of the records you want to be checked by default.</param>
        /// <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(object[] ArrayOf_PrimaryKeys, 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_tblOrderItem();

            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_Oit_GuidID.IsNull)
            {
                this.param.Param_Oit_GuidID = this.param_Oit_GuidID;
            }


            if (!this.param_Oit_GuidOrderID.IsNull)
            {
                this.param.Param_Oit_GuidOrderID = this.param_Oit_GuidOrderID;
            }


            if (!this.param_Oit_GuidProductID.IsNull)
            {
                this.param.Param_Oit_GuidProductID = this.param_Oit_GuidProductID;
            }


            System.Data.DataSet DS = null;

            SPs.spS_tblOrderItem SP = new SPs.spS_tblOrderItem();
            if (SP.Execute(ref this.param, ref DS, startRecord, maxRecords))
            {
                this.DataSource     = DS.Tables[this.tableName].DefaultView;
                this.DataValueField = this.valueMember;
                this.DataTextField  = this.displayMember;
                if (this.doDataBindAfterRefreshData)
                {
                    this.DataBind();
                }

                if (ArrayOf_PrimaryKeys != null)
                {
                    this.SetRecordsChecked(ArrayOf_PrimaryKeys, true);
                }
            }

            else
            {
                SP.Dispose();
                throw new OlymarsDemo.DataClasses.CustomException(this.param, "WebCheckBoxListCustom_spS_tblOrderItem", "RefreshData");
            }
        }
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <returns>[To be supplied.]</returns>
        public bool Refresh()
        {
            this.displayName = null;

            this.col_Oit_GuidOrderIDWasUpdated = false;
            this.col_Oit_GuidOrderIDWasSet     = false;
            this.col_Oit_GuidOrderID           = System.Data.SqlTypes.SqlGuid.Null;

            this.col_Oit_GuidProductIDWasUpdated = false;
            this.col_Oit_GuidProductIDWasSet     = false;
            this.col_Oit_GuidProductID           = System.Data.SqlTypes.SqlGuid.Null;

            this.col_Oit_LngAmountWasUpdated = false;
            this.col_Oit_LngAmountWasSet     = false;
            this.col_Oit_LngAmount           = System.Data.SqlTypes.SqlInt32.Null;

            bool alreadyOpened = false;

            Params.spS_tblOrderItem Param = new Params.spS_tblOrderItem(true);
            Param.CommandTimeOut = this.selectCommandTimeOut;
            switch (this.lastKnownConnectionType)
            {
            case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                Param.SetUpConnection(this.connectionString);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                Param.SetUpConnection(this.sqlConnection);
                alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction:
                Param.SetUpConnection(this.sqlTransaction);
                break;
            }

            if (!this.col_Oit_GuidID.IsNull)
            {
                Param.Param_Oit_GuidID = this.col_Oit_GuidID;
            }


            System.Data.SqlClient.SqlDataReader sqlDataReader = null;
            SPs.spS_tblOrderItem Sp = new SPs.spS_tblOrderItem(false);
            if (Sp.Execute(ref Param, out sqlDataReader))
            {
                if (sqlDataReader.Read())
                {
                    if (!sqlDataReader.IsDBNull(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidOrderID.ColumnIndex))
                    {
                        this.col_Oit_GuidOrderID = sqlDataReader.GetSqlGuid(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidOrderID.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidProductID.ColumnIndex))
                    {
                        this.col_Oit_GuidProductID = sqlDataReader.GetSqlGuid(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidProductID.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_LngAmount.ColumnIndex))
                    {
                        this.col_Oit_LngAmount = sqlDataReader.GetSqlInt32(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_LngAmount.ColumnIndex);
                    }

                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    this.recordIsLoaded = true;

                    return(true);
                }
                else
                {
                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    this.recordIsLoaded = false;

                    return(false);
                }
            }
            else
            {
                if (sqlDataReader != null && !sqlDataReader.IsClosed)
                {
                    sqlDataReader.Close();
                }

                CloseConnection(Sp.Connection, alreadyOpened);

                throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.tblOrderItem_Record", "Refresh");
            }
        }
Example #6
0
        /// <summary>
        /// Allows you to load a specific record of the [tblOrderItem] table.
        /// </summary>
        /// <param name="col_Oit_GuidID">Update this description in the &quot;Olymars/Description&quot; extended property of the &quot;Oit_GuidID&quot; column.</param>
        public bool Refresh(System.Data.SqlTypes.SqlGuid col_Oit_GuidID)
        {
            bool Status;

            Reset();

            if (col_Oit_GuidID.IsNull)
            {
                throw new ArgumentNullException("col_Oit_GuidID", "The primary key 'col_Oit_GuidID' can not have a Null value!");
            }


            this.col_Oit_GuidID = col_Oit_GuidID;

            this.Param.Reset();

            this.Param.Param_Oit_GuidID = this.col_Oit_GuidID;

            System.Data.SqlClient.SqlDataReader DR;
            SPs.spS_tblOrderItem SP = new SPs.spS_tblOrderItem(false);

            if (SP.Execute(ref this.Param, out DR))
            {
                Status = false;
                if (DR.Read())
                {
                    if (!DR.IsDBNull(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidOrderID.ColumnIndex))
                    {
                        this.col_Oit_GuidOrderID = DR.GetSqlGuid(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidOrderID.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidProductID.ColumnIndex))
                    {
                        this.col_Oit_GuidProductID = DR.GetSqlGuid(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidProductID.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_LngAmount.ColumnIndex))
                    {
                        this.col_Oit_LngAmount = DR.GetSqlInt32(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_LngAmount.ColumnIndex);
                    }

                    Status = true;
                }

                if (DR != null && !DR.IsClosed)
                {
                    DR.Close();
                }

                if (CloseConnectionAfterUse && SP.Connection != null && SP.Connection.State == System.Data.ConnectionState.Open)
                {
                    SP.Connection.Close();
                    SP.Connection.Dispose();
                }

                return(Status);
            }

            else
            {
                if (DR != null && !DR.IsClosed)
                {
                    DR.Close();
                }

                if (CloseConnectionAfterUse && SP.Connection != null && SP.Connection.State == System.Data.ConnectionState.Open)
                {
                    SP.Connection.Close();
                    SP.Connection.Dispose();
                }

                throw new OlymarsDemo.DataClasses.CustomException(this.Param, "OlymarsDemo.AbstractClasses.Abstract_tblOrderItem", "Refresh");
            }
        }