private void StudentList_Form_Load(object sender, EventArgs e) { //cargar gridview con data de estudiantes SQLiteCommand command = new SQLiteCommand("SELECT * FROM `student`"); dataGridView1.ReadOnly = true; DataGridViewImageColumn picCol = new DataGridViewImageColumn(); dataGridView1.RowTemplate.Height = 60; dataGridView1.DataSource = student.GetStudents(command); picCol = (DataGridViewImageColumn)dataGridView1.Columns[7]; picCol.ImageLayout = DataGridViewImageCellLayout.Stretch; dataGridView1.AllowUserToAddRows = false; }
//mostrar datos de estudiantes en dgv private void btnShowStudents_Click(object sender, EventArgs e) { data = "student"; SQLiteCommand command = new SQLiteCommand("SELECT `id`, `first_name`, `last_name`, `birthdate` FROM `student`"); dataGridView1.DataSource = student.GetStudents(command); }
private void AddScoreForm_Load(object sender, EventArgs e) { //llenar combobox con el nombre de los cursos comboBoxCourse.DataSource = course.GetAllCourses(); comboBoxCourse.DisplayMember = "label"; comboBoxCourse.ValueMember = "id"; //llenar dgv con datos de los estudiantes (id, nombre, apellido) SQLiteCommand command = new SQLiteCommand("SELECT `id`, `first_name`, `last_name` FROM `student`"); dataGridView1.DataSource = student.GetStudents(command); }
//funcion llena el datagridview public void fillGrid(SQLiteCommand command) { //cargar gridview con data de estudiantes dataGridView1.ReadOnly = true; DataGridViewImageColumn picCol = new DataGridViewImageColumn(); dataGridView1.RowTemplate.Height = 60; dataGridView1.DataSource = student.GetStudents(command); picCol = (DataGridViewImageColumn)dataGridView1.Columns[7]; picCol.ImageLayout = DataGridViewImageCellLayout.Stretch; dataGridView1.AllowUserToAddRows = false; }
private void PrintScoresForm_Load(object sender, EventArgs e) { //llenar dgv con datos de estudiantes dataGridView1.DataSource = student.GetStudents(new SQLiteCommand("SELECT `id`, `first_name`, `last_name` FROM `student`")); //llenar dgv con datos de score DataGridViewStudentsScore.DataSource = score.GetStudentsScore(); //llenar dgv con datos de cursos listBoxCourses.DataSource = course.GetAllCourses(); listBoxCourses.DisplayMember = "label"; listBoxCourses.ValueMember = "id"; }
//funcion llena el datagridview public void fillGrid(SQLiteCommand command) { dataGridView1.ReadOnly = true; DataGridViewImageColumn picCol = new DataGridViewImageColumn(); dataGridView1.RowTemplate.Height = 60; dataGridView1.DataSource = student.GetStudents(command); picCol = (DataGridViewImageColumn)dataGridView1.Columns[7]; picCol.ImageLayout = DataGridViewImageCellLayout.Stretch; dataGridView1.AllowUserToAddRows = false; //mostrar total estudiantes dependiendo de la fila dgv labelTotalStudents.Text = "Total Students: " + dataGridView1.Rows.Count; }
private void btnFind_Click(object sender, EventArgs e) { //buscar estudiante por ID try { int id = Convert.ToInt32(textBoxID.Text); SQLiteCommand command = new SQLiteCommand("SELECT `id`, `first_name`, `last_name`, `birthdate`, `gender`, `phone`, `address`, `picture` FROM `student` WHERE `id` =" + id); DataTable table = student.GetStudents(command); if (table.Rows.Count > 0) { textBoxFname.Text = table.Rows[0]["first_name"].ToString(); textBoxLname.Text = table.Rows[0]["last_name"].ToString(); maskedTextBoxPhone.Text = table.Rows[0]["phone"].ToString(); textBoxAddress.Text = table.Rows[0]["address"].ToString(); dateTimePicker1.Value = (DateTime)table.Rows[0]["birthdate"]; //genero if (table.Rows[0]["gender"].ToString() == "Female") { radioButtonFemale.Checked = true; } else { radioButtonMale.Checked = true; } //image byte[] pic = (byte[])table.Rows[0]["picture"]; MemoryStream picture = new MemoryStream(pic); pictureBoxStudent.Image = Image.FromStream(picture); } } catch (Exception ex) { MessageBox.Show("Enter a valid student ID", "Invalid ID", MessageBoxButtons.OK, MessageBoxIcon.Error); } }