Beispiel #1
0
        private void cmdNext_Click(object sender, EventArgs e)
        {
            if (EntryData.Count == 0)
            {
                MessageBox.Show("Nu exista nici o masina in asteptare!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            EntryData[0].dateEntry = DateTime.Now;
            AddEntryToCompleted(EntryData[0]);

            using (FixedObjectFileStream stream = new FixedObjectFileStream(dataFile, FileMode.Open, FileAccess.ReadWrite)) {
                stream.RemoveAt(0);
            }

            if (EntryData != null)
            {
                EntryData.RemoveAt(0);
                AutoIncrementNrCrt = EntryData.Count == 0 ? 1 : EntryData.Last().nrCrt + 1;
                lstTruckOrder.Items.RemoveAt(0);

                foreach (TruckInfo ti in EntryData)
                {
                    lstTruckOrder.Items[--ti.nrCrt - 1].SubItems[0].Text = ti.nrCrt.ToString();
                }
            }
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("EntryData"));
        }
Beispiel #2
0
 private void AddSkipToFile(TruckInfo entry)
 {
     using (FixedObjectFileStream fos = new FixedObjectFileStream(skipFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, true)) {
         entry.nrCrt = fos.NumberOfObjects + 1;
         fos.Add(entry);
     }
 }
Beispiel #3
0
        private void cmdRemTruck_Click(object sender, EventArgs e)
        {
            if (lstTruckOrder.SelectedItems.Count == 1)
            {
                using (FixedObjectFileStream stream = new FixedObjectFileStream(dataFile, FileMode.Open, FileAccess.ReadWrite)) {
                    stream.RemoveAt(lstTruckOrder.SelectedIndices[0]);

                    if (EntryData != null)
                    {
                        foreach (TruckInfo ti in EntryData.Skip(lstTruckOrder.SelectedIndices[0] + 1))
                        {
                            lstTruckOrder.Items[--ti.nrCrt].SubItems[0].Text = ti.nrCrt.ToString();
                        }
                    }
                }

                if (EntryData != null)
                {
                    EntryData.RemoveAt(lstTruckOrder.SelectedIndices[0]);
                    AutoIncrementNrCrt = EntryData.Count == 0 ? 1 : EntryData.Last().nrCrt + 1;
                }
                if (lstTruckOrder != null)
                {
                    lstTruckOrder.Items.Remove(lstTruckOrder.SelectedItems[0]);
                }

                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("EntryData"));
                }
            }
        }
Beispiel #4
0
        private void AddEntryToCompleted(TruckInfo entry)
        {
            if (!File.Exists(completedFile))
            {
                Stream s = File.Create(completedFile);
                s.Write(BitConverter.GetBytes(0), 0, 4);
                s.Close();
            }

            using (FixedObjectFileStream stream = new FixedObjectFileStream(completedFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, true)) {
                entry.nrCrt = stream.NumberOfObjects + 1;
                stream.Add(entry);
            }
        }
Beispiel #5
0
 private void LoadList(IList <TruckInfo> list, string filePath, Action <TruckInfo> callback)
 {
     if (File.Exists(filePath))
     {
         using (FixedObjectFileStream stream = new FixedObjectFileStream(filePath, FileMode.Open, FileAccess.ReadWrite)) {
             for (int i = 0; i < stream.Length; i++)
             {
                 TruckInfo ti = stream[i];
                 list.Add(ti);
                 callback?.Invoke(ti);
             }
         }
     }
 }
Beispiel #6
0
 private void AddEntryToFile(TruckInfo entry, bool first = false)
 {
     using (FixedObjectFileStream fos = new FixedObjectFileStream(dataFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, true)) {
         if (first)
         {
             fos.Insert(0, entry);
             for (int i = 1; i < fos.NumberOfObjects; i++)
             {
                 var e = fos[i];
                 e.nrCrt++;
                 fos[i] = e;
             }
         }
         else
         {
             fos.Add(entry);
         }
     }
 }
