private void btnGuargar_Click(object sender, EventArgs e) { bool paso = false; VendedorRepositorio repositorio = new VendedorRepositorio(); //RepositorioBase<Vendedor> repositorio = new RepositorioBase<Vendedor>(); if (ValidarGuardar()) { Vendedor vendedor = LlenarClase(); vendedor.Fecha = DateTime.Now.Date; int id = (int)VendedorIdnumericUpDown1.Value; double sueldo = Convert.ToDouble(SueldotextBox.Value); double porciento = Convert.ToDouble(PorcientotextBox.Value); porciento /= 100; double retencion = (sueldo * porciento); RetenciontextBox.Text = Convert.ToString(retencion); if (id == 0) { paso = repositorio.Guardar(vendedor); } else { paso = repositorio.Modificar(vendedor); } if (paso) { if (id == 0) { MessageBox.Show("Registro Guardado Correctamente!"); } else { MessageBox.Show("Actualizado Guardado Correctamente!"); } LimpiarCampos(); } else { MessageBox.Show("Error al intentar Guardar o Actualizar!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void Consulta() { repDados = new VendedorRepositorio(); try { var vend = repDados.GetById(CodVen); if (vend.VendedorId > 0) { if (vend.StatusVend == "A") { cb_Status.SelectedIndex = 0; //Ativo } else { cb_Status.SelectedIndex = 1; //Inativo } tb_Nome.Text = vend.NomeVendedor; tb_Email.Text = vend.EmailVend; tb_CPF.Text = vend.CpfVend; tb_CNPJ.Text = vend.CnpjVend; tb_Tel1.Text = vend.Tel1Vend; tb_Tel2.Text = vend.Tel2Vend; tb_perCom.Text = vend.PerComissao.ToString(); } else { MessageBox.Show("Vendedor não foi Encontrado!!!", Funcoes.msgCab, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } repDados.Dispose(); } catch (Exception ex) { MessageBox.Show("Não foi possível obter os dados, devido aos erros abaixo\n\n" + ex.Message, Funcoes.msgCab, MessageBoxButtons.OK, MessageBoxIcon.Error); repDados.Dispose(); } }
public UnitOfWorkRepository(NpgsqlConnection context, NpgsqlTransaction transaction) { UsuarioRepositorio = new UsuarioRepositorio(context, transaction); CidadeRepositorio = new CidadeRepositorio(context, transaction); ClienteRepositorio = new ClienteRepositorio(context, transaction); ContaPagarParcelaPagamentoRepositorio = new ContaPagarParcelaPagamentoRepositorio(context, transaction); ContaPagarParcelaRepositorio = new ContaPagarParcelaRepositorio(context, transaction); ContaPagarRepositorio = new ContaPagarRepositorio(context, transaction); ContratoParcelaPagamentoRepositorio = new ContratoParcelaPagamentoRepositorio(context, transaction); ContratoParcelaRepositorio = new ContratoParcelaRepositorio(context, transaction); ContratoRepositorio = new ContratoRepositorio(context, transaction); ContratoServicoRepositorio = new ContratoServicoRepositorio(context, transaction); FormaPagamentoRepositorio = new FormaPagamentoRepositorio(context, transaction); FornecedorRepositorio = new FornecedorRepositorio(context, transaction); PessoaRepositorio = new PessoaRepositorio(context, transaction); ProdutoRepositorio = new ProdutoRepositorio(context, transaction); ServicoPrestadoRepositorio = new ServicoPrestadoRepositorio(context, transaction); TelefoneRepositorio = new TelefoneRepositorio(context, transaction); VendedorRepositorio = new VendedorRepositorio(context, transaction); RelatorioRepositorio = new RelatorioRepositorio(context, transaction); PagamentoComissaoRepositorio = new PagamentoComissaoRepositorio(context, transaction); }
private void Consulta() { int row = 0; string status = ""; VendedorRepositorio consVen = new VendedorRepositorio(); switch (cb_Status.SelectedIndex) { case 1: status = "A"; break; case 2: status = "I"; break; } var Vendedores = consVen.ConsultaVen(status, tb_Doc.Text, tb_nome.Text); if (Vendedores.Count > 0) { grd_Dados.Rows.Clear(); foreach (Vendedor vend in Vendedores) { //Adiciona o PDV na Grid grd_Dados.Rows.Add(); grd_Dados.Rows[row].Cells[0].Value = vend.VendedorId; grd_Dados.Rows[row].Cells[1].Value = vend.NomeVendedor; if (vend.CnpjVend.Length > 0) { grd_Dados.Rows[row].Cells[2].Value = vend.CnpjVend; } if (vend.CpfVend.Length > 0) { grd_Dados.Rows[row].Cells[2].Value = vend.CpfVend; } grd_Dados.Rows[row].Cells[3].Value = vend.Tel1Vend; grd_Dados.Rows[row].Cells[4].Value = vend.Tel2Vend; switch (vend.StatusVend) { case "A": grd_Dados.Rows[row].Cells[5].Value = "Ativo"; break; case "I": grd_Dados.Rows[row].Cells[5].Value = "Inativo"; break; } row++; } } else { grd_Dados.Rows.Clear(); } consVen.Dispose(); }
private void bt_Gravar_Click(object sender, EventArgs e) { repDados = new VendedorRepositorio(); Vendedor mod = new Vendedor(); List <ErrosDB> erros = new List <ErrosDB>(); string retorno = ""; string status = ""; //Verificar os automáticos Primeiro. if (cb_Status.Text == "" || cb_Status.SelectedIndex == 0) { status = "A"; //Ativo } else { status = "I"; //Inativo } //Verifica campos Obrigatórios if (tb_Nome.Text == "") { MessageBox.Show("É necessário informar o nome do Fornecedor!!!", Funcoes.msgCab, MessageBoxButtons.OK, MessageBoxIcon.Information); tb_Nome.Focus(); return; } try { //Cadastra o Fornecedor mod.VendedorId = CodVen; mod.StatusVend = status; mod.CpfVend = tb_CPF.Text; mod.CnpjVend = tb_CNPJ.Text; mod.NomeVendedor = tb_Nome.Text; mod.EmailVend = tb_Email.Text; mod.Tel1Vend = tb_Tel1.Text; mod.Tel2Vend = tb_Tel2.Text; if (tb_perCom.Text != "") { mod.PerComissao = Convert.ToDecimal(tb_perCom.Text); } else { mod.PerComissao = 0; } if (CodVen > 0) //Modificar { erros = repDados.Update(mod); } else { erros = repDados.Add(mod); } if (erros.Count > 0) { foreach (ErrosDB erro in erros) { retorno += "Erro em: " + erro.PropertyName + " - " + erro.ErrorMessage + "\n"; } } else { retorno = "OK"; } } catch (Exception ex) { retorno = "Não foi possível gravar os dados, devido aos erros abaixo\n\n" + ex.Message; } if (retorno == "OK") { MessageBox.Show("Cadastro realizado com Sucesso!!!", Funcoes.msgCab, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Problemas ao realizar o cadastro!!!\n\nMais Detalhes Abaixo\n" + retorno, Funcoes.msgCab, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public VendedorServico() { _vendedorRepositorio = new VendedorRepositorio(); }