public static SupplierType GetSupplierTypeBySupplierTypeId(int supplierTypeId) { Database db = DatabaseFactory.CreateDatabase("SPARInsightManagement"); string sqlCommand = "GetSupplierTypeBySupplierTypeId"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "@SupplierTypeId", DbType.Int32, supplierTypeId); db.AddOutParameter(dbCommand, "@Description", DbType.String, 50); db.ExecuteNonQuery(dbCommand); SupplierType supplierType = new SupplierType(); supplierType.SupplierTypeId = supplierTypeId; supplierType.Description = db.GetParameterValue(dbCommand, "Description").ToString(); return(supplierType); }
public static List <SupplierType> GetSupplierTypeList() { List <SupplierType> list = new List <SupplierType>(); Database db = DatabaseFactory.CreateDatabase("SPARInsightManagement"); string sqlCommand = "GetSupplierTypeList"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { SupplierType supplierType = new SupplierType(); supplierType.SupplierTypeId = Convert.ToInt32(dataReader["SupplierTypeId"]); supplierType.Description = dataReader["Description"].ToString(); list.Add(supplierType); } } return(list); }