protected void provinciaBambino_SelectedIndexChanged(object sender, EventArgs e)
        {
            string    sql    = @"select * 
                        from Citta where prov = '" + provinciaBambino.SelectedValue + "'";
            adoNet    adoWeb = new adoNet();
            DataTable codice = adoWeb.eseguiQuery(sql, CommandType.Text);

            cittaBambino.DataSource     = codice;
            cittaBambino.DataTextField  = "descri";
            cittaBambino.DataValueField = "IdCitta";
            cittaBambino.DataBind();
        }
示例#2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["id"] == null)
     {
         Response.Redirect("~/Login.aspx");
     }
     else if ((string)Session["ruolo"] == "G")
     {
         adoNet.impostaConnessione();
         adoNet ado = new adoNet();
         string sql = "SELECT nome + ' ' + cognome AS NomeCognome FROM Genitori WHERE id = " + Session["id"];
         nomeCognome           = ado.eseguiScalar(sql, System.Data.CommandType.Text);
         sceltaBambino.Visible = true;
         sql = @"select Turni.id, Turni.numero 
                 from Turni
                 inner join FreqBambini on idTurno = Turni.id
                 inner join ParenteleBambini on FreqBambini.idBambino = ParenteleBambini.idBambino
                 inner join Genitori on Genitori.id = ParenteleBambini.idGenitore
                 where Genitori.id = " + Session["id"] + " AND Turni.anno = " + DateTime.Now.Year;
         DataTable dt = ado.eseguiQuery(sql, System.Data.CommandType.Text);
         foreach (DataRow dr in dt.Rows)
         {
             sceltaTurno.Items.Add(new ListItem(dr.ItemArray[1] + "° turno", dr.ItemArray[0].ToString()));
         }
     }
     else
     {
         adoNet.impostaConnessione();
         adoNet ado = new adoNet();
         string sql = "SELECT nome + ' ' + cognome AS NomeCognome FROM Personale WHERE id = " + Session["id"];
         nomeCognome           = ado.eseguiScalar(sql, System.Data.CommandType.Text);
         sceltaBambino.Visible = false;
         sql = @"select Turni.id, Turni.numero
                 from FreqPersonale
                 inner join Personale on idPersonale = Personale.id
                 inner join Turni on idTurno = Turni.id
                 where Personale.id = " + Session["id"];
         DataTable dt = ado.eseguiQuery(sql, System.Data.CommandType.Text);
         foreach (DataRow dr in dt.Rows)
         {
             sceltaTurno.Items.Add(new ListItem(dr.ItemArray[1] + "° turno", dr.ItemArray[0].ToString()));
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["id"] == null)
            {
                Response.Redirect("../../Login.aspx");
            }
            else
            {
                emailGenitore1C.SetFocusOnError    = true;
                emailGenitore1C.ValidateEmptyText  = false; //esegue il controllo anche se campo vuoto
                emailGenitore1C.EnableClientScript = false;
                emailGenitore1C.ForeColor          = System.Drawing.Color.Red;
                if (!Page.IsPostBack)
                {
                    datiGenitore2_CheckedChanged(new object(), new EventArgs());
                    //adoNet.impostaConnessione();


                    string    sql    = @"select * 
                        from Province";
                    adoNet    adoWeb = new adoNet();
                    DataTable codice = adoWeb.eseguiQuery(sql, CommandType.Text);
                    provinciaGenitore1.DataSource     = codice;
                    provinciaGenitore1.DataTextField  = "DescProvincia";
                    provinciaGenitore1.DataValueField = "CodProvincia";
                    provinciaGenitore1.DataBind();
                    provinciaGenitore1.SelectedIndex = -1;

                    provinciaGenitore2.DataSource     = codice;
                    provinciaGenitore2.DataTextField  = "DescProvincia";
                    provinciaGenitore2.DataValueField = "CodProvincia";
                    provinciaGenitore2.DataBind();
                    provinciaGenitore2.SelectedIndex = -1;
                }
            }
        }
        protected void salvaBambino_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                datiBambino.Visible       = false;
                termineIscrizione.Visible = true;
                Bambino newBambino = new Bambino();
                newBambino.nome         = nomeBambino.Text;
                newBambino.cognome      = cognomeBambino.Text;
                newBambino.sesso        = Convert.ToChar(sessoBambino.SelectedValue);
                newBambino.nazionalita  = Convert.ToInt32(nazionalitaBambino.SelectedValue);
                newBambino.dataNascita  = Convert.ToDateTime(dataNascitaBambino.Text);
                newBambino.cittaNascita = Convert.ToInt32(cittaNascitaBambino.SelectedValue);
                newBambino.CF           = codiceFiscaleBambino.Text;
                newBambino.indirizzo    = indirizzoBambino.Text;
                newBambino.numeroCivico = numeroCivicoBambino.Text;
                newBambino.provincia    = provinciaBambino.SelectedValue;
                newBambino.citta        = Convert.ToInt32(cittaBambino.SelectedValue);
                newBambino.classe       = Convert.ToInt32(classeBambino.SelectedValue);
                newBambino.scuola       = scuolaBambino.Text;


                newBambino.turni = new object[idTurni.Length, 17];
                int i = 0;
                foreach (int turno in idTurni)
                {
                    if (((CheckBox)tableTurni.FindControl(turno.ToString())).Checked)
                    {
                        newBambino.turni[i, 0] = turno;
                        try
                        {
                            newBambino.turni[i, 1] = ((RadioButtonList)tableTurni.FindControl("mensa" + turno.ToString())).SelectedValue == "No" ? 0 : 1;
                        }
                        catch (Exception ex)
                        {
                            newBambino.turni[i, 1] = 0;
                        }
                        for (int y = 0; y < ((CheckBoxList)tableTurni.FindControl("settimane" + turno.ToString())).Items.Count; y++)
                        {
                            newBambino.turni[i, y + 2] = Convert.ToInt32(((CheckBoxList)tableTurni.FindControl("settimane" + turno.ToString())).Items[y].Selected);
                        }
                        i++;
                    }
                }
                int n = 0;
                for (int k = 0; k <= Request.Cookies.Count; k++)
                {
                    try
                    {
                        if (Request.Cookies["bambino" + k].Value != null)
                        {
                            n++;
                        }
                    }
                    catch { }
                }
                Response.Cookies["bambino" + (n + 1)].Value  += newBambino.writeCookie();
                Response.Cookies["bambino" + (n + 1)].Expires = DateTime.Now.AddMinutes(30);
                //bambini.Add(newBambino);
                TableRow  tr = new TableRow();
                TableCell tc = new TableCell();
                tc.Text = newBambino.nome;
                tr.Cells.Add(tc);
                tc      = new TableCell();
                tc.Text = newBambino.cognome;
                tr.Cells.Add(tc);
                tc      = new TableCell();
                tc.Text = newBambino.dataNascita.ToShortDateString();
                tr.Cells.Add(tc);
                tc = new TableCell();
                for (int p = 0; p < newBambino.turni.GetLength(0); p++)
                {
                    if (Convert.ToInt32(newBambino.turni[p, 0]) != 0)
                    {
                        string    sql            = @"select * 
                        from Turni WHERE id = " + newBambino.turni[p, 0];
                        adoNet    adoWeb         = new adoNet();
                        DataTable dettaglioTurno = adoWeb.eseguiQuery(sql, CommandType.Text);
                        tc.Text += " ♦ Turno " + dettaglioTurno.Rows[0].Field <int>("numero").ToString() + ": " + dettaglioTurno.Rows[0].Field <DateTime>("dataInizio").ToShortDateString() + " - " + dettaglioTurno.Rows[0].Field <DateTime>("dataFine").ToShortDateString() + " ";
                        if (Convert.ToBoolean(dettaglioTurno.Rows[0].Field <bool>("servizioMensa")))
                        {
                            tc.Text += "- Mensa: " + (Convert.ToInt32(newBambino.turni[p, 1]) == 1 ? "Sì" : "No");
                        }
                        tc.Text += "<br/>";
                    }
                }
                tr.Cells.Add(tc);
                tableDettagli.Rows.Add(tr);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["id"] == null)
            {
                Response.Redirect("../../Login.aspx");
            }
            else
            {
                adoNet adoWeb = new adoNet();

                try
                {
                    if (Request.Cookies["genitore1"].Value == null)
                    {
                        Response.Redirect("./DatiGenitori.aspx");
                    }
                    else if (!IsPostBack)
                    {
                        adoNet.impostaConnessione();

                        bambini = new List <Bambino>();
                        Genitore genitore1 = new Genitore(Request.Cookies["genitore1"].Value);
                        Genitore genitore2;
                        try
                        {
                            if (Request.Cookies["genitore2"].Value != null)
                            {
                                genitore2 = new Genitore(Request.Cookies["genitore2"].Value);
                                if (genitore1.indirizzo == genitore2.indirizzo &&
                                    genitore1.numeroCivico == genitore2.numeroCivico &&
                                    genitore1.citta == genitore2.citta &&
                                    genitore1.provincia == genitore2.provincia)
                                {
                                    indirizzoUguale.Visible = true;
                                }
                                else
                                {
                                    indirizzoUguale.Visible = false;
                                }
                            }
                            else
                            {
                                indirizzoUguale.Visible = false;
                            }
                        }
                        catch (Exception ex)
                        {
                            indirizzoUguale.Visible = false;
                        }
                        string    sql    = @"select * 
                        from Nazioni ORDER BY DescNazione";
                        DataTable codice = adoWeb.eseguiQuery(sql, CommandType.Text);
                        nazionalitaBambino.DataSource     = codice;
                        nazionalitaBambino.DataTextField  = "DescNazione";
                        nazionalitaBambino.DataValueField = "IdNazione";
                        nazionalitaBambino.DataBind();

                        sql    = @"select * 
                        from Province ORDER BY DescProvincia";
                        codice = adoWeb.eseguiQuery(sql, CommandType.Text);
                        provinciaBambino.DataSource     = codice;
                        provinciaBambino.DataTextField  = "DescProvincia";
                        provinciaBambino.DataValueField = "CodProvincia";
                        provinciaBambino.DataBind();
                        provinciaBambino.SelectedIndex = -1;

                        sql    = @"select *, descri + ' (' + prov + ')' AS text
                        from Citta ORDER BY descri";
                        codice = adoWeb.eseguiQuery(sql, CommandType.Text);
                        cittaNascitaBambino.DataSource     = codice;
                        cittaNascitaBambino.DataTextField  = "text";
                        cittaNascitaBambino.DataValueField = "IdCitta";
                        cittaNascitaBambino.DataBind();

                        sql = @"select * 
                        from Classi";
                        DataTable classi = adoWeb.eseguiQuery(sql, CommandType.Text);
                        foreach (DataRow dr in classi.Rows)
                        {
                            ListItem ls = new ListItem(dr.Field <int>("anno").ToString() + "° " + ((dr.Field <string>("ME") == "M") ? "Media" : "Elementare"), dr.Field <int>("id").ToString());
                            classeBambino.Items.Add(ls);
                        }
                    }
                    else
                    {
                        string    sql   = @"select * 
                        from Turni WHERE idCentro = " + Session["idCentro"];
                        DataTable turni = adoWeb.eseguiQuery(sql, CommandType.Text);
                        int       y     = 0;
                        idTurni = new int[turni.Rows.Count];
                        foreach (DataRow turno in turni.Rows)
                        {
                            TableRow  tr       = new TableRow();
                            TableCell tc       = new TableCell();
                            CheckBox  checkBox = new CheckBox();
                            checkBox.ID = turno["id"].ToString();
                            idTurni[y]  = (int)(turno["id"]);
                            y++;
                            checkBox.CheckedChanged += turnoEvent;
                            checkBox.AutoPostBack    = true;
                            tc.Controls.Add(checkBox);
                            tr.Cells.Add(tc);
                            tc      = new TableCell();
                            tc.Text = (Convert.ToDateTime(turno["dataInizio"].ToString())).ToShortDateString();
                            tr.Cells.Add(tc);
                            tc      = new TableCell();
                            tc.Text = (Convert.ToDateTime(turno["dataFine"].ToString())).ToShortDateString();
                            tr.Cells.Add(tc);
                            int colSpan = 2;
                            if (Convert.ToBoolean(turno["servizioMensa"].ToString()))
                            {
                                tc = new TableCell();
                                //tr.Cells.Add(tc);
                                //tc = new TableCell();
                                //tc.ColumnSpan = 2;
                                RadioButtonList radio = new RadioButtonList();
                                radio.ID       = "mensa" + turno["id"].ToString();
                                radio.Enabled  = false;
                                radio.CssClass = "table-borderless";
                                radio.Items.Add("Sì");
                                radio.Items.Add("No");
                                tc.Controls.Add(radio);
                                tr.Cells.Add(tc);
                                colSpan += 3;
                            }
                            tableTurni.Rows.Add(tr);
                            tr = new TableRow();
                            tr.Cells.Add(new TableCell());
                            tc            = new TableCell();
                            tc.ColumnSpan = colSpan;
                            CheckBoxList checkBoxList = new CheckBoxList();
                            checkBoxList.ID      = "settimane" + turno["id"].ToString();
                            checkBoxList.Enabled = false;
                            checkBoxList.Visible = false;

                            DateTime data = new DateTime();
                            data = Convert.ToDateTime(turno["dataInizio"]);
                            checkBoxList.CssClass = "table-borderless";

                            for (int i = 0; i < Convert.ToInt32(turno["numeroSettimane"].ToString()); i++)
                            {
                                checkBoxList.Items.Add("Settimana " + (i + 1) + ": " + data.ToShortDateString() + " - " + data.AddDays(7).ToShortDateString());
                                data = data.AddDays(7);
                            }
                            tc.Controls.Add(checkBoxList);
                            tr.Cells.Add(tc);
                            tableTurni.Rows.Add(tr);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Response.Redirect("./DatiGenitori.aspx");
                }
                termineIscrizione.Enabled = false;

                for (int k = 0; k <= Request.Cookies.Count; k++)
                {
                    try
                    {
                        if (Request.Cookies["bambino" + k].Value != null)
                        {
                            Bambino newBambino = new Bambino();
                            newBambino.readCookie(Request.Cookies["bambino" + (k)].Value);
                            TableRow  tr = new TableRow();
                            TableCell tc = new TableCell();
                            tc.Text = newBambino.nome;
                            tr.Cells.Add(tc);
                            tc      = new TableCell();
                            tc.Text = newBambino.cognome;
                            tr.Cells.Add(tc);
                            tc      = new TableCell();
                            tc.Text = newBambino.dataNascita.ToShortDateString();
                            tr.Cells.Add(tc);
                            tc = new TableCell();
                            for (int p = 0; p < newBambino.turni.GetLength(0); p++)
                            {
                                if (Convert.ToInt32(newBambino.turni[p, 0]) != 0)
                                {
                                    string    sql            = @"select * 
                        from Turni WHERE id = " + newBambino.turni[p, 0];
                                    DataTable dettaglioTurno = adoWeb.eseguiQuery(sql, CommandType.Text);
                                    tc.Text += " ♦ Turno " + dettaglioTurno.Rows[0].Field <int>("numero").ToString() + ": " + dettaglioTurno.Rows[0].Field <DateTime>("dataInizio").ToShortDateString() + " - " + dettaglioTurno.Rows[0].Field <DateTime>("dataFine").ToShortDateString() + " ";
                                    if (Convert.ToBoolean(dettaglioTurno.Rows[0].Field <bool>("servizioMensa")))
                                    {
                                        tc.Text += "- Mensa: " + (Convert.ToInt32(newBambino.turni[p, 1]) == 1 ? "Sì" : "No");
                                    }
                                    tc.Text += "<br/>";
                                }
                            }
                            tr.Cells.Add(tc);
                            tc = new TableCell();
                            Button btn = new Button();
                            btn.CssClass = "btn btn-circle btn-danger";
                            Label lbl = new Label();
                            lbl.CssClass = "fas fa-trash";
                            btn.Controls.Add(lbl);
                            btn.Click += EliminaBambino_click;
                            btn.ID     = "bambino" + k;
                            tc.Controls.Add(btn);
                            tr.Cells.Add(tc);
                            tableDettagli.Rows.Add(tr);
                            termineIscrizione.Enabled = true;
                        }
                    }
                    catch (Exception ex) { }
                }
            }
        }
示例#6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.Params["type"] == "0")
                {
                    //Aggiungi
                    Page.Title               = "Aggiungi Animatore";
                    salvaAnimatore.Text      = "Aggiungi";
                    annullaAnimatore.Visible = true;
                }
                else if (Request.Params["type"] == "1")
                {
                    //Modifica
                    Page.Title               = "Modifica Animatore";
                    salvaAnimatore.Text      = "Modifica";
                    annullaAnimatore.Visible = true;
                }
                else if (Request.Params["type"] == "2")
                {
                    //Visualizza
                    Page.Title = "Visualizza Animatore";
                    annullaAnimatore.Visible = false;
                    salvaAnimatore.Text      = "Chiudi";
                }
                else
                {
                    //ERRORE: Redirect to pagina precedente
                    Response.Redirect(Request.UrlReferrer.ToString());
                }


                string    sql    = @"select * 
                        from Province ORDER BY DescProvincia";
                adoNet    adoWeb = new adoNet();
                DataTable codice = adoWeb.eseguiQuery(sql, CommandType.Text);
                provinciaAnimatore.DataSource     = codice;
                provinciaAnimatore.DataTextField  = "DescProvincia";
                provinciaAnimatore.DataValueField = "CodProvincia";
                provinciaAnimatore.DataBind();
                provinciaAnimatore.SelectedIndex = -1;

                sql    = @"select * 
                        from Citta ORDER BY descri";
                adoWeb = new adoNet();
                codice = adoWeb.eseguiQuery(sql, CommandType.Text);
                cittaNascitaAnimatore.DataSource     = codice;
                cittaNascitaAnimatore.DataTextField  = "descri";
                cittaNascitaAnimatore.DataValueField = "IdCitta";
                cittaNascitaAnimatore.DataBind();
                cittaNascitaAnimatore.SelectedIndex = -1;

                sql    = @"select * 
                        from Nazioni ORDER BY DescNazione";
                adoWeb = new adoNet();
                codice = adoWeb.eseguiQuery(sql, CommandType.Text);
                nazionalitaAnimatore.DataSource     = codice;
                nazionalitaAnimatore.DataTextField  = "DescNazione";
                nazionalitaAnimatore.DataValueField = "IdNazione";
                nazionalitaAnimatore.DataBind();
                nazionalitaAnimatore.SelectedIndex = -1;
            }
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtEmailUser.Text == "")
            {
                lblErrore.Text = "Utente non valido";
            }
            else if (txtPasswordUser.Text == "")
            {
                lblErrore.Text = "Password non valida";
            }
            else
            {
                // Controllo campi di Input
                if (txtEmailUser.Text.Contains("'") || txtEmailUser.Text.Contains("\"") ||
                    txtPasswordUser.Text.Contains("'") || txtPasswordUser.Text.Contains("\""))
                {
                    lblErrore.Text = "Caratteri non validi.";
                    return;
                }

                // Crea stringa SQL per verificare validità Utente/password
                string sql = @"select ruolo, Personale.id, idCentro
                        from FreqPersonale
                        inner join Personale on idPersonale = Personale.id 
                        inner join Turni on idTurno = Turni.id
                        where email = '" + txtEmailUser.Text + "' " +
                             "and pwd = '" + txtPasswordUser.Text + "' " +
                             "and anno = " + DateTime.Now.Year;

                adoNet    adoWeb = new adoNet();
                DataTable codice = adoWeb.eseguiQuery(sql, CommandType.Text);

                if (codice.Rows.Count == 0)
                {
                    sql = @"select id
                        from Genitori
                        where email = '" + txtEmailUser.Text + "' " +
                          "and pwd = '" + SHA.GenerateSHA512String(txtPasswordUser.Text) + "' ";
                    string codiceG = adoWeb.eseguiScalar(sql, CommandType.Text);

                    if (codiceG != string.Empty)
                    {
                        Session["ruolo"] = "G";
                        Session["id"]    = codiceG;
                        sql                 = @"select idCentro
                        from Turni
inner join FreqBambini on idTurno = Turni.id
inner join ParenteleBambini on FreqBambini.idBambino = ParenteleBambini.idBambino
inner join Genitori on Genitori.id = ParenteleBambini.idGenitore
                        where Genitori.id = " + codiceG + " AND Turni.anno = " + DateTime.Now.Year;
                        codiceG             = adoWeb.eseguiScalar(sql, CommandType.Text);
                        Session["idCentro"] = codiceG;
                        Session.Timeout     = 180;
                        if (Request.UrlReferrer.ToString().Contains("Loggato"))
                        {
                            Response.Redirect(Request.UrlReferrer.ToString());
                        }
                        else
                        {
                            Response.Redirect("./Loggato/Index.aspx");
                        }
                    }
                    else
                    {
                        lblErrore.Text = "ATTENZIONE!!! Utente e/o password non validi";
                    }
                }
                else
                {
                    // creazione session
                    Session["ruolo"]    = codice.Rows[0]["ruolo"];
                    Session["id"]       = codice.Rows[0]["Personale.id"];
                    Session["idCentro"] = codice.Rows[0]["idCentro"];
                    Session.Timeout     = 180;
                    if (Request.UrlReferrer.ToString().Contains("Loggato"))
                    {
                        Response.Redirect(Request.UrlReferrer.ToString());
                    }
                    else
                    {
                        Response.Redirect("./Loggato/Index.aspx");
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["id"] == null)
            {
                Response.Redirect("../../Login.aspx");
            }
            else
            {
                adoNet adoWeb = new adoNet();
                try
                {
                    if (Request.Cookies["genitore1"].Value == null)
                    {
                        Response.Redirect("./DatiGenitori.aspx");
                    }
                    else
                    if (!IsPostBack)
                    {
                        adoNet.impostaConnessione();

                        TableRow  tr = new TableRow();
                        TableCell tc = new TableCell();

                        // 0 - idTurno; 1 - nBambini; 2 - settimane; 3 - fuoriComune
                        int[,] v = new int[20, 3];

                        for (int k = 0; k <= Request.Cookies.Count; k++)
                        {
                            try
                            {
                                if (Request.Cookies["bambino" + k].Value != null)
                                {
                                    Bambino newBambino = new Bambino();
                                    newBambino.readCookie(Request.Cookies["bambino" + k].Value);
                                    tr      = new TableRow();
                                    tc      = new TableCell();
                                    tc.Text = newBambino.nome;
                                    tr.Cells.Add(tc);
                                    tc      = new TableCell();
                                    tc.Text = newBambino.cognome;
                                    tr.Cells.Add(tc);
                                    tc      = new TableCell();
                                    tc.Text = newBambino.dataNascita.ToShortDateString();
                                    tr.Cells.Add(tc);
                                    tc = new TableCell();
                                    for (int p = 0; p < newBambino.turni.GetLength(0); p++)
                                    {
                                        if (Convert.ToInt32(newBambino.turni[p, 0]) != 0)
                                        {
                                            string    sql            = @"select * 
                                                            from Turni WHERE id = " + newBambino.turni[p, 0];
                                            DataTable dettaglioTurno = adoWeb.eseguiQuery(sql, CommandType.Text);
                                            tc.Text += " ♦ Turno " + dettaglioTurno.Rows[0].Field <int>("numero").ToString() + ": " + dettaglioTurno.Rows[0].Field <DateTime>("dataInizio").ToShortDateString() + " - " + dettaglioTurno.Rows[0].Field <DateTime>("dataFine").ToShortDateString() + " ";
                                            if (Convert.ToBoolean(dettaglioTurno.Rows[0].Field <bool>("servizioMensa")))
                                            {
                                                tc.Text += "- Mensa: " + (Convert.ToInt32(newBambino.turni[p, 1]) == 1 ? "Sì" : "No");
                                            }
                                            tc.Text += "<br/>";
                                        }
                                    }
                                    tr.Cells.Add(tc);
                                    tableDettagli.Rows.Add(tr);

                                    for (int p = 0; p < newBambino.turni.GetLength(0); p++)
                                    {
                                        if (Convert.ToInt32(newBambino.turni[p, 0]) != 0)
                                        {
                                            for (int o = 0; o < v.GetLength(0); o++)
                                            {
                                                if (v[o, 0] == Convert.ToInt32(newBambino.turni[p, 0]) &&
                                                    v[o, 2] == calcoloSettimane(newBambino.turni, p) &&
                                                    v[o, 3] == verificaComune(newBambino, p))
                                                {
                                                    v[o, 1]++;
                                                    break;
                                                }
                                                else
                                                {
                                                    for (int t = 0; t < v.GetLength(0); t++)
                                                    {
                                                        if (v[t, 0] == 0)
                                                        {
                                                            v[t, 0] = Convert.ToInt32(newBambino.turni[p, 0]);
                                                            v[t, 1] = 1;
                                                            v[t, 2] = calcoloSettimane(newBambino.turni, p);
                                                            v[t, 3] = verificaComune(newBambino, p);
                                                            break;
                                                        }
                                                    }
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            catch (Exception ex) { }
                        }


                        decimal totale = 0;

                        for (int o = 0; o < v.GetLength(0); o++)
                        {
                            if (v[o, 0] != 0)
                            {
                                tr = new TableRow();
                                tc = new TableCell();
                                string    sql            = @"select * 
                        from Turni WHERE id = " + v[o, 0];
                                DataTable dettaglioTurno = adoWeb.eseguiQuery(sql, CommandType.Text);
                                tc.Text += dettaglioTurno.Rows[0].Field <int>("numero").ToString() + "° Turno: " + dettaglioTurno.Rows[0].Field <DateTime>("dataInizio").ToShortDateString() + " - " + dettaglioTurno.Rows[0].Field <DateTime>("dataFine").ToShortDateString() + " ";
                                tr.Cells.Add(tc);
                                tc      = new TableCell();
                                tc.Text = v[o, 1].ToString();
                                tr.Cells.Add(tc);
                                tc      = new TableCell();
                                tc.Text = v[o, 2].ToString();
                                tr.Cells.Add(tc);
                                tc = new TableCell();
                                if (v[o, 2] <= dettaglioTurno.Rows[0].Field <int>("p1"))
                                {
                                    if (v[o, 1] < 3)
                                    {
                                        tc.Text = dettaglioTurno.Rows[0].Field <decimal>("p1quotaBamb" + v[o, 1]).ToString("F") + " €";
                                        totale += dettaglioTurno.Rows[0].Field <decimal>("p1quotaBamb" + v[o, 1]);
                                    }
                                    else
                                    {
                                        decimal calc = dettaglioTurno.Rows[0].Field <decimal>("p1quotaBamb3");
                                        for (int y = 3; y <= v[o, 1]; y++)
                                        {
                                            calc += dettaglioTurno.Rows[0].Field <decimal>("p1quotaBamb1");
                                        }
                                        tc.Text = calc.ToString("F") + " €";
                                        totale += calc;
                                    }
                                }
                                else
                                {
                                    if (v[o, 1] < 3)
                                    {
                                        tc.Text = dettaglioTurno.Rows[0].Field <decimal>("p2quotaBamb" + v[o, 1]).ToString("F") + " €";
                                        totale += dettaglioTurno.Rows[0].Field <decimal>("p2quotaBamb" + v[o, 1]);
                                    }
                                    else
                                    {
                                        decimal calc = dettaglioTurno.Rows[0].Field <decimal>("p2quotaBamb3");
                                        for (int y = 3; y <= v[o, 1]; y++)
                                        {
                                            calc += dettaglioTurno.Rows[0].Field <decimal>("p2quotaBamb1");
                                        }
                                        tc.Text = calc.ToString("F") + " €";
                                        totale += calc;
                                    }
                                }
                                if (v[o, 3] == 1)
                                {
                                    tc.Text += "<br/>   + " + (dettaglioTurno.Rows[0].Field <decimal>("quotaFuoriComune") * v[o, 1]).ToString("F") + " €";
                                    totale  += dettaglioTurno.Rows[0].Field <decimal>("quotaFuoriComune") * v[o, 1];
                                }
                                tr.Cells.Add(tc);
                                tablePagamento.Rows.Add(tr);
                            }
                        }
                        tr                 = new TableRow();
                        tc                 = new TableCell();
                        tc.ColumnSpan      = 3;
                        tc.Text            = "TOTALE:";
                        tc.Font.Bold       = true;
                        tc.HorizontalAlign = HorizontalAlign.Right;
                        tr.Cells.Add(tc);
                        tc           = new TableCell();
                        tc.Font.Bold = true;
                        tc.ID        = "totDaPagare";
                        tc.Text      = totale.ToString("F") + " €";
                        tr.Cells.Add(tc);
                        Response.Cookies["totDaPagare"].Value   = totale.ToString("F");
                        Response.Cookies["totDaPagare"].Expires = DateTime.Now.AddMinutes(30);
                        tablePagamento.Rows.Add(tr);
                    }
                    else
                    {
                    }
                }
                catch (Exception ex)
                {
                    Response.Redirect("./DatiGenitori.aspx");
                }
            }
        }