private void newAccount()
        {
            if (txtName.Text != null /*&& novoTipo != null*/)
            {
                string connection = App.Connection;
                using (var ctx = new ControleDeGastosDataContext(App.Connection))
                {
                    //Sets the AccountTypeID index to the same index as
                    //the AccounType (option selected by the user)
                    ListAccountTypeID.SelectedIndex = ListAccountType.SelectedIndex;

                    TB_CONTA novaConta = new TB_CONTA()
                    {
                        CTA_NOME = txtName.Text,
                        TPC_ID = (long)ListAccountTypeID.SelectedItem,
                        CTA_DT_INICIO = System.DateTime.Today,
                        CTA_DT_FIM = Convert.ToDateTime(System.DateTime.MaxValue.ToString()),
                        CTA_VALOR_INICIAL = Convert.ToDecimal(txtInitialValue.Text),
                        MOE_ID = 1,
                        CTA_ENCERRADA = (bool) checkEncerrada.IsChecked,
                        CTA_FLAG_ATIVA = true
                    };

                    ctx.TB_CONTAS.InsertOnSubmit(novaConta);
                    ctx.SubmitChanges();
                }

                NavigationService.GoBack();
            }
            else
            {
                MessageBox.Show("Digite um nome");
            }
        }
 private void loadExistingAccountInfo()
 {
     foreach (TB_CONTA Account in ListAccount)
     {
         if (Account.CTA_ID == Convert.ToInt32(accountId))
         {
             currentAccount = Account;
             ListAccountType.SelectedIndex = ListAccountTypeID.Items.IndexOf(Account.TPC_ID);
             txtName.Text = Account.CTA_NOME;
             txtInitialValue.Text = Account.CTA_VALOR_INICIAL.ToString();
             checkEncerrada.IsChecked = Account.CTA_ENCERRADA;
             break;
         }
     }
     
 }
        private void appBarConfirmarButton_Click(object sender, EventArgs e)
        {
            if (txtName != null /*&& novoTipo != null*/)
            {
                string connection = App.Connection;
                using (var ctx = new ControleDeGastosDataContext(App.Connection))
                {
                    TB_TIPO_CONTA novoTipoConta = new TB_TIPO_CONTA()
                    {
                        TPC_NOME = "Banco",
                        TPC_FLAG_ATIVA = true
                    };

                    ctx.TB_TIPO_CONTAs.InsertOnSubmit(novoTipoConta);
                    ctx.SubmitChanges();

                    TB_CONTA novaConta = new TB_CONTA()
                    {
                        CTA_NOME = txtName.Text,
                        TPC_ID = 1,
                        CTA_DT_INICIO = System.DateTime.Today,
                        CTA_DT_FIM = System.DateTime.Today,
                        CTA_FLAG_ATIVA = true
                    };

                    ctx.TB_CONTAS.InsertOnSubmit(novaConta);
                    ctx.SubmitChanges();


                    NavigationService.GoBack();
                }
            }
            else
            {
                MessageBox.Show("Digite um nome e tipo");
            }
        }