private void btnLoadData_Click_1(object sender, EventArgs e) { try { this.lblCount.Text = "Plase wait..."; this.Enabled = false; switch (this.Text) { case "MMM 837P": { MMM837p clsMMM = new MMM837p(); //new MMM837p(server, database, uid, password); clsMMM.loadData(txtFoxFile.Text, lblTotal, dataGridView1); } break; case "PMC 837P": { MMM837p clsPMC = new MMM837p(); clsPMC.loadData(txtFoxFile.Text, lblTotal, dataGridView1); } break; } MessageBox.Show("Done..."); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { this.Enabled = true; this.lblCount.Text = "0"; } }