示例#1
0
        private void buttonEliminar_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("¿Desea eliminar este trabajo?"
                                              , "Confirmar Calificación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                con.Open();
                con.Command("delete from assignment_student where idAssignment = " + idAssignment + ";");
                con.Command("delete from Assignment where idAssignment = " + idAssignment + ";");
                con.Close();
                parent.fillDataGridAssignment();
                this.Close();
            }
        }
示例#2
0
 private void buttonEnviar_Click(object sender, EventArgs e)
 {
     con.Open();
     con.Command("update Course set description = '" + textBoxDesc.Text.ToString() + "' where idCourse = " + selectedCourse + ";");
     con.Close();
     MessageBox.Show("Se envió el anuncio correctamente");
 }
示例#3
0
        private void buttonSend_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || numericUpDown1.Value == 0)
            {
                MessageBox.Show("Debe llenar todos los campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DialogResult dr = MessageBox.Show("¿Desea actualizar  este curso?", "Confirmar Envío", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dr.Equals(DialogResult.No))
            {
                return;
            }
            try
            {
                con.Open();
                con.Command(@"update course set name = '" + textBox1.Text + "', idProfessor = " + numericUpDown1.Value.ToString() + " where idCourse = " + idCourse + ";");
                con.Close();
            }
            catch (System.Data.SQLite.SQLiteException)
            {
                con.Close();
                MessageBox.Show("ID de profesor no valido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                con.Close();
            }
        }
示例#4
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();
        }
示例#5
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();
        }
示例#6
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();
            }
        }
示例#7
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("¿Desea enviar la siguiente calificación?: " + numericUpDown1.Value.ToString()
                                              , "Confirmar Calificación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                con.Open();
                string sql = @"update assignment_student set grade={0} where idAssignment ={1} and idStudent={2};";
                con.Command(string.Format(sql, numericUpDown1.Value, idAssignment, idStudent));
                con.Close();
                MessageBox.Show("Se ha guardado la calificación exitosamente.", "Entrega Calificada", MessageBoxButtons.OK, MessageBoxIcon.Information);
                parent.fillDataGridTrabajos();
                Close();
            }
        }
示例#8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("Debe llenar todos los campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DialogResult dr = MessageBox.Show("¿Desea enviar la respuesta?", "Confirmar Envío", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dr == DialogResult.Yes)
            {
                string sql = @"insert into post(idForum,text,idAuthor) values ({0},'{1}',{2});";
                con.Open();
                con.Command(string.Format(sql, idForum, textBox1.Text, idAutor));
                con.Close();
                GetOP();
                textBox1.Text = "";
            }
        }
示例#9
0
        void editAcc()
        {
            string firstName = textBoxFirstName.Text;
            string lastName  = textBoxLastName.Text;
            string password  = textBoxPassword.Text;

            con.Open();
            string idAccount = con.SelectSingle(string.Format(@"Select a.idAccount from account a
                                                inner join {0} u on a.id{0} = u.id{0}
                                                where u.id{0} = {1};", accountType, idUser));

            con.Close();

            if (firstName == "" || lastName == "" || password == "")
            {
                MessageBox.Show("Todos los campos deben llenarse", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DialogResult dr = MessageBox.Show("¿Desea editar esta cuenta?", "Confirmar Envío", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dr.Equals(DialogResult.No))
            {
                return;
            }

            string sql = string.Format(@"update {2} set firstName='{0}', lastName='{1}' where id{2}={3};", firstName, lastName, accountType, idUser);

            con.Open();
            con.Command(string.Format(sql));

            sql = @"update account set password='******' where idaccount={1};";
            con.Command(string.Format(sql, password, idAccount));
            con.Close();
            parent.fillGrids();
            this.Close();
        }