private void _backup() { count++; if (count >= 100) { RecordEntry r1 = new RecordEntry() { clientName = comboBox1.Text, billableTime = timeDisplay1.Text, actualTime = stopwatches[0].ElapsedTimeSpan, notes = textBox1.Text }; RecordEntry r2 = new RecordEntry() { clientName = comboBox2.Text, billableTime = timeDisplay2.Text, actualTime = stopwatches[1].ElapsedTimeSpan, notes = textBox2.Text }; RecordEntry r3 = new RecordEntry() { clientName = comboBox3.Text, billableTime = timeDisplay3.Text, actualTime = stopwatches[2].ElapsedTimeSpan, notes = textBox3.Text }; RecordEntry r4 = new RecordEntry() { clientName = comboBox4.Text, billableTime = timeDisplay4.Text, actualTime = stopwatches[3].ElapsedTimeSpan, notes = textBox4.Text }; RecordEntry r5 = new RecordEntry() { clientName = comboBox5.Text, billableTime = timeDisplay5.Text, actualTime = stopwatches[4].ElapsedTimeSpan, notes = textBox5.Text }; TimerRecord backupRecord = new TimerRecord() { record1 = r1, record2 = r2, record3 = r3, record4 = r4, record5 = r5 }; BinarySerialization.WriteToBinaryFile<TimerRecord>(_bak_loc + "\\Billable_Time_Backup.bak", backupRecord); count = 0; } }
private void _restore() { if (File.Exists(_bak_loc + "\\Billable_Time_Backup.bak")) { TimerRecord restore = BinarySerialization.ReadFromBinaryFile<TimerRecord>(_bak_loc + "\\Billable_Time_Backup.bak"); comboBox1.Text = restore.record1.clientName; stopwatches[0].ElapsedTimeSpan = restore.record1.actualTime; textBox1.Text = restore.record1.notes; comboBox2.Text = restore.record2.clientName; stopwatches[1].ElapsedTimeSpan = restore.record2.actualTime; textBox2.Text = restore.record2.notes; comboBox3.Text = restore.record3.clientName; stopwatches[2].ElapsedTimeSpan = restore.record3.actualTime; textBox3.Text = restore.record3.notes; comboBox4.Text = restore.record4.clientName; stopwatches[3].ElapsedTimeSpan = restore.record4.actualTime; textBox4.Text = restore.record4.notes; comboBox5.Text = restore.record5.clientName; stopwatches[4].ElapsedTimeSpan = restore.record5.actualTime; textBox5.Text = restore.record5.notes; } }