private void button2_Click(object sender, EventArgs e) { RoleDetailFrm sysUser = new RoleDetailFrm(); sysUser.StartPosition = FormStartPosition.CenterParent; sysUser.ShowDialog(); }
public void insert() { Role r = new Role(); string role; RoleDetailFrm r1 = new RoleDetailFrm(); role = r.RoleName; MySqlConnection connection = new MySqlConnection("server = localhost; uid=root; database=umt"); string insert = "INSERT INTO system_users(Name,Username,Password,Address,Role) VALUES('" + txtName.Text + "','" + txtUserName.Text + "','" + txtPass.Text + "','" + txtAddress.Text + "','" + r.RoleName + "')"; connection.Open(); MySqlCommand cmd = new MySqlCommand(insert, connection); try { if (cmd.ExecuteNonQuery() == 1) { MessageBox.Show("Data Saved"); } else { MessageBox.Show("Data not Inserted"); } } catch (Exception) { MessageBox.Show("Error"); } connection.Close(); }