private void Valid()
        {
            if (btConcluirServico.Visibility == Visibility.Hidden)
            {
                ServicoBLL bll = new ServicoBLL();
                if (bll.ExisteNumeroBloco(int.Parse(txNumBloco.Text)))
                {
                    throw new Exception("Já existe um serviço com o N° do bloco informado");
                }
            }

            if (int.Parse(txNumBloco.Text) <= 0)
            {
                throw new Exception("Informe um N° de bloco válido");
            }

            if (txData.SelectedDate == null)
            {
                throw new Exception("Informe uma data correta");
            }

            if (string.IsNullOrEmpty(txCliente.Text))
            {
                throw new Exception("Informe o nome do cliente");
            }
        }
        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) { }
        }
        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);
            }
        }
Exemple #4
0
        private void btEditar_Click(object sender, EventArgs e)
        {
            if (dgvServico.SelectedRows.Count > 0)
            {
                var id = Convert.ToInt32(dgvServico.CurrentRow.Cells[0].Value.ToString());

                if (txtDescricao.Text == "")
                {
                    MessageBox.Show("Por favor escreva o nome do serviço !!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtDescricao.BackColor = Color.Yellow;
                    txtDescricao.Focus();
                    return;
                }

                if (txtPrecoServico.Text == string.Empty || txtPrecoServico.Text == "0" || txtPrecoServico.Text == "")
                {
                    MessageBox.Show("Campo preço do serviço esta vázio!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtPrecoServico.BackColor = Color.Yellow;
                    txtPrecoServico.Focus();
                    return;
                }

                Servico servico = new Servico();
                servico.Id = id;
                servico.DescricaoSERVICO = txtDescricao.Text;
                servico.PrecoSERVICO     = Convert.ToDecimal(txtPrecoServico.Text.ToString());

                ServicoBLL bll      = new ServicoBLL();
                bool       mensagem = bll.AlterarServico(servico);

                DesabiltarBotoes();
                LimpaCampos();
                CarregarServico(ListaServico());
            }
        }
        private void btIncluirServico_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Valid();
                SalvarServico();

                IncluirItemServico iis = new IncluirItemServico();
                iis.ShowDialog();

                if (iis.Item == null)
                {
                    return;
                }

                iis.Item.ServicoId = int.Parse(txNumBloco.Text);
                ServicoBLL bll = new ServicoBLL();
                bll.AdicionaItem(iis.Item);

                FillForm(iis.Item.ServicoId);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Atenção",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        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 btIncluirMaterial_Click(object sender, RoutedEventArgs e)
        {
            IncluirMaterialServico ims = new IncluirMaterialServico();

            ims.ShowDialog();

            if (ims.Cancelado)
            {
                return;
            }

            try
            {
                Valid();
                SalvarServico();

                ims.Material.ServicoId = int.Parse(txNumBloco.Text);

                ServicoBLL bll = new ServicoBLL();
                bll.AdicionaMaterial(ims.Material);

                FillForm(ims.Material.ServicoId);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Atenção",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        public static int MediaDiariaMaterial(this Material mat,
                                              DateTime dataInicio, DateTime dataFim)
        {
            ServicoBLL bll = new ServicoBLL();

            return(bll.GetMediaDiariaMaterial(mat.Id,
                                              dataInicio, dataFim));
        }
Exemple #9
0
 private void btExcluir_Click(object sender, EventArgs e)
 {
     if (txtCodigo.Text != "")
     {
         ServicoBLL bll      = new ServicoBLL();
         bool       mensagem = bll.ExcluirCadastro(Convert.ToInt32(txtCodigo.Text.ToString()));
         //  DesabiltarBotoes();
         CarregarServico(ListaServico());
     }
 }
Exemple #10
0
        private void btIncuir_Click(object sender, EventArgs e)
        {
            Servico servico = new Servico();

            servico.DescricaoSERVICO = txtNomeFuncionario.Text;
            servico.PrecoSERVICO     = Convert.ToDecimal(txtNomeFuncionario.Text);

            ServicoBLL bll      = new ServicoBLL();
            string     mensagem = bll.CadastrarServico(servico);

            MessageBox.Show(mensagem, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            DesabiltarBotoes();

            CarregarServico(bll.ListaServico());
        }
Exemple #11
0
        private void FillServicosAndamento()
        {
            spServicos.Children.Clear();

            var            bll      = new ServicoBLL();
            List <Servico> servicos = bll.Search(txPesquisa.Text)
                                      .Where(s => !s.Finalizado).ToList();

            foreach (var serv in servicos)
            {
                var card = new CardServico(serv);
                card.Edicao += Card_Edicao;
                spServicos.Children.Add(card);
            }
        }
        private void btRemoverMaterial_Click(object sender, RoutedEventArgs e)
        {
            MaterialServico mat = (MaterialServico)datagridMateriais.SelectedItem;

            if (mat == null)
            {
                return;
            }

            ServicoBLL bll = new ServicoBLL();

            bll.RemoveMaterial(mat.Id);

            FillForm(mat.ServicoId);
        }
        private void btExcluir_Click(object sender, RoutedEventArgs e)
        {
            var res = MessageBox.Show($"Deseja realmente excluir o serviço e seus itens? \nEsta ação não poderá ser revertida!",
                                      "Excluir serviço", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (res == MessageBoxResult.No)
            {
                return;
            }

            ServicoBLL bll = new ServicoBLL();

            bll.Remove(int.Parse(txNumBloco.Text));
            Close();
        }
Exemple #14
0
        private void btEditar_Click(object sender, EventArgs e)
        {
            if (dgvFuncionarios.SelectedRows.Count > 0)
            {
                var id = Convert.ToInt32(dgvFuncionarios.CurrentRow.Cells[0].Value.ToString());

                Servico servico = new Servico();
                servico.Id = id;
                servico.DescricaoSERVICO = dgvFuncionarios.Text;
                servico.PrecoSERVICO     = Convert.ToDecimal(dgvFuncionarios.Text.ToString());

                ServicoBLL bll      = new ServicoBLL();
                bool       mensagem = bll.AlterarServico(servico);

                DesabiltarBotoes();
                CarregarServico(ListaServico());
            }
        }
        private void btRemoverServico_Click(object sender, RoutedEventArgs e)
        {
            ItemServico item = (ItemServico)dataGrid.SelectedItem;

            if (item == null)
            {
                return;
            }

            ServicoBLL bll = new ServicoBLL();

            try
            {
                bll.RemoveItem(item.Id);
            }
            catch { }
            FillForm(int.Parse(txNumBloco.Text));
        }
Exemple #16
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();
        }
Exemple #17
0
        private void btIncuir_Click(object sender, EventArgs e)
        {
            Servico servico = new Servico();

            if (txtDescricao.Text == "")
            {
                MessageBox.Show("Por favor escreva o nome do serviço !!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDescricao.BackColor = Color.Yellow;
                txtDescricao.Focus();
                return;
            }
            else
            {
                servico.DescricaoSERVICO  = txtDescricao.Text;
                txtPrecoServico.BackColor = Color.White;
            }

            if (txtPrecoServico.Text == string.Empty || txtPrecoServico.Text == "0" || txtPrecoServico.Text == "")
            {
                MessageBox.Show("Campo preço do serviço esta vázio!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtPrecoServico.BackColor = Color.Yellow;
                txtPrecoServico.Focus();
                return;
            }
            else
            {
                txtPrecoServico.BackColor = Color.White;
                servico.PrecoSERVICO      = Convert.ToDecimal(txtPrecoServico.Text);
            }

            ServicoBLL bll      = new ServicoBLL();
            string     mensagem = bll.CadastrarServico(servico);

            MessageBox.Show(mensagem, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            DesabiltarBotoes();

            CarregarServico(bll.ListaServico());
            LimpaCampos();
        }