Example #1
0
        private void Ricerca()
        {
            Classi.ClassiAnagrafiche.Richiedenti _Richiedenti = new Classi.ClassiAnagrafiche.Richiedenti();
            this.txtsNome.DBDefaultValue    = "%";
            this.txtsCognome.DBDefaultValue = "%";
            S_ControlsCollection _SCollection = new S_ControlsCollection();

            _SCollection.AddItems(this.PanelRicerca.Controls);
            DataSet _MyDs = _Richiedenti.GetData(_SCollection).Copy();

            this.DataGridRicerca.DataSource = _MyDs.Tables[0];
            if (_MyDs.Tables[0].Rows.Count == 0)
            {
                DataGridRicerca.CurrentPageIndex = 0;
            }
            else
            {
                int Pagina = 0;
                if ((_MyDs.Tables[0].Rows.Count % DataGridRicerca.PageSize) > 0)
                {
                    Pagina++;
                }
                if (DataGridRicerca.PageCount != Convert.ToInt32((_MyDs.Tables[0].Rows.Count / DataGridRicerca.PageSize) + Pagina))
                {
                    DataGridRicerca.CurrentPageIndex = 0;
                }
            }

            this.DataGridRicerca.DataBind();
            this.GridTitle1.NumeroRecords = _MyDs.Tables[0].Rows.Count.ToString();
        }
        private void btnsSalva_Click(object sender, System.EventArgs e)
        {
            Classi.ClassiAnagrafiche.Richiedenti _Richiedenti_0 = new Classi.ClassiAnagrafiche.Richiedenti();
            this.txtsNome.DBDefaultValue    = "%";
            this.txtsCognome.DBDefaultValue = "%";
            this.CmbProgetto.DBDefaultValue = DBNull.Value;
            S_ControlsCollection _SCollection_0 = new S_ControlsCollection();

            S_Controls.Collections.S_Object s_p_nome = new S_Object();
            s_p_nome.ParameterName = "p_nome";
            s_p_nome.DbType        = CustomDBType.VarChar;
            s_p_nome.Direction     = ParameterDirection.Input;
            s_p_nome.Index         = 0;
            s_p_nome.Value         = txtsNome.Text;

            _SCollection_0.Add(s_p_nome);

            S_Controls.Collections.S_Object s_p_cognome = new S_Object();
            s_p_cognome.ParameterName = "p_cognome";
            s_p_cognome.DbType        = CustomDBType.VarChar;
            s_p_cognome.Direction     = ParameterDirection.Input;
            s_p_cognome.Index         = 1;
            s_p_cognome.Value         = txtsCognome.Text;

            _SCollection_0.Add(s_p_cognome);

            S_Controls.Collections.S_Object s_p_idGruppo = new S_Object();
            s_p_idGruppo.ParameterName = "p_idGruppo";
            s_p_idGruppo.DbType        = CustomDBType.Integer;
            s_p_idGruppo.Direction     = ParameterDirection.Input;
            s_p_idGruppo.Index         = 2;
            s_p_idGruppo.Value         = cmbsGruppo.SelectedValue;

            _SCollection_0.Add(s_p_idGruppo);

            S_Controls.Collections.S_Object s_p_idProgetto = new S_Object();
            s_p_idProgetto.ParameterName = "p_progetto";
            s_p_idProgetto.DbType        = CustomDBType.Integer;
            s_p_idProgetto.Direction     = ParameterDirection.Input;
            s_p_idProgetto.Index         = 3;
            s_p_idProgetto.Value         = CmbProgetto.SelectedValue;

            _SCollection_0.Add(s_p_idProgetto);


            DataSet _MyDs = _Richiedenti_0.CheckData(_SCollection_0).Copy();

            if (_MyDs.Tables[0].Rows.Count == 0 || itemId != 0)
            {
                this.txtsCognome.DBDefaultValue = DBNull.Value;
                this.txtsNome.DBDefaultValue    = DBNull.Value;
                if (CmbProgetto.SelectedValue == "0")
                {
                    //this.txtsCognome.Text=this.txtsCognome.Text.Trim();
                    //this.txtsNome.Text= this.txtsNome.Text.Trim();
                    this.cmbsGruppo.DBDefaultValue = DBNull.Value;
                }
                this.txtstelefono.DBDefaultValue = DBNull.Value;
                this.txtsemail.DBDefaultValue    = DBNull.Value;
                this.txtsstanza.DBDefaultValue   = DBNull.Value;

                int i_RowsAffected = 0;
                S_Controls.Collections.S_ControlsCollection _SCollection = new S_Controls.Collections.S_ControlsCollection();
                _SCollection.AddItems(this.PanelEdit.Controls);

                S_Controls.Collections.S_Object s_p_idProgetto1 = new S_Object();
                s_p_idProgetto1.ParameterName = "p_progetto";
                s_p_idProgetto1.DbType        = CustomDBType.Integer;
                s_p_idProgetto1.Direction     = ParameterDirection.Input;
                s_p_idProgetto1.Index         = 3;
                if (CmbProgetto.SelectedValue == "0")
                {
                    s_p_idProgetto1.Value = DBNull.Value;
                }
                else
                {
                    s_p_idProgetto1.Value = CmbProgetto.SelectedValue;
                }

                _SCollection.Add(s_p_idProgetto1);


                try
                {
                    if (itemId == 0)
                    {
                        Classi.ClassiAnagrafiche.Richiedenti _Richiedenti = new TheSite.Classi.ClassiAnagrafiche.Richiedenti();
                        i_RowsAffected = _Richiedenti.Add(_SCollection);
                    }
                    else
                    {
                        Classi.ClassiAnagrafiche.Richiedenti _Richiedenti = new TheSite.Classi.ClassiAnagrafiche.Richiedenti();
                        i_RowsAffected = _Richiedenti.Update(_SCollection, itemId);
                    }

                    if (i_RowsAffected > 0)
                    {
                        Server.Transfer("Richiedenti.aspx");
                    }
                }
                catch (Exception ex)
                {
                    string s_Err = ex.Message.ToString().ToUpper();
                    PanelMess.ShowError(s_Err, true);
                }
            }
            else
            {
                PanelMess.ShowError("Richiedente esistente", true);
            }
        }