Exemplo n.º 1
0
        private bool IsDup()
        {
            Classi.Function _Function = new TheSite.Classi.Function();
            // Nome della tabella
            string tabella = "Ditta";
            // Nome del campo sui cui effettuare la ricerca (WHERE)
            string campo_input = "Descrizione";
            // Il campo valore è relativo alla stringa
            string valore = "'" + txtsDescrizione.Text.Trim().Replace("'", "''") + "'";
            //valore = valore.Replace("'","''");
            // Nome del Campo restituito in Output
            string  campo_output = "Ditta_ID";
            DataSet _MyDs        = _Function.ControllaDuplicato(tabella, campo_input, valore, campo_output);

            // Controllo se ho trovato qualcosa con la descrizione passata in input
            if (_MyDs.Tables[0].Rows.Count == 0)             // se non trovo niente retistuisco false
            {
                return(false);
            }
            else
            {
                DataRow _Dr = _MyDs.Tables[0].Rows[0];
                // Controllo Se sono in modifica
                if (itemId > 0)
                {
                    //Controllo se sto modificando me stesso
                    if (Int32.Parse(_Dr[0].ToString()) != itemId)
                    {
                        return(true);                        // se non sto modificando me stesso restituisco true
                    }
                    else
                    {
                        return(false);                        // se non sto modificando me stesso restituisco false
                    }
                }
                else
                {
                    return(true);                    // se sto inserendo e ho trovato qualcosa restituisco true
                }
            }
        }
Exemplo n.º 2
0
        private bool ControllaDup()
        {
            Classi.Function _Function = new TheSite.Classi.Function();
            // Nome della tabella
            string tabella = "Contabilizzazione";
            // Nome del campo sui cui effettuare la ricerca (WHERE)
            string campo_input = "Contabilizzazione";
            // Il campo valore è relativo alla stringa
            string valore = "'" + txtsdescrizione.Text.Trim().Replace("'", "''") + "'";
            // Nome del Campo restituito in Output
            string campo_output = "IdContabilizzazione";

            DataSet _MyDs = _Function.ControllaDuplicato(tabella, campo_input, valore, campo_output);

            if (_MyDs.Tables[0].Rows.Count == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }