public async void initGridV() { dataGridView1.DataSource = await aS.getAll(); dataGridView1.Columns[0].Visible = false; dataGridView1.Columns[1].Visible = false; dataGridView1.Columns[2].Visible = false; dataGridView1.Columns.Add("Student name", "Student name"); dataGridView1.Columns.Add("Laboratory number", "Laboratory number"); dataGridView1.Columns.Add("", ""); dataGridView1.Columns.Add("", ""); users = await uS.getAll(); List <string> userNames = new List <string>(); foreach (UserModel u in users) { userNames.Add(u.FullName); } usersComboBox.DataSource = userNames; labs = await lS.getAll(); List <int> labNumbers = new List <int>(); foreach (LaboratoryModel l in labs) { labNumbers.Add(l.Number); } LaboratoriesComboBox.DataSource = labNumbers; for (int i = 0; i < dataGridView1.RowCount; i++) { var row = dataGridView1.Rows[i]; UserModel cUsr; int usrID = Int32.Parse(row.Cells["StudentID"].Value.ToString()); cUsr = users.FirstOrDefault(l => l.ID == usrID); row.Cells["Student name"].Value = cUsr.FullName; LaboratoryModel cLab; int labID = Int32.Parse(row.Cells["LaboratoryID"].Value.ToString()); cLab = labs.FirstOrDefault(l => l.ID == labID); row.Cells["Laboratory number"].Value = cLab.Number; DataGridViewButtonCell bEdit = new DataGridViewButtonCell(); bEdit.Value = "edit"; row.Cells[dataGridView1.ColumnCount - 2] = bEdit; DataGridViewButtonCell bDelete = new DataGridViewButtonCell(); bDelete.Value = "delete"; row.Cells[dataGridView1.ColumnCount - 1] = bDelete; } }
public async void initGridV() { dataGridView1.DataSource = await lS.getAll(); dataGridView1.Columns[0].Visible = false; dataGridView1.Columns.Add("", ""); dataGridView1.Columns.Add("", ""); for (int i = 0; i < dataGridView1.RowCount; i++) { var row = dataGridView1.Rows[i]; DataGridViewButtonCell bEdit = new DataGridViewButtonCell(); bEdit.Value = "edit"; row.Cells[dataGridView1.ColumnCount - 2] = bEdit; DataGridViewButtonCell bDelete = new DataGridViewButtonCell(); bDelete.Value = "delete"; row.Cells[dataGridView1.ColumnCount - 1] = bDelete; } }
public async void initGridV(string email) { UserServices uS = new UserServices(); List <UserModel> users = await uS.getAll(); userID = users.FirstOrDefault(u => u.Email == email).ID; List <LaboratoryModel> labs = await lS.getAll(); dataGridView1.DataSource = labs; dataGridView1.Columns["ID"].Visible = false; dataGridView1.Columns.Add("Attended", "Attended"); dataGridView1.Columns.Add("", ""); AttendanceServices aS = new AttendanceServices(); List <AttendanceModel> atts = await aS.getAll(); for (int i = 0; i < dataGridView1.RowCount; i++) { var row = dataGridView1.Rows[i]; DataGridViewButtonCell bAssign = new DataGridViewButtonCell(); bAssign.Value = "See assignments"; row.Cells[dataGridView1.ColumnCount - 1] = bAssign; int labID = Int32.Parse(row.Cells["ID"].Value.ToString()); row.Cells["Attended"].Value = "No"; foreach (AttendanceModel a in atts) { if (a.LaboratoryID == labID) { if (a.StudentID == userID) { row.Cells["Attended"].Value = "Yes"; } } } } }
public async void initGridV() { dataGridView1.DataSource = await aS.getAll(); dataGridView1.Columns[0].Visible = false; dataGridView1.Columns[1].Visible = false; dataGridView1.Columns.Add("Laboratory number", "Laboratory number"); dataGridView1.Columns.Add("", ""); dataGridView1.Columns.Add("", ""); dataGridView1.Columns["Description"].Width = 230; users = await uS.getAll(); assigns = await aS.getAll(); List <string> aNames = new List <string>(); assigns.ForEach(a => aNames.Add(a.Name)); assignmentComboBox.DataSource = aNames; labs = await lS.getAll(); List <int> labNumbers = new List <int>(); foreach (LaboratoryModel l in labs) { labNumbers.Add(l.Number); } labNrComboBox.DataSource = labNumbers; for (int i = 0; i < dataGridView1.RowCount; i++) { var row = dataGridView1.Rows[i]; LaboratoryModel cLab; int labID = Int32.Parse(row.Cells["LaboratoryID"].Value.ToString()); cLab = labs.FirstOrDefault(l => l.ID == labID); row.Cells["Laboratory number"].Value = cLab.Number; DataGridViewButtonCell bEdit = new DataGridViewButtonCell(); bEdit.Value = "edit"; row.Cells[dataGridView1.ColumnCount - 2] = bEdit; DataGridViewButtonCell bDelete = new DataGridViewButtonCell(); bDelete.Value = "delete"; row.Cells[dataGridView1.ColumnCount - 1] = bDelete; } }
public async void refreshGridV() { dataGridView1.DataSource = null; dataGridView1.Rows.Clear(); dataGridView1.Columns.Clear(); dataGridView1.Refresh(); dataGridView1.DataSource = await aS.getAll(); dataGridView1.Columns[0].Visible = false; dataGridView1.Columns[1].Visible = false; dataGridView1.Columns.Add("Laboratory number", "Laboratory number"); dataGridView1.Columns.Add("", ""); dataGridView1.Columns.Add("", ""); dataGridView1.Columns["Description"].Width = 230; assigns = await aS.getAll(); var lS = new LaboratoryServices(); for (int i = 0; i < dataGridView1.RowCount; i++) { var row = dataGridView1.Rows[i]; List <LaboratoryModel> labs = await lS.getAll(); LaboratoryModel cLab; int labID = Int32.Parse(row.Cells[1].Value.ToString()); cLab = labs.FirstOrDefault(l => l.ID == labID); row.Cells["Laboratory number"].Value = cLab.Number; DataGridViewButtonCell bEdit = new DataGridViewButtonCell(); bEdit.Value = "edit"; row.Cells[dataGridView1.ColumnCount - 2] = bEdit; DataGridViewButtonCell bDelete = new DataGridViewButtonCell(); bDelete.Value = "delete"; row.Cells[dataGridView1.ColumnCount - 1] = bDelete; } }