Пример #1
0
        //Confirma e grava agência no banco
        private void btnConfirmar_Click(object sender, EventArgs e)
        {
            //Chamar a função de validação dos campos (validação centralizada em uma classe)
            Validar valida = new Validar();

            if (valida.valCampoVazio(this.Controls) == true)
            {
                //Incluir
                if (_altera == false)
                {
                    Gerenciador.Data.dbGerenciadorEntities objGerenciador = new Gerenciador.Data.dbGerenciadorEntities();
                    var objAgencia = new Gerenciador.Data.Agencia();

                    objAgencia.numero    = Convert.ToInt32(txtNumeroAgencia.Text);
                    objAgencia.banco     = Convert.ToInt32(cmbBancoCadAgencia.Text);
                    objAgencia.descricao = txtDescAgencia.Text;

                    objGerenciador.AddToAgencia(objAgencia);
                    objGerenciador.SaveChanges();

                    MessageBox.Show("Agência Cadastrada com sucesso!", "Cadastro", MessageBoxButtons.OK, MessageBoxIcon.Information,
                                    MessageBoxDefaultButton.Button2);
                    this.Close();
                }
                //ALTERAR
                else
                {
                    using (var objGerenciador = new dbGerenciadorEntities())
                    {
                        var objAgencia = new Gerenciador.Data.Agencia();
                        objAgencia = (from conv in objGerenciador.Agencia
                                      where conv.numero == _numeroAG
                                      select conv).First();

                        objAgencia.numero    = Convert.ToInt32(txtNumeroAgencia.Text);
                        objAgencia.banco     = Convert.ToInt32(cmbBancoCadAgencia.Text);
                        objAgencia.descricao = txtDescAgencia.Text;
                        objGerenciador.SaveChanges();

                        MessageBox.Show("Agência alterada com sucesso!", "Cadastro", MessageBoxButtons.OK, MessageBoxIcon.Information,
                                        MessageBoxDefaultButton.Button2);
                        this.Close();
                    }
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Create a new Agencia object.
 /// </summary>
 /// <param name="numero">Initial value of the numero property.</param>
 /// <param name="banco">Initial value of the banco property.</param>
 /// <param name="descricao">Initial value of the descricao property.</param>
 public static Agencia CreateAgencia(global::System.Int32 numero, global::System.Int32 banco, global::System.String descricao)
 {
     Agencia agencia = new Agencia();
     agencia.numero = numero;
     agencia.banco = banco;
     agencia.descricao = descricao;
     return agencia;
 }
Пример #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Agencia EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAgencia(Agencia agencia)
 {
     base.AddObject("Agencia", agencia);
 }