Beispiel #7
0
        private void cmdReturnToList_Click(object sender, EventArgs e)
        {
            if (lstSkip.SelectedItems.Count == 1)
            {
                var entry = SkipData[lstSkip.SelectedIndices[0]];
                entry.nrCrt = 1;

                entry.dateReturn = DateTime.Now;
                RestoreToList(entry);
                AddEntryToFile(entry, true);
                EntryData.Insert(0, entry);
                EntryData[0].nrCrt = 0;

                foreach (TruckInfo ti in EntryData)
                {
                    lstTruckOrder.Items[ti.nrCrt].SubItems[0].Text = (++ti.nrCrt).ToString();
                }

                using (FixedObjectFileStream stream = new FixedObjectFileStream(skipFile, FileMode.Open, FileAccess.ReadWrite)) {
                    stream.RemoveAt(lstSkip.SelectedIndices[0]);

                    if (SkipData != null)
                    {
                        foreach (TruckInfo ti in SkipData.Skip(lstSkip.SelectedIndices[0] + 1))
                        {
                            lstSkip.Items[--ti.nrCrt].SubItems[0].Text = ti.nrCrt.ToString();
                        }
                    }
                }

                if (SkipData != null)
                {
                    SkipData.RemoveAt(lstSkip.SelectedIndices[0]);
                }
                if (lstSkip != null)
                {
                    lstSkip.Items.Remove(lstSkip.SelectedItems[0]);
                }

                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("EntryData"));
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SkipData"));
            }
        }
