//isAtkTypeOfSupplier : 0 is false AND 1 is true public List<Category> GetTypeOfSupplier(byte isAtkTypeOfSupplier) { List<Category> listCategory = null; string criteria; if (isAtkTypeOfSupplier == 0) criteria = " AND category_name not like '%General%' "; else criteria = " AND category_name like '%General%' "; try { using (SqlConnection con = new SqlConnection(VisitaJayaPerkasa.Constant.VisitaJayaPerkasaApplication.connectionString)) { Constant.VisitaJayaPerkasaApplication.anyConnection = false; con.Open(); Constant.VisitaJayaPerkasaApplication.anyConnection = true; using (SqlCommand command = new SqlCommand( "SELECT DISTINCT c.* FROM [Category] c, [SUPPLIER] s WHERE (c.deleted = '0' OR c.deleted is null) AND " + "(s.deleted = '0' OR s.deleted is null) AND c.category_id = s.category_id" + criteria + "ORDER BY category_name ASC" , con)) { SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Category category = new Category(); category.ID = Utility.Utility.ConvertToUUID(reader.GetValue(0).ToString()); category.CategoryCode = reader.GetString(1); category.CategoryName = reader.GetString(2); if (listCategory == null) listCategory = new List<Category>(); listCategory.Add(category); category = null; } } } } catch (Exception e) { Logging.Error("SqlPriceListRepository.cs - GetTypeOfSupplier() " + e.Message); } return listCategory; }
public List<Category> GetCategories() { List<Category> listCategory = null; try { using (SqlConnection con = new SqlConnection(VisitaJayaPerkasa.Constant.VisitaJayaPerkasaApplication.connectionString)) { Constant.VisitaJayaPerkasaApplication.anyConnection = false; con.Open(); Constant.VisitaJayaPerkasaApplication.anyConnection = true; using (SqlCommand command = new SqlCommand( "SELECT category_id, category_code, category_name FROM [Category] " + "WHERE (deleted is null OR deleted = '0') " + "ORDER BY category_name ASC" , con)) { SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Category category = new Category(); category.ID = Utility.Utility.ConvertToUUID(reader.GetValue(0).ToString()); category.CategoryCode = reader.GetString(1); category.CategoryName = reader.GetString(2); if (listCategory == null) listCategory = new List<Category>(); listCategory.Add(category); category = null; } } } } catch (Exception e) { Logging.Error("SqlCategoryRepository.cs - GetCategories() " + e.Message); } return listCategory; }