private void RecordEdit() { //Edit user string cUser = dataGridView1.CurrentRow.Cells["USER_NAME"].Value.ToString(); PowerUserForm pUserF = new PowerUserForm(this.Icon, this.Font); pUserF.textBox1.Text = cUser; var rslt = pUserF.ShowDialog(); if (rslt == DialogResult.OK) { if (pUserF.textBox1.Text.Trim().Length > 0) { OleDbCommand cmd = new OleDbCommand("", connection); cmd.CommandText = "update POWER_USERS set \n" + "USER_NAME='" + MainForm.StrToSQLStr(pUserF.textBox1.Text) + "' \n" + "where USER_NAME='" + MainForm.StrToSQLStr(cUser) + "'"; if (MainForm.cmdExecute(cmd) >= 0) { DS.Tables["POWER_USERS"].Clear(); daPowerUsers.Fill(DS, "POWER_USERS"); } } } }
private void btnAdd_Click(object sender, EventArgs e) { //Insert new user PowerUserForm pUserF = new PowerUserForm(this.Icon, this.Font); var rslt = pUserF.ShowDialog(); if (rslt == DialogResult.OK) { if (pUserF.textBox1.Text.Trim().Length > 0) { OleDbCommand cmd = new OleDbCommand("", connection); cmd.CommandText = "insert into POWER_USERS (USER_NAME) \n" + "values('" + MainForm.StrToSQLStr(pUserF.textBox1.Text) + "')"; if (MainForm.cmdExecute(cmd) >= 0) { DS.Tables["POWER_USERS"].Clear(); daPowerUsers.Fill(DS, "POWER_USERS"); } } } }