コード例 #1
0
 public int Cadastrar(Venda venda)
 {
     try
     {
         IntanciarVendaRepositorio();
         _banco.Entry(venda).State = EntityState.Added;
         return _banco.SaveChanges() == Sucesso ? Sucesso : Insucesso;
     }
     catch (CustomException erro)
     {
         throw new CustomException(erro.Message);
     }
     catch (Exception erro)
     {
         throw new Exception(erro.Message);
     }
 }
コード例 #2
0
 private Venda PopularVendaSemDinheiro(Venda venda)
 {
     try
     {
         return new Venda
         {
             Data = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day),
             LucroTotal = GetLucroDivididoPelaParcela(),
             IDTIPOPAGAMENTO = _tipoPagamentoRepositorio.GetIDPeloNome(cbbTipoDePagamento.Text),
             VendaTotal = GetTotalDividoPelaParcela(),
             IdUsuario = Usuarios.IDStatic
         };
     }
     catch (CustomException erro)
     {
         throw new CustomException(erro.Message);
     }
     catch (Exception erro)
     {
         throw new Exception(erro.Message);
     }
 }
コード例 #3
0
        private Venda PopularVendaComDinheiro(Venda venda)
        {
            try
            {
                InstanciaCaixaRepositorio();
                decimal valorTroco = Convert.ToDecimal(txtTroco.Text.Substring(2, txtTroco.Text.Length - 2));
                if (_caixaRepositorio.GetValor().Valor < valorTroco)
                {
                    MyErro.MyCustomException("Valor do troco acima do valor no caixa, é necessário abrir o caixa para a venda ocorrer corretamente.");
                }
                return new Venda
                {
                    Data = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day),
                    LucroTotal = GetLucroDivididoPelaParcela(),
                    IDTIPOPAGAMENTO = _tipoPagamentoRepositorio.GetIDPeloNome(cbbTipoDePagamento.Text),
                    VendaTotal = GetTotalDividoPelaParcela(),
                    IdUsuario = Usuarios.IDStatic
                };

            }
            catch (CustomException erro)
            {
                throw new CustomException(erro.Message);
            }
            catch (Exception erro)
            {
                throw new Exception(erro.Message);
            }
        }
コード例 #4
0
ファイル: frmCaixa.cs プロジェクト: mikemajesty/petshopv1
        private Venda PopularVendaSemDinheiro(Venda venda)
        {
            try
            {
                venda = new Venda();
                venda.Data = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                venda.LucroTotal = GetValorLucroTotal();
                venda.IDTIPOPAGAMENTO = _tipoPagamentoRepositorio.GetIDPeloNome(cbbTipoDePagamento.Text);
                venda.VendaTotal = GetValorNaComanda();
                venda.IdUsuario = Usuarios.IDStatic;
                return venda;

            }
            catch (CustomException erro)
            {
                throw new CustomException(erro.Message);
            }
            catch (Exception erro)
            {
                throw new Exception(erro.Message);
            }
        }
コード例 #5
0
ファイル: frmCaixa.cs プロジェクト: mikemajesty/petshopv1
 private Venda PopularVendaComDinheiro(Venda venda)
 {
     try
     {
         InstanciaCaixaRepositorio();
         decimal valorTroco = Convert.ToDecimal(txtTroco.Text.Substring(2, txtTroco.Text.Length - 2));
         if (_caixaRepositorio.GetValor().Valor < valorTroco)
         {
             MyErro.MyCustomException("É necessário abrir o caixa para a venda ocorrer corretamente.");
         }
         venda = new Venda();
         venda.Data = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
         venda.LucroTotal = GetValorLucroTotal();
         venda.IDTIPOPAGAMENTO = _tipoPagamentoRepositorio.GetIDPeloNome(cbbTipoDePagamento.Text);
         venda.VendaTotal = VendaTotal;
         venda.IdUsuario = Usuarios.IDStatic;
         return venda;
     }
     catch (CustomException erro)
     {
         throw new CustomException(erro.Message);
     }
     catch (Exception erro)
     {
         throw new Exception(erro.Message);
     }
 }
コード例 #6
0
        private Venda PopularVendaComDinheiro(Venda venda)
        {
            try
            {
                InstanciaCaixaRepositorio();
                decimal valorTroco = GetValorTroco();
                if (_caixaRepositorio.GetValor().Valor < valorTroco)
                {
                    MyErro.MyCustomException($"Você não possui {GetValorTroco()} no caixa. Atualize o valor ou adicione valor ao mesmo.");
                }
                return venda = new Venda
                {
                    Data = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day),
                    VendaTotal = VendaTotal,
                    LucroTotal = GetValorLucroTotal(),
                    IDTIPOPAGAMENTO = _tipoPagamentoRepositorio.GetIDPeloNome(cbbTipoDePagamento.Text),
                    IdUsuario = Usuarios.IDStatic
                };

            }
            catch (CustomException erro)
            {
                throw new CustomException(erro.Message);
            }
            catch (Exception erro)
            {
                throw new Exception(erro.Message);
            }
        }