private void BtnCsvInput_Click(object sender, EventArgs e) { DialogResult result = csvOpenFileDialog.ShowDialog(); List <VisitorsInformation> visitorList = new List <VisitorsInformation>(); if (result == DialogResult.OK) { using (var stream = new FileStream(csvOpenFileDialog.FileName, FileMode.Open, FileAccess.Read)) { var cs = new CsvChecker <VisitorsInformation>() { UseTextQualifier = true }; visitorList = cs.ReadFromFile(stream); WriteCheckInDataToFile(visitorList); } } DispInputGridView.Hide(); if (visitorList.Count > 0) { BindingList <VisitorsInformation> bindingList = new BindingList <VisitorsInformation>(visitorList); BindingSource source = new BindingSource(bindingList, null); DispInputGridView.DataSource = source; DispInputGridView.Show(); } }
private void NewEntryBtn_Click(object sender, EventArgs e) { lblMnlInput.Show(); lblMnlInput.Text = "Manual Input"; long ID = Int64.Parse(tempVisitorID.Text); visitorID.Text = (ID + 1).ToString(); tempVisitorID.Text = visitorID.Text; ResetVisitorsEntryForm(); lblMainMsg.Hide(); dispReportPanel.Hide(); newVisitorEntryPanel.Show(); errFirstName.Visible = false; errLastName.Visible = false; errOccupation.Visible = false; errContactNo.Visible = false; errEmailAddress.Visible = false; errAddress.Visible = false; btnSave.Text = "Check In"; TxtInputPanel.Show(); MainGrpBox.Text = "Register Visitors"; if (File.Exists("CheckinsInformation.csv")) { List <VisitorsInformation> list = new List <VisitorsInformation>(); using (Stream stream = new FileStream("CheckinsInformation.csv", FileMode.Open, FileAccess.Read)) { CsvChecker <VisitorsInformation> cs = new CsvChecker <VisitorsInformation>() { UseTextQualifier = true, }; list = cs.ReadFromFile(stream); } BindingList <VisitorsInformation> bindingList = new BindingList <VisitorsInformation>(list); BindingSource source = new BindingSource(bindingList, null); DispInputGridView.DataSource = source; DispInputGridView.Show(); } }