private void LoadData() { EntryData.Clear(); SkipData.Clear(); LoadList(EntryData, dataFile, (ti) => { AddToList(ti); AutoIncrementNrCrt = ti.nrCrt + 1; }); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("EntryData")); LoadList(SkipData, skipFile, (ti) => { AddToSkipList(ti); }); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SkipData")); }
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")); } }
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")); }