private void bunifuFlatButton2_Click(object sender, EventArgs e)
        {
            if (bunifuDropdown1.selectedIndex != -1 && bunifuDropdown2.selectedIndex != -1 && bunifuDropdown3.selectedIndex != -1)
            {
                try
                {
                    if (Decan == true)
                    {
                        this.IdDepartamentSelectat = IdDepartamenteDropDown.ElementAt(bunifuDropdown1.selectedIndex);
                    }
                    this.idAniScolari_Selectat = IDAniScolari.ElementAt(bunifuDropdown2.selectedIndex);
                    this.AnSelectat            = (bunifuDropdown3.selectedIndex) + 1;

                    //luem fiecare specializare din departamentul selectat
                    //dam clear la chestiile de pe noua pagina
                    var catalog      = new CatalogEntities1();
                    var specializare = from s in catalog.Specializares
                                       where s.DepartamentID == IdDepartamentSelectat
                                       select s;

                    int nrStudenti          = 0;
                    int Integralisti        = 0;
                    int nrTotalStudenti     = 0;
                    int nrTotalIntegralisti = 0;
                    int nrTotalRestantieri  = 0;
                    int nrTotalR1           = 0;
                    int nrTotalR2           = 0;
                    int nrTotalR3           = 0;
                    foreach (var s in specializare)
                    {
                        //ne intrebam ce an e si apelam fix pentru anul care trebuie
                        if (AnSelectat == 1)
                        {
                            var statistici = catalog.usp_statistica_an1(IdDepartamentSelectat, s.SpecializareID, idAniScolari_Selectat);
                            foreach (var item in statistici.ToList())
                            {
                                nrStudenti   = (int)item.NR_STUDENTI;
                                Integralisti = (int)item.NR_STUDENTI_INTEGRALISTI;
                                if (Integralisti == 0)//asta asa ca nu avem adaugat in baza de date
                                {
                                    Integralisti = 1;
                                }
                                if (nrStudenti == 0)
                                {
                                    nrStudenti = 1;
                                }
                                Form1.gui.Cadru_AfisareStatistici_AdaugaDataGrid(s.Nume, nrStudenti, Integralisti, nrStudenti - Integralisti, (int)item.NR_STUDENTI_R1, (int)item.NR_STUDENTI_R2, (int)item.NR_STUDENTI_R3, (int)(Integralisti * 100 / nrStudenti));
                                nrTotalStudenti     += nrStudenti;
                                nrTotalIntegralisti += Integralisti;
                                nrTotalRestantieri  += (nrStudenti - Integralisti);
                                nrTotalR1           += (int)item.NR_STUDENTI_R1;
                                nrTotalR2           += (int)item.NR_STUDENTI_R2;
                                nrTotalR3           += (int)item.NR_STUDENTI_R3;
                            }
                        }
                        else if (AnSelectat == 2)
                        {
                            var statistici = catalog.usp_statistica_an2(IdDepartamentSelectat, s.SpecializareID, idAniScolari_Selectat);
                            foreach (var item in statistici.ToList())
                            {
                                nrStudenti   = (int)item.NR_STUDENTI;
                                Integralisti = (int)item.NR_STUDENTI_INTEGRALISTI;
                                if (Integralisti == 0)
                                {
                                    Integralisti = 1;
                                }
                                if (nrStudenti == 0)
                                {
                                    nrStudenti = 1;
                                }
                                Form1.gui.Cadru_AfisareStatistici_AdaugaDataGrid(s.Nume, nrStudenti, Integralisti, nrStudenti - Integralisti, (int)item.NR_STUDENTI_R1, (int)item.NR_STUDENTI_R2, (int)item.NR_STUDENTI_R3, (int)(Integralisti * 100 / nrStudenti));
                                nrTotalStudenti     += nrStudenti;
                                nrTotalIntegralisti += Integralisti;
                                nrTotalRestantieri  += (nrStudenti - Integralisti);
                                nrTotalR1           += (int)item.NR_STUDENTI_R1;
                                nrTotalR2           += (int)item.NR_STUDENTI_R2;
                                nrTotalR3           += (int)item.NR_STUDENTI_R3;
                            }
                        }
                        else if (AnSelectat == 3)
                        {
                            var statistici = catalog.usp_statistica_an3(IdDepartamentSelectat, s.SpecializareID, idAniScolari_Selectat);
                            foreach (var item in statistici.ToList())
                            {
                                nrStudenti   = (int)item.NR_STUDENTI;
                                Integralisti = (int)item.NR_STUDENTI_INTEGRALISTI;
                                if (Integralisti == 0)
                                {
                                    Integralisti = 1;
                                }
                                if (nrStudenti == 0)
                                {
                                    nrStudenti = 1;
                                }
                                Form1.gui.Cadru_AfisareStatistici_AdaugaDataGrid(s.Nume, nrStudenti, Integralisti, nrStudenti - Integralisti, (int)item.NR_STUDENTI_R1, (int)item.NR_STUDENTI_R2, (int)item.NR_STUDENTI_R3, (int)(Integralisti * 100 / nrStudenti));
                                nrTotalStudenti     += nrStudenti;
                                nrTotalIntegralisti += Integralisti;
                                nrTotalRestantieri  += (nrStudenti - Integralisti);
                                nrTotalR1           += (int)item.NR_STUDENTI_R1;
                                nrTotalR2           += (int)item.NR_STUDENTI_R2;
                                nrTotalR3           += (int)item.NR_STUDENTI_R3;
                            }
                        }
                        else if (AnSelectat == 4)
                        {
                            var statistici = catalog.usp_statistica_an4(IdDepartamentSelectat, s.SpecializareID, idAniScolari_Selectat);
                            foreach (var item in statistici.ToList())
                            {
                                nrStudenti   = (int)item.NR_STUDENTI;
                                Integralisti = (int)item.NR_STUDENTI_INTEGRALISTI;
                                if (Integralisti == 0)
                                {
                                    Integralisti = 1;
                                }
                                if (nrStudenti == 0)
                                {
                                    nrStudenti = 1;
                                }
                                Form1.gui.Cadru_AfisareStatistici_AdaugaDataGrid(s.Nume, nrStudenti, Integralisti, nrStudenti - Integralisti, (int)item.NR_STUDENTI_R1, (int)item.NR_STUDENTI_R2, (int)item.NR_STUDENTI_R3, (int)(Integralisti * 100 / nrStudenti));
                                nrTotalStudenti     += nrStudenti;
                                nrTotalIntegralisti += Integralisti;
                                nrTotalRestantieri  += (nrStudenti - Integralisti);
                                nrTotalR1           += (int)item.NR_STUDENTI_R1;
                                nrTotalR2           += (int)item.NR_STUDENTI_R2;
                                nrTotalR3           += (int)item.NR_STUDENTI_R3;
                            }
                        }
                    }
                    int promovabilitate = (int)(nrTotalIntegralisti * 100 / nrTotalStudenti);
                    Form1.gui.Cadru_AfisareStatistici_SetStatistics(nrTotalStudenti, promovabilitate, nrTotalIntegralisti, nrTotalStudenti - nrTotalIntegralisti, nrTotalR1, nrTotalR2, nrTotalR3);
                    Form1.gui.Bring_CadruAfisareStatistici();
                }
                catch (Exception ex)
                {
                    //Console.WriteLine(ex.ToString());
                    FormError newForm = new FormError();
                    newForm.SetText(ex.ToString());
                    newForm.ShowDialog();
                }
            }
        }