Exemple #1
0
 private void btnTestAll_Click(object sender, EventArgs e)
 {
     try
     {
         bool anyErrors = false;
         foreach (DataGridViewRow row in dataGridView1.Rows)
         {
             row.ErrorText = null;
             if (row.IsNewRow)
             {
                 continue;
             }
             dsConnections.ConnectionItemRow ci = (dsConnections.ConnectionItemRow)((DataRowView)row.DataBoundItem).Row;
             string message;
             if (!ci.Test(out message, this))
             {
                 anyErrors     = true;
                 row.ErrorText = message;
             }
         }
         if (!anyErrors)
         {
             MessageBox.Show("All connection strings are valid.");
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
Exemple #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == colLoginButton.Index)
                {
                    DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
                    if (row.IsNewRow)
                    {
                        return;
                    }

                    row.ErrorText = null;
                    dsConnections.ConnectionItemRow ci = (dsConnections.ConnectionItemRow)((DataRowView)row.DataBoundItem).Row;
                    if (ci.InteractiveLogin())
                    {
                        string message;
                        if (!ci.Test(out message, this))
                        {
                            row.ErrorText = message;
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }