private void metroButtonRegAddU_Click(object sender, EventArgs e) { if (metroTextBoxUnames.Text == "" || metroTextBoxPws.Text == "") { MessageBox.Show("Fields cannot be empty"); } else { CommonDBTransaction c = new CommonDBTransaction(); string sql = "SELECT * FROM Registar WHERE Username = '******'"; DataTable d = c.searchData(sql); metroGridRegs.DataSource = d; if (d.Rows.Count > 0) { MetroMessageBox.Show(this, "This Data already exist"); } else { Registar obj = new Registar(metroTextBoxUnames.Text, metroTextBoxPws.Text); RegistarTransactions tr = new RegistarTransactions(); tr.addRegistar(obj); MetroMessageBox.Show(this, "Data Saved Sucessfully !"); clearReg(); } } }
void DataGridViewReg() { RegistarTransactions c = new RegistarTransactions(); string sql = "SELECT * FROM Registar"; DataTable dt = c.searchData(sql); metroGridRegs.DataSource = dt; }