Exemplo n.º 1
0
        private void FillTheDatagrid()
        {
            //fill the datagrid view

            originalTable = accountMgr.ReturnWholeAccountTable();

            DataTable showTable = new DataTable();

            showTable.Columns.Add("Name");
            showTable.Columns.Add("Job");
            showTable.Columns.Add("Email");
            showTable.Columns.Add("Superviser");

            foreach (DataRow dr in originalTable.Rows)
            {
                DataRow rowForShow = showTable.NewRow();
                rowForShow["Name"] = dr["accountName"];


                JobDescription jobD = (JobDescription)int.Parse(dr["job"].ToString());
                rowForShow["Job"] = jobD.ToString();

                rowForShow["Email"] = dr["email"];

                int superviser = int.Parse(dr["superviser"].ToString());
                foreach (DataRow dr2 in originalTable.Rows)
                {
                    if (int.Parse(dr2["id"].ToString()) == superviser)
                    {
                        rowForShow["Superviser"] = dr2["accountName"];
                    }
                }
                showTable.Rows.Add(rowForShow);

                dataGridView1.DataSource = showTable;
            }
        }