public bool AdicionaBalancete(balancete balancetesp)
        {
            try
            {
                conservadoraEntities model = Conexao.getInstance();
                IQueryable<balancete> i = from p in model.balancetes select p;
                IEnumerable<balancete> max = i.OrderBy(p => p.idbalancete);

                if (max.Count() > 0)
                    balancetesp.idbalancete = max.Last().idbalancete == null ? 1 : max.Last().idbalancete + 1;
                else
                    balancetesp.idbalancete = 1;

                model.AddTobalancetes(balancetesp);

                model.SaveChanges();
                return true;
            }
            catch (Exception e)
            {
                var x = e.InnerException;
                return false;
            }
        }
        public bool SalvaBalancete(balancete balancetesp)
        {
            try
            {
                conservadoraEntities model = Conexao.getInstance();
                IQueryable<balancete> query = from p in model.balancetes where p.idbalancete == balancetesp.idbalancete select p;
                balancete balancetes2 = query.First();
                balancetes2.idbalancete = balancetesp.idbalancete;

                balancetes2.data = balancetesp.data;
                balancetes2.caminhoArquivo = balancetesp.caminhoArquivo;
                balancetes2.idcondominios = balancetesp.idcondominios;
                model.SaveChanges();
                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the balancetes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTobalancetes(balancete balancete)
 {
     base.AddObject("balancetes", balancete);
 }
 /// <summary>
 /// Create a new balancete object.
 /// </summary>
 /// <param name="idbalancete">Initial value of the idbalancete property.</param>
 /// <param name="idcondominios">Initial value of the idcondominios property.</param>
 /// <param name="apenasSindico">Initial value of the apenasSindico property.</param>
 public static balancete Createbalancete(global::System.Int32 idbalancete, global::System.Int32 idcondominios, global::System.Boolean apenasSindico)
 {
     balancete balancete = new balancete();
     balancete.idbalancete = idbalancete;
     balancete.idcondominios = idcondominios;
     balancete.apenasSindico = apenasSindico;
     return balancete;
 }
 public bool SalvaBalancete(balancete balancetesp, string acesso)
 {
     if (acesso != Conexao.SenhaAcesso) throw new Exception();
     return controle.SalvaBalancete(balancetesp);
 }