/// <summary> /// Add or update people in the people file /// </summary> private void AddUpdatePeopleFile_Click(object sender, EventArgs e) { try { openFileDialog1.FileName = PeopleFile.Text; openFileDialog1.Filter = "Microsoft Excel Files (*.xls;*.xlsx)|*.xls;*.xlsx|Comma-delimited Text Files (*.csv)|*.csv|All files (*.*)|*.*"; openFileDialog1.Title = "Select the People file to use for adding/updating"; openFileDialog1.CheckFileExists = true; openFileDialog1.CheckPathExists = true; DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.Cancel) { return; } Database DB = new Database(DSN.Text); int Count = PeopleMaintenance.AddUpdate(DB, openFileDialog1.FileName); UpdateDatabaseStatus(); SetGUIEnabled(true); MessageBox.Show("Added/updated " + Count.ToString() + " people", "Add/Update Successful"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Unable to add/update people", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void TestAddUpdate() { ResetDatabase(); // Add/update the rows in "TestPeople/input1.xls" int Count = PeopleMaintenance.AddUpdate(DB, AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPeople\\input1.xls" ); Assert.AreEqual(Count, 4); VerifyAddUpdateResults(); // Delete the rows in "different setnb.xls", verify that nothing happened PeopleMaintenance.Remove(DB, AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPeopleMaintenance\\different setnb.xls" ); VerifyAddUpdateResults(); }