public ResponseOpList GetAllOpsWithRange(string startingIndex, string endingIndex) { ResponseOpList theResponse = new ResponseOpList(); openDataConnection(); SqlCommand cmdGetAllOps = new SqlCommand("GetAllOps", theConnection); cmdGetAllOps.CommandType = System.Data.CommandType.StoredProcedure; theReader = cmdGetAllOps.ExecuteReader(); int numRecords = 0; if (theReader.HasRows) { List<Op> listOfOps = new List<Op>(); while (theReader.Read()) { Op thisOp = new Op(); thisOp.storeID = (int)theReader["StoreID"]; thisOp.storeNumber = theReader["StoreNumber"].ToString(); thisOp.area = theReader["Area"].ToString(); thisOp.division = theReader["Division"].ToString(); thisOp.region = theReader["Region"].ToString(); thisOp.district = theReader["District"].ToString(); thisOp.areaName = theReader["AreaName"].ToString(); thisOp.rdOutlookName = theReader["RDOutlookName"].ToString(); thisOp.rdEmailAddress = theReader["RDEmailAddress"].ToString(); thisOp.divisionName = theReader["DivisionName"].ToString(); thisOp.dvpOutlookname = theReader["DVPOutlookName"].ToString(); thisOp.dvpEmailAddress = theReader["DVPEmailAddress"].ToString(); thisOp.regionName = theReader["RegionName"].ToString(); thisOp.rdOutlookName = theReader["RDOutlookName"].ToString(); thisOp.rdEmailAddress = theReader["RDEmailAddress"].ToString(); thisOp.divisionName = theReader["DivisionName"].ToString(); thisOp.dmOutlookName = theReader["DMOutlookName"].ToString(); thisOp.dmEmailAddress = theReader["DMEmailAddress"].ToString(); thisOp.rvpEmailAddress = theReader["RVPEmailAddress"].ToString(); thisOp.rvpOutlookName = theReader["RVPOutlookName"].ToString(); listOfOps.Add(thisOp); numRecords++; } theResponse.ops = new List<Op>(); int startIndex = Int32.Parse(startingIndex); int endIndex = Int32.Parse(endingIndex); endIndex = startIndex + endIndex; if (startIndex <= 0) { startIndex = 1; } if (startIndex > 0 && endIndex >= startIndex) { if (endIndex > numRecords) { endIndex = numRecords; } for (int i = startIndex; i <= endIndex; i++) { theResponse.ops.Add(listOfOps[i - 1]); } theResponse.numberOfRecords = numRecords; theResponse.statusCode = 0; theResponse.statusDescription = ""; } else { theResponse.statusCode = 6; theResponse.statusDescription = "The starting or ending index did not fall within the data range"; } } else { theResponse.statusCode = 4; theResponse.statusDescription = "There are no Ops defined"; } closeDataConnection(); return theResponse; }
public ResponseOpList GetOpsForStoreID(string storeID) { ResponseOpList theResponse = new ResponseOpList(); if (storeID == null || storeID.Equals("")) { theResponse.statusCode = 3; theResponse.statusDescription = "Missing Store ID"; } else { openDataConnection(); SqlCommand cmdGet = new SqlCommand("GetOpsForStore", theConnection); cmdGet.Parameters.AddWithValue("@storeID", storeID); cmdGet.CommandType = System.Data.CommandType.StoredProcedure; try { theReader = cmdGet.ExecuteReader(); if (theReader.HasRows) { theResponse.ops = new List<Op>(); while (theReader.Read()) { Op thisOp = new Op(); thisOp.storeID = (int)theReader["StoreID"]; thisOp.storeNumber = theReader["StoreNumber"].ToString(); thisOp.area = theReader["Area"].ToString(); thisOp.division = theReader["Division"].ToString(); thisOp.region = theReader["Region"].ToString(); thisOp.district = theReader["District"].ToString(); thisOp.areaName = theReader["AreaName"].ToString(); thisOp.rdOutlookName = theReader["RDOutlookName"].ToString(); thisOp.rdEmailAddress = theReader["RDEmailAddress"].ToString(); thisOp.divisionName = theReader["DivisionName"].ToString(); thisOp.dvpOutlookname = theReader["DVPOutlookName"].ToString(); thisOp.dvpEmailAddress = theReader["DVPEmailAddress"].ToString(); thisOp.regionName = theReader["RegionName"].ToString(); thisOp.rdOutlookName = theReader["RDOutlookName"].ToString(); thisOp.rdEmailAddress = theReader["RDEmailAddress"].ToString(); thisOp.divisionName = theReader["DivisionName"].ToString(); thisOp.dmOutlookName = theReader["DMOutlookName"].ToString(); thisOp.dmEmailAddress = theReader["DMEmailAddress"].ToString(); thisOp.rvpOutlookName = theReader["RVPOutlookName"].ToString(); thisOp.rvpEmailAddress = theReader["RVPEmailAddress"].ToString(); theResponse.ops.Add(thisOp); } theResponse.statusCode = 0; theResponse.statusDescription = ""; } else { theResponse.statusCode = 4; theResponse.statusDescription = "There are no ops for the store ID " + storeID; } } catch (Exception _exception) { theResponse.statusCode = 6; theResponse.statusDescription = _exception.Message; } theReader.Close(); closeDataConnection(); } return theResponse; }
public ResponseOpList GetAllOps() { ResponseOpList theResponse = new ResponseOpList(); openDataConnection(); SqlCommand cmdGetAllOps = new SqlCommand("GetAllOps", theConnection); cmdGetAllOps.CommandType = System.Data.CommandType.StoredProcedure; theReader = cmdGetAllOps.ExecuteReader(); if (theReader.HasRows) { theResponse.ops = new List<Op>(); while (theReader.Read()) { Op thisOp = new Op(); thisOp.storeID = (int)theReader["StoreID"]; thisOp.storeNumber = theReader["StoreNumber"].ToString(); thisOp.area = theReader["Area"].ToString(); thisOp.division = theReader["Division"].ToString(); thisOp.region = theReader["Region"].ToString(); thisOp.district = theReader["District"].ToString(); thisOp.areaName = theReader["AreaName"].ToString(); thisOp.rdOutlookName = theReader["RDOutlookName"].ToString(); thisOp.rdEmailAddress = theReader["RDEmailAddress"].ToString(); thisOp.divisionName = theReader["DivisionName"].ToString(); thisOp.dvpOutlookname = theReader["DVPOutlookName"].ToString(); thisOp.dvpEmailAddress = theReader["DVPEmailAddress"].ToString(); thisOp.regionName = theReader["RegionName"].ToString(); thisOp.rdOutlookName = theReader["RDOutlookName"].ToString(); thisOp.rdEmailAddress = theReader["RDEmailAddress"].ToString(); thisOp.divisionName = theReader["DivisionName"].ToString(); thisOp.dmOutlookName = theReader["DMOutlookName"].ToString(); thisOp.dmEmailAddress = theReader["DMEmailAddress"].ToString(); thisOp.rvpOutlookName = theReader["RVPOutlookName"].ToString(); thisOp.rvpEmailAddress = theReader["RVPEmailAddress"].ToString(); thisOp.districtName = theReader["DistrictName"].ToString(); theResponse.ops.Add(thisOp); } theResponse.statusCode = 0; theResponse.statusDescription = ""; } else { theResponse.statusCode = 4; theResponse.statusDescription = "There are no Ops defined"; } closeDataConnection(); return theResponse; }