Example #1
0
 private void LoadData()
 {
     try
     {
         this.Validate();
         this.swimmersBindingSource.EndEdit();
         this.swimmersTableAdapter.Update(this.poolBDDataSet);
         DataGridViewMain.Update();
         DataGridViewMain.Rows.Clear();
         SqlConnection con = new SqlConnection(this.swimmersTableAdapter.Connection.ConnectionString);
         con.Open();
         SqlCommand command = con.CreateCommand();
         command.CommandText = $"SELECT * FROM Swimmers";
         SqlDataReader reader = command.ExecuteReader();
         while (reader.Read())
         {
             DataGridViewMain.Rows.Add(reader[0], reader[1], reader[2], reader[3], reader[4], reader[5]);
         }
         reader.Close();
         con.Close();
         MessageBox.Show("Update successful");
     }
     catch (Exception)
     {
         MessageBox.Show("Update failed");
     }
 }
Example #2
0
        public static void Main()
        {
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Configure main logic:
            var factory    = new MessageBoxFactory();
            var mainForm   = new DataGridViewMain();
            var controller = new StandardController(mainForm, null);

#if !DEBUG
            try
            {
                controller.LoadApp();
            }
            catch (Exception a)
            {
                factory.ShowMessageBox(EMessageBox.Standard,
                                       string.Format(Resources.UnknownExceptionMessage, a.Message),
                                       Settings.Default.AppName,
                                       MessageBoxButtons.OK,
                                       MessageBoxIcon.Error);

                return;
            }
#else
            controller.LoadApp();
#endif

            Application.Run(mainForm);
        }
Example #3
0
        private void MainForm_Activated(object sender, EventArgs e)
        {
            this.Validate();
            this.swimmersBindingSource.EndEdit();
            this.swimmersTableAdapter.Update(this.poolBDDataSet);
            DataGridViewMain.Update();
            SqlConnection con = new SqlConnection(this.swimmersTableAdapter.Connection.ConnectionString);

            con.Open();
            SqlCommand command = con.CreateCommand();

            command.CommandText = $"SELECT * FROM Swimmers";
            SqlDataReader reader = command.ExecuteReader();

            DataGridViewMain.Rows.Clear();
            while (reader.Read())
            {
                DataGridViewMain.Rows.Add(reader[0], reader[1], reader[2], reader[3], reader[4], reader[5]);
            }
            reader.Close();
            con.Close();
        }