Archive for Ottobre, 2008

ASP.NET Compilation Models

WebReference News Ottobre 30th, 2008

This week we discuss the details of how ASP.NET applications are compiled. This information isn’t vital to your success as an ASP.NET developer, but understanding the architecture of your development environment makes you a better developer. By Jim Cheshire. 1027

Chiamata Form Comuni

CodeKeep C# Feed Ottobre 30th, 2008

Description: Chiamata Form Comuni

Link: http://www.codekeep.net/snippets/d9993e35-7dfd-4d7d-8104-7ad9e5b2cc18.aspx

            RicComune f = new RicComune();
            f.Comune = cOMUNEtextBox.Text;
            f.Provincia = "";
            f.SoloStatiEsteri = false;
            f.SoloValidi = false;
            f.ShowDialog();
            if (f.Selezione == true)
            {
                cOMUNELabel2.Text = f.CodCat;
                cOMUNEtextBox.Text = f.Comune;
                cAPTextBox.Text = f.Cap;
            }

How to select data from a DataTabe in a DataSet with LINQ

CodeKeep C# Feed Ottobre 29th, 2008

Description: Select and sort values from a TataTable and returns a OrderedEnumerableRowCollection.

Link: http://www.codekeep.net/snippets/6a2b80e9-b8f9-4f4f-b094-0d2d413bb237.aspx

var result = from row in titelDataSet1.Table1
             where row.Titel != ""
             orderby row.Titel ascending
             select row;

How to select data from a DataTabe in a DataSet with LINQ

CodeKeep C# Feed Ottobre 29th, 2008

Description: Select and sort values from a TataTable and returns a OrderedEnumerableRowCollection.

Link: http://www.codekeep.net/snippets/7e25ab99-b1a2-4df3-b27f-9488dcedc9be.aspx

var result = from row in DataSet.DataTable
                         where row.Surname == "Peter"
                         orderby row.Name ascending
                         select row;

Riga Slezionata in Datagridview

CodeKeep C# Feed Ottobre 29th, 2008

Description: Riga Slezionata in Datagridview

Link: http://www.codekeep.net/snippets/35aa538e-131b-4cf0-951e-ab553e060f61.aspx

            string rigasel = dataGridView1.CurrentRow.ToString();
            if (rigasel == "DataGridViewRow { Index=0 }")
            {
                MessageBox.Show("Selezionare una colonna");
            }
            else
            { MessageBox.Show("Riga selezionata");}

Cambia Impo Controlli

CodeKeep C# Feed Ottobre 29th, 2008

Description: Cambia le impostazioni di tutti i controlli di un form

Link: http://www.codekeep.net/snippets/76d6aef0-dc1e-4c11-91cd-fee54ea06b6e.aspx

        private void ResettaColori(Control control)
        {
            control.ForeColor = SystemColors.ControlText;
            if (this.HasChildren)
            {
                foreach (Control childControl in control.Controls)
                {
                    ResettaColori(childControl);
                }
            }
        }

Ritorna Comune

CodeKeep C# Feed Ottobre 29th, 2008

Description: Ritorna Comune

Link: http://www.codekeep.net/snippets/0c349dbb-2598-4698-a7a2-cd905f648a7f.aspx

private string RitornaComune(string CodCat, string NomeDB)
        {
            string conn = StringaConnessione.GetStringaConnessione(NomeDB);
            SqlConnection connection = new SqlConnection(conn);
            SqlDataAdapter adapter = new SqlDataAdapter();
            String StrSql = "SELECT COMUNE FROM COMUNI WHERE " +
                            "CODCAT='" + CodCat + "'";
            adapter.SelectCommand = new SqlCommand(StrSql, connection);
            SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
            connection.Open();
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet, "COMUNI");
            string DesComune = dataSet.Tables["COMUNI"].Rows[0]["COMUNE"].ToString();
            connection.Close();
            return DesComune;

        }

Controllo Campi Obbligatori

CodeKeep C# Feed Ottobre 29th, 2008

Description: Controllo Campi Obbligatori

Link: http://www.codekeep.net/snippets/5c57e134-5114-4476-95e8-248cdf5db150.aspx

        public bool ControlloCampiObbligatori()
        {
            bool Valida = true;

            Cfiscale cf = new Cfiscale();
            if (!cf.Validate(cFISCALEAMMTextBox.Text, "DB0000"))
            {
                MessageBox.Show("Codice Fiscale Amministratore Errato!",
                "Errore di digitazione", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cFISCALEAMMTextBox.Focus();
                Valida = false;
            }
            if (!cf.Validate(cFISCALERESTextBox.Text, "DB0000"))
            {
                MessageBox.Show("Codice Fiscale Amministratore Errato!",
                "Errore di digitazione", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cFISCALERESTextBox.Focus();
                Valida = false;
            }
            if (!cf.Validate(cFISCALEPRESTextBox.Text, "DB0000"))
            {
                MessageBox.Show("Codice Fiscale Presidente Errato!",
                "Errore di digitazione", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cFISCALEPRESTextBox.Focus();
                Valida = false;
            }
            if (!cf.Validate(cFISCALEPSTextBox.Text, "DB0000"))
            {
                MessageBox.Show("Codice Fiscale Pruduttore Software!",
                "Errore di digitazione", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cFISCALEPSTextBox.Focus();
                Valida = false;
            }
            return Valida;

IsGuid

CodeKeep C# Feed Ottobre 29th, 2008

Description: check for is GUID

Link: http://www.codekeep.net/snippets/b73e4378-5716-4518-8dff-da5960b4be64.aspx

private bool IsGuid(string guid)
        {
            try
            {
                Guid id = new Guid(guid.ToString());
            }
            catch (FormatException)
            {
                return false;
            }
            return true;
        }

DataGrid a RunTime

CodeKeep C# Feed Ottobre 29th, 2008

Description: Impostazione di una datagrid a runtime

Link: http://www.codekeep.net/snippets/efbdce51-50f0-4666-abeb-dfeac8685c74.aspx

            System.Windows.Forms.DataGridViewCellStyle DgVs2 = new System.Windows.Forms.DataGridViewCellStyle();
            dataGridView1.Columns[2].AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
            DgVs2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            DgVs2.Format = "C2";
            DgVs2.ForeColor = System.Drawing.Color.Red;
            dataGridView1.Columns[2].DefaultCellStyle = DgVs2;
            dataGridView1.Columns[2].HeaderText = "Dare";
            dataGridView1.Columns[2].ReadOnly = true;
            dataGridView1.Columns[2].Width = 58;

Next »