Beispiel #1
0
        public Tables.Supplier GetOne_Supplier(Guid id)
        {
            Params.spS_tblSupplier param = new Params.spS_tblSupplier(true);

            param.SetUpConnection(string.Empty);

            param.Param_Sup_GuidID = id;

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

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

                    record.Col_Sup_GuidID.UseNull = sqlDataReader.IsDBNull(SPs.spS_tblSupplier.Resultset1.Fields.Column_Sup_GuidID.ColumnIndex);
                    if (!record.Col_Sup_GuidID.UseNull)
                    {
                        record.Col_Sup_GuidID.Value = sqlDataReader.GetSqlGuid(SPs.spS_tblSupplier.Resultset1.Fields.Column_Sup_GuidID.ColumnIndex).Value;
                    }

                    record.Col_Sup_StrName.UseNull = sqlDataReader.IsDBNull(SPs.spS_tblSupplier.Resultset1.Fields.Column_Sup_StrName.ColumnIndex);
                    if (!record.Col_Sup_StrName.UseNull)
                    {
                        record.Col_Sup_StrName.Value = sqlDataReader.GetSqlString(SPs.spS_tblSupplier.Resultset1.Fields.Column_Sup_StrName.ColumnIndex).Value;
                    }


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

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

                    return(null);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <returns>[To be supplied.]</returns>
        public bool Refresh()
        {
            this.displayName = null;

            this.col_Sup_StrNameWasUpdated = false;
            this.col_Sup_StrNameWasSet     = false;
            this.col_Sup_StrName           = System.Data.SqlTypes.SqlString.Null;

            bool alreadyOpened = false;

            Params.spS_tblSupplier Param = new Params.spS_tblSupplier(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_Sup_GuidID.IsNull)
            {
                Param.Param_Sup_GuidID = this.col_Sup_GuidID;
            }


            System.Data.SqlClient.SqlDataReader sqlDataReader = null;
            SPs.spS_tblSupplier Sp = new SPs.spS_tblSupplier(false);
            if (Sp.Execute(ref Param, out sqlDataReader))
            {
                if (sqlDataReader.Read())
                {
                    if (!sqlDataReader.IsDBNull(SPs.spS_tblSupplier.Resultset1.Fields.Column_Sup_StrName.ColumnIndex))
                    {
                        this.col_Sup_StrName = sqlDataReader.GetSqlString(SPs.spS_tblSupplier.Resultset1.Fields.Column_Sup_StrName.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.Supplier", "Refresh");
            }
        }