private void NextButton_Click(object sender, RoutedEventArgs e) { try { if (FCB.IorO() == IOState.IO) { FCB.updateRecCancel(); } //FCB.seekRec(1, 1); //CurrentSector++; BackButton.IsEnabled = true; if (GoToIntegerUpDown.Value >= FCB.GetFileDescription().EofRecNr) { NextButton.IsEnabled = false; } GoToIntegerUpDown.Value++; GoTo(); } catch (Exception exp) { ErrorHandling.ShowError(exp.Message); NextButton.IsEnabled = false; } }
private void BackButton_Click(object sender, RoutedEventArgs e) { try { if (FCB.IorO() == IOState.IO) { FCB.updateRecCancel(); } //FCB.seekRec(1, -1); //CurrentSector--; GoToIntegerUpDown.Value--; NextButton.IsEnabled = true; if (GoToIntegerUpDown.Value <= 0) { GoToIntegerUpDown.Value = 0; BackButton.IsEnabled = false; } GoTo(); } catch (Exception exp) { ErrorHandling.ShowError(exp.Message); BackButton.IsEnabled = false; } }
private void ReadRecord() { ((IRecordUserControl)RecordDetailsStackPanel.Children[0]).ClearFields(); if (GoToIntegerUpDown.Value != FCB.GetFileDescription().EofRecNr) { switch (FCB.IorO()) { case IOState.IO: if (IsStore()) { Store temp = new Store(); FCB.readRec(temp, 1); ((IRecordUserControl)RecordDetailsStackPanel.Children[0]).Record = temp; } else if (IsProduct()) { Product temp = new Product(); FCB.readRec(temp, 1); ((IRecordUserControl)RecordDetailsStackPanel.Children[0]).Record = temp; } else if (IsEmployee()) { Employee temp = new Employee(); FCB.readRec(temp, 1); ((IRecordUserControl)RecordDetailsStackPanel.Children[0]).Record = temp; } break; case IOState.O: if (IsStore()) { Store temp = new Store(); FCB.readRec(temp); ((IRecordUserControl)RecordDetailsStackPanel.Children[0]).Record = temp; } else if (IsProduct()) { Product temp = new Product(); FCB.readRec(temp); ((IRecordUserControl)RecordDetailsStackPanel.Children[0]).Record = temp; } else if (IsEmployee()) { Employee temp = new Employee(); FCB.readRec(temp); ((IRecordUserControl)RecordDetailsStackPanel.Children[0]).Record = temp; } break; default: throw new Exception("Unknown format to read/write from file."); } } }
private void FirstButton_Click(object sender, RoutedEventArgs e) { try { if (FCB.IorO() == IOState.IO) { FCB.updateRecCancel(); } //InitData(); GoToIntegerUpDown.Value = 0; GoTo(); } catch (Exception exp) { ErrorHandling.ShowError(exp.Message); } }
private void LastButton_Click(object sender, RoutedEventArgs e) { try { if (FCB.IorO() == IOState.IO) { FCB.updateRecCancel(); } //FCB.seekRec(0, (int)FCB.GetFileDescription().FileAddr - 4 + (int)FCB.GetFileDescription().EofRecNr - 1); // FCB.seekRec(0, (int)FCB.GetFileDescription().EofRecNr - 1); GoToIntegerUpDown.Value = (int)FCB.GetFileDescription().EofRecNr; GoTo(); NextButton.IsEnabled = false; BackButton.IsEnabled = true; } catch (Exception exp) { ErrorHandling.ShowError(exp.Message); } }
private void GoTo() { try { if (GoToIntegerUpDown.Value > MaxRecord) { GoToIntegerUpDown.Value = MaxRecord; throw new Exception("GoTo value too high"); } if (FCB.IorO() == IOState.IO) { FCB.updateRecCancel(); } FCB.seekRec(0, (int)GoToIntegerUpDown.Value); CurrentRecordNumber = GoToIntegerUpDown.Value; //if (CurrentSector == FCB.GetFileDescription().EofRecNr) NextButton.IsEnabled = false; //else //{ if (GoToIntegerUpDown.Value == 0) { BackButton.IsEnabled = false; } else { BackButton.IsEnabled = true; } NextButton.IsEnabled = true; //} ReadRecord(); } catch (Exception exp) { ErrorHandling.ShowError(exp.Message); } }
private void InitAvailableButtons() { try { switch (FCB.IorO()) { case IOState.IO: SaveButton.IsEnabled = true; CencelButton.IsEnabled = true; break; case IOState.O: ((IRecordUserControl)RecordDetailsStackPanel.Children[0]).DisableControls(); break; case IOState.E: AddButton.IsEnabled = true; CencelButton.IsEnabled = true; LastButton.IsEnabled = false; BackButton.IsEnabled = false; GoToButton.IsEnabled = false; GoToIntegerUpDown.IsEnabled = false; NextButton.IsEnabled = false; FirstButton.IsEnabled = false; break; default: throw new Exception("Unknown format to read/write from file."); } } catch (Exception exp) { ErrorHandling.ShowError(exp.Message); this.Close(); } }