/**Escribede un objeto de la clase CIndice*/ public void EscribeIndicePrimario(CIndice indPri) { BinaryWriter bw; bw = getBw(); bw.BaseStream.Seek(indPri.getDirInd(), SeekOrigin.Begin); bw.Write(indPri.getTipoInd()); bw.Write(indPri.getTamIndPri()); bw.Write(indPri.getIndPrim()); bw.Write(indPri.getSigInd()); bw.Write(indPri.getCabBloques()); bw.Write(indPri.getDirInd()); }
/**\Compara dos indices primario*/ public int comparateTo(CIndice indB) { int res = -1; switch (this.getTipoInd()) { case 2://Short if (BitConverter.ToInt16(getIndPrim(), 0) > BitConverter.ToInt16(indB.getIndPrim(), 0)) res = 1; else if (BitConverter.ToInt16(getIndPrim(), 0) == BitConverter.ToInt16(indB.getIndPrim(), 0)) res = 0; break; case 3://Int if (BitConverter.ToInt32(getIndPrim(), 0) > BitConverter.ToInt32(indB.getIndPrim(), 0)) res = 1; else if (BitConverter.ToInt32(getIndPrim(), 0) == BitConverter.ToInt32(indB.getIndPrim(), 0)) res = 0; break; case 5://Long if (BitConverter.ToInt64(getIndPrim(), 0) > BitConverter.ToInt64(indB.getIndPrim(), 0)) res = 1; else if (BitConverter.ToInt64(getIndPrim(), 0) == BitConverter.ToInt64(indB.getIndPrim(), 0)) res = 0; break; case 7://Cadena byte []cA = getIndPrim(); byte[] cB = indB.getIndPrim(); char[] cadA = new char[cA.Length]; char[] cadB = new char[cB.Length]; string claveA, claveB; for (int i = 0; i < cA.Length; i++) cadA[i] = (char)cA[i]; claveA = new string(cadA); for (int i = 0; i < cB.Length; i++) cadB[i] = (char)cB[i]; claveB = new string(cadB); if (claveA.ToUpper().CompareTo(claveB.ToUpper()) > 0) res = 1; else if (claveA.ToUpper().CompareTo(claveB.ToUpper()) == 0) res = 0; break; } return (res); }
/**Se obtiene el Id de un indice primario*/ public string dameIndPri(CIndice ind) { string cad = null; switch (ind.getTipoInd()) { case 3://Tipo Entero cad = BitConverter.ToInt32(ind.getIndPrim(), 0).ToString(); break; case 5://Clave primaria de tipo Long cad = BitConverter.ToInt64(ind.getIndPrim(), 0).ToString(); break; case 7://Tipo cadena char []car = new char[1]; car[0] = (char)ind.getIndPrim()[0]; cad = new string(car); break; } return (cad); }