2
Guys good afternoon.
I’m having difficulty performing a task, which is as follows::
I have a customer registration, that when the user edits something from the register, when saving is presented a screen, for it indicate the reason for the change, but on this screen, can not leave the reason blank, that enters the problem..
I’m using IF to check whether it’s filled or not, but even if it falls on LSE and displaying my warning message, it closes the screen and goes back to the customer registration screen,
In the client registration screen, when clicking the save button, executes the code:
else if (editar == 1)
{
Observacao_cliente obs = new Observacao_cliente(id_cliente); // verificar qual tipo de retorno para poder cadastrar a atualização.
if (obs.ShowDialog() == DialogResult.OK)
{
chek_new_cli = cadastro_bd.cadastro_cliente(editar, textBox13.Text, textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, textBox15.Text, textBox16.Text, textBox6.Text, textBox9.Text, textBox10.Text, textBox11.Text, textBox12.Text, comboBox1.Text, bloq_v, textBox7.Text, textBox8.Text, textBox14.Text);
if (chek_new_cli > 0)
{
//inicia o cadastro no banco....
In the observation_client form, when clicking the save button, executes the code:
private void button1_Click(object sender, EventArgs e) // botão salvar
{
if (comboBox1.Text != string.Empty && textBox2.Text != string.Empty)
{
check_salvar = cadastro.cadastro_obs_cliente(id_cliente, dateTimePicker1.Text, comboBox1.Text, textBox2.Text);
if (check_salvar > 0)
{
this.Close();
}
}
else
{
MessageBox.Show("O título e nem o motivo podem estar em branco!", "Observações Gerais", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
Have you tried treating the Form Onclose event? On onclose you will test if the field is empty and does not change the state preventing the event from continuing.
– Andre Mesquita
Onclose? I will search on. Thank you.
– Thomas Erich Pimentel
Read this article showing how the event treatment works Article MSDN
– Andre Mesquita
Thanks a lot friend. I managed to settle with your help.
– Thomas Erich Pimentel