private void BindStatoLavoro(string idstato)
        {
            this.cmbsstatolavoro.Items.Clear();

            TheSite.Classi.ManProgrammata.SfogliaRdlOdlPaging _SfogliaRdlOdlPaging = new TheSite.Classi.ManProgrammata.SfogliaRdlOdlPaging("");

            DataSet _MyDs = _SfogliaRdlOdlPaging.GetStatoLavoro();

            if (_MyDs.Tables[0].Rows.Count > 0)
            {
                this.cmbsstatolavoro.DataSource = Classi.GestoreDropDownList.ItemBlankDataSource(
                    _MyDs.Tables[0], "descrizione", "id", "- Selezionare lo Stato di Lavoro  -", "");
                this.cmbsstatolavoro.DataTextField  = "descrizione";
                this.cmbsstatolavoro.DataValueField = "id";
                this.cmbsstatolavoro.DataBind();

                if (idstato != "")
                {
                    try                      //TODO: questo try cach non dovrebbe esistere in quanto la funzione non dovrebbe andare in errore
                    {
                        this.cmbsstatolavoro.SelectedValue = idstato;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            else
            {
                string s_Messagggio = "- Nessuno Stato di Lavoro  -";
                this.cmbsstatolavoro.Items.Add(Classi.GestoreDropDownList.ItemMessaggio(s_Messagggio, String.Empty));
            }
        }
        private void Ricerca(bool reset)
        {
            S_Controls.Collections.S_ControlsCollection CollezioneControlli = new S_Controls.Collections.S_ControlsCollection();

            // Data Da
            string giornoDA = "01";
            string meseDA   = cmbsMeseDa.SelectedValue;
            string annoDA   = cmbsAnnoDa.SelectedValue;
            string dataDA   = giornoDA + "/" + meseDA + "/" + annoDA;

            S_Controls.Collections.S_Object s_P_DaData = new S_Object();
            s_P_DaData.ParameterName = "P_DaData";
            s_P_DaData.DbType        = CustomDBType.VarChar;
            s_P_DaData.Direction     = ParameterDirection.Input;
            s_P_DaData.Index         = 0;
            s_P_DaData.Size          = 10;
            s_P_DaData.Value         = dataDA;
            CollezioneControlli.Add(s_P_DaData);

            // Data a
            string giornoA = DateTime.DaysInMonth(Int16.Parse(cmbsAnnoA.SelectedValue), Int16.Parse(cmbsMeseA.SelectedValue)).ToString();
            string meseA   = cmbsMeseA.SelectedValue;
            string annoA   = cmbsAnnoA.SelectedValue;
            string dataA   = giornoA + "/" + meseA + "/" + annoA;

            S_Controls.Collections.S_Object s_P_AData = new S_Object();
            s_P_AData.ParameterName = "P_AData";
            s_P_AData.DbType        = CustomDBType.VarChar;
            s_P_AData.Direction     = ParameterDirection.Input;
            s_P_AData.Index         = 1;
            s_P_AData.Size          = 10;
            s_P_AData.Value         = dataA;
            CollezioneControlli.Add(s_P_AData);

            // Servizio
            S_Controls.Collections.S_Object s_P_servizio = new S_Object();
            s_P_servizio.ParameterName = "P_servizio";
            s_P_servizio.DbType        = CustomDBType.Integer;
            s_P_servizio.Direction     = ParameterDirection.Input;
            s_P_servizio.Index         = 2;
            s_P_servizio.Value         = (cmbsServizio.SelectedValue == "0")?0:int.Parse(cmbsServizio.SelectedValue);
            CollezioneControlli.Add(s_P_servizio);

            // DITTA
            S_Controls.Collections.S_Object s_P_ditta = new S_Object();
            s_P_ditta.ParameterName = "P_ditta";
            s_P_ditta.DbType        = CustomDBType.Integer;
            s_P_ditta.Direction     = ParameterDirection.Input;
            s_P_ditta.Index         = 3;
            s_P_ditta.Value         = (cmbsDitta.SelectedValue == "0")?0:int.Parse(cmbsDitta.SelectedValue);
            CollezioneControlli.Add(s_P_ditta);

            // Ordine di Lavoro
            S_Controls.Collections.S_Object s_P_odl = new S_Object();
            s_P_odl.ParameterName = "P_odl";
            s_P_odl.DbType        = CustomDBType.Integer;
            s_P_odl.Direction     = ParameterDirection.Input;
            s_P_odl.Index         = 4;
            s_P_odl.Value         = (txtOrdineLavoro.Text == "")?0:int.Parse(txtOrdineLavoro.Text);
            CollezioneControlli.Add(s_P_odl);

            // Bl codice dell'edificio
            S_Controls.Collections.S_Object s_P_bl_id = new S_Object();
            s_P_bl_id.ParameterName = "P_bl_id";
            s_P_bl_id.DbType        = CustomDBType.VarChar;
            s_P_bl_id.Direction     = ParameterDirection.Input;
            s_P_bl_id.Index         = 5;
            s_P_bl_id.Size          = 50;
            s_P_bl_id.Value         = RicercaModulo1.TxtCodice.Text;
            CollezioneControlli.Add(s_P_bl_id);

            // Bl Descrizione dell'edificio
            S_Controls.Collections.S_Object s_P_campus = new S_Object();
            s_P_campus.ParameterName = "P_campus";
            s_P_campus.DbType        = CustomDBType.VarChar;
            s_P_campus.Direction     = ParameterDirection.Input;
            s_P_campus.Index         = 6;
            s_P_campus.Size          = 50;
            s_P_campus.Value         = RicercaModulo1.Campus;
            CollezioneControlli.Add(s_P_campus);

            // Cognome e nome dell'addetto
            S_Controls.Collections.S_Object s_P_addetto_id = new S_Object();
            s_P_addetto_id.ParameterName = "P_addetto_id";
            s_P_addetto_id.DbType        = CustomDBType.VarChar;
            s_P_addetto_id.Direction     = ParameterDirection.Input;
            s_P_addetto_id.Index         = 7;
            s_P_addetto_id.Size          = 250;
            s_P_addetto_id.Value         = Addetti1.NomeCompleto;
            CollezioneControlli.Add(s_P_addetto_id);

            // Richiesta di Lavoro
            S_Controls.Collections.S_Object s_P_rdl = new S_Object();
            s_P_rdl.ParameterName = "P_rdl";
            s_P_rdl.DbType        = CustomDBType.Integer;
            s_P_rdl.Direction     = ParameterDirection.Input;
            s_P_rdl.Index         = 8;
            s_P_rdl.Value         = (txtRichiestaLavoro.Text == "")?0:int.Parse(txtRichiestaLavoro.Text);
            CollezioneControlli.Add(s_P_rdl);

            // Descrizione
            S_Controls.Collections.S_Object s_P_descrizione = new S_Object();
            s_P_descrizione.ParameterName = "P_descrizione";
            s_P_descrizione.DbType        = CustomDBType.VarChar;
            s_P_descrizione.Direction     = ParameterDirection.Input;
            s_P_descrizione.Index         = 9;
            s_P_descrizione.Size          = 250;
            s_P_descrizione.Value         = txtDescrizione.Text;
            CollezioneControlli.Add(s_P_descrizione);

            // Stato della richiesta
            S_Controls.Collections.S_Object s_P_statoric = new S_Object();
            s_P_statoric.ParameterName = "P_statoric";
            s_P_statoric.DbType        = CustomDBType.Integer;
            s_P_statoric.Direction     = ParameterDirection.Input;
            s_P_statoric.Index         = 10;
            s_P_statoric.Value         = (cmbsstatolavoro.SelectedValue == "")?0:int.Parse(cmbsstatolavoro.SelectedValue);
            CollezioneControlli.Add(s_P_statoric);

            // Standard delle apparecchiature
            S_Controls.Collections.S_Object s_P_standard = new S_Object();
            s_P_standard.ParameterName = "P_standard";
            s_P_standard.DbType        = CustomDBType.Integer;
            s_P_standard.Direction     = ParameterDirection.Input;
            s_P_standard.Index         = 11;
            s_P_standard.Value         = (cmbsStdApparecchiature.SelectedValue == "")?0:int.Parse(cmbsStdApparecchiature.SelectedValue);
            CollezioneControlli.Add(s_P_standard);

            // Apparecchiature
            S_Controls.Collections.S_Object s_P_apparecchiatura = new S_Object();
            s_P_apparecchiatura.ParameterName = "P_apparecchiatura";
            s_P_apparecchiatura.DbType        = CustomDBType.VarChar;
            s_P_apparecchiatura.Direction     = ParameterDirection.Input;
            s_P_apparecchiatura.Size          = 50;
            s_P_apparecchiatura.Index         = 12;
            s_P_apparecchiatura.Value         = CodiceApparecchiature1.CodiceApparecchiatura;
            CollezioneControlli.Add(s_P_apparecchiatura);

            S_Controls.Collections.S_Object s_p_TipoManutenzione = new S_Object();
            s_p_TipoManutenzione.ParameterName = "p_TipoManutenzione";
            s_p_TipoManutenzione.DbType        = CustomDBType.Integer;
            s_p_TipoManutenzione.Direction     = ParameterDirection.Input;
            s_p_TipoManutenzione.Index         = 13;
            s_p_TipoManutenzione.Value         = Classi.TipoManutenzioneType.ManutenzioneProgrammata;
            CollezioneControlli.Add(s_p_TipoManutenzione);

            S_Controls.Collections.S_Object s_p_pageindex = new S_Object();
            s_p_pageindex.ParameterName = "pageindex";
            s_p_pageindex.DbType        = CustomDBType.Integer;
            s_p_pageindex.Direction     = ParameterDirection.Input;
            s_p_pageindex.Index         = 14;
            s_p_pageindex.Value         = 1;
            CollezioneControlli.Add(s_p_pageindex);

            S_Controls.Collections.S_Object s_p_pagesize = new S_Object();
            s_p_pagesize.ParameterName = "pagesize";
            s_p_pagesize.DbType        = CustomDBType.Integer;
            s_p_pagesize.Direction     = ParameterDirection.Input;
            s_p_pagesize.Index         = 15;
            s_p_pagesize.Value         = DataGrid1.PageSize;
            CollezioneControlli.Add(s_p_pagesize);

            TheSite.Classi.ManProgrammata.SfogliaRdlOdlPaging _SfogliaRdlOdlPaging = new TheSite.Classi.ManProgrammata.SfogliaRdlOdlPaging(Context.User.Identity.Name);
            DataSet _Ds = _SfogliaRdlOdlPaging.GetData(CollezioneControlli);


            CurrentPage.Text = _currentPageNumber.ToString();

            Double _totalPages = 1;

            if (reset == true)
            {
                int _totalRecords = _SfogliaRdlOdlPaging.Update(CollezioneControlli, 0);
                this.GridTitle1.NumeroRecords = _totalRecords.ToString();
                _totalPages     = _totalRecords / DataGrid1.PageSize;
                TotalPages.Text = (System.Math.Ceiling(_totalPages)).ToString();
            }
            else
            {
                _totalPages = Double.Parse(TotalPages.Text);
            }

            if (_currentPageNumber == 1)
            {
                PreviousPage.Enabled = false;

                if (_totalPages > 1)
                {
                    NextPage.Enabled = true;
                }
                else
                {
                    NextPage.Enabled = false;
                }
            }
            else
            {
                PreviousPage.Enabled = true;

                if (_currentPageNumber == _totalPages)
                {
                    NextPage.Enabled = false;
                }
                else
                {
                    NextPage.Enabled = true;
                }
            }


            if (int.Parse(TotalPages.Text) > 0)
            {
                this.GridTitle1.Visible = true;
                DataGrid1.Visible       = true;
                PagingLink.Visible      = true;
                DataGrid1.DataSource    = _Ds.Tables[0];
                DataGrid1.DataBind();
            }
            else
            {
                PagingLink.Visible      = false;
                DataGrid1.Visible       = false;
                this.GridTitle1.Visible = false;
            }
        }