Ejemplo n.º 1
0
        public static bool TryToRun(Action <SqlConnection> execute, string onFailMessage)
        {
            do
            {
                try
                {
                    using (SqlConnection dbcon = new SqlConnection(ConnectionSettings.Instance.ConnectionString))
                    {
                        dbcon.Open();
                        execute(dbcon);
                        return(true);
                    }
                }
                catch (SqlException e)
                {
                    Alerts.Error(e.Message);
                    Console.Clear();
                }
            } while (MessageBox.Show(onFailMessage) == MessageBox.MessageBoxResult.Yes);

            return(false);
        }