3
I have three buttons, one for insert, another to alter and one for record.
The button of record will work to save data either from an insertion or a change.
How to identify which button I pressed to the button Record whether I am saving an insert or a change?
private void button_inserir_Click(object sender, EventArgs e)
{
this.Text = "Inserir dados";
textBox_ordenado.ReadOnly = false;
textBox_ordenado.Enabled = true;
textBox_ordenado.Focus();
textBox_subsidios.ReadOnly = false;
textBox_subsidios.Enabled = true;
textBox_subsidios.TabStop = true;
dateTimePicker_data.Enabled = true;
button_guardar.Visible = true;
}
private void button_alterar_Click(object sender, EventArgs e)
{
this.Text = "Alterar dados";
textBox_ordenado.ReadOnly = false;
textBox_ordenado.Enabled = true;
textBox_ordenado.Focus();
textBox_subsidios.ReadOnly = false;
textBox_subsidios.Enabled = true;
textBox_subsidios.TabStop = true;
dateTimePicker_data.Enabled = true;
button_guardar.Visible = true;
}
private void button_guardar_Click(object sender, EventArgs e)
{
if (button_inserir) // Não sei como fazer
{
// executa uma stored Procedure (inserir)
}
else if (button_alterar) // Não sei como fazer
{
// executa outra stored Procedure (alterar)
}
}
how about?
if(this.Text == "Inserir dados")
else if(this.Text == "Alterar dados")
– Marconi
Got that way @Marconi Thanks so much for the help
– Diogo Sousa
Glad I could help you @Diogo.
– Marconi
@Marconi Why not put an answer?
– stderr
@zekk doesn’t even need yours is already well completed.:)
– Marconi