public ProductLots GetsByString(string sString) { ProductLots oProductLots = new ProductLots(); try { SqlCommand cmd = new SqlCommand(sString, _conn); cmd.CommandType = CommandType.Text; if (_conn.State == ConnectionState.Open) { } else { cmd.Connection.Open(); } IDataReader reader = cmd.ExecuteReader(); oProductLots = CreateObjects(reader); reader.Close(); cmd.Dispose(); cmd.Connection.Close(); } catch (Exception e) { throw new ServiceException(e.Message, e); } return(oProductLots); }
public ProductLots GetsByID(int nID) { ProductLots oProductLots = new ProductLots(); try { SqlCommand cmd = new SqlCommand("SP_ProductLot_GetsByID", _conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@Pro_ID", SqlDbType.Int)).Value = nID; if (_conn.State == ConnectionState.Open) { } else { cmd.Connection.Open(); } IDataReader reader = cmd.ExecuteReader(); oProductLots = CreateObjects(reader); reader.Close(); cmd.Dispose(); cmd.Connection.Close(); } catch (Exception e) { throw new ServiceException(e.Message, e); } return(oProductLots); }
private ProductLots CreateObjects(IDataReader oReader) { ProductLots oProductLots = new ProductLots(); NullHandler oHandler = new NullHandler(oReader); while (oReader.Read()) { ProductLot oItem = CreateObject(oHandler); oProductLots.Add(oItem); } return(oProductLots); }