void BtnAlteraClick(object sender, EventArgs e) { if (dgvCadastro.Rows.Count == 0) { return; } int i = dgvCadastro.CurrentRow.Index; string nf = dgvCadastro.Rows[i].Cells["NF"].Value.ToString().Trim(); short seq = Globais.StrToShort(dgvCadastro.Rows[i].Cells["Seq"].Value.ToString()); fCadTitulo frm = new fCadTitulo('a', nf, seq); frm.ShowDialog(); if (frm.result) { CarregaTitulos(); Grid.Sort(dgvCadastro, col_sorted, ord_sorted); for (i = 0; i < dgvCadastro.Rows.Count; i++) { string NF = dgvCadastro.Rows[i].Cells["NF"].Value.ToString().Trim(); if (NF.Equals(nf)) { dgvCadastro.Rows[i].Cells["Vencimento"].Selected = true; break; } } } }
void Colore() { foreach (DataGridViewRow row in dgvCadastro.Rows) { if ((bool)row.Cells["S"].Value) { row.DefaultCellStyle.BackColor = Color.SkyBlue; } else { row.DefaultCellStyle.BackColor = Color.White; } if (row.Cells["Data"].Value != null) { if (!row.Cells["Orçamento"].Value.ToString().Contains("/")) { int mes = DateTime.Parse(row.Cells["Data"].Value.ToString()).Month; int ano = DateTime.Parse(row.Cells["Data"].Value.ToString()).Year; string s = mes.ToString("0#") + "/" + ano.ToString("####") + " - " + row.Cells["Orçamento"].Value.ToString(); row.Cells["Orçamento"].Value = s; } } if (row.Cells["CodPedido"].Value != null) { short codpedido = Globais.StrToShort(row.Cells["CodPedido"].Value.ToString()); if (codpedido == 2) { row.Cells["Fornecedor"].Value = "SERVICO"; } } } }
void BtnConfirmaClick(object sender, EventArgs e) { cParametrosRemessa prms = new cParametrosRemessa(); prms.COD_EMPRESA = edtCodigo.Text; prms.NOM_EMPRESA = edtRazao.Text; prms.NRO_REMESSA = Globais.StrToInt(edtRemessa.Text); prms.NRO_NOSSO = Globais.StrToInt(edtNosso.Text); prms.COD_CARTEIRA = Globais.StrToInt(edtCarteira.Text); prms.COD_AGENCIA = Globais.StrToInt(edtAgencia.Text); prms.DIG_AGENCIA = Globais.StrToShort(edtDVAgencia.Text); prms.COD_CONTA = Globais.StrToInt(edtConta.Text); prms.DIG_CONTA = Globais.StrToShort(edtDVConta.Text); prms.PER_MULTA = Globais.StrToFloat(edtMulta.Text); prms.VLR_BONIFICACAO = Globais.StrToFloat(edtBonificacao.Text); prms.VLR_ATRASO = Globais.StrToFloat(edtAtraso.Text); prms.QTD_PRAZO_DESCONTO = Globais.StrToShort(edtPrazo.Text); prms.VLR_DESCONTO = Globais.StrToFloat(edtDesconto.Text); prms.DES_MENSAGEM1 = edtMsg1.Text; prms.DES_MENSAGEM2 = edtMsg2.Text; prms.DES_MENSAGEM3 = edtMsg3.Text; prms.DES_MENSAGEM4 = edtMsg4.Text; string msg = ""; if (!prms.Altera(ref msg)) { MessageBox.Show(msg, "Erro na gravação", MessageBoxButtons.OK, MessageBoxIcon.Error); } Close(); }
void BtnExcluiClick(object sender, EventArgs e) { if (dgvCadastro.Rows.Count == 0) { return; } int i = dgvCadastro.CurrentRow.Index; string nf = dgvCadastro.Rows[i].Cells["NF"].Value.ToString().Trim(); short seq = Globais.StrToShort(dgvCadastro.Rows[i].Cells["Seq"].Value.ToString()); string msg = ""; if (filtro_pedido.Length == 0) { DialogResult r = MessageBox.Show(nf + "-" + seq.ToString(), "Confirma a exclusão?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.No) { return; } if (titulos.Exclui(nf, seq, ref msg)) { CarregaTitulos(); Grid.Sort(dgvCadastro, col_sorted, ord_sorted); } } else { titulos.Desassocia(nf, seq, ref msg); CarregaTitulos(); Grid.Sort(dgvCadastro, col_sorted, ord_sorted); } }
void BtnItensClick(object sender, EventArgs e) { if (dgvCadastro.Rows.Count == 0) { return; } int i = dgvCadastro.CurrentRow.Index; short codigo = Globais.StrToShort(dgvCadastro.Rows[i].Cells["Cod"].Value.ToString()); string fornecedor = dgvCadastro.Rows[i].Cells["Fornecedor"].Value.ToString(); DateTime data = DateTime.Parse(dgvCadastro.Rows[i].Cells["Data"].Value.ToString()); string cliente = dgvCadastro.Rows[i].Cells["Cliente"].Value.ToString(); string caracteristica = dgvCadastro.Rows[i].Cells["Característica"].Value.ToString().Trim(); cCaracteristicas caracteristicas = new cCaracteristicas(); string formula = caracteristicas.Formula(fornecedor, caracteristica); frmCadItens frm = new frmCadItens(); frm.fornecedor = fornecedor; frm.data = data; frm.cod_orcamento = codigo; frm.cliente = cliente; frm.tabela = dgvCadastro.Rows[i].Cells["Tabela"].Value.ToString(); frm.formula = formula; frm.pedido = dgvCadastro.Rows[i].Cells["P"].Value.ToString().Trim().Equals("S"); frm.ShowDialog(); string chave = dgvCadastro.Rows[i].Cells["Chave"].Value.ToString().Trim(); CarregaOrcamentos(); Grid.Sort(dgvCadastro, col_sorted, ord_sorted); Grid.MarcaSelecionados(dgvCadastro); Grid.Posiciona(dgvCadastro, chave); }
void DgvCadastroRowEnter(object sender, DataGridViewCellEventArgs e) { edtResumo.Text = dgvCadastro.Rows[e.RowIndex].Cells["Resumo"].Value.ToString(); edtUsuario.Text = dgvCadastro.Rows[e.RowIndex].Cells["Usuário"].Value.ToString(); dtpData.Value = DateTime.Parse(dgvCadastro.Rows[e.RowIndex].Cells["Data"].Value.ToString()); edtObservacao.Text = dgvCadastro.Rows[e.RowIndex].Cells["Observação"].Value.ToString(); edtTabela.Text = dgvCadastro.Rows[e.RowIndex].Cells["Tabela"].Value.ToString(); edtCaracteristica.Text = dgvCadastro.Rows[e.RowIndex].Cells["Característica"].Value.ToString(); fornecedor = dgvCadastro.Rows[e.RowIndex].Cells["Fornecedor"].Value.ToString(); cliente = dgvCadastro.Rows[e.RowIndex].Cells["Cliente"].Value.ToString(); consultor = dgvCadastro.Rows[e.RowIndex].Cells["Consultor"].Value.ToString(); DateTime data = DateTime.Parse(dgvCadastro.Rows[e.RowIndex].Cells["Data"].Value.ToString()); short codigo = Globais.StrToShort(dgvCadastro.Rows[e.RowIndex].Cells["Cod"].Value.ToString()); CarregaAnexos(fornecedor, data, codigo); // seta a comissao de acordo com o limiar da caracteristica if ((dgvCadastro.Rows[e.RowIndex].Cells["Fornecedor"].Value != null) && (dgvCadastro.Rows[e.RowIndex].Cells["Característica"].Value != null)) { float vlr_itens = Globais.StrToFloat(dgvCadastro.Rows[e.RowIndex].Cells["Valor Itens"].Value.ToString()); float vlr_desconto = Globais.StrToFloat(dgvCadastro.Rows[e.RowIndex].Cells["Desconto"].Value.ToString()); float per_consultor = Globais.StrToFloat(dgvCadastro.Rows[e.RowIndex].Cells["Comissão Consultor"].Value.ToString()); string caracteristica = dgvCadastro.Rows[e.RowIndex].Cells["Característica"].Value.ToString().Trim(); float limiar = Globais.StrToFloat(dgvCadastro.Rows[e.RowIndex].Cells["Limiar"].Value.ToString()); float sinal = orcamento.CalculaSinal(fornecedor, caracteristica, vlr_itens, vlr_desconto, per_consultor, limiar); cComissaoLimiar comissao = new cComissaoLimiar(); float vlr_orcamento = vlr_itens - vlr_desconto; float per_comissao = comissao.Calcula(fornecedor, caracteristica, vlr_orcamento, sinal); edtPerComissao.Text = per_comissao.ToString("#0.00"); edtVlrComissao.Text = (per_comissao * vlr_orcamento / 100f).ToString("###,##0.00"); } }
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); }
short CodOrcamento(string orcamento) { if (orcamento.Contains("/")) { return(Globais.StrToShort(orcamento.Substring(10))); } else { return(Globais.StrToShort(orcamento)); } }
void BtnFechaClick(object sender, EventArgs e) { if (dgvCadastro.Rows.Count > 0) { int i = dgvCadastro.CurrentRow.Index; nf = dgvCadastro.Rows[i].Cells["NF"].Value.ToString().Trim(); seq = Globais.StrToShort(dgvCadastro.Rows[i].Cells["Seq"].Value.ToString()); result = true; } Close(); }
void BtnConfirmaClick(object sender, EventArgs e) { fornecedor = edtCodigo.Text; idt_dataI = dtpDataI.Checked ? "S" : "N"; dataI = dtpDataI.Value; idt_dataF = dtpDataF.Checked ? "S" : "N"; dataF = dtpDataF.Value; idt_ou_entrega = chkOuEntrega.Checked ? "S" : "N"; idt_nao_entregues = chkNaoEntregues.Checked ? "S" : "N"; dias_nao_entregues = Globais.StrToShort(edtNaoEntregues.Text); idt_ou_montagem = chkOuMontagem.Checked ? "S" : "N"; idt_nao_montados = chkNaoMontados.Checked ? "S" : "N"; dias_nao_montados = Globais.StrToShort(edtNaoMontados.Text); idt_entrega_previstaI = dtpEntregaPrevistaI.Checked ? "S" : "N"; entrega_previstaI = dtpEntregaPrevistaI.Value; idt_entrega_previstaF = dtpEntregaPrevistaF.Checked ? "S" : "N"; entrega_previstaF = dtpEntregaPrevistaF.Value; idt_entrega_realI = dtpEntregaRealI.Checked ? "S" : "N"; entrega_realI = dtpEntregaRealI.Value; idt_entrega_realF = dtpEntregaRealF.Checked ? "S" : "N"; entrega_realF = dtpEntregaRealF.Value; idt_montagem_previstaI = dtpMontagemPrevistaI.Checked ? "S" : "N"; montagem_previstaI = dtpMontagemPrevistaI.Value; idt_montagem_previstaF = dtpMontagemPrevistaF.Checked ? "S" : "N"; montagem_previstaF = dtpMontagemPrevistaF.Value; idt_montagem_realI = dtpMontagemRealI.Checked ? "S" : "N"; montagem_realI = dtpMontagemRealI.Value; idt_montagem_realF = dtpMontagemRealF.Checked ? "S" : "N"; idt_omitir_anos_anteriores = chkAnosAnteriores.Checked ? "S" : "N"; idt_sem_previsao = chkSemPrevisao.Checked ? "S" : "N"; idt_pendentes_consultor = chkPendentesConsultor.Checked ? "S" : "N"; idt_pendentes_vendedor = chkPendentesVendedor.Checked ? "S" : "N"; montagem_realF = dtpMontagemRealF.Value; vendedor = cbxUsuarios.Text; cliente = edtCliente.Text; consultor = edtConsultor.Text; pedido_fornec = edtPedidoFornec.Text; nf_fornec = edtNFFornec.Text; observacao = edtObservacao.Text; idt_cadastroI = dtpCadastroI.Checked ? "S" : "N"; cadastroI = dtpCadastroI.Value; idt_cadastroF = dtpCadastroF.Checked ? "S" : "N"; cadastroF = dtpCadastroF.Value; result = true; float valor = 0; float.TryParse(edtVlrInicial.Text, out valor); vlr_inicial = (valor != 0) ? valor.ToString() : ""; float.TryParse(edtVlrFinal.Text, out valor); vlr_final = (valor != 0) ? valor.ToString() : ""; numero_pedido = edtPedido.Text; caracteristica = cbxCaracteristicas.Text; Close(); }
void AbreAnexo(string codigo) { if (dgvCadastro.Rows.Count == 0) { return; } int i = dgvCadastro.CurrentRow.Index; short cod_orcamento = Globais.StrToShort(dgvCadastro.Rows[i].Cells["Cod"].Value.ToString()); string fornecedor = dgvCadastro.Rows[i].Cells["Fornecedor"].Value.ToString(); DateTime data = DateTime.Parse(dgvCadastro.Rows[i].Cells["Data"].Value.ToString()); string fn = orcamento.CarregaAnexo(fornecedor, data, cod_orcamento, codigo); System.Diagnostics.Process.Start("explorer", fn); //File.Delete(fn); }
void BtnConfirmaClick(object sender, EventArgs e) { string msg = ""; bool result; short limiar = Globais.StrToShort(edtCodigo.Text); float valor = Globais.StrToFloat(edtDescricao.Text); if (acao == 'I') { acao = 'i'; return; } if (acao == 'A') { acao = 'a'; return; } if (acao == 'i') { result = comissao.Inclui(fornecedor, caracteristica, limiar, valor, ref msg); } else { result = comissao.Altera(fornecedor, caracteristica, limiar, valor, ref msg); } if (!result) { if (acao == 'i') { MessageBox.Show(limiar.ToString() + "\n" + msg, "Erro na inclusão da comissão", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(limiar.ToString() + "\n" + msg, "Erro na alteração da comissão", MessageBoxButtons.OK, MessageBoxIcon.Error); } } this.Cursor = Cursors.WaitCursor; comissao.Carrega(fornecedor, caracteristica, dgvCadastro); this.Cursor = Cursors.Default; int selecionado = Procura(limiar.ToString(), true); if (selecionado >= 0) { dgvCadastro.Rows[selecionado].Cells[0].Selected = true; AtualizaDados(selecionado); } DesabilitaEdicao(); }
public void Posiciona(string fornecedor, DateTime data, short orcamento, short pedido) { for (int i = 0; i < dgvCadastro.Rows.Count; i++) { string _fornecedor = dgvCadastro.Rows[i].Cells["Fornecedor"].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()); if (_fornecedor.Equals(fornecedor) && (_data == data) && (_orcamento == orcamento) && (_pedido == pedido)) { dgvCadastro.Rows[i].Cells[0].Selected = true; dgvCadastro.CurrentCell = dgvCadastro.Rows[i].Cells[0]; return; } } }
void BtnCopiaClick(object sender, EventArgs e) { if (dgvCadastro.Rows.Count == 0) { return; } int i = dgvCadastro.CurrentRow.Index; short cod_orcamento = Globais.StrToShort(dgvCadastro.Rows[i].Cells["Cod"].Value.ToString()); string fornecedor = dgvCadastro.Rows[i].Cells["Fornecedor"].Value.ToString(); DateTime data = DateTime.Parse(dgvCadastro.Rows[i].Cells["Data"].Value.ToString()); orcamento.Copia(fornecedor, data, cod_orcamento); string chave = dgvCadastro.Rows[i].Cells["Chave"].Value.ToString().Trim(); CarregaOrcamentos(); Grid.Sort(dgvCadastro, col_sorted, ord_sorted); Grid.MarcaSelecionados(dgvCadastro); Grid.Posiciona(dgvCadastro, chave); }
void BtnCadAnexosClick(object sender, EventArgs e) { if (dgvCadastro.Rows.Count == 0) { return; } int i = dgvCadastro.CurrentRow.Index; short codigo = Globais.StrToShort(dgvCadastro.Rows[i].Cells["Cod"].Value.ToString()); string fornecedor = dgvCadastro.Rows[i].Cells["Fornecedor"].Value.ToString(); DateTime data = DateTime.Parse(dgvCadastro.Rows[i].Cells["Data"].Value.ToString()); frmAnexosOrcamento frmCad = new frmAnexosOrcamento(); frmCad.fornecedor = fornecedor; frmCad.data = data; frmCad.cod_orcamento = codigo; frmCad.ShowDialog(); CarregaAnexos(fornecedor, data, codigo); dgvCadastro.Focus(); }
void BtnExcluiClick(object sender, EventArgs e) { string msg = ""; bool result; if (acao == 'c') { return; } result = comissao.Exclui(fornecedor, caracteristica, Globais.StrToShort(edtCodigo.Text), ref msg); if (!result) { MessageBox.Show(edtCodigo.Text + "\r\n" + Globais.ErroExclusao("Comissão encontrada", msg), "Erro na exclusão da comissão", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.Cursor = Cursors.WaitCursor; comissao.Carrega(fornecedor, caracteristica, dgvCadastro); this.Cursor = Cursors.Default; if (dgvCadastro.Rows.Count == 0) { InicializaCampos(); } }
void BtnItensClick(object sender, EventArgs e) { if (!Confirma()) { return; } acao = 'a'; short codigo = Globais.StrToShort(edtCodigo.Text); string fornecedor = edtFornecedor.Text; DateTime data = dtpData.Value; string cliente = edtCliente.Text; frmCadItens frm = new frmCadItens(); frm.pedido = (pedido != null) && pedido.Equals("S"); frm.fornecedor = fornecedor; cCaracteristicas caracteristicas = new cCaracteristicas(); frm.formula = caracteristicas.Formula(fornecedor, cbxCaracteristicas.Text); frm.data = data; frm.cod_orcamento = codigo; frm.cliente = cliente; frm.tabela = cbxTabelas.Text; frm.ShowDialog(); CalculaValores(); string salva; salva = edtPercent.Text; calculando = true; edtPercent.Text = ""; calculando = false; edtPercent.Text = salva; salva = edtPerConsultor.Text; calculando = true; edtPerConsultor.Text = ""; calculando = false; edtPerConsultor.Text = salva; }
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 CbxTabelasSelectedIndexChanged(object sender, EventArgs e) { if (carregando) { return; } cOrcamentos orcamentos = new cOrcamentos(); if (cbxCaracteristicas.Text.Trim().Length == 0) { return; } float valor = orcamentos.RecalculaTotal(edtFornecedor.Text, dtpData.Value, Globais.StrToShort(edtCodigo.Text), cbxCaracteristicas.Text.Trim(), cbxTabelas.Text.Trim()); edtValor.Text = valor.ToString("#,###,##0.00"); float total; total = Globais.StrToFloat(edtValor.Text) - Globais.StrToFloat(edtDesconto.Text); // - Globais.StrToFloat(edtVlrConsultor.Text); edtTotal.Text = total.ToString("#,###,##0.00"); }
void CalculaValores() { cOrcamentos orcamentos = new cOrcamentos(); float valor = orcamentos.RecalculaTotal(edtFornecedor.Text, dtpData.Value, Globais.StrToShort(edtCodigo.Text), cbxCaracteristicas.Text.Trim(), ""); edtValor.Text = valor.ToString("#,###,##0.00"); float total; total = Globais.StrToFloat(edtValor.Text) - Globais.StrToFloat(edtDesconto.Text); // - Globais.StrToFloat(edtVlrConsultor.Text); edtTotal.Text = total.ToString("#,###,##0.00"); }
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"; } }
void BtnImprimeClick(object sender, EventArgs e) { fParametrosImpressao frm = new fParametrosImpressao(); frm.ShowDialog(); if (!frm.result) { return; } //string pdf = "c:\\softplace\\receber.pdf"; string pdf = "receber.pdf"; string order = ""; if (col_sorted.Equals("Natureza")) { order = "order by b.DES_NATUREZA"; } else if (col_sorted.Equals("Vencimento")) { order = "order by a.DAT_VENCIMENTO"; } else if (col_sorted.Equals("NF")) { order = "order by a.NRO_NF"; } else if (col_sorted.Equals("Seq")) { order = "order by a.SEQ_TITULO"; } else if (col_sorted.Equals("Cliente")) { order = "order by a.COD_CLIENTE"; } else if (col_sorted.Equals("Valor")) { order = "order by a.VLR_PREVISTO"; } else if (col_sorted.Equals("Recebido")) { order = "order by a.VLR_RECEBIDO"; } else if (col_sorted.Equals("Recebimento")) { order = "order by a.DAT_RECEBIMENTO"; } if ((ord_sorted == SortOrder.Descending) && !order.Equals("")) { order += " desc"; } if (order.Equals("")) { order = "order by a.DAT_VENCIMENTO"; } if (frm.relatorio) { if (titulos.Gera(where, pdf, frm.titulo, frm.quartil1, frm.quartil2, frm.quartil3, order)) { System.Diagnostics.Process.Start("explorer", pdf); } } else { if (dgvCadastro.Rows.Count == 0) { return; } int i = dgvCadastro.CurrentRow.Index; string nf = dgvCadastro.Rows[i].Cells["NF"].Value.ToString().Trim(); short seq = Globais.StrToShort(dgvCadastro.Rows[i].Cells["Seq"].Value.ToString()); if (cRecibo.gera(pdf, nf, seq)) { System.Diagnostics.Process.Start("explorer", pdf); } } }
void BtnConfirmaClick(object sender, EventArgs e) { string area = edtArea.Text.Trim(); sArea = area; if (area.CompareTo("") == 0) { MessageBox.Show("Área", "Campo obrigatório", MessageBoxButtons.OK, MessageBoxIcon.Warning); edtArea.Focus(); return; } string produto = edtProduto.Text.Trim(); if (produto.CompareTo("") == 0) { MessageBox.Show("Produto", "Campo obrigatório", MessageBoxButtons.OK, MessageBoxIcon.Warning); edtProduto.Focus(); return; } int qtde; if (!int.TryParse(edtQtde.Text, out qtde) || (qtde == 0)) { MessageBox.Show("Quantidade", "Campo obrigatório", MessageBoxButtons.OK, MessageBoxIcon.Warning); edtQtde.Focus(); return; } string msg = ""; string especial; bool result; if (acao == 'I') { acao = 'i'; return; } if (acao == 'A') { acao = 'a'; return; } especial = item_especial ? "S" : "N"; if (item_especial) { preco_unitario = Globais.StrToFloat(edtPrecoFormula.Text); } if (acao == 'i') { result = orcamento.IncluiItem(fornecedor, data, cod_orcamento, area, produto, edtSubCodigo.Text, (short)qtde, edtMedidas.Text, preco_unitario, //StrToFloat(edtPrecoUnitario.Text), preco_tabela, especial, edtDescricaoProd.Text, edtTexto.Text, edtEspecificos.Text, ref msg); } else { result = orcamento.AlteraItem(fornecedor, data, cod_orcamento, area, Globais.StrToShort(edtDescricao.Text), produto, edtSubCodigo.Text, (short)qtde, edtMedidas.Text, preco_unitario, //StrToFloat(edtPrecoUnitario.Text), preco_tabela, especial, edtDescricaoProd.Text, edtTexto.Text, edtEspecificos.Text, ref msg); } if (!result) { if (acao == 'i') { MessageBox.Show(edtProduto.Text + "\n" + msg, "Erro na inclusão do item", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(edtProduto.Text + "\n" + msg, "Erro na alteração do item", MessageBoxButtons.OK, MessageBoxIcon.Error); } } orcamento.CarregaItens(dgvCadastro, fornecedor, data, cod_orcamento, formula, tabela); Colore(); Grid.Sort(dgvCadastro, col_sorted, ord_sorted); int selecionado = ProcuraItem(area, produto); if (selecionado >= 0) { dgvCadastro.Rows[selecionado].Cells[0].Selected = true; AtualizaDados(selecionado); AtualizaDadosLocal(selecionado); } DesabilitaEdicao(); SetaEdicaoLocal(false); }
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 BtnExcluiClick(object sender, EventArgs e) { string msg = ""; bool result; if (acao == 'c') { return; } result = orcamento.ExcluiItem(fornecedor, data, cod_orcamento, edtArea.Text.Trim(), Globais.StrToShort(edtDescricao.Text), ref msg); if (!result) { MessageBox.Show(edtDescricao.Text, "Erro na exclusão do item", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } orcamento.CarregaItens(dgvCadastro, fornecedor, data, cod_orcamento, formula, tabela); Colore(); if (dgvCadastro.Rows.Count == 0) { InicializaCampos(); } }
void BtnLoteClick(object sender, EventArgs e) { if (!Valida()) { return; } fLote frm = new fLote(); if (frm.ShowDialog() == DialogResult.Cancel) { return; } float valor = Globais.StrToFloat(edtValor.Text); float recebido = Globais.StrToFloat(edtRecebido.Text); string msg = ""; cTitulosXeceber titulos = new cTitulosXeceber(); int n = cbxNaturezas.SelectedIndex; string natureza = (n >= 0) ? cbxCodNaturezas.Items[n].ToString() : ""; int f = cbxFormas.SelectedIndex; string forma = (f >= 0) ? cbxCodFormas.Items[f].ToString() : ""; int p = cbxPendencias.SelectedIndex; string pendencia = (p >= 0) ? cbxCodPendencias.Items[p].ToString() : ""; ArrayList pedidos = new ArrayList(); foreach (string pedido in cbxPedidos.Items) { pedidos.Add(pedido); } int repeticoes = frm.repeticoes; string frequencia = frm.frequencia; DateTime limite = frm.limite; bool idt_limite = frm.idt_limite; DateTime vencimento = dtpVencimento.Value; string texto = ""; short codigo = Globais.StrToShort(edtSequencia.Text); int r = 0; while ((repeticoes-- > 0) || idt_limite) { if (idt_limite && (vencimento > limite)) { break; } r++; string tipo = "F"; if (rbtVariavel.Checked) { tipo = "V"; } result = titulos.Inclui(nf, codigo, edtUsuario.Text, dtpEntrada.Value, vencimento, edtParceiro.Text, natureza, tipo, pedidos, valor, dtpRecebimento.Checked, dtpRecebimento.Value, recebido, forma, pendencia, edtObservacao.Text, ckbCancelado.Checked ? "S" : "N", edtMotivo.Text, ref msg); codigo++; texto = texto + "\r\n" + codigo.ToString() + " - " + vencimento.ToString("d/M/yyyy"); if (frequencia.Equals("Semanal")) { vencimento = vencimento.AddDays(7); } else if (frequencia.Equals("Quinzenal")) { vencimento = vencimento.AddDays(15); } else if (frequencia.Equals("Mensal")) { vencimento = vencimento.AddMonths(1); } else if (frequencia.Equals("Anual")) { vencimento = vencimento.AddYears(1); } } string titulo = "Foram gerados " + r.ToString() + " títulos"; MessageBox.Show(texto, titulo); Close(); }
void BtnConfirmaClick(object sender, EventArgs e) { if (!Valida()) { return; } float valor = Globais.StrToFloat(edtValor.Text); float recebido = Globais.StrToFloat(edtRecebido.Text); string msg = ""; cTitulosXeceber titulos = new cTitulosXeceber(); int n = cbxNaturezas.SelectedIndex; string natureza = (n >= 0) ? cbxCodNaturezas.Items[n].ToString() : ""; int f = cbxFormas.SelectedIndex; string forma = (f >= 0) ? cbxCodFormas.Items[f].ToString() : ""; int p = cbxPendencias.SelectedIndex; string pendencia = (p >= 0) ? cbxCodPendencias.Items[p].ToString() : ""; //string fornecedor=""; //DateTime data = DateTime.Now; //short orcamento=0; //short pedido=0; //if (cbxPedidos.Text.Trim().Length > 0) //{ //string[] partes = cbxPedidos.Text.Split(' '); //fornecedor = partes[0]; //data = DateTime.Parse(partes[1]); //orcamento = Globais.StrToShort(partes[2]); //pedido = Globais.StrToShort(partes[3]); //} ArrayList pedidos = new ArrayList(); foreach (string pedido in cbxPedidos.Items) { pedidos.Add(pedido); } string tipo = "F"; if (rbtVariavel.Checked) { tipo = "V"; } if (acao == 'i') { result = titulos.Inclui(nf, Globais.StrToShort(edtSequencia.Text), edtUsuario.Text, dtpEntrada.Value, dtpVencimento.Value, edtParceiro.Text, natureza, tipo, pedidos, valor, dtpRecebimento.Checked, dtpRecebimento.Value, recebido, forma, pendencia, edtObservacao.Text, ckbCancelado.Checked ? "S" : "N", edtMotivo.Text, ref msg); if (!result) { MessageBox.Show(msg, "Erro na inclusão" + "\n" + msg, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { result = titulos.Altera(nf, Globais.StrToShort(edtSequencia.Text), edtUsuario.Text, dtpEntrada.Value, dtpVencimento.Value, edtParceiro.Text, natureza, tipo, pedidos, valor, dtpRecebimento.Checked, dtpRecebimento.Value, recebido, forma, pendencia, edtObservacao.Text, ckbCancelado.Checked ? "S" : "N", edtMotivo.Text, //fornecedor, //data, //orcamento, //pedido, ref msg); if (!result) { MessageBox.Show(msg, "Erro na alteração", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } Close(); }
void EdtCopiaClick(object sender, EventArgs e) { if (dgvCadastro.Rows.Count == 0) { return; } string parceiro = edtParceiro.Text.Trim(); string codigo = edtCodigo.Text.Trim(); string ativo = chkAtivo.Checked ? "S" : "N"; string imprime_ipi = chkIPI.Checked ? "S" : "N"; fCodigoCopia frm = new fCodigoCopia(parceiro, codigo, edtDescricao.Text, edtFormulaPedido.Text, Globais.StrToFloat(edtConsultor.Text), Globais.StrToFloat(edtVendedor.Text), Globais.StrToFloat(edtFilial.Text), Globais.StrToFloat(edtLimiar.Text), edtObservacao.Text, edtRacional.Text, edtServico.Text, ativo, Globais.StrToShort(edtDias.Text), edtVendedorProdutos.Text, edtVendedorServicos.Text, edtConsultorProdutos.Text, edtConsultorServicos.Text, edtFilialProdutos.Text, edtFilialServicos.Text, Globais.StrToFloat(edtFrete.Text), cbxIntroducoes.Text, cbxInformacoesFornecimento.Text, cbxTermosGarantia.Text, cbxCondicoesMontagem.Text, cbxTermosAprovacao.Text, imprime_ipi ); frm.ShowDialog(); this.Cursor = Cursors.WaitCursor; caracteristicas.Carrega(dgvCadastro, chkFiltroAtivos.Checked); this.Cursor = Cursors.Default; Sort(col_sorted, ord_sorted); codigo_sel = frm.novo_codigo; int selecionado = Posiciona(parceiro, frm.novo_codigo); if (selecionado >= 0) { AtualizaDados(selecionado); AtualizaDadosLocal(selecionado); } }
void BtnConfirmaClick(object sender, EventArgs e) { string msg = ""; bool result; string parceiro = edtParceiro.Text.Trim(); string codigo = edtCodigo.Text.Trim(); if (edtParceiro.Text.Trim().CompareTo("") != 0) { cParceiros parceiros = new cParceiros(); string des = "", fisjur = ""; if (!parceiros.Procura(edtParceiro.Text, ref des, ref fisjur)) { MessageBox.Show(edtParceiro.Text, "Parceiro não Cadastrado", MessageBoxButtons.OK, MessageBoxIcon.Warning); edtParceiro.Focus(); return; } } if (acao == 'I') { acao = 'i'; return; } if (acao == 'A') { acao = 'a'; return; } string imprime_ipi = chkIPI.Checked ? "S" : "N"; string ativo = chkAtivo.Checked ? "S" : "N"; if (acao == 'i') { result = caracteristicas.Inclui(parceiro, codigo, edtDescricao.Text, edtFormulaPedido.Text, Globais.StrToFloat(edtConsultor.Text), Globais.StrToFloat(edtVendedor.Text), Globais.StrToFloat(edtFilial.Text), Globais.StrToFloat(edtLimiar.Text), edtObservacao.Text, edtRacional.Text, edtServico.Text, ativo, Globais.StrToShort(edtDias.Text), edtVendedorProdutos.Text, edtVendedorServicos.Text, edtConsultorProdutos.Text, edtConsultorServicos.Text, edtFilialProdutos.Text, edtFilialServicos.Text, Globais.StrToFloat(edtFrete.Text), cbxIntroducoes.Text, cbxInformacoesFornecimento.Text, cbxTermosGarantia.Text, cbxCondicoesMontagem.Text, cbxTermosAprovacao.Text, imprime_ipi, ref msg); } else { result = caracteristicas.Altera(parceiro, codigo, edtDescricao.Text, edtFormulaPedido.Text, Globais.StrToFloat(edtConsultor.Text), Globais.StrToFloat(edtVendedor.Text), Globais.StrToFloat(edtFilial.Text), Globais.StrToFloat(edtLimiar.Text), edtObservacao.Text, edtRacional.Text, edtServico.Text, ativo, Globais.StrToShort(edtDias.Text), edtVendedorProdutos.Text, edtVendedorServicos.Text, edtConsultorProdutos.Text, edtConsultorServicos.Text, edtFilialProdutos.Text, edtFilialServicos.Text, Globais.StrToFloat(edtFrete.Text), cbxIntroducoes.Text, cbxInformacoesFornecimento.Text, cbxTermosGarantia.Text, cbxCondicoesMontagem.Text, cbxTermosAprovacao.Text, imprime_ipi, ref msg); } if (!result) { if (acao == 'i') { MessageBox.Show(parceiro + "-" + codigo + "\r\n" + msg, "Erro na inclusão da característica", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(parceiro + "-" + codigo + "\r\n" + msg, "Erro na alteração da característica", MessageBoxButtons.OK, MessageBoxIcon.Error); } } primeira = dgvCadastro.FirstDisplayedScrollingRowIndex; this.Cursor = Cursors.WaitCursor; caracteristicas.Carrega(dgvCadastro, chkFiltroAtivos.Checked); this.Cursor = Cursors.Default; Sort(col_sorted, ord_sorted); int selecionado = Posiciona(parceiro.Trim(), codigo.Trim()); if (selecionado >= 0) { AtualizaDados(selecionado); AtualizaDadosLocal(selecionado); } if (primeira != -1) { dgvCadastro.FirstDisplayedScrollingRowIndex = primeira; } DesabilitaEdicao(); SetaEdicaoLocal(false); }