public void Incluir(ModeloVenda modelo) { //if (modelo.ComData != DateTime.Now) //{ // throw new Exception("A data da compra não corresponde a data atual"); //} if (modelo.CliCod <= 0) { throw new Exception("O código do cliente deve ser informado"); } if (modelo.VenNome == "") { throw new Exception("O nome do cliente precisa ser informado"); } if (modelo.VendasMista == 0 && modelo.VenWinthor == 0) { throw new Exception("Identifique os valores de Vendas Winthor"); } if (string.IsNullOrEmpty(modelo.VenWinthor.ToString())) { throw new Exception("Identifique os valores de Vendas Winthor"); } DALVenda DALobj = new DALVenda(conexao); DALobj.Incluir(modelo); }
//------------------------------------------------------------------------------------------------------------------- public void Alterar(ModeloVenda obj) { //O nome da categoria é obrigatorio if (obj.ven_nfiscal <= 0) { throw new Exception("Campo não Informado"); } if (obj.ven_pagto_total <= 0) { throw new Exception("Campo obrigatorio"); } if (obj.ven_nparcela <= 0) { throw new Exception("Campo Obrigatorio"); } if (obj.ven_status <= 0) { throw new Exception("Campo Obrigatorio"); } DALVenda DALobj = new DALVenda(); DALobj.alterar(obj); }
public void Alterar(ModeloVenda modelo) { if (modelo.VenCod <= 0) { throw new Exception("O código da venda deve ser maior que zero!"); } if (modelo.VenNparcelas <= 0) { throw new Exception("O numero de parcelas deve ser maior que zero!"); } if (modelo.CliCod <= 0) { throw new Exception("O código do cliente deve ser informado!"); } if (modelo.VenTotal <= 0) { throw new Exception("O totals deve ser maior que zero!"); } if (modelo.VenNfiscal <= 0) { throw new Exception("O numero da nota fiscal deve ser maior que zero!"); } DALVenda DALObj = new DALVenda(conexao); DALObj.Alterar(modelo); }
private void filtrarData(DateTime inicio, DateTime fim) { if (inicio < fim) { dgvListaCondicionais.DataSource = DALVenda.carregarCondicionaisPorData(inicio, fim); } }
//------------------------------------------------------------------------------------------------------------------- public void Incluir(ModeloVenda obj, SqlConnection cn, SqlTransaction tran) { //O nome da categoria é obrigatorio if (obj.ven_nfiscal <= 0) { throw new Exception("Campo não Informado"); } if (obj.ven_pagto_total <= 0) { throw new Exception("Campo obrigatorio"); } if (obj.ven_nparcela <= 0) { throw new Exception("Campo Obrigatorio"); } if (obj.ven_status <= 0) { throw new Exception("Campo Obrigatorio"); } DALVenda DALobj = new DALVenda(); DALobj.incluir(obj, cn, tran); }
public void Alterar(ModeloVenda modelo) { if (modelo.VenNParcelas <= 0) { throw new Exception("O número de parcelas dever ser maior do que zero"); } if (modelo.CliCod <= 0) { throw new Exception("O código do fornecedor deve ser informado"); } if (modelo.VenTotal <= 0) { throw new Exception("O valor da venda deve ser informado"); } if (modelo.VenNFiscal <= 0) { throw new Exception("O número da nota fiscal deve ser informado"); } DALVenda DALobj = new DALVenda(conexao); DALobj.Alterar(modelo); }
public Boolean CancelarVenda(int codigo) { if (codigo <= 0) { throw new Exception("O código da venda deve ser maior que zero!"); } DALVenda DALObj = new DALVenda(conexao); return(DALObj.CancelarVenda(codigo)); }
public int QuantidadeParcelasNaoPagas(int Codigo) { if (Codigo <= 0) { throw new Exception("O número deve ser maior do que zero"); } DALVenda DALobj = new DALVenda(conexao); return(DALobj.QuantidadeParcelasNaoPagas(Codigo)); }
public ModeloVenda CarregaModeloVenda(int codigo) { if (codigo <= 0) { throw new Exception("O código da venda deve ser maior que zero!"); } DALVenda DALObj = new DALVenda(conexao); return(DALObj.CarregaModeloVenda(codigo)); }
public int QuantidadeParcelasNaoPagas(int Codigo) { if (Codigo <= 0) { throw new Exception("O código da venda deve ser maior que zero!"); } DALVenda DALObj = new DALVenda(conexao); return(DALObj.QuantidadeParcelasNaoPagas(Codigo)); }
public ModeloVenda CarregaModeloVenda(int codigo) { if (codigo <= 0) { throw new Exception("O número deve ser maior do que zero"); } DALVenda DALobj = new DALVenda(conexao); return(DALobj.CarregaModeloVenda(codigo)); }
public void IncluirW(ModeloVenda modelo) { if (modelo.VenWinthor <= 0) { throw new Exception("O valor da venda deve ser maior que zero"); } DALVenda DALobj = new DALVenda(conexao); DALobj.IncluirW(modelo); }
public void Excluir(int codigo) { if (codigo <= 0) { throw new Exception("O código da venda deve ser maior que zero!"); } DALVenda DALObj = new DALVenda(conexao); DALObj.Excluir(codigo); }
public CategoriaPagamento selecionarCategoriaPagamentoComID(int id) { //List<categoria> lista =new List<categoria>(); DALVenda objDAL = new DALVenda(); CategoriaPagamento cat; //var objDAL = new DALCategoria(); cat = objDAL.SelecionarCategoriaPagamentoComCodigo(id); //objDAL = null; return(cat); }
public void AlterarSf(ModeloVenda modelo) { if (modelo.VenCod <= 0) { throw new Exception("O código da compra dever ser maior do que zero"); } DALVenda DALobj = new DALVenda(conexao); DALobj.AlterarSf(modelo); }
public void Excluir(int codigo) { if (codigo <= 0) { throw new Exception("O número deve ser maior do que zero"); } DALVenda DALobj = new DALVenda(conexao); DALobj.Excluir(codigo); }
public Boolean CancelarVenda(int codigo) { if (codigo <= 0) { throw new Exception("O número deve ser maior do que zero"); } DALVenda DALobj = new DALVenda(conexao); return(DALobj.CancelarVenda(codigo)); }
private void btnRealizarCondicional_Click(object sender, EventArgs e)//modificar para condicional, será que manteremos o produto ou retiraremos já na condicional ? { if (listaprodutocondicional != null && listaprodutocondicional.Count > 0) { DALVenda venda = new DALVenda(); Condicional ven = new Condicional(); Cliente cli = new Cliente(); List <ItensCondicional> listiv = new List <ItensCondicional>(); ItensVenda iv = new ItensVenda(); DALPessoa dalpes = new DALPessoa(); cli = (dalpes.retornarCliente((int)cbClienteCond.SelectedValue)); ven.idCliente = cli.id;//(int)cbCliente.SelectedValue; // int testarProduto = 0; //ven.Valor = decimal.Parse(txtPreco.Text); ven.data = DateTime.Now; //ven.valorrestante = ven.Valor; //ven.idCategoriaPagamento = (int)cbTipoPagamento.SelectedValue; //ven.qtdParcelas = int.Parse(nudParcelamento.Text); //ven.valorrestante = 0; ven.status = "Pendente";//cbStatusCondicionalLista.SelectedValue.ToString(); foreach (ProdutoModel prod in listaprodutocondicional) { ItensCondicional iv2 = new ItensCondicional(); iv2.idProduto = prod.id; //ven.Valor = ven.Valor + prod.preco; //ven.valorrestante = ven.valorrestante + prod.preco; listiv.Add(iv2); } bool resultado = venda.RealizarCondicional(ven, listiv, cli); dgvListaCondicionais.DataSource = (new DALVenda().carregarCondicionais()).ToList(); dgvProdutosCondicional.DataSource = null; txtQtdCond.Text = ""; txtPrecoCond.Text = ""; if (resultado) { avisosCond.Text = "Condicional completado !"; } else { avisosCond.Text = "Condicional não completado !"; } } else { avisosCond.Text = "Selecine algum produto !"; } }
private void FrmVendas_Load(object sender, EventArgs e) { //dgvVendas.DataSource = DALVenda.CustomLoad(1, dtp_Venda.Value.Year.ToString() + "-" + dtp_Venda.Value.Month.ToString() + "-" + dtp_Venda.Value.Day.ToString()); dgvVendas.DataSource = DALVenda.Filtrar(1, dtp_Venda.Value.Year.ToString() + "-" + dtp_Venda.Value.Month.ToString() + "-" + dtp_Venda.Value.Day.ToString()); cb_data.Checked = true; txt_busca.Enabled = false; cb_fun.Enabled = false; //iniciando o combobox de funcionário cb_fun.DataSource = DALFuncionario.CarregarGrid(); cb_fun.ValueMember = "fun_cod"; cb_fun.DisplayMember = "fun_nome"; cb_fun.SelectedIndex = -1; }
public bool Excluir(CategoriaPagamento item) { //escreve a função de excluir, krl var objDAL = new DALVenda(); if (objDAL != null) { objDAL.Excluir(item); return(true); } else { return(false); } }
private void btnMudarStatus_Click(object sender, EventArgs e) { if (dgvListaCondicionais.RowCount > 0) { int id = (int)dgvListaCondicionais.CurrentRow.Cells[3].Value; //dgvVenda.DataSource = dgvListaCondicionais.DataSource; idCondicional = id; string status = cbStatusCondicionalLista.SelectedItem.ToString(); DALVenda objDAL = new DALVenda(); objDAL.ModificarStatusCondicional(id, status); avisosLista.Text = "Status do condicional modificado !"; dgvListaCondicionais.DataSource = (new DALVenda().carregarCondicionais()).ToList(); idCondicional = 0; //tabControl1.SelectTab(0); } else { MessageBox.Show("Não há condicional selecionado !"); } }
private void btnSalvar_Click(object sender, EventArgs e) { var cat = new CategoriaPagamento(); var BLLCat = new BLLVenda(); if (txtDescricao.Text != "" && DALVenda.SelecionarCodTipoPagamento(txtDescricao.Text) == 0) { cat.nome = txtDescricao.Text; BLLCat.Salvar(cat); txtDescricao.Text = ""; cbCategoria.DataSource = BLLVenda.listarCategoriaPagamento(); cbCategoria.ValueMember = "id"; cbCategoria.DisplayMember = "descricao"; MessageBox.Show("Salvo com sucesso !"); } else { MessageBox.Show("Informe algum nome ! Lembre-se, não pode ser um que já existe !"); } }
public bool Salvar(CategoriaPagamento item) { try { DALVenda DALobj = new DALVenda(); if (DALobj.Salvar(item) == true) { DALobj = null; return(true); } else { DALobj = null; return(false); } } catch (Exception) { return(false); } }
private void Btn_aplicar_Click(object sender, EventArgs e) { if (cb_data.Checked) { dgvVendas.DataSource = DALVenda.Filtrar(1, dtp_Venda.Value.Year.ToString() + "-" + dtp_Venda.Value.Month.ToString() + "-" + dtp_Venda.Value.Day.ToString()); } else if (cb_cliente.Checked) { if (txt_busca.Text != "") { try { dgvVendas.DataSource = DALVenda.Filtrar(2, txt_busca.Text); } catch { MessageBox.Show("cliente não cadastrado"); } } else { MessageBox.Show("Informe o nome do cliente"); } } else if (cb_funcionario.Checked) { if (cb_fun.Text != "") { dgvVendas.DataSource = DALVenda.Filtrar(3, cb_fun.Text); } else { MessageBox.Show("Informe o nome do funcionario"); } } else { dgvVendas.DataSource = DALVenda.CarregarGrid(); } }
private void btnFinalizarVenda_Click(object sender, EventArgs e) { try { //Analisando se todos os campos foram preenchidos if (cbxTipoPagamento.Text != "" & cbxStatus.Text != "") { /* ***************************************** * ***************** Venda ***************** * *****************************************/ venda.VendaData = DateTime.Now.Date; //Pegando as venda e vendo a quantidade DataTable tabela = DALVenda.CarregarGrid(); venda.VendaNotaFiscal = DateTime.Now.Date.ToString("dd/mm/yyyy") + "ADAPT" + tabela.Rows.Count; venda.VendaParcelas = int.Parse(cbxQuantParcela.Text); venda.VendaStatus = cbxStatus.Text; venda.TipoPagamentoCod = (int)cbxTipoPagamento.SelectedValue; //Cadastrando BLLVenda.Incluir(venda); //Pegando o id da compra salva venda.VendaCod = int.Parse(DALVenda.PegarId()); /* ***************************************** * *************** Prestação *************** * *****************************************/ if (venda.VendaParcelas > 1) //Analisando se teve parcelamento { //Criando um variavel para salvar a data da nova prestação DateTime ProximaPrestação = DateTime.Now.Date; //Criando e salvando as parcelas for (int i = 0; i < venda.VendaParcelas; i++) { venda.Parcelas.Add(new MParcelasVenda(ValorParcela, ProximaPrestação.AddMonths(i + 1), venda.VendaCod)); //Instanciando a parcela //Salvando as Parcelas BLLParcelasVenda.Incluir(venda.Parcelas[i]); } } else { //Criando e salvando as parcelas venda.Parcelas.Add(new MParcelasVenda(ValorParcela, DateTime.Now.Date, venda.VendaCod)); //Instanciando a parcela //Salvando as Parcelas BLLParcelasVenda.Incluir(venda.Parcelas[0]); } /* ***************************************** * ***************** Itens ***************** * *****************************************/ foreach (var item in venda.Itens) { item.VendaCod = venda.VendaCod; BLLItensVenda.Incluir(item); } MessageBox.Show("Venda Cadastrada com Sucesso"); Resultado = "OK"; Close(); } } catch (SqlException ex) { MessageBox.Show(ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnCarregarClientes_Click(object sender, EventArgs e) { dgvClientesParaCondicional.DataSource = DALVenda.carregarClientesParaCondicional(); }
public DataTable Localizar(DateTime dtinicial, DateTime dtfinal) { DALVenda DALobj = new DALVenda(conexao); return(DALobj.Localizar(dtinicial, dtfinal)); }
public DataTable Localizar(int codigo) { DALVenda DALobj = new DALVenda(conexao); return(DALobj.Localizar(codigo)); }
public static void Incluir(MVenda modelo) { DALVenda.Incluir(modelo); }
private void btnSalvar_Click(object sender, EventArgs e) { //int id = (int)dgvProdutos.CurrentRow.Cells[0].Value; if (listaproduto != null && listaproduto.Count > 0) { DALVenda venda = new DALVenda(); Venda ven = new Venda(); Cliente cli = new Cliente(); List <ItensVenda> listiv = new List <ItensVenda>(); ItensVenda iv = new ItensVenda(); DALPessoa dalpes = new DALPessoa(); cli = (dalpes.retornarCliente((int)cbCliente.SelectedValue)); ven.idCliente = cli.id;//(int)cbCliente.SelectedValue; //ven.Valor = decimal.Parse(txtPreco.Text); ven.data = DateTime.Now; //ven.valorrestante = ven.Valor; ven.idCategoriaPagamento = (int)cbTipoPagamento.SelectedValue; ven.qtdParcelas = int.Parse(nudParcelamento.Text); ven.valorrestante = Convert.ToDecimal(txtPrecoFinal.Text); ven.Valor = Convert.ToDecimal(txtPrecoFinal.Text); ven.status = "Faturado"; foreach (ProdutoModel prod in listaproduto) { ItensVenda iv2 = new ItensVenda(); iv2.idProduto = prod.id; //foreach (ProdutoModel item in listaprodutocondicional) //{ // if (item.id == prod.id) // { // MessageBox.Show("Por favor, não selecione uma quantidade maior de um produto do que há"); // } //} // ven.Valor = ven.Valor + prod.preco; //ven.valorrestante = ven.valorrestante + prod.preco; listiv.Add(iv2); } //if(nudParcelamento.Value > 0) //{ //metodo diferente para parcelamentos //} bool resultado = venda.RealizarVenda(ven, listiv, cli); if (idCondicional != 0) { //string status = "Vendido"; venda.ModificarStatusCondicionalVenda(idCondicional); dgvListaCondicionais.DataSource = (new DALVenda().carregarCondicionais()).ToList(); idCondicional = 0; } if (resultado) { //avisos.Text = "Venda completada !"; MessageBox.Show("Venda completada !"); limparTextBoxes(this.Controls); limparTextBoxEMasked(tabPage1); dgvVenda.DataSource = null; //frmCADVenda_Load(sender,e); listaproduto = null; } else { MessageBox.Show("Venda não completada !"); } } else { avisos.Text = "Selecine algum produto !"; } }