Пример #1
0
        private void StaticsForm_Load(object sender, EventArgs e)
        {
            panTotalColor  = panelTotal.BackColor;
            panMaleColor   = panelMale.BackColor;
            panFemaleColor = panelFemale.BackColor;

            STUDENT student             = new STUDENT();
            double  totalStudents       = Convert.ToDouble(student.totalStudent());
            double  totalMaleStudents   = Convert.ToDouble(student.totalMaleStudents());
            double  totalFemaleStudents = Convert.ToDouble(student.totalFemaleStudents());

            double malePercentage   = totalMaleStudents * 100 / totalStudents;
            double FemalePercentage = totalFemaleStudents * 100 / totalStudents;

            labelTotal.Text  = "Total studenți: " + totalStudents.ToString();
            labelMale.Text   = "Elevi: " + malePercentage.ToString("0.00") + "%";
            labelFemale.Text = "Eleve: " + FemalePercentage.ToString("0.00") + "%";
        }
Пример #2
0
        private void buttonAddStudent_Click(object sender, EventArgs e)
        {
            Decolorare();
            STUDENT student = new STUDENT();

            #region Variables
            string   fname   = textBoxPrenume.Text;
            string   lname   = textBoxNume.Text;
            string   clasa   = comboBoxClasa.Text;
            DateTime bdate   = dateTimePicker1.Value;
            string   phone   = textBoxTelefon.Text;
            string   address = textBoxAdresa.Text;
            string   gender  = "Male";
            if (radioButtonFemale.Checked)
            {
                gender = "Female";
            }
            MemoryStream pic = new MemoryStream();

            int born_year = dateTimePicker1.Value.Year;
            int this_year = DateTime.Now.Year;
            #endregion
            if ((this_year - born_year < 10) || (this_year - born_year > 100))
            {
                MessageBox.Show("Vârsta trebuie să fie între 10 și 100", "Dată de naștere invalidă", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (verif())
            {
                pictureBoxStudentImage.Image.Save(pic, pictureBoxStudentImage.Image.RawFormat);
                if (student.insertStudent(fname, lname, clasa, bdate, phone, gender, address, pic))
                {
                    MessageBox.Show("Student adăugat", "Adaugă student", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Eroare!", "Adaugă student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Există câmpuri necompletate!", "Adaugă student", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }