public List<InventoryCategory> GetAllCategory() { List<InventoryCategory> aList = new List<InventoryCategory>(); try { this.OpenConnection(); string sqlCommand = String.Format(SqlQueries.GetQuery(Query.GetAllCategory)); IDataReader oReader = this.ExecuteReader(sqlCommand); if (oReader != null) { while (oReader.Read()) { InventoryCategory aCategory = new InventoryCategory(); aCategory = ReaderToCategory(oReader); aList.Add(aCategory); } } } catch (Exception ex) { throw new Exception("GetAllCategory()",ex); } finally { this.CloseConnection(); } return aList; }
private InventoryCategory ReaderToCategory(IDataReader oReader) { InventoryCategory aCategory = new InventoryCategory(); try { aCategory.CategoryId = Convert.ToInt32(oReader["IC_id"]); } catch { } try { aCategory.CategoryName = oReader["IC_name"].ToString(); } catch { } return aCategory; }
private void LoadRawMaterialItem() { if (cmbRawCategory2.SelectedIndex >= 0) { InventoryCategory aCategory = new InventoryCategory(); aCategory = (InventoryCategory)cmbRawCategory2.SelectedItem; InventoryItemDAO aInventoryItemDao = new InventoryItemDAO(); List<InventoryItem> aInventoryItems = new List<InventoryItem>(); aInventoryItems = aInventoryItemDao.GetItemByCategory(aCategory.CategoryId); cmbProductName.DisplayMember = "ItemName"; cmbProductName.ValueMember = "ItemId"; cmbProductName.DataSource = aInventoryItems; } }