public List <BusinessObjects.GetProductStock> getProdAlongWithSalesQuantity_ByAll(string connString) { try { //s.ID,s.name,s.description, s.unitPrice, s.cost, s.category, s.warranty,sp.TotalQuantity,sp.date_ List <BusinessObjects.GetProductStock> ProductList = new List <BusinessObjects.GetProductStock>(); string query = @"exec getProdAlongWithSalesQuantity_ByAll "; SqlConnection conn = DBHelper.GetConnection(connString); conn.Open(); SqlDataReader reader = DBHelper.ReadData(query, conn); while (reader.Read()) { BusinessObjects.GetProductStock pObj = new BusinessObjects.GetProductStock(); pObj.ID = Convert.ToInt32(reader[0].ToString()); pObj.name = reader[1].ToString(); pObj.description = reader[2].ToString(); pObj.unitPrice = Convert.ToDecimal(reader[3].ToString()); pObj.cost = Convert.ToDecimal(reader[4].ToString()); pObj.category = Convert.ToInt32(reader[5].ToString()); pObj.warranty = reader[6].ToString(); pObj.TotalQuantity = Convert.ToInt32(reader[7].ToString()); //pObj.date_ = Convert.ToDateTime(reader[8].ToString()); //reader[8].Equals(DBNull.Value) //pObj.date_ = DateTime.ParseExact(reader[8].ToString(), "yyyy/MM/dd", null); pObj.date_ = Convert.ToDateTime(reader[8].ToString()); ProductList.Add(pObj); } conn.Close(); return(ProductList); } catch (Exception ex) { throw ex; } }
public List <BusinessObjects.GetProductStock> getProdAlongWithSalesQuantity_ByDate(string connString, DateTime sDate, DateTime eDate) { try { //s.ID,s.name,s.description, s.unitPrice, s.cost, s.category, s.warranty,sp.TotalQuantity,sp.date_ List <BusinessObjects.GetProductStock> ProductList = new List <BusinessObjects.GetProductStock>(); string query = @"exec getProdAlongWithSalesQuantity_ByDate '" + sDate.ToString("dd-MMM-yyyy") + "', '" + eDate.ToString("dd-MMM-yyyy") + "' "; SqlConnection conn = DBHelper.GetConnection(connString); conn.Open(); SqlDataReader reader = DBHelper.ReadData(query, conn); while (reader.Read()) { BusinessObjects.GetProductStock pObj = new BusinessObjects.GetProductStock(); pObj.ID = Convert.ToInt32(reader[0].ToString()); pObj.name = reader[1].ToString(); pObj.description = reader[2].ToString(); pObj.unitPrice = Convert.ToDecimal(reader[3].ToString()); pObj.cost = Convert.ToDecimal(reader[4].ToString()); pObj.category = Convert.ToInt32(reader[5].ToString()); pObj.warranty = reader[6].ToString(); pObj.TotalQuantity = Convert.ToInt32(reader[7].ToString()); pObj.date_ = Convert.ToDateTime(reader[8].ToString()); ProductList.Add(pObj); } conn.Close(); return(ProductList); } catch (Exception ex) { throw ex; } }