public async void initGridV()
        {
            List <AssignmentModel> allAssignments = await aS.getAll();

            List <AssignmentModel> assList = new List <AssignmentModel>();

            foreach (AssignmentModel a in allAssignments)
            {
                if (a.LaboratoryID == laboratoryID)
                {
                    assList.Add(a);
                }
            }
            dataGridView1.DataSource = assList;
            dataGridView1.Columns["LaboratoryID"].Visible = false;
            dataGridView1.Columns["ID"].Visible           = false;
            dataGridView1.Columns.Add("", "");
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                var row = dataGridView1.Rows[i];
                DataGridViewButtonCell bAssign = new DataGridViewButtonCell();
                bAssign.Value = "Add submission";
                row.Cells[dataGridView1.ColumnCount - 1] = bAssign;
            }
        }
Beispiel #2
0
        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;
            }
        }