-1
I need some help, but I don’t know how I can make this code.
I have a form and in this form I have a button that deletes in an SQL table, I want to make the button is disabled and to enable it I want to make the user type a password.
Follow the code of the button that calls the form to enter the password.
private void btnExcluir_Click(object sender, EventArgs e)
{
frmExclusao excluir = new frmExclusao(txtID.Text);
excluir.Show();
}
follow the password form code.
private void btn_Ok_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Confirma a exclusão do cadastro", "Atenção", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
{
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "DELETE FROM tbl_amostra WHERE ID = '" + txtID.Text + "'";
cmd.Connection = conex;
conex.Open();
cmd.ExecuteNonQuery();
conex.Close();
}
Could you give us more details? Is your project web? If so, are you using a jQuery, Angular...? Edit your question in more detail, so it’s easier to help you.
– Ana Carolina Manzan
Good morning. No and web and an executable in c#, I need to do the following when open the form the button is disabled, when I click with the mouse on the disabled button it open a new form, enter a password and give ok and then yes, enable the button to delete the data.
– Junior Guerreiro
What you’ve achieved so far?
– Cassio Alves
Your project is Win Forms, WPF...? The more details you can provide, the easier we can answer the question. If possible put a print screen on the question to get a better idea of what you want to do.
– Ana Carolina Manzan
You want to click a disabled button? ._.
– igventurelli
That’s right click on a disabled button it call another form, asking for a password to enable the button
– Junior Guerreiro