private void studentsListForm_Load(object sender, EventArgs e)
        {
            MySqlCommand command = new MySqlCommand("SELECT * FROM `student` ORDER BY `last_name`");

            dataGridView1.ReadOnly = true;
            DataGridViewImageColumn picCol = new DataGridViewImageColumn();

            dataGridView1.RowTemplate.Height = 80;
            dataGridView1.DataSource         = student.getStudents(command);
            picCol             = (DataGridViewImageColumn)dataGridView1.Columns[8];
            picCol.ImageLayout = DataGridViewImageCellLayout.Stretch;
            dataGridView1.AllowUserToAddRows = false;
        }
Esempio n. 2
0
        public void fillGrid(MySqlCommand command)
        {
            dataGridView1.ReadOnly = true;
            DataGridViewImageColumn picCol = new DataGridViewImageColumn();

            dataGridView1.RowTemplate.Height = 80;
            dataGridView1.DataSource         = student.getStudents(command);

            picCol             = (DataGridViewImageColumn)dataGridView1.Columns[8];
            picCol.ImageLayout = DataGridViewImageCellLayout.Stretch;

            dataGridView1.AllowUserToAddRows = false;
        }
Esempio n. 3
0
        private void buttonFind_Click(object sender, EventArgs e)
        {
            try
            {
                int          id      = Convert.ToInt32(textBoxID.Text);
                MySqlCommand command = new MySqlCommand("SELECT `id`, `first_name`, `last_name`, `clasa`, `birthdate`, `gender`, `phone`, `address`, `picture` FROM `student` WHERE `id`=" + id);

                DataTable table = student.getStudents(command);

                if (table.Rows.Count > 0)
                {
                    textBoxPrenume.Text = table.Rows[0]["first_name"].ToString();
                    textBoxNume.Text    = table.Rows[0]["last_name"].ToString();
                    comboBoxClasa.Text  = table.Rows[0]["clasa"].ToString();
                    textBoxTelefon.Text = table.Rows[0]["phone"].ToString();
                    textBoxAdresa.Text  = table.Rows[0]["address"].ToString();

                    dateTimePicker1.Value = (DateTime)table.Rows[0]["birthdate"];

                    if (table.Rows[0]["gender"].ToString() == "Female")
                    {
                        radioButtonFemale.Checked = true;
                    }
                    else
                    {
                        radioButtonMale.Checked = true;
                    }

                    byte[]       pic     = (byte[])table.Rows[0]["picture"];
                    MemoryStream picture = new MemoryStream(pic);
                    pictureBoxStudentImage.Image = Image.FromStream(picture);
                }
                else
                {
                    MessageBox.Show("Introduceți un ID valid", "ID invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    textBoxPrenume.Text          = "Prenume";
                    textBoxNume.Text             = "Nume";
                    textBoxTelefon.Text          = "Telefon";
                    comboBoxClasa.Text           = "";
                    textBoxAdresa.Text           = "Adresă";
                    dateTimePicker1.Value        = DateTime.Now;
                    pictureBoxStudentImage.Image = null;
                }
            }
            catch
            {
            }
        }
Esempio n. 4
0
        private void dataGridView1_Click(object sender, EventArgs e)
        {
            textBoxIDnota.Text = "";
            textBoxIDelev.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            textBoxNume.Text   = dataGridView1.CurrentRow.Cells[1].Value.ToString() + " " + dataGridView1.CurrentRow.Cells[2].Value.ToString();
            try
            {
                string id = "", NumeMaterie = "";
                id          = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                NumeMaterie = comboBoxMaterie.Text;
                string average = "SELECT AVG(nota) FROM `grades` WHERE `elev`='" + id + "' AND `materie`='" + NumeMaterie + "' AND `teza`=false";
                string result  = count.execCount(average);

                string test    = "SELECT COUNT(*) FROM `grades` WHERE `elev`='" + id + "' AND `materie`='" + NumeMaterie + "' AND `teza`=false";
                string testare = count.execCount(test);
                if (Convert.ToInt32(testare) == 0)
                {
                    if (comboBoxMaterie.Text != "")
                    {
                        textBoxMedie.Text = "Note insuficiente";
                        textBoxNote.Text  = "0";
                    }
                    else
                    {
                        textBoxMedie.Text = "";
                        textBoxNote.Text  = "";
                    }
                }
                else
                {
                    try
                    {
                        string cautaTeza  = "SELECT `nota` FROM `grades` WHERE `elev`='" + id + "' AND `materie`='" + NumeMaterie + "' AND `teza`=true";
                        string TezaGasita = count.execCount(cautaTeza);
                        int    ValTeza    = Convert.ToInt32(TezaGasita);
                        test    = "SELECT COUNT(*) FROM `grades` WHERE `elev`='" + id + "' AND `materie`='" + NumeMaterie + "' AND `teza`=true";
                        testare = count.execCount(test);
                        if (Convert.ToInt32(testare) > 1)
                        {
                            textBoxMedie.Text = "EROARE TEZE";
                        }
                        else if (Convert.ToInt32(testare) == 1)
                        {
                            double number = Convert.ToDouble(result);
                            number *= 3;
                            number += ValTeza;
                            number /= 4;

                            textBoxMedie.Text = number.ToString();
                            textBoxNote.Text  = count.totalGrades(NumeMaterie, id);
                        }
                    }
                    catch
                    {
                        textBoxMedie.Text = result;
                        textBoxNote.Text  = count.totalGrades(NumeMaterie, id);
                    }
                }

                MySqlCommand command = new MySqlCommand("SELECT `id`, `nota`, `date`, `teza` FROM `grades` WHERE `materie`='" + NumeMaterie + "' AND `elev`='" + id + "'");
                dataGridView2.ReadOnly = true;
                DataGridViewImageColumn picCol = new DataGridViewImageColumn();
                dataGridView2.RowTemplate.Height = 40;
                dataGridView2.DataSource         = student.getStudents(command);
                dataGridView2.AllowUserToAddRows = false;

                comboBoxEditNota.SelectedItem = "";
                textBoxIDnota.Text            = "";
            }
            catch
            {
                textBoxMedie.Text        = "-";
                textBoxNote.Text         = "0";
                dataGridView2.DataSource = null;
            }

            try
            {
                string id = "", NumeMaterie = "";
                id          = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                NumeMaterie = comboBoxMaterie.Text;

                textBoxTotal.Text      = count.totalAbsente(id);
                textBoxMotivate.Text   = count.totalAbsenteMotivate(id);
                textBoxNemotivate.Text = count.totalAbsenteNemotivate(id);

                MySqlCommand command1 = new MySqlCommand("SELECT `id`, `materie`, `data`, `motivat` FROM `absente` WHERE `elev`='" + id + "'");
                dataGridView3.ReadOnly = true;
                DataGridViewImageColumn picCol1 = new DataGridViewImageColumn();
                dataGridView3.RowTemplate.Height = 40;
                dataGridView3.DataSource         = student.getStudents(command1);
                dataGridView3.AllowUserToAddRows = false;
            }
            catch
            {
            }

            try
            {
                string id = "", NumeMaterie = "";
                id          = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                NumeMaterie = comboBoxMaterie.Text;

                MySqlCommand command2 = new MySqlCommand("SELECT `id`, `materie`, `data`, `motivat` FROM `absente` WHERE `elev`='" + id + "' AND `materie`='" + NumeMaterie + "'");

                DataGridViewImageColumn picCol11 = new DataGridViewImageColumn();
                dataGridView4.RowTemplate.Height = 40;
                dataGridView4.DataSource         = student.getStudents(command2);
                dataGridView4.AllowUserToAddRows = false;
                dataGridView4.ReadOnly           = true;
                textBoxAbsMaterie.Text           = count.totalAbsenteMaterie(id, NumeMaterie);
            }
            catch
            {
                textBoxAbsMaterie.Text = "0";
            }
        }