示例#1
0
        /// <summary>
        /// Gets the contents of the record
        /// </summary>
        /// <returns>The contents of the record in a string array</returns>
        public string[] GetRecordContents(ref HeaderData tHeader)
        {
            string[] sToReurn = new string[fieldData.Length];
            Array.Copy(fieldData, sToReurn, fieldData.Length);
            for (int i = 0; i < sToReurn.Length; i++)
            {
                if (sToReurn[i] != null && tHeader.fFieldTypes[i] != HeaderData.FieldTypes.Numeric)
                {
                    sToReurn[i] = sToReurn[i].Trim();
                }
                else if (sToReurn[i] != null && tHeader.fFieldTypes[i] == HeaderData.FieldTypes.Numeric)
                {
                    sToReurn[i] = sToReurn[i].TrimStart(' ');
                }
            }

            return(sToReurn);
        }
示例#2
0
        private void LoadTable()
        {
            byte[] bData = GetFileData(dBaseFileName);
            tHeader = new HeaderData(bData);
            //rRecords = new Record[tHeader.nOfRecords];
            rRecords         = new List <Record>(tHeader.nRecordCount * 2);
            sFieldNames      = tHeader.sFieldNames;
            string[,] sTable = new string[tHeader.nOfRecords, tHeader.nOfFields];
            ReadContentsOfFields(ref sTable, bData, tHeader);
            sFileName = dBaseFileName;

            for (int i = 0; i < tHeader.nOfRecords; i++)
            {
                string[] toShoveInRecord = new string[tHeader.nOfFields];
                for (int x = 0; x < tHeader.nOfFields; x++)
                {
                    toShoveInRecord[x] = sTable[i, x];
                }
                rRecords.Add(new Record(toShoveInRecord, tHeader.nFieldLength, ref tHeader));
            }

            bTableIsActuallyLoaded = true;
            dtLastIndexUpdate      = DateTime.Now;
        }
示例#3
0
        /// <summary>
        /// Initialises the record
        /// </summary>
        /// <param name="dataToPutInField">The data to go in fields</param>
        /// <param name="nFieldLengths">The length of each field (number of characters)</param>
        public Record(string[] dataToPutInField, int[] nFieldLengths, ref HeaderData tHeader)
        {
            fieldData = dataToPutInField;
            for (int i = 0; i < fieldData.Length; i++)
            {
                if (tHeader.fFieldTypes[i] == HeaderData.FieldTypes.Numeric)
                {
                    if (fieldData[i].TrimEnd(' ') == "")
                    {
                        fieldData[i] = "0";
                    }
                    else
                    {
                        fieldData[i] = fieldData[i].Replace(".00000", "");
                    }
                    while (fieldData[i].Length < tHeader.nFieldLength[i])
                    {
                        fieldData[i] = " " + fieldData[i];
                    }
                }
                else
                {
                    while (fieldData[i].Length < tHeader.nFieldLength[i])
                    {
                        fieldData[i] += " ";
                    }
                }
            }
            nOfFields  = fieldData.Length;
            recordData = ConvertRecordToBytes(nFieldLengths);
            bChanged   = false;
            TrimEndingZeros();

            trimmedFieldData = new string[fieldData.Length];
            reTrim();
        }
示例#4
0
 /// <summary>
 /// Puts the data passed into the record
 /// </summary>
 /// <param name="dataToEnter">The data to put in the record</param>
 public void PutDataInRecord(string[] dataToEnter, ref HeaderData tHeader)
 {
     bChanged  = true;
     fieldData = dataToEnter;
     for (int i = 0; i < fieldData.Length; i++)
     {
         if (tHeader.fFieldTypes[i] == HeaderData.FieldTypes.Numeric)
         {
             while (fieldData[i].Length != tHeader.nFieldLength[i])
             {
                 fieldData[i] = " " + fieldData[i];
             }
         }
         else
         {
             while (fieldData[i].Length != tHeader.nFieldLength[i])
             {
                 fieldData[i] += " ";
             }
         }
     }
     TrimEndingZeros();
     reTrim();
 }
示例#5
0
 /// <summary>
 /// Initialises the record
 /// </summary>
 /// <param name="CombinedString">A character seperated string containing the field data</param>
 /// <param name="splitChar">The character that splits the fields</param>
 public Record(string CombinedString, char splitChar, ref HeaderData tHeader)
 {
     fieldData = CombinedString.Split(splitChar);
     nOfFields = fieldData.Length;
     TrimEndingZeros();
 }
示例#6
0
 /// <summary>
 /// Initialises the record
 /// </summary>
 /// <param name="commaSeperatedDataToPutInField">A comma seperated string with the field data</param>
 public Record(string commaSeperatedDataToPutInField, ref HeaderData tHeader)
 {
     fieldData = commaSeperatedDataToPutInField.Split(',');
     nOfFields = fieldData.Length;
     TrimEndingZeros();
 }