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); }
private void Login() { SQLiteConnector con = new SQLiteConnector(); string username = textUser.Text.ToUpper(); string password = textPassword.Text; if (username == "" || password == "") { MessageBox.Show("Debe llenar ambos campos.", "Campos Vacios", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string sql = @"select idAccount from Account where username='******' and password='******';"; string idAccount = ""; try { con.Open(); idAccount = con.SelectSingle(sql); sql = @"select idProfessor from account where idAccount=" + idAccount; if (con.SelectSingle(sql) == "") { sql = @"select idStudent from account where idAccount=" + idAccount; if (con.SelectSingle(sql) == "") { con.Close(); Admin.AdminMain main = new Admin.AdminMain(this); // TODO: implemenent admin screen main.Show(); } else { con.Close(); FormMainStudent main = new FormMainStudent(this, idAccount); main.Show(); } } else { con.Close(); FormsProfesor.FormProfessor main = new FormsProfesor.FormProfessor(this, idAccount); // TODO: implemenent teacher screen main.Show(); } con.Close(); this.Hide(); } catch (System.Data.SQLite.SQLiteException err) { //MessageBox.Show(err.Message.ToString()); Console.WriteLine(err.Message); } catch (System.IndexOutOfRangeException) { MessageBox.Show("Usuario o contraseña incorrecta", "Credenciales Inválidas", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { con.Close(); } }