void BtnAlteraComissaoClick(object sender, EventArgs e) { if (dgvCadastro.Rows.Count == 0) { return; } int i = dgvCadastro.CurrentRow.Index; //float percentual_anterior = Globais.StrToFloat(dgvCadastro.Rows[i].Cells["Pago"].Value.ToString()); fAlteraComissao frm = new fAlteraComissao(); frm.total = Globais.StrToFloat(dgvCadastro.Rows[i].Cells["Valor"].Value.ToString()); frm.percentual = Globais.StrToFloat(dgvCadastro.Rows[i].Cells["Pago"].Value.ToString()); frm.pago = bool.Parse(dgvCadastro.Rows[i].Cells["PG"].Value.ToString()); frm.justificativa = dgvCadastro.Rows[i].Cells["Justificativa"].Value.ToString(); frm.ShowDialog(); if (!frm.result) { return; } //pago_zerado = (percentual_anterior > 0.001) && (frm.percentual < 0.001); pago_zerado = (frm.pago && (frm.percentual < 0.001)); dgvCadastro.Rows[i].Cells["PG"].Value = frm.pago; dgvCadastro.Rows[i].Cells["Justificativa"].Value = frm.justificativa; string fornecedor = dgvCadastro.Rows[i].Cells["FornecedorOrcamento"].Value.ToString(); DateTime data = DateTime.Parse(dgvCadastro.Rows[i].Cells["Data"].Value.ToString()); short orcamento = CodOrcamento(dgvCadastro.Rows[i].Cells["Orcamento"].Value.ToString()); short pedido = Globais.StrToShort(dgvCadastro.Rows[i].Cells["CodPedido"].Value.ToString()); cPedidos ped = new cPedidos(); int isel = Globais.StrToInt(dgvCadastro.Rows[i].Cells["isel"].Value.ToString()); int nsel = dgvSelecao.Rows.Count; if (rbtVendedor.Checked) { ped.AlteraPerVendedor(fornecedor, data, orcamento, pedido, frm.percentual, frm.justificativa); dgvSelecao.Rows[isel].Cells["PerVendedor"].Value = frm.percentual; dgvSelecao.Rows[isel].Cells["JusVendedor"].Value = frm.justificativa; ped.AlteraIdtVendedor(fornecedor, data, orcamento, pedido, frm.pago); dgvSelecao.Rows[isel].Cells["IdtVendedor"].Value = frm.pago ? "S" : "N"; } if (rbtConsultor.Checked) { ped.AlteraPerConsultor(fornecedor, data, orcamento, pedido, frm.percentual, frm.justificativa); dgvSelecao.Rows[isel].Cells["PerConsultor"].Value = frm.percentual; dgvSelecao.Rows[isel].Cells["JusConsultor"].Value = frm.justificativa; ped.AlteraIdtConsultor(fornecedor, data, orcamento, pedido, frm.pago); dgvSelecao.Rows[isel].Cells["IdtConsultor"].Value = frm.pago ? "S" : "N"; } if (rbtFilial.Checked) { ped.AlteraPerFilial(fornecedor, data, orcamento, pedido, frm.percentual, frm.justificativa); dgvSelecao.Rows[isel].Cells["PerFilial"].Value = frm.percentual; dgvSelecao.Rows[isel].Cells["JusFilial"].Value = frm.justificativa; ped.AlteraIdtFilial(fornecedor, data, orcamento, pedido, frm.pago); dgvSelecao.Rows[isel].Cells["IdtFilial"].Value = frm.pago ? "S" : "N"; } calcula(); Posiciona(fornecedor, data, orcamento, pedido); }
void BtnImprimeClick(object sender, EventArgs e) { fParametrosImpressaoCom frm = new fParametrosImpressaoCom(dgvCadastro); frm.ShowDialog(); if (!frm.result) { return; } cPedidos pedidos = new cPedidos(); if (pedidos.ListaComissao(dgvCadastro, rbtVendedor.Checked, rbtConsultor.Checked, rbtFilial.Checked, frm.somente_pago, frm.somente_pagar, frm.titulo, frm.justificativas)) { System.Diagnostics.Process.Start("explorer", "comissao.pdf"); } }
void AlteraIdt(DataGridViewRow row, string pago, float percentual) { string fornecedor = row.Cells["Fornecedor Orçamento"].Value.ToString(); DateTime data = DateTime.Parse(row.Cells["Data"].Value.ToString()); short orcamento = CodOrcamento(row.Cells["Orçamento"].Value.ToString()); short pedido = Globais.StrToShort(row.Cells["CodPedido"].Value.ToString()); cPedidos ped = new cPedidos(); if (rbtVendedor.Checked) { ped.AlteraIdtVendedor(fornecedor, data, orcamento, pedido, pago.Equals("S")); } if (rbtConsultor.Checked) { ped.AlteraIdtConsultor(fornecedor, data, orcamento, pedido, pago.Equals("S")); } if (rbtFilial.Checked) { ped.AlteraIdtFilial(fornecedor, data, orcamento, pedido, pago.Equals("S")); } if (pago.Equals("S")) { if (rbtVendedor.Checked) { ped.AlteraPerVendedor(fornecedor, data, orcamento, pedido, percentual, null); } if (rbtConsultor.Checked) { ped.AlteraPerConsultor(fornecedor, data, orcamento, pedido, percentual, null); } if (rbtFilial.Checked) { ped.AlteraPerFilial(fornecedor, data, orcamento, pedido, percentual, null); } } }
void BtnConfirmaClick(object sender, EventArgs e) { // verifica se os dados do cliente estão preenchidos cParceiro parceiro = new cParceiro(); string mensagem = ""; for (;;) { mensagem = ""; if (!parceiro.Le(cliente)) { MessageBox.Show("Cliente não cadastrado"); return; } if (parceiro.NOM_PARCEIRO.Length == 0) { mensagem = "NOME não preenchido"; } if (parceiro.NRO_CPF_CNPJ.Length == 0) { mensagem = mensagem + "\nCPF/CNPJ não preenchido"; } bool entrega = false; if (parceiro.DES_LOGRADOURO_ENTREGA.Length == 0) { if (parceiro.DES_LOGRADOURO.Length == 0) { mensagem = mensagem + "\nLOGRADOURO não preenchido"; } } else { entrega = true; } if (!entrega) { if (parceiro.NRO_ENDERECO.Length == 0) { mensagem = mensagem + "\nNRO não preenchido"; } if (parceiro.NOM_BAIRRO.Length == 0) { mensagem = mensagem + "\nBAIRRO não preenchido"; } if (parceiro.NOM_CIDADE.Length == 0) { mensagem = mensagem + "\nCIDADE não preenchido"; } if (parceiro.COD_ESTADO.Length == 0) { mensagem = mensagem + "\nESTADO não preenchido"; } if (parceiro.NRO_CEP.Length == 0) { mensagem = mensagem + "\nCEP não preenchido"; } } else { if (parceiro.NRO_ENDERECO_ENTREGA.Length == 0) { mensagem = mensagem + "\nNRO não preenchido"; } if (parceiro.NOM_BAIRRO_ENTREGA.Length == 0) { mensagem = mensagem + "\nBAIRRO não preenchido"; } if (parceiro.NOM_CIDADE_ENTREGA.Length == 0) { mensagem = mensagem + "\nCIDADE não preenchida"; } if (parceiro.COD_ESTADO_ENTREGA.Length == 0) { mensagem = mensagem + "\nESTADO não preenchido"; } if (parceiro.NRO_CEP_ENTREGA.Length == 0) { mensagem = mensagem + "\nCEP não preenchido"; } } if ((parceiro.NRO_FONE1.Length == 0) && (parceiro.NRO_CELULAR.Length == 0)) { mensagem = mensagem + "\nFONE não preenchido"; } if (mensagem.Length == 0) { break; } DialogResult r = MessageBox.Show(mensagem, "Atualizar cadastro?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.No) { break; } cControleAcesso acesso = new cControleAcesso(); frmCadParceiros frmCad = new frmCadParceiros(true); frmCad.where = "where COD_PARCEIRO='" + cliente + "'"; frmCad.ReadOnly = !acesso.PermissaoPrograma(Globais.sUsuario, Globais.sFilial, 2, "fCadParceiros"); frmCad.ShowDialog(); } if (mensagem.Length != 0) { return; } cOrcamentos orc = new cOrcamentos(); ArrayList itens = orc.VerificaEspecificos(fornecedor, data, orcamento); if (itens.Count > 0) { mensagem = "Itens sem código específico:"; foreach (string item in itens) { mensagem = mensagem + "\n" + item; } MessageBox.Show(mensagem, "Erro na consistência"); return; } string msg = ""; cPedidos pedidos = new cPedidos(); string cod_condicao = cbxCondicoesPagto.Text.Trim(); if (cod_condicao.Length > 10) { cod_condicao = cbxCondicoesPagto.Text.Substring(0, 10).Trim(); } int nro_pedido = 0; string idt_frete = rbtCliente.Checked ? "C" : "F"; if (dif > 0) { result = pedidos.Inclui(fornecedor, data, orcamento, 1, vlr_itens - dif, Globais.sUsuario, DateTime.Now, dtpEntrega.Value, dtpEntrega.Checked ? "S" : "N", dtpMontagem.Value, dtpMontagem.Checked ? "S" : "N", cod_condicao, edtTransportadora.Text, "", idt_frete, ref nro_pedido, ref msg); } else { result = pedidos.Inclui(fornecedor, data, orcamento, 1, vlr_itens - vlr_desconto, Globais.sUsuario, DateTime.Now, dtpEntrega.Value, dtpEntrega.Checked ? "S" : "N", dtpMontagem.Value, dtpMontagem.Checked ? "S" : "N", cod_condicao, edtTransportadora.Text, "", idt_frete, ref nro_pedido, ref msg); } if (!result) { MessageBox.Show("Pedido\n" + msg, "Erro na geração do pedido", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (dif > 0) { // se as fórmulas forem diferentes gera pedido de serviços para SOFTPLACE pedidos.Inclui(fornecedor, data, orcamento, 2, dif - vlr_desconto, Globais.sUsuario, DateTime.Now, dtpEntrega.Value, dtpEntrega.Checked ? "S" : "N", dtpMontagem.Value, dtpMontagem.Checked ? "S" : "N", cod_condicao, edtTransportadora.Text, servico, idt_frete, ref nro_pedido, ref msg); if (!result) { MessageBox.Show("Serviços\n" + msg, "Erro na geração do pedido", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } MessageBox.Show("Pedidos gerados com sucesso"); } else { MessageBox.Show("Pedido gerado com sucesso"); } Close(); }
private void ConsultaOrdenesButton_Click(object sender, RoutedEventArgs e) { cPedidos cPedidos = new cPedidos(); cPedidos.Show(); }
private void CabecalhoCliente(string COD_FORNECEDOR, DateTime DAT_ORCAMENTO, short COD_ORCAMENTO, bool servico) { cPedidos pedido = new cPedidos(); cPedidoPDF pedido_pdf = new cPedidoPDF(); pedido_pdf.cab2 = pedido.DadosCabecalho2(COD_FORNECEDOR, DAT_ORCAMENTO, COD_ORCAMENTO, servico); Tabela table = new Tabela(6); table.AddCell(Celula2("Cliente", 1, true)); table.AddCell(Celula2(pedido_pdf.cab2.cliente, 3, false)); table.AddCell(Celula2("CPF/CNPJ", 1, true)); table.AddCell(Celula2(pedido_pdf.cab2.cnpj, 1, false)); table.AddCell(Celula2("Endereço", 1, true)); table.AddCell(Celula2(pedido_pdf.cab2.endereco.Trim() + " " + pedido_pdf.cab2.numero.Trim() + " - " + pedido_pdf.cab2.compl.Trim() + "\r\n" + pedido_pdf.cab2.bairro.Trim() + " - " + pedido_pdf.cab2.cidade.Trim() + " - " + pedido_pdf.cab2.estado.Trim() + " - " + "CEP " + CEP.PoeEdicao(pedido_pdf.cab2.cep), 3, false)); table.AddCell(Celula2("IE", 1, true)); table.AddCell(Celula2(pedido_pdf.cab2.ie, 1, false)); table.AddCell(Celula2("Local Entrega", 1, true)); if (pedido_pdf.cab2.entrega.Trim().Length > 0) { table.AddCell(Celula2(pedido_pdf.cab2.entrega.Trim() + " " + pedido_pdf.cab2.numero_entrega.Trim() + " - " + pedido_pdf.cab2.compl_entrega.Trim() + "\r\n" + pedido_pdf.cab2.bairro_entrega.Trim() + " - " + pedido_pdf.cab2.cidade_entrega.Trim() + " - " + pedido_pdf.cab2.estado_entrega.Trim() + " - " + "CEP " + CEP.PoeEdicao(pedido_pdf.cab2.cep), 3, false)); } else { table.AddCell(Celula2(pedido_pdf.cab2.endereco.Trim() + " " + pedido_pdf.cab2.numero.Trim() + " - " + pedido_pdf.cab2.compl.Trim() + "\r\n" + pedido_pdf.cab2.bairro.Trim() + " - " + pedido_pdf.cab2.cidade.Trim() + " - " + pedido_pdf.cab2.estado.Trim() + " - " + "CEP " + CEP.PoeEdicao(pedido_pdf.cab2.cep), 3, false)); } table.AddCell(Celula2("IM", 1, true)); table.AddCell(Celula2(pedido_pdf.cab2.im, 1, false)); table.AddCell(Celula2("Contato", 1, true)); table.AddCell(Celula2(pedido_pdf.cab2.contato, 1, false)); table.AddCell(Celula2("Fone", 1, true)); string fones = FONES.Concatena(pedido_pdf.cab2.fone, pedido_pdf.cab2.fone2, pedido_pdf.cab2.celular, pedido_pdf.cab2.fone1_parceiro, pedido_pdf.cab2.fone2_parceiro, pedido_pdf.cab2.celular_parceiro); table.AddCell(Celula2(fones, 1, false)); table.AddCell(Celula2("email", 1, true)); table.AddCell(Celula2(pedido_pdf.cab2.email, 1, false)); doc.Add(table); }
private void cPedidosMenuItem_Click(object sender, RoutedEventArgs e) { cPedidos cPedidos = new cPedidos(); cPedidos.Show(); }
void CarregaPedidos() { string filtro_selecionados = ""; foreach (string selecionado in selecionados) { string[] partes = selecionado.Split(' '); string fornecedor_sel = partes[0].Trim(); DateTime data_sel = DateTime.Parse(partes[1].Trim()); string orcamento_sel = partes[2].Trim(); string pedido_sel = partes[3].Trim(); filtro_selecionados = filtro_selecionados + " or (a.COD_FORNECEDOR='" + fornecedor_sel + "' and " + "a.DAT_ORCAMENTO='" + data_sel.ToString("M/d/yyyy") + "' and " + "a.COD_ORCAMENTO=" + orcamento_sel + " and " + "a.COD_PEDIDO=" + pedido_sel + ")"; } cPedidos pedidos = new cPedidos(); this.Cursor = Cursors.WaitCursor; pedidos.CarregaSelecao(dgvCadastro, frmFiltro.fornecedor, frmFiltro.vendedor, frmFiltro.idt_ou_entrega, frmFiltro.idt_nao_entregues, frmFiltro.dias_nao_entregues, frmFiltro.idt_entrega_previstaI, frmFiltro.entrega_previstaI, frmFiltro.idt_entrega_previstaF, frmFiltro.entrega_previstaF, frmFiltro.idt_entrega_realI, frmFiltro.entrega_realI, frmFiltro.idt_entrega_realF, frmFiltro.entrega_realF, frmFiltro.idt_ou_montagem, frmFiltro.idt_nao_montados, frmFiltro.dias_nao_montados, frmFiltro.idt_montagem_previstaI, frmFiltro.montagem_previstaI, frmFiltro.idt_montagem_previstaF, frmFiltro.montagem_previstaF, frmFiltro.idt_montagem_realI, frmFiltro.montagem_realI, frmFiltro.idt_montagem_realF, frmFiltro.montagem_realF, frmFiltro.cliente, frmFiltro.consultor, "", filtro_selecionados, frmFiltro.pedido_fornec, frmFiltro.nf_fornec, frmFiltro.observacao, frmFiltro.idt_dataI, frmFiltro.dataI, frmFiltro.idt_dataF, frmFiltro.dataF, frmFiltro.idt_omitir_anos_anteriores, frmFiltro.idt_sem_previsao, frmFiltro.idt_pendentes_consultor, frmFiltro.idt_pendentes_vendedor, frmFiltro.idt_cadastroI, frmFiltro.cadastroI, frmFiltro.idt_cadastroF, frmFiltro.cadastroF); foreach (DataGridViewRow row in dgvCadastro.Rows) { row.Selected = false; } SetChecks(); this.Cursor = Cursors.Default; }
private void Colore() { double total = 0; int registros = 0; cPedidos pedido = new cPedidos(); foreach (DataGridViewRow row in dgvCadastro.Rows) { short codigo = Globais.StrToShort(row.Cells["Cod"].Value.ToString()); string fornecedor = row.Cells["Fornecedor"].Value.ToString(); DateTime data = DateTime.Parse(row.Cells["Data"].Value.ToString()); /* * if (false) * { * row.Cells["P"].Value = pedido.Existe(fornecedor, data, codigo) ? "S" : "N"; * row.Cells["M"].Value = orcamento.Especial(fornecedor, data, codigo); * } */ /* * switch (row.Cells["Situação"].Value.ToString()[0]) * { * case 'E': row.Cells["Situação"].Value = "Em Andamento"; break; * case 'C': row.Cells["Situação"].Value = "Cancelado"; break; * case 'S': row.Cells["Situação"].Value = "Substituido"; break; * case 'F': row.Cells["Situação"].Value = "Fechado"; break; * } */ DataGridViewCell cell = row.Cells["Sinal"]; cell.Style.BackColor = Color.Yellow; cell.Style.SelectionBackColor = Color.Yellow; cell.Value = "0"; if (row.Cells["Valor Itens"].Value != null) { float vlr_itens = Globais.StrToFloat(row.Cells["Valor Itens"].Value.ToString()); float vlr_desconto = Globais.StrToFloat(row.Cells["Desconto"].Value.ToString()); // colore de acordo com o limiar da caracteristica if ((row.Cells["Fornecedor"].Value != null) && (row.Cells["Característica"].Value != null)) { float per_consultor = Globais.StrToFloat(row.Cells["Comissão Consultor"].Value.ToString()); string caracteristica = row.Cells["Característica"].Value.ToString().Trim(); float limiar = Globais.StrToFloat(row.Cells["Limiar"].Value.ToString()); float sinal = orcamento.CalculaSinal(fornecedor, caracteristica, vlr_itens, vlr_desconto, per_consultor, limiar); cell.Value = sinal.ToString("#0"); cell.Style.BackColor = Color.Yellow; cell.Style.SelectionBackColor = Color.Yellow; if (sinal > 0) { cell.Style.BackColor = Color.Green; cell.Style.SelectionBackColor = Color.Green; } else if (sinal < 0) { cell.Style.BackColor = Color.Red; cell.Style.SelectionBackColor = Color.Red; } } total += (vlr_itens - vlr_desconto); } DataGridViewCell cellFornecedor = row.Cells["Fornecedor"]; DataGridViewCell cellValor = row.Cells["Valor"]; cellValor.Style.BackColor = cellFornecedor.Style.BackColor; cellValor.Style.SelectionBackColor = cellFornecedor.Style.SelectionBackColor; if (row.Cells["Preço Tabela Alterado"].Value != null) { int alterados = Globais.StrToInt(row.Cells["Preço Tabela Alterado"].Value.ToString()); if (alterados > 0) { cellValor.Style.BackColor = Color.Orange; cellValor.Style.SelectionBackColor = Color.Orange; } } if (row.Cells["Tabela Ativa"].Value != null) { string ativa = row.Cells["Tabela Ativa"].Value.ToString(); if (ativa.Equals("N")) { cellValor.Style.BackColor = Color.Red; cellValor.Style.SelectionBackColor = Color.Red; } } registros++; } edtTotal.Text = total.ToString("#,###,##0.00"); edtRegistros.Text = registros.ToString(); }
void BtnPedidoClick(object sender, EventArgs e) { if (dgvCadastro.Rows.Count == 0) { return; } int i = dgvCadastro.CurrentRow.Index; // pedidos com sinal negativo só podem ser gerados pelo administrador int sinal = int.Parse(dgvCadastro.Rows[i].Cells["Sinal"].Value.ToString()); if ((sinal < 0) && !Globais.bAdministrador) { MessageBox.Show("Esse pedido precisa de autorização"); return; } string fornecedor = dgvCadastro.Rows[i].Cells["Fornecedor"].Value.ToString().Trim(); string caracteristica = dgvCadastro.Rows[i].Cells["Característica"].Value.ToString().Trim(); DateTime data = DateTime.Parse(dgvCadastro.Rows[i].Cells["Data"].Value.ToString()); short codigo = Globais.StrToShort(dgvCadastro.Rows[i].Cells["Cod"].Value.ToString()); string especial = orcamento.Especial(fornecedor, data, codigo); if (especial.Equals("S") && !Globais.bAdministrador) { MessageBox.Show("Esse pedido precisa de autorização"); return; } float vlr_itens = Globais.StrToFloat(dgvCadastro.Rows[i].Cells["Valor Itens"].Value.ToString()); float vlr_desconto = Globais.StrToFloat(dgvCadastro.Rows[i].Cells["Desconto"].Value.ToString()); string cliente = dgvCadastro.Rows[i].Cells["Cliente"].Value.ToString().Trim(); cCaracteristicas caracteristicas = new cCaracteristicas(); string servico = ""; float dif = caracteristicas.DiferencaFormulas(fornecedor, caracteristica, data, codigo, ref servico); short dias = caracteristicas.DiasMontagem(fornecedor, caracteristica); cPedidos pedidos = new cPedidos(); if (pedidos.Existe(fornecedor, data, codigo)) { MessageBox.Show("Já existe pedido para esse orçamento", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } fGeraPedido frm = new fGeraPedido(dif, fornecedor, data, codigo, vlr_itens, vlr_desconto, servico, sinal, cliente, dias); frm.ShowDialog(); if (frm.result) { string msg = ""; if (!orcamento.AlteraStatus(fornecedor, data, codigo, 'F', ref msg)) { MessageBox.Show("Erro na alteração da situação\r\r" + msg); } if (!orcamento.AlteraPedido(fornecedor, data, codigo, 'S')) { MessageBox.Show("Erro na alteração do IDT de pedido"); } dgvCadastro.Rows[i].Cells["P"].Value = 'S'; dgvCadastro.Rows[i].Cells["Situação"].Value = "Fechado"; } }