private void btConcluirServico_Click(object sender, RoutedEventArgs e)
        {
            Valid();

            var cx = new CaixaBLL().GetCaixaAberto();

            if (cx == null)
            {
                MessageBox.Show("O caixa deve estar aberto antes de realizar o pagamento do serviço",
                                "Atenção", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            ServicoBLL         bll   = new ServicoBLL();
            decimal            total = bll.Find(int.Parse(txNumBloco.Text)).GetTotalGeral();
            PagamentoAdiantado pa    = new PagamentoAdiantado(total,
                                                              int.Parse(txNumBloco.Text), true);

            pa.ShowDialog();

            if (pa.Confirmado)
            {
                Close();
            }
        }
        private void SalvarServico()
        {
            try
            {
                Valid();

                ServicoBLL bll  = new ServicoBLL();
                int        id   = int.Parse(txNumBloco.Text);
                Servico    serv = (id == 0
                    ? new Servico()
                    : bll.Find(id));
                if (serv == null)
                {
                    serv = new Servico();
                }

                serv.Id       = id;
                serv.Data     = txData.SelectedDate.Value;
                serv.Cliente  = txCliente.Text;
                serv.Telefone = txTelefone.Text;
                serv.Obs      = txObs.Text;

                bll.Save(serv);

                txNumBloco.IsEnabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Atenção",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        public void FillForm(int id)
        {
            try
            {
                var     bll  = new ServicoBLL();
                Servico serv = bll.Find(id);
                dataGrid.ItemsSource          = serv.ItemServico.ToList();
                datagridMateriais.ItemsSource = serv.MaterialServico.ToList();
                txNumBloco.Text       = serv.Id.ToString();
                txData.SelectedDate   = serv.Data;
                txCliente.Text        = serv.Cliente;
                txTelefone.Text       = serv.Telefone;
                txObs.Text            = serv.Obs;
                txTotalMateriais.Text = serv.GetTotalMateriais().ToString("N2");
                txTotalServicos.Text  = serv.GetTotalServicos().ToString("N2");
                txAdiantamento.Text   = serv.GetValorAdiantado().ToString("N2");
                txFalta.Text          = serv.GetValorRestantePagar().ToString("N2");

                btExcluir.Visibility         = Visibility.Visible;
                btConcluirServico.Visibility = Visibility.Visible;
                lbTitulo.Content             = $"Editando serviço, N° {txNumBloco.Text}";
                txNumBloco.IsEnabled         = false;
            }
            catch (Exception ex) { }
        }
Exemple #4
0
        private void btConfirmar_Click(object sender, RoutedEventArgs e)
        {
            Caixa          cx = new CaixaBLL().GetCaixaAberto();
            MovimentoCaixa mc = new MovimentoCaixa();

            mc.ServicoId      = ServicoId;
            mc.CaixaId        = cx.Id;
            mc.FormaPagamento = (int)comboBox.SelectedValue;
            mc.Valor          = decimal.Parse(txValorAdiantamento.Text);
            mc.Tipo           = (int)TipoMovCaixa.Entrada;
            mc.Obs            = $"Adiantamento de pagamento do serviço N° {ServicoId}";

            if (mc.FormaPagamento == -1)
            {
                MessageBox.Show("Selecione uma forma de pagamento",
                                "Atenção", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            MovimentoCaixaBLL bll = new MovimentoCaixaBLL();

            bll.Save(mc);

            if (FecharServico)
            {
                ServicoBLL servBLL = new ServicoBLL();
                var        serv    = servBLL.Find(ServicoId);
                serv.Finalizado = true;
                servBLL.Save(serv);

                List <MaterialServico> materiaisServ = serv.MaterialServico.ToList();

                foreach (MaterialServico m in materiaisServ)
                {
                    MaterialBLL matBll   = new MaterialBLL();
                    var         material = matBll.Find(m.MaterialId);
                    material.Estoque -= m.Quantidade;
                    matBll.Save(material);
                }
            }

            Confirmado = true;
            Close();
        }