Example #1
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");
            }
        }