コード例 #1
0
        private void Actualizar_Click(object sender, EventArgs e)
        {
            if (panelCaixasTexto.Enabled)
            {
                if (verificaCaixasTexto(sender, e) == false)
                {
                    MessageBox.Show("Todos os campos devem estar preenchidos!", "Verificação");
                    return;
                }

                SqlConnection conn = Global.Conn;
                SqlCommand cmd = new SqlCommand("Spupdatebalcao", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("nbalcao", int.Parse(nBalcaoTextBox.Text));
                cmd.Parameters.AddWithValue("ntelefone", int.Parse(ntelefoneTextBox.Text));
                cmd.Parameters.AddWithValue("nome", nomeTextBox.Text);
                cmd.Parameters.AddWithValue("horario", horarioTextBox.Text);
                cmd.Parameters.AddWithValue("país", paísTextBox.Text);
                cmd.Parameters.AddWithValue("localidade", localidadeTextBox.Text);
                cmd.Parameters.AddWithValue("endereco", enderecoTextBox.Text);
                cmd.Parameters.AddWithValue("codpostal", codPostalTextBox.Text);
                cmd.Parameters.AddWithValue("servicos", servicosTextBox.Text);
                cmd.Parameters.AddWithValue("fax", int.Parse(faxTextBox.Text));
                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro ao actualizar balcão!\n " + ex.Message);
                    return;
                }
                finally
                {
                    conn.Close();
                }

                panelCaixasTexto.Enabled = false;
                butActualizar.Text = "Actualizar";
                balcao balcao = new balcao();
                this.Close();
                balcao.Show();
            }
            else
            {
                panelCaixasTexto.Enabled = true;
                butActualizar.Text = "Guardar";
                butCancelar.Visible = true;
                butInserir.Enabled = false;
                butEliminar.Enabled = false;
            }
        }
コード例 #2
0
 private void butBalcao_Click(object sender, EventArgs e)
 {
     this.Hide();
     balcao balcao = new balcao();
     balcao.Show();
 }
コード例 #3
0
 private void butCancelar_Click(object sender, EventArgs e)
 {
     balcao balcao = new balcao();
     this.Close();
     balcao.Show();
 }
コード例 #4
0
        private void Eliminar_Click(object sender, EventArgs e)
        {
            if (butEliminar.Text == "Confirmar")
            {
                SqlConnection conn = Global.Conn;
                SqlCommand cmd = new SqlCommand("Deletebalcao", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("nbalcao", int.Parse(nBalcaoTextBox.Text));
                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro ao actualizar balcão!\n " + ex.Message);
                    return;
                }
                finally
                {
                    conn.Close();
                }

                butEliminar.Text = "Eliminar";
                balcao balcao = new balcao();
                this.Close();
                balcao.Show();
            }
            else
            {
                butEliminar.Text = "Confirmar";
                butCancelar.Visible = true;
                butInserir.Enabled = false;
                butActualizar.Enabled = false;
            }
        }