private void btnFinalizar_Click(object sender, EventArgs e) { Controller.FechamentoController fec = new Controller.FechamentoController(); Controller.AgendaController ac = new Controller.AgendaController(); Controller.VendaController vc = new Controller.VendaController(); //criar fechamento, atribuir nas vendas e agendamentos if (!String.IsNullOrEmpty(ttbCliente.Text) && !String.IsNullOrEmpty(mskTotalGeral.Text)) { double total = Convert.ToDouble(mskTotalGeral.Text.ToString()); int res = fec.gravarFechamento(pes, total); if (res > 0) { int i = 0; bool teste = false; while (i < listaAgenda.Count && !teste) { Entidades.Fechamento fechamento = new Entidades.Fechamento(); fechamento.Codigo = res; listaAgenda.ElementAt(i).Fechamento = fechamento; int p = ac.atualizaFechamento(listaAgenda.ElementAt(i)); if (p > 0) { i++; } else { teste = true; } } if (i < listaAgenda.Count) { MessageBox.Show("Erro ao atualizar agenda!"); } else { int k = 0; bool resp = false; while (k < listaVendas.Count && !resp) { int t = vc.atualizaFechamento(listaVendas.ElementAt(k).Codigo, res); if (t > 0) { k++; } else { teste = true; } } if (k < listaVendas.Count) { MessageBox.Show("Erro ao atualizar venda!"); } else { Views.Funcoes_Fundamentais.RF_F11_Quitar_Contas_a_Receber.GerarContasReceber gerar = new RF_F11_Quitar_Contas_a_Receber.GerarContasReceber(res, total, "fechamento", pes); gerar.ShowDialog(); } } } else { MessageBox.Show("Erro ao gravar fechamento!"); } } }
private void btnFecharVenda_Click(object sender, EventArgs e) { try { Controller.VendaController vendaController = new Controller.VendaController(); if (!String.IsNullOrWhiteSpace(ttbCliente.Text)) { if (listVendaProduto.Count > 0) { int rest = vendaController.gravaVendaProduto(DateTime.Now, "", Convert.ToDouble(mskValorTotal.Text), "", codPessoa, listVendaProduto); this.codV = rest; this.total = somaValorTotal(listVendaProduto); if (rest > 0) { MessageBox.Show("Venda Gravada com Sucesso!"); if (statusFiado == true) { DialogResult dialogResult = MessageBox.Show("Cliente habilitado para pagamento fiado. Deseja pagar no Fiado? ", "Aviso", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { MessageBox.Show("Uma venda foi gerada para o cliente para acertar depois!"); _limpaCampos(); } else if (dialogResult == DialogResult.No) { Views.Funcoes_Fundamentais.RF_F11_Quitar_Contas_a_Receber.GerarContasReceber gerarContas = new RF_F11_Quitar_Contas_a_Receber.GerarContasReceber(this.codV, this.total); gerarContas.ShowDialog(); _limpaCampos(); } } else { Views.Funcoes_Fundamentais.RF_F11_Quitar_Contas_a_Receber.GerarContasReceber gerarContas = new RF_F11_Quitar_Contas_a_Receber.GerarContasReceber(this.codV, this.total); gerarContas.ShowDialog(); _limpaCampos(); } } else { MessageBox.Show("Erro ao Finalizar venda!"); } } else { MessageBox.Show("Insira Produto(s) para finalizar a venda."); } } else { MessageBox.Show("Informe o Cliente"); } } catch (Exception) { throw; } }