public ProdCatagorys GetsByString(string sString) { ProdCatagorys oProdCatagorys = new ProdCatagorys(); try { SqlCommand cmd = new SqlCommand("SP_ProdCatagory_GetsByString", _conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@catId", SqlDbType.VarChar)).Value = sString; if (_conn.State == ConnectionState.Open) { } else { cmd.Connection.Open(); } IDataReader reader = cmd.ExecuteReader(); oProdCatagorys = CreateObjects(reader); reader.Close(); cmd.Dispose(); cmd.Connection.Close(); } catch (Exception e) { throw new ServiceException(e.Message, e); } return(oProdCatagorys); }
public ProdCatagorys Gets() { ProdCatagorys oProdCatagorys = new ProdCatagorys(); try { SqlCommand cmd = new SqlCommand("SP_ProdCatagory_Gets", _conn); cmd.CommandType = CommandType.StoredProcedure; if (_conn.State == ConnectionState.Open) { } else { cmd.Connection.Open(); } IDataReader reader = cmd.ExecuteReader(); oProdCatagorys = CreateObjects(reader); reader.Close(); cmd.Dispose(); cmd.Connection.Close(); } catch (Exception e) { throw new ServiceException(e.Message, e); } return(oProdCatagorys); }
private ProdCatagorys CreateObjects(IDataReader oReader) { ProdCatagorys oProdCatagorys = new ProdCatagorys(); NullHandler oHandler = new NullHandler(oReader); while (oReader.Read()) { ProdCatagory oItem = CreateObject(oHandler); oProdCatagorys.Add(oItem); } return(oProdCatagorys); }