Beispiel #8
0
        private void cmdSkip_Click(object sender, EventArgs e)
        {
            if (EntryData.Count == 0)
            {
                MessageBox.Show("Nu exista nici o masina in asteptare!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            var         entry = EntryData[0];
            CommentForm cForm = new CommentForm();

            cForm.Comment = entry.comments;
            cForm.ShowDialog();
            if (cForm.DialogResult == DialogResult.OK)
            {
                entry.comments = cForm.Comment;
            }
            entry.dateSkip = DateTime.Now;
            AddSkipToFile(entry);
            AddToSkipList(entry);
            SkipData.Add(entry);
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SkipData"));

            using (FixedObjectFileStream stream = new FixedObjectFileStream(dataFile, FileMode.Open, FileAccess.ReadWrite)) {
                stream.RemoveAt(0);
            }

            if (EntryData != null)
            {
                EntryData.RemoveAt(0);
                AutoIncrementNrCrt = EntryData.Count == 0 ? 1 : EntryData.Last().nrCrt + 1;
                lstTruckOrder.Items.RemoveAt(0);

                foreach (TruckInfo ti in EntryData)
                {
                    lstTruckOrder.Items[--ti.nrCrt - 1].SubItems[0].Text = ti.nrCrt.ToString();
                }
            }
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("EntryData"));
        }
Beispiel #9
0
 private void AddEntryToFile(TruckInfo entry, bool first = false)
 {
     using (FixedObjectFileStream fos = new FixedObjectFileStream(dataFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, true)) {
         if (first) {
             fos.Insert(0, entry);
             for (int i = 1; i < fos.NumberOfObjects; i++) {
                 var e = fos[i];
                 e.nrCrt++;
                 fos[i] = e;
             }
         } else
             fos.Add(entry);
     }
 }
Beispiel #10
0
 private void LoadList(IList<TruckInfo> list, string filePath, Action<TruckInfo> callback)
 {
     if (File.Exists(filePath)) {
         using (FixedObjectFileStream stream = new FixedObjectFileStream(filePath, FileMode.Open, FileAccess.ReadWrite)) {
             for (int i = 0; i < stream.Length; i++) {
                 TruckInfo ti = stream[i];
                 list.Add(ti);
                 callback?.Invoke(ti);
             }
         }
     }
 }
Beispiel #11
0
        private void CreateRaport(DateTime rDate, string file)
        {
            if (!File.Exists(completedFile)) {
                MessageBox.Show("Fisierul in care se stocheaza istoricul intrarilor nu a fost gasit.\nDaca este prima folosire a aplicatiei si nu s-a folosit niciodata functia Urmatorul, totul este in regula.\nIn caz contrar anuntati administratorul.", "Nu s-a putut crea raportul", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            string dataRaport = rDate.ToString("dd.MM.yyyy");

            FileInfo fileInfo = new FileInfo(file);
            fileInfo.Directory.Create();

            Microsoft.Office.Interop.Excel.Application excelApp = null;
            _Workbook excelWb = null;
            try {
                excelApp = new Microsoft.Office.Interop.Excel.Application();
                excelApp.DisplayAlerts = false;
                excelApp.Visible = false;
                excelApp.UserControl = false;
                excelWb = excelApp.Workbooks.Add("");
                _Worksheet excelWs = excelWb.ActiveSheet;

                excelWs.Range[excelWs.Cells[1, 1], excelWs.Cells[1, 5]].Merge();

                excelWs.Cells[1, 1] = "Raport pentru ziua: " + dataRaport;

                excelWs.Cells[3, 1] = "Nr. Crt.";
                AddBorder(excelWs.Cells[3, 1], XlBorderWeight.xlThick);

                excelWs.Cells[3, 2] = "Nr. Auto";
                AddBorder(excelWs.Cells[3, 2], XlBorderWeight.xlThick);

                excelWs.Cells[3, 3] = "Marfa";
                AddBorder(excelWs.Cells[3, 3], XlBorderWeight.xlThick);

                excelWs.Cells[3, 4] = "Data Inregistrare";
                AddBorder(excelWs.Cells[3, 4], XlBorderWeight.xlThick);

                excelWs.Cells[3, 5] = "Data Intrare";
                AddBorder(excelWs.Cells[3, 5], XlBorderWeight.xlThick);

                excelWs.Cells[3, 6] = "Data Sarit";
                AddBorder(excelWs.Cells[3, 6], XlBorderWeight.xlThick);

                excelWs.Cells[3, 7] = "Data Intoarcere";
                AddBorder(excelWs.Cells[3, 7], XlBorderWeight.xlThick);

                excelWs.Cells[3, 8] = "Comentarii";
                AddBorder(excelWs.Cells[3, 8], XlBorderWeight.xlThick);

                int i = 1;

                using (FixedObjectFileStream stream = new FixedObjectFileStream(completedFile, FileMode.Open, FileAccess.ReadWrite)) {
                    for (int j = 0; j < stream.Length; j++) {
                        TruckInfo ti = stream[j];

                        if (ti.dateRegistered.ToString("dd.MM.yyyy") != dataRaport)
                            continue;

                        excelWs.Cells[3 + i, 1] = i;
                        excelWs.Cells[3 + i, 2] = ti.nrAuto;
                        excelWs.Cells[3 + i, 3] = ti.payload;
                        excelWs.Cells[3 + i, 4] = ti.dateRegistered;
                        excelWs.Cells[3 + i, 5] = ti.dateEntry;
                        excelWs.Cells[3 + i, 6] = ti.dateSkip == DateTime.MinValue ? "" : ti.dateSkip.ToString("HH:mm:ss dd.MM.yyyy");
                        excelWs.Cells[3 + i, 7] = ti.dateReturn == DateTime.MinValue ? "" : ti.dateReturn.ToString("HH:mm:ss dd.MM.yyyy");
                        excelWs.Cells[3 + i, 8] = ti.comments;
                        i++;
                    }
                }

                if (i != 1)
                    AddBorder(excelWs.get_Range("A4", "H" + (i + 2)), XlBorderWeight.xlThin, true, true);
                else {
                    // Nu avem nimic de raportat. ABORT
                    MessageBox.Show("Raportul pe data " + dataRaport + " este gol. Raportul nu a fost salvat.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    excelWb.Close(false, Type.Missing, Type.Missing);
                    excelApp.Quit();
                    return;
                }

                Range r = excelWs.Range[excelWs.Cells[1, 1], excelWs.Cells[1, 6]];
                r.EntireColumn.AutoFit();
                r.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                foreach (Range rr in r.Columns) {
                    rr.ColumnWidth = rr.ColumnWidth + 2;
                }

                r = excelWs.get_Range("A3", "H" + (i + 2));
                r.HorizontalAlignment = XlHAlign.xlHAlignCenter;

                excelWb.SaveAs(file, XlFileFormat.xlWorkbookDefault, Type.Missing, Type.Missing,
                                false, false, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

                excelWb.Close(false, Type.Missing, Type.Missing);
                excelApp.Quit();

            } catch (Exception ex) {
                MessageBox.Show("Salvarea raportului a esuat!\nMessage: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                if (excelWb != null)
                    excelWb.Close(false, Type.Missing, Type.Missing);
                if (excelApp != null)
                    excelApp.Quit();
            }
        }
Beispiel #12
0
        private void cmdSkip_Click(object sender, EventArgs e)
        {
            if (EntryData.Count == 0) {
                MessageBox.Show("Nu exista nici o masina in asteptare!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            var entry = EntryData[0];
            CommentForm cForm = new CommentForm();
            cForm.Comment = entry.comments;
            cForm.ShowDialog();
            if (cForm.DialogResult == DialogResult.OK) {
                entry.comments = cForm.Comment;
            }
            entry.dateSkip = DateTime.Now;
            AddSkipToFile(entry);
            AddToSkipList(entry);
            SkipData.Add(entry);
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SkipData"));

            using (FixedObjectFileStream stream = new FixedObjectFileStream(dataFile, FileMode.Open, FileAccess.ReadWrite)) {
                stream.RemoveAt(0);
            }

            if (EntryData != null) {
                EntryData.RemoveAt(0);
                AutoIncrementNrCrt = EntryData.Count == 0 ? 1 : EntryData.Last().nrCrt + 1;
                lstTruckOrder.Items.RemoveAt(0);

                foreach (TruckInfo ti in EntryData)
                    lstTruckOrder.Items[--ti.nrCrt - 1].SubItems[0].Text = ti.nrCrt.ToString();
            }
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("EntryData"));
        }
Beispiel #13
0
        private void cmdReturnToList_Click(object sender, EventArgs e)
        {
            if (lstSkip.SelectedItems.Count == 1) {
                var entry = SkipData[lstSkip.SelectedIndices[0]];
                entry.nrCrt = 1;

                entry.dateReturn = DateTime.Now;
                RestoreToList(entry);
                AddEntryToFile(entry, true);
                EntryData.Insert(0, entry);
                EntryData[0].nrCrt = 0;

                foreach (TruckInfo ti in EntryData)
                    lstTruckOrder.Items[ti.nrCrt].SubItems[0].Text = (++ti.nrCrt).ToString();

                using (FixedObjectFileStream stream = new FixedObjectFileStream(skipFile, FileMode.Open, FileAccess.ReadWrite)) {
                    stream.RemoveAt(lstSkip.SelectedIndices[0]);

                    if (SkipData != null)
                        foreach (TruckInfo ti in SkipData.Skip(lstSkip.SelectedIndices[0] + 1))
                            lstSkip.Items[--ti.nrCrt].SubItems[0].Text = ti.nrCrt.ToString();
                }

                if (SkipData != null) {
                    SkipData.RemoveAt(lstSkip.SelectedIndices[0]);
                }
                if (lstSkip != null)
                    lstSkip.Items.Remove(lstSkip.SelectedItems[0]);

                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("EntryData"));
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SkipData"));
            }
        }
Beispiel #14
0
        private void cmdRemTruck_Click(object sender, EventArgs e)
        {
            if (lstTruckOrder.SelectedItems.Count == 1) {
                using (FixedObjectFileStream stream = new FixedObjectFileStream(dataFile, FileMode.Open, FileAccess.ReadWrite)) {
                    stream.RemoveAt(lstTruckOrder.SelectedIndices[0]);

                    if (EntryData != null)
                        foreach (TruckInfo ti in EntryData.Skip(lstTruckOrder.SelectedIndices[0] + 1))
                            lstTruckOrder.Items[--ti.nrCrt].SubItems[0].Text = ti.nrCrt.ToString();
                }

                if (EntryData != null) {
                    EntryData.RemoveAt(lstTruckOrder.SelectedIndices[0]);
                    AutoIncrementNrCrt = EntryData.Count == 0 ? 1 : EntryData.Last().nrCrt + 1;
                }
                if (lstTruckOrder != null)
                    lstTruckOrder.Items.Remove(lstTruckOrder.SelectedItems[0]);

                if (PropertyChanged != null) {
                    PropertyChanged(this, new PropertyChangedEventArgs("EntryData"));
                }
            }
        }
Beispiel #15
0
        private void cmdNext_Click(object sender, EventArgs e)
        {
            if (EntryData.Count == 0) {
                MessageBox.Show("Nu exista nici o masina in asteptare!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            EntryData[0].dateEntry = DateTime.Now;
            AddEntryToCompleted(EntryData[0]);

            using (FixedObjectFileStream stream = new FixedObjectFileStream(dataFile, FileMode.Open, FileAccess.ReadWrite)) {
                stream.RemoveAt(0);
            }

            if (EntryData != null) {
                EntryData.RemoveAt(0);
                AutoIncrementNrCrt = EntryData.Count == 0 ? 1 : EntryData.Last().nrCrt + 1;
                lstTruckOrder.Items.RemoveAt(0);

                foreach (TruckInfo ti in EntryData)
                    lstTruckOrder.Items[--ti.nrCrt - 1].SubItems[0].Text = ti.nrCrt.ToString();
            }
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("EntryData"));
        }
Beispiel #16
0
 private void AddSkipToFile(TruckInfo entry)
 {
     using (FixedObjectFileStream fos = new FixedObjectFileStream(skipFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, true)) {
         entry.nrCrt = fos.NumberOfObjects + 1;
         fos.Add(entry);
     }
 }
Beispiel #17
0
        private void CreateRaport(DateTime rDate, string file)
        {
            if (!File.Exists(completedFile))
            {
                MessageBox.Show("Fisierul in care se stocheaza istoricul intrarilor nu a fost gasit.\nDaca este prima folosire a aplicatiei si nu s-a folosit niciodata functia Urmatorul, totul este in regula.\nIn caz contrar anuntati administratorul.", "Nu s-a putut crea raportul", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            string dataRaport = rDate.ToString("dd.MM.yyyy");

            FileInfo fileInfo = new FileInfo(file);

            fileInfo.Directory.Create();

            Microsoft.Office.Interop.Excel.Application excelApp = null;
            _Workbook excelWb = null;

            try {
                excelApp = new Microsoft.Office.Interop.Excel.Application();
                excelApp.DisplayAlerts = false;
                excelApp.Visible       = false;
                excelApp.UserControl   = false;
                excelWb = excelApp.Workbooks.Add("");
                _Worksheet excelWs = excelWb.ActiveSheet;

                excelWs.Range[excelWs.Cells[1, 1], excelWs.Cells[1, 5]].Merge();


                excelWs.Cells[1, 1] = "Raport pentru ziua: " + dataRaport;

                excelWs.Cells[3, 1] = "Nr. Crt.";
                AddBorder(excelWs.Cells[3, 1], XlBorderWeight.xlThick);

                excelWs.Cells[3, 2] = "Nr. Auto";
                AddBorder(excelWs.Cells[3, 2], XlBorderWeight.xlThick);

                excelWs.Cells[3, 3] = "Marfa";
                AddBorder(excelWs.Cells[3, 3], XlBorderWeight.xlThick);

                excelWs.Cells[3, 4] = "Data Inregistrare";
                AddBorder(excelWs.Cells[3, 4], XlBorderWeight.xlThick);

                excelWs.Cells[3, 5] = "Data Intrare";
                AddBorder(excelWs.Cells[3, 5], XlBorderWeight.xlThick);

                excelWs.Cells[3, 6] = "Data Sarit";
                AddBorder(excelWs.Cells[3, 6], XlBorderWeight.xlThick);

                excelWs.Cells[3, 7] = "Data Intoarcere";
                AddBorder(excelWs.Cells[3, 7], XlBorderWeight.xlThick);

                excelWs.Cells[3, 8] = "Comentarii";
                AddBorder(excelWs.Cells[3, 8], XlBorderWeight.xlThick);

                int i = 1;

                using (FixedObjectFileStream stream = new FixedObjectFileStream(completedFile, FileMode.Open, FileAccess.ReadWrite)) {
                    for (int j = 0; j < stream.Length; j++)
                    {
                        TruckInfo ti = stream[j];

                        if (ti.dateRegistered.ToString("dd.MM.yyyy") != dataRaport)
                        {
                            continue;
                        }

                        excelWs.Cells[3 + i, 1] = i;
                        excelWs.Cells[3 + i, 2] = ti.nrAuto;
                        excelWs.Cells[3 + i, 3] = ti.payload;
                        excelWs.Cells[3 + i, 4] = ti.dateRegistered;
                        excelWs.Cells[3 + i, 5] = ti.dateEntry;
                        excelWs.Cells[3 + i, 6] = ti.dateSkip == DateTime.MinValue ? "" : ti.dateSkip.ToString("HH:mm:ss dd.MM.yyyy");
                        excelWs.Cells[3 + i, 7] = ti.dateReturn == DateTime.MinValue ? "" : ti.dateReturn.ToString("HH:mm:ss dd.MM.yyyy");
                        excelWs.Cells[3 + i, 8] = ti.comments;
                        i++;
                    }
                }

                if (i != 1)
                {
                    AddBorder(excelWs.get_Range("A4", "H" + (i + 2)), XlBorderWeight.xlThin, true, true);
                }
                else
                {
                    // Nu avem nimic de raportat. ABORT
                    MessageBox.Show("Raportul pe data " + dataRaport + " este gol. Raportul nu a fost salvat.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    excelWb.Close(false, Type.Missing, Type.Missing);
                    excelApp.Quit();
                    return;
                }

                Range r = excelWs.Range[excelWs.Cells[1, 1], excelWs.Cells[1, 6]];
                r.EntireColumn.AutoFit();
                r.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                foreach (Range rr in r.Columns)
                {
                    rr.ColumnWidth = rr.ColumnWidth + 2;
                }

                r = excelWs.get_Range("A3", "H" + (i + 2));
                r.HorizontalAlignment = XlHAlign.xlHAlignCenter;



                excelWb.SaveAs(file, XlFileFormat.xlWorkbookDefault, Type.Missing, Type.Missing,
                               false, false, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

                excelWb.Close(false, Type.Missing, Type.Missing);
                excelApp.Quit();
            } catch (Exception ex) {
                MessageBox.Show("Salvarea raportului a esuat!\nMessage: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                if (excelWb != null)
                {
                    excelWb.Close(false, Type.Missing, Type.Missing);
                }
                if (excelApp != null)
                {
                    excelApp.Quit();
                }
            }
        }
Beispiel #18
0
        private void AddEntryToCompleted(TruckInfo entry)
        {
            if (!File.Exists(completedFile)) {
                Stream s = File.Create(completedFile);
                s.Write(BitConverter.GetBytes(0), 0, 4);
                s.Close();
            }

            using (FixedObjectFileStream stream = new FixedObjectFileStream(completedFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, true)) {
                entry.nrCrt = stream.NumberOfObjects + 1;
                stream.Add(entry);
            }
        }