public List <BusinessObjects.sales_product> getSales_Product_BySID(string connString, int SID) { try { List <BusinessObjects.sales_product> ProductList = new List <BusinessObjects.sales_product>(); string query = @"select p_id,sales_id,quantity,price,total,pname,warranty from sales_product where sales_id= " + SID + ""; SqlConnection conn = DBHelper.GetConnection(connString); conn.Open(); SqlDataReader reader = DBHelper.ReadData(query, conn); while (reader.Read()) { BusinessObjects.sales_product pObj = new BusinessObjects.sales_product(); pObj.p_id = Convert.ToInt32(reader[0].ToString()); pObj.sales_id = Convert.ToInt32(reader[1].ToString()); pObj.quantity = Convert.ToInt32(reader[2].ToString()); pObj.price = Convert.ToDecimal(reader[3].ToString()); pObj.total = Convert.ToDecimal(reader[4].ToString()); pObj.pname = reader[5].ToString(); pObj.warranty = reader[6].ToString(); ProductList.Add(pObj); } conn.Close(); return(ProductList); } catch (Exception ex) { throw ex; } }
public List <sales_product> getSales_ProductByCatID(string con, int catID) { try { List <BusinessObjects.sales_product> ProductList = new List <BusinessObjects.sales_product>(); string query = @"exec getSalesByCatID " + catID + ""; SqlConnection conn = DBHelper.GetConnection(con); conn.Open(); SqlDataReader reader = DBHelper.ReadData(query, conn); while (reader.Read()) { BusinessObjects.sales_product pObj = new BusinessObjects.sales_product(); pObj.p_id = Convert.ToInt32(reader[0].ToString()); pObj.sales_id = Convert.ToInt32(reader[1].ToString()); pObj.quantity = Convert.ToInt32(reader[2].ToString()); pObj.price = Convert.ToDecimal(reader[3].ToString()); pObj.total = Convert.ToDecimal(reader[4].ToString()); ProductList.Add(pObj); } conn.Close(); return(ProductList); } catch (Exception ex) { throw ex; } }