public Collection<PawnListEntry> ReportSearchItems(string SearchString, char? PawnStatusId) { SqlConnection conn = new SqlConnection(connectionString); //Create Command w/Parameters SqlCommand cmd = new SqlCommand("ReportSearchItems", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SearchString", SearchString); cmd.Parameters.AddWithValue("@PawnStatusId", PawnStatusId); try { conn.Open(); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleResult); Collection<PawnListEntry> rows = new Collection<PawnListEntry>(); PawnListEntry currentrow; while (reader.Read()) { currentrow = new PawnListEntry( reader["Type"].ToString(), int.Parse(reader["Id"].ToString()), DateTime.Parse(reader["PawnDate"].ToString()), reader["Name"].ToString(), reader["Description"].ToString(), decimal.Parse(reader["Amount"].ToString()), reader["Location"].ToString(), reader["CurrentStatus"].ToString(), DateTime.Parse(reader["StatusDate"].ToString()), reader["Employee"].ToString() ); rows.Add(currentrow); } return rows; } catch (Exception Ex) { throw Ex; } }
public ObservableCollection<PawnListEntry> PawnGetFloorList(int ItemTypeId) { SqlConnection conn = new SqlConnection(connectionString); //Create Command w/Parameters SqlCommand cmd = new SqlCommand("PawnGetFloorList", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ItemTypeId", ItemTypeId); try { conn.Open(); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleResult); ObservableCollection<PawnListEntry> rows = new ObservableCollection<PawnListEntry>(); PawnListEntry currentrow; while (reader.Read()) { currentrow = new PawnListEntry( reader["Type"].ToString(), int.Parse(reader["Id"].ToString()), DateTime.Parse(reader["PawnDate"].ToString()), int.Parse(reader["FirstPawnId"].ToString()), DateTime.Parse(reader["FirstPawnDate"].ToString()), reader["Name"].ToString(), reader["Description"].ToString(), decimal.Parse(reader["Amount"].ToString()), reader["Location"].ToString(), reader["CurrentStatus"].ToString(), DateTime.Parse(reader["StatusDate"].ToString()), reader["Employee"].ToString(), reader["CustomerNote"].ToString(), reader["PawnNote"].ToString(), int.Parse(reader["Active"].ToString()), int.Parse(reader["PaidInt"].ToString()), int.Parse(reader["PickedUp"].ToString()), int.Parse(reader["Floored"].ToString()), int.Parse(reader["MonthsBehind"].ToString()) ); rows.Add(currentrow); } return rows; } catch (Exception Ex) { throw Ex; } }