private void fillDataGrid() { string sql = @"select c.name as Clase,sum(ass.grade) as Nota,sum(a.weight) as Total from student s left join assignment_student ass on s.idStudent=ass.idStudent inner join assignment a on a.idassignment = ass.idassignment inner join course c on c.idcourse=a.idcourse where s.idstudent={0} group by c.idCourse;"; con.Open(); dataGridView1.DataSource = con.SelectTable(String.Format(sql, idStudent)); con.Close(); dataGrabbed = true; DataGridViewColumn dc = new DataGridViewColumn() { Name = "percentGrade", Visible = true, HeaderText = "Promedio", CellTemplate = new DataGridViewTextBoxCell() }; dataGridView1.Columns.Insert(3, dc); //setAverages(); }
private void FillDataGridView() { con.Open(); string sql = @"select c.name as Curso, c.idCourse from course c inner join course_student cs on c.idCourse=cs.idCourse inner join student s on s.idStudent=cs.idCourse where cs.idStudent= " + idStudent + ";"; dataGridView1.DataSource = con.SelectTable(sql); //Fill Tareas con.Close(); dataGridView1.Columns[1].Visible = false; dataGridView1.ClearSelection(); dataGridView1.CurrentCell = null; SelectedCellForeground = dataGridView1.DefaultCellStyle.SelectionForeColor; SelectedCellBackground = dataGridView1.DefaultCellStyle.SelectionBackColor; dataGridView1.DefaultCellStyle.SelectionBackColor = dataGridView1.DefaultCellStyle.BackColor; dataGridView1.DefaultCellStyle.SelectionForeColor = dataGridView1.DefaultCellStyle.ForeColor; }
//string GetUserName() //{ // string name = ""; // string sql = @" select b.firstname,b.lastname from account a // inner join professor b // on a.idProfessor=b.idProfessor // where a.idaccount={0} // union // select b.firstname,b.lastname from account a // inner join student b // on a.idStudent=b.idStudent // where a.idaccount={0};"; // sql = string.Format(sql, idAccount); // try // { // con.Open(); // DataTable dt = con.SelectTable(sql); // name += dt.Rows[0].ItemArray[0].ToString(); // name += " " + dt.Rows[0].ItemArray[1].ToString(); // } // catch (System.Data.SQLite.SQLiteException err) // { // con.Close(); // MessageBox.Show(err.Message.ToString()); // } // catch (System.IndexOutOfRangeException) // { // con.Close(); // con.Open(); // string isAdmin = con.SelectSingle(string.Format("Select isAdmin from account where idaccount={0}",idAccount)); // con.Close(); // if(isAdmin=="True") // { // name = "Administrador"; // } // else // { // name = "Usuario sin nombre. (Si esta leyendo esto, regañe al diseñador de base de dato o el menso del front-end)"; // } // } // finally // { // con.Close(); // } // return name; //} public string GetUserName() { string name = ""; con.Open(); idStudent = con.SelectSingle("select idStudent from account where idAccount =" + idAccount); DataTable tmp = con.SelectTable("select firstname, lastname from student where idStudent = " + idStudent); name = tmp.Rows[0].ItemArray[0].ToString() + ' '; name += tmp.Rows[0].ItemArray[1].ToString(); con.Close(); return(name); }