Exemple #1
0
 void setMax()
 {
     con.Open();
     max           = con.SelectSingle("Select weight from assignment where idassignment = " + idAssignment + ";");
     labelMax.Text = "(Máximo de " + max + ")";
     con.Close();
     numericUpDown1.Maximum = Convert.ToDecimal(max);
 }
Exemple #2
0
        public void fillDataGridTrabajos()
        {
            string sql = @"select ass.idStudent as Matricula, s.firstname as Nombre, s.lastname as Apellido, ass.completed as Entregado, ass.grade as Calificación
    from student s inner join assignment_student ass on s.idStudent=ass.idStudent
where idAssignment = " + idAssignment;

            con.Open();
            dataGridView1.DataSource = con.SelectTable(sql);
            con.Close();
        }
Exemple #3
0
        public string GetUserName()
        {
            string name = "";

            con.Open();
            idProfessor = con.SelectSingle("select idProfessor from account where idAccount =" + idAccount);
            DataTable tmp = con.SelectTable("select firstname, lastname from professor where idProfessor = " + idProfessor);

            name  = tmp.Rows[0].ItemArray[0].ToString() + ' ';
            name += tmp.Rows[0].ItemArray[1].ToString();
            con.Close();
            return(name);
        }
Exemple #4
0
 public void FillDataGrid()
 {
     con.Open();
     dataGridView1.DataSource = con.SelectTable(string.Format(sql, idCourse));
     con.Close();
     dataGridView1.Columns["idForum"].Visible = false;
 }
Exemple #5
0
 void fillDataGrid()
 {
     con.Open();
     dataGridView1.DataSource = con.SelectTable(@"select c.idCourse as ID, c.name as Nombre, c.idProfessor as 'id Professor', p.lastname  as apellido from
                                                 course c inner join professor p on c.idProfessor = p.idProfessor;");
     con.Close();
 }
Exemple #6
0
        public MainWindowVM()
        {
            bool   status  = false;
            string db_file = "db_file.sqlite";

            //Init and Test Database Connection
            IDBConnectorEF dbconn = new SQLiteConnector(db_file);

            status = dbconn.Open();
            if (status)
            {
                dbconn.Close();
            }

            if (status)
            {
                //Assign to application wide shared variable.
                AppData.DBConn = dbconn;

                //Add ViewModel to the Content list
                _ContentVM.Add(new Module.Client.ClientManagerVM());
                _ContentVM.Add(new Module.Service.ClientManagerVM());
                _ContentVM.Add(new Module.Other.OtherManagerVM());

                //Init Menu Bar Commands.
                InitializeCommands();
            }
        }
Exemple #7
0
 public void fillStudents()
 {
     con.Open();
     dataGridView1.DataSource = con.SelectTable(@"select cs.idStudent as ID, s.lastname as Apellido from course_student cs 
                                                   inner join student s on s.idStudent = cs.idStudent where idCourse = " + idCourse + ";");
     con.Close();
 }
Exemple #8
0
        private void InsertForum()
        {
            string name    = textBoxName.Text;
            string content = textBoxContent.Text;
            string sql     = @"insert into forum(name, description,idauthor,idcourse) values('{0}','{1}',{2},{3});";

            con.Open();
            con.Command(string.Format(sql, name, content, idAuthor, idCourse));
            con.Close();
        }
Exemple #9
0
 private void fillFields()
 {
     con.Open();
     textBoxFirstName.Text = con.SelectSingle("select firstname from " + accountType + " where id" + accountType + " = " + idUser).ToString();
     textBoxLastName.Text  = con.SelectSingle("select lastname from " + accountType + " where id" + accountType + " = " + idUser).ToString();
     textBoxPassword.Text  = con.SelectSingle(string.Format(@"select a.password from account a
                                                             inner join {0} s on a.id{0} = s.id{0}
                                                             where a.id{0} = {1};", accountType, idUser)).ToString();
     con.Close();
     if (accountType.ToLower() == "professor")
     {
         comboBox1.SelectedIndex = 1;
     }
     else
     {
         comboBox1.SelectedIndex = 0;
     }
     comboBox1.Enabled = false;
 }
Exemple #10
0
        public void fillGrids()
        {
            string sql = @"select s.idStudent as Matrícula, s.firstname as Nombre, s.lastname as Apellido, a.username as Cuenta
    from student s left join Account a on a.idStudent = s.idStudent;";

            con.Open();
            dataGridStudents.DataSource = con.SelectTable(sql);

            sql = @"select s.idProfessor as Matrícula, s.firstname as Nombre, s.lastname as Apellido, a.username as Cuenta
    from professor s left join Account a on a.idProfessor = s.idProfessor;";
            dataGridProfessors.DataSource = con.SelectTable(sql);
            con.Close();
        }
Exemple #11
0
        private void SendHomework(string title, string desc, string val)
        {
            string sql = @"insert into assignment(weight,name,description,idCourse) values({0},'{1}','{2}',{3});";

            sql = String.Format(sql, val, title, desc, idCourse);
            DataTable dt;

            try
            {
                con.Open();
                con.Command(sql);
                dt = con.SelectTable("select idStudent from course_student where idCourse=" + idCourse + ";");
                string idAss = con.SelectSingle("select idAssignment from assignment where idAssignment=(Select max(idAssignment) from assignment);");
                sql = "insert into assignment_student(idassignment,idstudent) values({0},{1});";

                foreach (DataRow r in dt.Rows)
                {
                    con.Command(string.Format(sql, idAss, r.ItemArray[0].ToString()));
                }

                con.Close();
            }
            catch (System.Data.SQLite.SQLiteException err)
            {
                MessageBox.Show(err.Message.ToString());
            }
            catch (System.IndexOutOfRangeException err)
            {
                MessageBox.Show("Error en el foreach\n" + err.Message);
            }

            finally
            {
                con.Close();
            }
            parent.fillDataGridAssignment();
            this.Close();
        }
Exemple #12
0
        private void button1_Click(object sender, EventArgs e)
        {
            string idStudent = numericUpDown1.Value.ToString();

            try
            {
                string sql = @"insert into Course_student (idCourse, idStudent) values (" + idCourse + "," + idStudent + ");";
                con.Open();
                con.Command(sql);
                DataTable dt = con.SelectTable(@"select idAssignment from assignment where idCourse = " + idCourse + ";");
                foreach (DataRow r in dt.Rows)
                {
                    con.Command(@"insert into assignment_student (idStudent, idAssignment) values (" + idStudent + "," + r.ItemArray[0].ToString() + ");");
                }
                MessageBox.Show("Estudiante modificado existosamente", "Modificación Existosa", MessageBoxButtons.OK, MessageBoxIcon.Information);
                con.Close();
            }
            catch (System.Data.SQLite.SQLiteException error)
            {
                con.Close();
                if (error.Message.Contains("UNIQUE constraint"))
                {
                    MessageBox.Show("Este estudiante ya está inscritio", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (error.Message.Contains("FOREIGN KEY"))
                {
                    MessageBox.Show("No existe un estudiante con esta matrícula", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show(error.Message);
                }
            }
            finally
            {
                con.Close();
            }
        }
Exemple #13
0
 private void getTitle()
 {
     con.Open();
     this.Text = "Foro: " + con.SelectSingle(@"select name from Forum where idForum=" + idForum + ";");
     con.Close();
 }