示例#1
0
        public string delete(string _reqDelete, string _tableName, Dictionary <int, DBParametre> _list_params)
        {
            string test = "";

            int nbrLigneDeleted = 0;

            try
            {
                con = SQLConnexion.getConnection();
                con.Open();
                MySqlCommand cmd = new MySqlCommand(_reqDelete, con);

                if (_list_params != null && _list_params.Count > 0)
                {
                    foreach (int key in _list_params.Keys)
                    {
                        DBParametre param = (DBParametre)_list_params[key];
                        cmd.Parameters.AddWithValue(param.ParameterName, param.Value);
                    }
                }

                nbrLigneDeleted = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                test = ex.Message;
                labo.modele.SYS_LOG_Modele.tracerException(ex);
            }

            // fermeture de la connexion
            try
            {
                con.Close();
            }
            catch (Exception ex)
            {
                test = ex.Message;
                labo.modele.SYS_LOG_Modele.tracerException(ex);
            }

            if (Outils.Fonctions_String.getString_toCompare(test).Equals("") &&
                nbrLigneDeleted <= 0)
            {
                test = "Suppression impossible";
            }

            return(test);
        }
示例#2
0
        public string executeNonQuery(string _req, Dictionary <int, DBParametre> _list_params)
        {
            string test = "";

            try
            {
                con = SQLConnexion.getConnection();
                con.Open();
                MySqlCommand cmd = new MySqlCommand(_req, con);

                if (_list_params != null && _list_params.Count > 0)
                {
                    foreach (int key in _list_params.Keys)
                    {
                        DBParametre param = (DBParametre)_list_params[key];
                        cmd.Parameters.AddWithValue(param.ParameterName, param.Value);
                    }
                }


                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                test = ex.Message;
                labo.modele.SYS_LOG_Modele.tracerException(ex);
            }

            // fermeture de la connexion
            try
            {
                con.Close();
            }
            catch (Exception ex)
            {
                test = ex.Message;
                labo.modele.SYS_LOG_Modele.tracerException(ex);
            }

            return(test);
        }
示例#3
0
        public DataTable getResults(string _reqSelect, string _tableName, Dictionary <int, DBParametre> _list_params)
        {
            DataSet   daSet1   = new DataSet();
            DataTable daTable1 = new DataTable();

            try
            {
                MySqlCommand cmd;
                con = SQLConnexion.getConnection();
                con.Open();
                cmd = new MySqlCommand(_reqSelect, con);

                if (_list_params != null && _list_params.Count > 0)
                {
                    foreach (int key in _list_params.Keys)
                    {
                        DBParametre param = (DBParametre)_list_params[key];
                        cmd.Parameters.AddWithValue(param.ParameterName, param.Value);
                    }
                }

                //cmd.Parameters.AddWithValue("@dt_cre", dt_cre);
                //cmd.Parameters.AddWithValue("@id_societe", _id_societe);

                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                adapter.Fill(daSet1, _tableName);
                daTable1 = daSet1.Tables[_tableName];
            }
            catch (Exception ex)
            {
                labo.modele.SYS_LOG_Modele.tracerException(ex, _reqSelect);
            }
            finally
            {
                con.Close();
            }
            return(daTable1);
        }