Ejemplo n.º 1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            dataGridView1.DefaultCellStyle.SelectionBackColor = SelectedCellBackground;
            dataGridView1.DefaultCellStyle.SelectionForeColor = SelectedCellForeground;
            selectedCourse  = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
            labelTitle.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();

            string sql = "select description from course where idcourse =" + selectedCourse + ";";

            con.Open();
            labelDesc.Text  = con.SelectSingle(sql);
            labelProfe.Text = "Prof. " + con.SelectSingle("select p.lastname from professor p inner join course c on c.idprofessor = p.idprofessor where c.idCourse=" + selectedCourse + ";");
            con.Close();

            FillHWDataGridView();
            FillForosDataGridView();
        }
Ejemplo n.º 2
0
        //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);
        }
Ejemplo n.º 3
0
        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();
            }
        }