/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (AdditionalAddressInfo != null) { hashCode = hashCode * 59 + AdditionalAddressInfo.GetHashCode(); } if (City != null) { hashCode = hashCode * 59 + City.GetHashCode(); } if (CountryCode != null) { hashCode = hashCode * 59 + CountryCode.GetHashCode(); } if (FirstName != null) { hashCode = hashCode * 59 + FirstName.GetHashCode(); } if (HouseNumber != null) { hashCode = hashCode * 59 + HouseNumber.GetHashCode(); } if (State != null) { hashCode = hashCode * 59 + State.GetHashCode(); } if (StateCode != null) { hashCode = hashCode * 59 + StateCode.GetHashCode(); } if (Street != null) { hashCode = hashCode * 59 + Street.GetHashCode(); } if (Surname != null) { hashCode = hashCode * 59 + Surname.GetHashCode(); } if (SurnamePrefix != null) { hashCode = hashCode * 59 + SurnamePrefix.GetHashCode(); } if (Zip != null) { hashCode = hashCode * 59 + Zip.GetHashCode(); } return(hashCode); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (AdditionalAddressInfo != null) { hashCode = hashCode * 59 + AdditionalAddressInfo.GetHashCode(); } if (City != null) { hashCode = hashCode * 59 + City.GetHashCode(); } if (CountryCode != null) { hashCode = hashCode * 59 + CountryCode.GetHashCode(); } if (HouseNumber != null) { hashCode = hashCode * 59 + HouseNumber.GetHashCode(); } if (Iban != null) { hashCode = hashCode * 59 + Iban.GetHashCode(); } if (Id != null) { hashCode = hashCode * 59 + Id.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (ReferenceParty != null) { hashCode = hashCode * 59 + ReferenceParty.GetHashCode(); } if (ReferencePartyId != null) { hashCode = hashCode * 59 + ReferencePartyId.GetHashCode(); } if (Street != null) { hashCode = hashCode * 59 + Street.GetHashCode(); } if (Zip != null) { hashCode = hashCode * 59 + Zip.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if Debtor instances are equal /// </summary> /// <param name="other">Instance of Debtor to be compared</param> /// <returns>Boolean</returns> public bool Equals(Debtor other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( AdditionalAddressInfo == other.AdditionalAddressInfo || AdditionalAddressInfo != null && AdditionalAddressInfo.Equals(other.AdditionalAddressInfo) ) && ( City == other.City || City != null && City.Equals(other.City) ) && ( CountryCode == other.CountryCode || CountryCode != null && CountryCode.Equals(other.CountryCode) ) && ( FirstName == other.FirstName || FirstName != null && FirstName.Equals(other.FirstName) ) && ( HouseNumber == other.HouseNumber || HouseNumber != null && HouseNumber.Equals(other.HouseNumber) ) && ( State == other.State || State != null && State.Equals(other.State) ) && ( StateCode == other.StateCode || StateCode != null && StateCode.Equals(other.StateCode) ) && ( Street == other.Street || Street != null && Street.Equals(other.Street) ) && ( Surname == other.Surname || Surname != null && Surname.Equals(other.Surname) ) && ( SurnamePrefix == other.SurnamePrefix || SurnamePrefix != null && SurnamePrefix.Equals(other.SurnamePrefix) ) && ( Zip == other.Zip || Zip != null && Zip.Equals(other.Zip) )); }
/// <summary> /// Returns true if Creditor instances are equal /// </summary> /// <param name="other">Instance of Creditor to be compared</param> /// <returns>Boolean</returns> public bool Equals(Creditor other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( AdditionalAddressInfo == other.AdditionalAddressInfo || AdditionalAddressInfo != null && AdditionalAddressInfo.Equals(other.AdditionalAddressInfo) ) && ( City == other.City || City != null && City.Equals(other.City) ) && ( CountryCode == other.CountryCode || CountryCode != null && CountryCode.Equals(other.CountryCode) ) && ( HouseNumber == other.HouseNumber || HouseNumber != null && HouseNumber.Equals(other.HouseNumber) ) && ( Iban == other.Iban || Iban != null && Iban.Equals(other.Iban) ) && ( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( ReferenceParty == other.ReferenceParty || ReferenceParty != null && ReferenceParty.Equals(other.ReferenceParty) ) && ( ReferencePartyId == other.ReferencePartyId || ReferencePartyId != null && ReferencePartyId.Equals(other.ReferencePartyId) ) && ( Street == other.Street || Street != null && Street.Equals(other.Street) ) && ( Zip == other.Zip || Zip != null && Zip.Equals(other.Zip) )); }
/// <summary> /// Retrieves a subset of incident information to display in the all incidents tab DataSet. /// This method was designed for efficiency - all incident is retrieved in a single SELECT statement and passed to an Incident object /// which then exposes the data /// </summary> /// <param name="incidentNumber">The unique incident number to retrieve information for</param> /// <returns>An object representing the collection of information for a single incident</returns> public IncidentInfo GetAllDetails(int incidentNumber) { //will hold the results DateTime dateTime = DateTime.MinValue; string caller = string.Empty; string exchange = string.Empty; IncidentType type = null; string details = string.Empty; Address address = null; AdditionalAddressInfo additionalAddressInfo = null; string summary = string.Empty; string oic = string.Empty; List<AssignedResource> assignedResources = new List<AssignedResource>(); string operatorName = string.Empty; DateTime stopTime = DateTime.MinValue; DateTime incidentClosedTime = DateTime.MinValue; //the statement to execute string statement = "SELECT * FROM incident" + Environment.NewLine + "INNER JOIN IncidentType" + Environment.NewLine + "ON incident.IncidentTypeName = incidenttype.Name" + Environment.NewLine + "LEFT JOIN Incident_Resource " + Environment.NewLine + "ON incident.IncidentNumber = Incident_Resource.IncidentIncidentNumber" + Environment.NewLine + "INNER JOIN operator" + Environment.NewLine + "ON operator.Id = incident.OperatorId" + Environment.NewLine + "LEFT JOIN appliance" + Environment.NewLine + "ON Incident_Resource.ResourceCallSign = appliance.CallSign" + Environment.NewLine + "WHERE incident.IncidentNumber = @incidentNo;"; //object that will execute the query MySqlCommand command = new MySqlCommand(statement, connection); command.Parameters.AddWithValue("@incidentNo", incidentNumber); //execute MySqlDataReader myReader = null; //reads the database data try { // open the connection only if it is currently closed if (command.Connection.State == System.Data.ConnectionState.Closed) command.Connection.Open(); //close the reader if it currently exists if (myReader != null && !myReader.IsClosed) myReader.Close(); myReader = command.ExecuteReader(); //execute the select statement //read the data sent back from MySQL server and create the IncidentInfo object while (myReader.Read()) { //retrieve all the data - each area is separated into different regions below #region Incident Details if (!myReader.IsDBNull(12)) dateTime = myReader.GetDateTime(12); if (!myReader.IsDBNull(13)) caller = myReader.GetString(13); if (!myReader.IsDBNull(14)) exchange = myReader.GetString(14); if (!myReader.IsDBNull(20) && !myReader.IsDBNull(21)) type = new IncidentType(myReader.GetString(20), myReader.GetString(21)); if (!myReader.IsDBNull(15)) details = myReader.GetString(15); if (!myReader.IsDBNull(18)) summary = myReader.GetString(18); if (!myReader.IsDBNull(19)) oic = myReader.GetString(19); if (!myReader.IsDBNull(32)) operatorName = myReader.GetString(32); if (!myReader.IsDBNull(16)) stopTime = myReader.GetDateTime(16); if (!myReader.IsDBNull(17)) incidentClosedTime = myReader.GetDateTime(17); #endregion #region Address Data string building = string.Empty; if (!myReader.IsDBNull(2)) building = myReader.GetString(2); string number = string.Empty; if (!myReader.IsDBNull(3)) number = myReader.GetString(3); string street = string.Empty; if (!myReader.IsDBNull(4)) street = myReader.GetString(4); string town = string.Empty; if (!myReader.IsDBNull(5)) town = myReader.GetString(5); string postcode = string.Empty; if (!myReader.IsDBNull(6)) postcode = myReader.GetString(6); string county = string.Empty; if (!myReader.IsDBNull(7)) county = myReader.GetString(7); double longitude = myReader.GetDouble(8); double latitude = myReader.GetDouble(9); address = new Address(-1, building, number, street, town, postcode, county, longitude, latitude); #endregion #region Assigned Resource Data string callSign = string.Empty; if (!myReader.IsDBNull(23)) callSign = myReader.GetString(23); DateTime alerted = DateTime.MinValue; if (!myReader.IsDBNull(24)) alerted = myReader.GetDateTime(24); DateTime mobile = DateTime.MinValue; if (!myReader.IsDBNull(25)) mobile = myReader.GetDateTime(25); DateTime inAttendance = DateTime.MinValue; if (!myReader.IsDBNull(26)) inAttendance = myReader.GetDateTime(26); DateTime available = DateTime.MinValue; if (!myReader.IsDBNull(27)) available = myReader.GetDateTime(27); DateTime closedDown = DateTime.MinValue; if (!myReader.IsDBNull(28)) closedDown = myReader.GetDateTime(28); string appOic = string.Empty; if (!myReader.IsDBNull(37)) appOic = myReader.GetString(37); int crew = -1; if (!myReader.IsDBNull(38)) crew = myReader.GetInt32(38); int ba = -1; if (!myReader.IsDBNull(39)) ba = myReader.GetInt32(39); assignedResources.Add(new AssignedResource(callSign, alerted, mobile, inAttendance, available, closedDown, appOic, crew, ba)); #endregion } } catch (Exception ex) { MessageBox.Show(ex.ToString()); MessageBox.Show(statement); } finally { //close the connections if (myReader != null) myReader.Close(); command.Connection.Close(); } //return the data return new IncidentInfo(incidentNumber, dateTime, caller, exchange, type, details, address, additionalAddressInfo, summary, oic, assignedResources.ToArray(), operatorName, stopTime, incidentClosedTime); }