public List<BLL.BusinessObject.Product> GetAllActiveProduct() { List<BLL.BusinessObject.Product> lstProduct = new List<BLL.BusinessObject.Product>(); try { object[] mParams = { }; Database dBase = EnterpriseLibraryContainer.Current.GetInstance<Database>("CSWebDSN"); using (IDataReader reader = dBase.ExecuteReader("sprocCS_GetAllActiveProduct", mParams)) { while (reader.Read()) { BLL.BusinessObject.Product objProduct = new BLL.BusinessObject.Product(); if (reader["ProductID"] != DBNull.Value) objProduct.ProductID = Convert.ToInt32(reader["ProductID"]); if (reader["ProductName"] != DBNull.Value) objProduct.ProductName = Convert.ToString(reader["ProductName"]); lstProduct.Add(objProduct); } } } catch (Exception ex) { Common.LogError("CSWeb > Error > " + (new StackTrace()).GetFrame(0).GetMethod().Name, ex.ToString()); } return lstProduct; }
public List<BLL.BusinessObject.Product> GetAllProduct(PageInfo vobjPageInfo) { Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>("CSWebDSN");//DatabaseFactory.CreateDatabase(Config); DbCommand dbCommand = db.GetStoredProcCommand("[sprocCS_GetProducts_V2]"); db.AddInParameter(dbCommand, "SortColumnName", DbType.String, vobjPageInfo.SortColumnName); db.AddInParameter(dbCommand, "SortDirection", DbType.String, vobjPageInfo.SortDirection); db.AddInParameter(dbCommand, "SearchText", DbType.String, vobjPageInfo.SearchText); List<BLL.BusinessObject.Product> list = new List<BLL.BusinessObject.Product>(); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { BLL.BusinessObject.Product obj = new BLL.BusinessObject.Product(); list.Add(PopulateProductInfo(dataReader)); } } return list; }
private BLL.BusinessObject.Product PopulateProductInfo(IDataReader dataReader) { BLL.BusinessObject.Product obj = new BLL.BusinessObject.Product(); if (dataReader["ProductID"] != DBNull.Value) { obj.ProductID = (int)dataReader["ProductID"]; } if (dataReader["ProductName"] != DBNull.Value) { obj.ProductName = (string)dataReader["ProductName"]; } if (dataReader["Description"] != DBNull.Value) { obj.Description = (string)dataReader["Description"]; } if (dataReader["BarCode"] != DBNull.Value) { obj.BarCode = (string)dataReader["BarCode"]; } if (dataReader["Brand"] != DBNull.Value) { obj.Brand = (string)dataReader["Brand"]; } if (dataReader["BuyingPrice"] != DBNull.Value) { obj.BuyingPrice = (decimal)dataReader["BuyingPrice"]; } if (dataReader["SellingPrice"] != DBNull.Value) { obj.SellingPrice = (decimal)dataReader["SellingPrice"]; } if (dataReader["Tax"] != DBNull.Value) { obj.Tax = (decimal)dataReader["Tax"]; } if (dataReader["Margin"] != DBNull.Value) { obj.Margin = (decimal)dataReader["Margin"]; } if (dataReader["BarCode"] != DBNull.Value) { obj.BarCode = (string)dataReader["BarCode"]; } if (dataReader["Season"] != DBNull.Value) { obj.Season = (string)dataReader["Season"]; } if (dataReader["Quantity"] != DBNull.Value) { obj.Quantities = dataReader["Quantity"].ToString(); } if (dataReader["Stock"] != DBNull.Value) { obj.Stock = dataReader["Stock"].ToString(); } if (dataReader["QuantityDetails"] != DBNull.Value) { obj.QuantityDetails = dataReader["QuantityDetails"].ToString(); } if (dataReader["StockDetails"] != DBNull.Value) { obj.StockDetails = dataReader["StockDetails"].ToString(); } return obj; }
private BLL.BusinessObject.Product PopulateData(IDataReader dataReader) { BLL.BusinessObject.Product objData = new BLL.BusinessObject.Product(); if (dataReader["ProductID"] != DBNull.Value) { objData.ProductID = (int)dataReader["ProductID"]; } if (dataReader["ProductName"] != DBNull.Value) { objData.ProductName = (string)dataReader["ProductName"]; } if (dataReader["Description"] != DBNull.Value) { objData.Description = (string)dataReader["Description"]; } if (dataReader["BrandID"] != DBNull.Value) { objData.BrandID = (int)dataReader["BrandID"]; } if (dataReader["SeasonID"] != DBNull.Value) { objData.SeasonID = (int)dataReader["SeasonID"]; } if (dataReader["CategoryID"] != DBNull.Value) { objData.CategoryID = (int)dataReader["CategoryID"]; } if (dataReader["SizeID"] != DBNull.Value) { objData.SizeID = (string)dataReader["SizeID"]; } if (dataReader["BuyingPrice"] != DBNull.Value) { objData.BuyingPrice = (decimal)dataReader["BuyingPrice"]; } if (dataReader["SellingPrice"] != DBNull.Value) { objData.SellingPrice = (decimal)dataReader["SellingPrice"]; } if (dataReader["Tax"] != DBNull.Value) { objData.Tax = (decimal)dataReader["Tax"]; } if (dataReader["Margin"] != DBNull.Value) { objData.Margin = (decimal)dataReader["Margin"]; } if (dataReader["BarCode"] != DBNull.Value) { objData.BarCode = (string)dataReader["BarCode"]; } return objData; }
public BLL.BusinessObject.Product GetProductByID(int ProductID) { BLL.BusinessObject.Product objData = new BLL.BusinessObject.Product(); Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>("CSWebDSN");//DatabaseFactory.CreateDatabase(Config); DbCommand dbCommand = db.GetStoredProcCommand("sprocCS_GetProductByID"); db.AddInParameter(dbCommand, "ProductID", DbType.Int32, ProductID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { objData = PopulateData(dataReader); } } return objData; }