//Show all Districts public List<District> getAllDistricts() // dafq is wrong here? { List<District> returnList = new List<District>(); dbCmd = new SqlCommand(); string sqlQuery = "SELECT * FROM District"; dbCmd = DbConnection.GetDbCommand(sqlQuery); IDataReader dbReader; dbReader = dbCmd.ExecuteReader(); while (dbReader.Read()) { District district = new District(); district = createDistrict(dbReader); returnList.Add(district); } dbCmd.Parameters.Clear(); DbConnection.Close(); return returnList; }
//Insert a new District public void addDistrict(District district) { dbCmd = new SqlCommand(); string sqlQuery = "INSERT INTO District VALUES " + "(@districtId, @primSalePersId, @name)"; dbCmd = DbConnection.GetDbCommand(sqlQuery); parmDistrictId.Value = district.DistrictId; dbCmd.Parameters.Add(parmDistrictId); parmPrimeSalePersId.Value = district.PrimSalePersId; dbCmd.Parameters.Add(parmPrimeSalePersId); parmName.Value = district.Name; dbCmd.Parameters.Add(parmName); try { dbCmd.Parameters.Clear(); DbConnection.Close(); } catch (SqlException) { } }
private static District createDistrict(IDataReader dbReader) { District district = new District(); district.DistrictId = Convert.ToInt32(dbReader["districtId"].ToString()); district.PrimSalePersId = Convert.ToInt32(dbReader["primSalePersId"].ToString()); district.Name = dbReader["name"].ToString(); return district; }
public void changePrimarySalesPerson(int districtid, int primeSalePersId) { IDistrict _dbDistrict = new DbDistrictHandler(); District district = new District(); district.DistrictId = districtid; district.PrimSalePersId = primeSalePersId; _dbDistrict.changePrimarySalesPerson(districtid, primeSalePersId); }
public void addDistrict(int districtid, int primSalePersId, string name) { IDistrict _dbDistrict = new DbDistrictHandler(); District district = new District(); district.DistrictId = districtid; district.PrimSalePersId = primSalePersId; district.Name = name; _dbDistrict.addDistrict(district); }