public List<Record> findByEndDate(DateTime intervalStart, DateTime intervalEnd) { StreamReader reader = File.OpenText(filePath); string tempLine = reader.ReadLine(); string[] sep = { ";" }; List<Record> resultSet = new List<Record>(); while (!String.IsNullOrEmpty(tempLine)) { String[] valueArr = tempLine.Split(sep, StringSplitOptions.None); Record tempRecord = new Record(valueArr[0], valueArr[1], valueArr[2], valueArr[3], DateTime.Parse(valueArr[4]), valueArr[5]); if ((tempRecord.AccountEndDate > intervalStart) && (tempRecord.AccountEndDate < intervalEnd)) { resultSet.Add(new Record(tempRecord.UserName, tempRecord.FirstName, tempRecord.LastName, tempRecord.Department, tempRecord.AccountEndDate, tempRecord.TelephoneNumber)); } tempLine = reader.ReadLine(); } return resultSet; ; }
private void button1_Click(object sender, EventArgs e) { string phone = PhoneCountryCode.Text + " " + PhoneAreaCode.Text + " " + PhoneNumber.Text; Record tempRecord = new Record(UserName.Text, FirstName.Text, LastName.Text, Department.Text, AccountEndDate.Value, phone); if (!FormValidation()) { return; } if (saveData(tempRecord)) { MessageBox.Show("Success!!!", "Congratulations"); } }
public bool saveData(Record record) { StringBuilder csv = new StringBuilder(); csv.Append(record.UserName); csv.Append(";"); csv.Append(record.FirstName); csv.Append(";"); csv.Append(record.LastName); csv.Append(";"); csv.Append(record.Department); csv.Append(";"); csv.Append(record.AccountEndDatestr); csv.Append(";"); csv.Append(record.TelephoneNumber); csv.Append("\n"); File.AppendAllText(filePath, csv.ToString()); return true; }