//Initially fill the listview with employees private void fillListView() { SqlConnection cnn = new SqlConnection(); DBcnn database = new DBcnn(cnn); database.connect(null); database.open(); SqlCommand cmd = new SqlCommand("SELECT EMPLOYEE_ID, LAST_NAME, BACKGROUND FROM EMPLOYEES WHERE TITLE = 'New Hire'", cnn); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); foreach (DataRow dr in dt.Rows) { int id = Convert.ToInt32(dr["EMPLOYEE_ID"]); string lastName = dr["LAST_NAME"].ToString().Trim(' '); string background = dr["BACKGROUND"].ToString().Trim(' '); NewHire newHire = new NewHire(id, lastName, background); newHireList.Add(newHire); } foreach (NewHire newHire in newHireList) { int id = newHire.ID; string lastName = newHire.LastName; string background = newHire.Background; ListViewItem i = new ListViewItem(id.ToString()); i.SubItems.Add(lastName); i.SubItems.Add(background); employeeListView.Items.Add(i); } }
//loads json file private void LoginForm_Load(object sender, EventArgs e) { //this bit of the code will add the items in the json file retrieved from the AWS to our database //create the list that the newhires will be passed to List <Employee> newguys = new List <Employee>(); //create a newhire to get the newhire information from then assigns the it to the newguys list of employees NewHire newHires = new NewHire(); newguys = newHires.getJson(); newHires.add(newguys); }