/// <summary> /// Basic method used in operator+ Basically helps generate the Guarantor Object. /// </summary> /// <param name="G1"></param> /// <param name="NewPatient"></param> /// <returns></returns> public static Guarantors Add(Guarantors G1, int NewPatient) { if (G1 == null) { throw new Exception("Null reference passed to Guarnator Operator -dwk"); } if (G1.PATIENTS == null) { G1.PATIENTS = new int[1]; G1.PATIENTS[0] = NewPatient; return(G1); } for (int i = 0; i < G1.PATIENTS.Length; i++) { if (G1.PATIENTS[i] == NewPatient) { return(G1); // ignore the attempt to add } } int[] Temp1 = new int[G1.PATIENTS.Length + 1]; ArrayCopySmalltoLarge(G1.PATIENTS, Temp1); Temp1[Temp1.Length - 1] = NewPatient; G1.PATIENTS = Temp1; return(G1); }
/// <summary> /// Return 0 if Guarantors are identical /// other wise returns comparison between guarantor numbers. /// Throws exception if obj is not type Guarantor or /// if obj == null /// Note PATIENTS element of Guarantor must be in same order /// for them to be counted as the same. /// </summary> /// <param name="obj"></param> /// <returns></returns> public int CompareTo(object obj) { Guarantors G1 = this; Guarantors G2 = null; if (obj is Guarantors) { G2 = (Guarantors)obj; } else { throw new Exception("Object passed to Guarantors.CompareTo(object) is not Type Guarantor -dwk"); } if (G2 == null) { throw new Exception("Null reference passed to Guarantors.CompareTo(object). -dwk "); } if (G1.Number != G2.Number) { return(G1.Number.CompareTo(G2.Number)); } // Guarantor Numbers Equal so compare arrays return(CompareArrays(G1.PATIENTS, G2.PATIENTS)); }
/// <summary> /// Basic method used in operator+ Basically helps generate the Guarantor Object. /// </summary> /// <param name="G1"></param> /// <param name="NewPatient"></param> /// <returns></returns> public static Guarantors Add(Guarantors G1, int NewPatient) { if (G1 == null) throw new Exception("Null reference passed to Guarnator Operator -dwk"); if (G1.PATIENTS == null) { G1.PATIENTS = new int[1]; G1.PATIENTS[0] = NewPatient; return G1; } for (int i = 0; i < G1.PATIENTS.Length; i++) if (G1.PATIENTS[i] == NewPatient) return G1; // ignore the attempt to add int[] Temp1 = new int[G1.PATIENTS.Length + 1]; ArrayCopySmalltoLarge( G1.PATIENTS, Temp1); Temp1[Temp1.Length-1] = NewPatient; G1.PATIENTS = Temp1; return G1; }
/// <summary> /// Removes NewPatient from G1.PATIENTS if it NewPatient is present in G1.PATIENTS. /// </summary> public static Guarantors Subtract(Guarantors G1, int NewPatient) { if (G1 == null) { throw new Exception("Operator - in Guarantors cannot apply to a null reference -dwk"); } int IndexToRemove = -1; if (G1.PATIENTS == null) { return(G1); // ie NewPatient is obviously not present } for (int i = 0; i < G1.PATIENTS.Length; i++) { if (G1.PATIENTS[i] == NewPatient) { IndexToRemove = i; } } if (IndexToRemove == -1) { return(G1); // NewPatient not present in G1.PATIENTS } int[] Temp = new int[G1.PATIENTS.Length - 1]; int index = 0; for (int i = 0; i < G1.PATIENTS.Length; i++) { if (i != IndexToRemove) { Temp[index] = G1.PATIENTS[i]; index++; } } G1.PATIENTS = Temp; return(G1); }
/// <summary> /// Calls the first overload /// </summary> public static Guarantors Add(int NewPatient, Guarantors G1) { return(Guarantors.Add(G1, NewPatient)); }
/// <summary> /// Should add NewPatient to the G1.PATIENTS. /// if G1.PATIENTS already contains NewPatient then nothing is done. /// </summary> public static Guarantors operator +(Guarantors G1, int NewPatient) { return(Guarantors.Add(G1, NewPatient)); }
/// <summary> /// Removes NewPatient from G1.PATIENTS if it NewPatient is present in G1.PATIENTS. /// </summary> public static Guarantors Subtract(int NewPatient, Guarantors G1) { return(Subtract(G1, NewPatient)); }
public GuarantorLedgerItemsCollection(Guarantors Guarantor) { this.m_Guarantors = Guarantor; this.m_GuarantorNumber = this.m_Guarantors.Number; }
/// <summary> /// Calls the first overload /// </summary> public static Guarantors Add(int NewPatient, Guarantors G1) { return Guarantors.Add(G1, NewPatient); }
/// <summary> /// Removes NewPatient from G1.PATIENTS if it NewPatient is present in G1.PATIENTS. /// </summary> public static Guarantors Subtract(Guarantors G1, int NewPatient) { if (G1 == null) throw new Exception("Operator - in Guarantors cannot apply to a null reference -dwk"); int IndexToRemove = -1; if(G1.PATIENTS == null) return G1; // ie NewPatient is obviously not present for (int i = 0; i < G1.PATIENTS.Length; i++) { if (G1.PATIENTS[i] == NewPatient) IndexToRemove = i; } if (IndexToRemove == -1) return G1; // NewPatient not present in G1.PATIENTS int[] Temp = new int[G1.PATIENTS.Length - 1]; int index = 0; for (int i = 0; i < G1.PATIENTS.Length; i++) { if (i != IndexToRemove) { Temp[index] = G1.PATIENTS[i]; index++; } } G1.PATIENTS = Temp; return G1; }
/// <summary> /// Removes NewPatient from G1.PATIENTS if it NewPatient is present in G1.PATIENTS. /// </summary> public static Guarantors Subtract(int NewPatient, Guarantors G1) { return Subtract(G1, NewPatient); }