void BtnExcluiClick(object sender, EventArgs e) { if (dgvCadastro.Rows.Count == 0) { return; } int i = dgvCadastro.CurrentRow.Index; int codigo = Globais.StrToInt(dgvCadastro.Rows[i].Cells["Cod"].Value.ToString()); DialogResult r = MessageBox.Show(codigo.ToString(), "Confirma a exclusão?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.No) { return; } string fornecedor = dgvCadastro.Rows[i].Cells["Fornecedor"].Value.ToString(); string msg = ""; DateTime data = DateTime.Parse(dgvCadastro.Rows[i].Cells["Data"].Value.ToString()); if (orcamento.Exclui(fornecedor, data, codigo, ref msg)) { CarregaOrcamentos(); Grid.Sort(dgvCadastro, col_sorted, ord_sorted); Grid.MarcaSelecionados(dgvCadastro); } }
void DbgProgramasCellDoubleClick(object sender, DataGridViewCellEventArgs e) { string msg = ""; int iPrograma = e.RowIndex; DataGridViewRow row = dbgProgramas.Rows[iPrograma]; if (row.DefaultCellStyle.BackColor == Color.Green) { row.DefaultCellStyle.BackColor = Color.Red; row.DefaultCellStyle.SelectionBackColor = Color.Red; controle.ExcluiPrograma(dbgUsuarios.Rows[iUsuario].Cells[0].Value.ToString().Trim(), dbgFiliais.Rows[iFilial].Cells[0].Value.ToString().Trim(), Globais.StrToInt(dbgSistemas.Rows[iSistema].Cells[0].Value.ToString()), dbgProgramas.Rows[iPrograma].Cells[0].Value.ToString().Trim(), ref msg); } else { row.DefaultCellStyle.BackColor = Color.Green; row.DefaultCellStyle.SelectionBackColor = Color.Green; controle.IncluiPrograma(dbgUsuarios.Rows[iUsuario].Cells[0].Value.ToString().Trim(), dbgFiliais.Rows[iFilial].Cells[0].Value.ToString().Trim(), Globais.StrToInt(dbgSistemas.Rows[iSistema].Cells[0].Value.ToString()), dbgProgramas.Rows[iPrograma].Cells[0].Value.ToString().Trim(), ref msg); } }
void BtnConfirmaClick(object sender, EventArgs e) { situacoes.Clear(); foreach (DataGridViewRow row in dgvSituacoes.Rows) { if (!(bool)row.Cells["Seleciona"].Value) { continue; } situacoes.Add(row.Cells["Código"].Value.ToString()); } fornecedor = edtCodigo.Text; filtrar_data = ckbData.Checked; mesi = (int)udMesI.Value; mesf = (int)udMesF.Value; anoi = Globais.StrToInt(edtAnoI.Text); anof = Globais.StrToInt(edtAnoF.Text); vendedor = cbxUsuarios.Text; cliente = edtCliente.Text; consultor = edtConsultor.Text; caracteristica = cbxCaracteristicas.Text; result = true; idt_cadastroI = dtpCadastroI.Checked ? "S" : "N"; cadastroI = dtpCadastroI.Value; idt_cadastroF = dtpCadastroF.Checked ? "S" : "N"; cadastroF = dtpCadastroF.Value; resumo = edtResumo.Text; Close(); }
void DgvCadastroRowEnter(object sender, DataGridViewCellEventArgs e) { if (dgvCadastro.Rows.Count == 0) { return; } int i = e.RowIndex; if (dgvCadastro.Rows[i].Cells["isel"].Value == null) { return; } int isel = Globais.StrToInt(dgvCadastro.Rows[i].Cells["isel"].Value.ToString()); if (rbtVendedor.Checked) { edtJustificativa.Text = dgvSelecao.Rows[isel].Cells["JusVendedor"].Value.ToString(); } if (rbtConsultor.Checked) { edtJustificativa.Text = dgvSelecao.Rows[isel].Cells["JusConsultor"].Value.ToString(); } if (rbtFilial.Checked) { edtJustificativa.Text = dgvSelecao.Rows[isel].Cells["JusFilial"].Value.ToString(); } }
public void AtualizaDadosLocal(int i) { item_especial = ckbEspecial.Checked = dgvCadastro.Rows[i].Cells["Especial"].Value.ToString().Trim().Equals("S"); item_generico = ckbGenerico.Checked = dgvCadastro.Rows[i].Cells["Genérico"].Value.ToString().Trim().Equals("S"); edtArea.Text = dgvCadastro.Rows[i].Cells["Área"].Value.ToString().Trim(); edtDescricao.Text = dgvCadastro.Rows[i].Cells["Seq"].Value.ToString().Trim(); edtProduto.Text = dgvCadastro.Rows[i].Cells["Produto"].Value.ToString().Trim(); edtSubCodigo.Text = dgvCadastro.Rows[i].Cells["Sub-Código"].Value.ToString().Trim(); edtDescricaoProd.Text = dgvCadastro.Rows[i].Cells["Descrição"].Value.ToString().Trim(); edtTexto.Text = dgvCadastro.Rows[i].Cells["Texto"].Value.ToString().Trim(); edtEspecificos.Text = dgvCadastro.Rows[i].Cells["Específicos"].Value.ToString().Trim(); ultimo_produto = edtProduto.Text.Trim(); ultimo_subcodigo = edtSubCodigo.Text.Trim(); edtQtde.Text = dgvCadastro.Rows[i].Cells["Qtde"].Value.ToString().Trim(); edtMedidas.Text = dgvCadastro.Rows[i].Cells["Medidas"].Value.ToString().Trim(); preco_formula = Globais.StrToFloat(dgvCadastro.Rows[i].Cells["Preço"].Value.ToString()); preco_unitario = Globais.StrToFloat(dgvCadastro.Rows[i].Cells["Preço Unitário"].Value.ToString()); preco_tabela = Globais.StrToFloat(dgvCadastro.Rows[i].Cells["Preço Tabela"].Value.ToString()); if (item_generico) { edtPrecoGenerico.Text = preco_tabela.ToString("#,###,##0.00"); } else { edtPrecoGenerico.Text = 0.ToString("#,###,##0.00"); } edtPrecoFormula.Text = preco_formula.ToString("#,###,##0.00"); float total = Globais.Arredonda(preco_formula) * Globais.StrToInt(edtQtde.Text); edtPrecoTotal.Text = total.ToString("#,###,##0.00"); MostraImagem(); }
void ColoreProgramas() { string usuario = dbgUsuarios.Rows[iUsuario].Cells[0].Value.ToString().Trim(); string filial = dbgFiliais.Rows[iFilial].Cells[0].Value.ToString().Trim(); int sistema = Globais.StrToInt(dbgSistemas.Rows[iSistema].Cells[0].Value.ToString()); FbCommand cmd = new FbCommand("select 1 from USUARIOS_PROGRAMAS where COD_USUARIO=@usuario and COD_FILIAL=@filial and COD_SISTEMA=@sistema and COD_PROGRAMA=@programa", Globais.bd); FbDataReader reader; cmd.Parameters.Add("@usuario", FbDbType.Char); cmd.Parameters.Add("@filial", FbDbType.Char); cmd.Parameters.Add("@sistema", FbDbType.Integer); cmd.Parameters.Add("@programa", FbDbType.Char); foreach (DataGridViewRow row in dbgProgramas.Rows) { DataGridViewCell cell = row.Cells[0]; string programa = cell.Value.ToString().Trim(); cmd.Parameters["@usuario"].Value = usuario; cmd.Parameters["@filial"].Value = filial; cmd.Parameters["@sistema"].Value = sistema; cmd.Parameters["@programa"].Value = programa; reader = cmd.ExecuteReader(CommandBehavior.SingleRow); if (!reader.Read()) { row.DefaultCellStyle.BackColor = Color.Red; row.DefaultCellStyle.SelectionBackColor = Color.Red; } else { row.DefaultCellStyle.BackColor = Color.Green; row.DefaultCellStyle.SelectionBackColor = Color.Green; } reader.Close(); } }
void BtnAlteraClick(object sender, EventArgs e) { if (dgvCadastro.Rows.Count == 0) { return; } int i = dgvCadastro.CurrentRow.Index; int codigo = Globais.StrToInt(dgvCadastro.Rows[i].Cells["Código"].Value.ToString()); fCadTitulo frm = new fCadTitulo('a', codigo); frm.ShowDialog(); if (frm.result) { CarregaTitulos(); Grid.Sort(dgvCadastro, col_sorted, ord_sorted); for (i = 0; i < dgvCadastro.Rows.Count; i++) { int cod = Globais.StrToInt(dgvCadastro.Rows[i].Cells["Código"].Value.ToString()); if (cod == codigo) { dgvCadastro.Rows[i].Cells["Parceiro"].Selected = true; break; } } } }
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 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 CarregaProgramas() { int sistema = Globais.StrToInt(dbgSistemas.Rows[iSistema].Cells[0].Value.ToString()); programas = new cProgramas(); this.Cursor = Cursors.WaitCursor; programas.Carrega(dbgProgramas, sistema); this.Cursor = Cursors.Default; }
void BtnProgramasClick(object sender, EventArgs e) { if (dgvCadastro.Rows.Count == 0) { return; } frmCadProgramas frm = new frmCadProgramas(); frm.sistema = Globais.StrToInt(edtCodigo.Text); frm.des_sistema = edtDescricao.Text; frm.ShowDialog(); }
float ProcuraValorPago(int i) { foreach (DataGridViewRow row in dgvCadastro.Rows) { int isel = Globais.StrToInt(row.Cells["isel"].Value.ToString()); if (isel == i) { float pago = Globais.StrToFloat(row.Cells["Pago"].Value.ToString()); return(pago); } } return(0); }
void UdMesFValueChanged(object sender, EventArgs e) { int ano; if (udMesF.Value == 13) { udMesF.Value = 1; ano = Globais.StrToInt(edtAnoF.Text) + 1; edtAnoF.Text = ano.ToString(); } if (udMesF.Value == 0) { udMesF.Value = 12; ano = Globais.StrToInt(edtAnoF.Text) - 1; if (ano < 0) { ano = 0; } edtAnoF.Text = ano.ToString(); } }
void BtnExcluiClick(object sender, EventArgs e) { if (dgvAcoes.Rows.Count == 0) { return; } int i = dgvAcoes.CurrentRow.Index; string codigo = dgvAcoes.Rows[i].Cells[0].Value.ToString(); DialogResult r = MessageBox.Show(codigo, "Confirma a exclusão?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.No) { return; } AcaoComercial acao = new AcaoComercial(); acao.SeqAcao = Globais.StrToInt(codigo); this.Cursor = Cursors.WaitCursor; try { AcaoDAO.Exclui(acao); } catch (Exception ex) { Log.Grava(Globais.sUsuario, "erro:" + ex.Message); MessageBox.Show("Erro na exclusão:\n" + ex.Message); return; } finally { this.Cursor = Cursors.Default; } CarregaAcoes(); Grid.Sort(dgvAcoes, col_sorted, ord_sorted); Grid.MarcaSelecionados(dgvAcoes); }
void BtnExcluiClick(object sender, EventArgs e) { if (dgvCadastro.Rows.Count == 0) { return; } int i = dgvCadastro.CurrentRow.Index; int codigo = Globais.StrToInt(dgvCadastro.Rows[i].Cells["Código"].Value.ToString()); DialogResult r = MessageBox.Show(codigo.ToString(), "Confirma a exclusão?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.No) { return; } string msg = ""; if (titulos.Exclui(codigo, ref msg)) { CarregaTitulos(); Grid.Sort(dgvCadastro, col_sorted, ord_sorted); } }
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(); }
/* * private void calcula_itens(string fornecedor, DateTime data, short orcamento, string formula, float per_calculo, ref float per_recalculo) * { * FbCommand cmd = new FbCommand("select " + * " a.seq_item, " + * " a.qtd_item, " + * " a.idt_especial, " + * " a.vlr_preco, " + * " b.per_ipi " + * "from ITENS a, PRODUTOS b " + * "where a.cod_fornecedor='" + fornecedor + "' and " + * " a.dat_orcamento='" + data.ToString("M/d/yyyy") + "' and " + * " a.cod_orcamento=" + orcamento + " and " + * " a.cod_fornecedor=b.cod_parceiro and " + * " a.cod_produto=b.cod_produto and " + * " a.sub_codigo=b.sub_codigo " + * " order by a.seq_item", * Globais.bd); * float valor_recalculo = 0; * FbDataReader reader = cmd.ExecuteReader(CommandBehavior.Default); * while (reader.Read()) * { * short seq = (short)(!reader.IsDBNull(0) ? (int)reader.GetInt16(0) : 0); * short qtd = (short)(!reader.IsDBNull(1) ? (int)reader.GetInt16(1) : 0); * string especial = (reader.IsDBNull(2) ? reader.GetString(2) : ""); * float valor = (!reader.IsDBNull(3) ? (int)reader.GetFloat(3) : 0f); * float ipi = (!reader.IsDBNull(4) ? (int)reader.GetFloat(4) : 0f); * valor_recalculo = valor; * Globais.CalculaFormula(ref valor_recalculo, formula, 0); * per_recalculo = valor_recalculo * per_calculo / valor; * } * reader.Close(); * } */ void calcula() { cComissaoLimiar comissao_limiar = new cComissaoLimiar(); float tot_pedido = 0; float tot_valor = 0; float tot_calculo = 0; float tot_recalculo = 0; float tot_pago = 0; float tot_comissao = 0; float valor_pago = 0; float valor_pagar = 0; int n = 0; if (rbtVendedor.Checked || rbtFilial.Checked) { dgvCadastro.Columns["Vendedor"].HeaderText = "Vendedor"; } else { dgvCadastro.Columns["Vendedor"].HeaderText = "Consultor"; } dgvCadastro.Rows.Clear(); cCaracteristicas carac = new cCaracteristicas(); int isel = 0; foreach (DataGridViewRow sel in dgvSelecao.Rows) { if (!(bool)sel.Cells["S"].Value) { isel++; continue; } int i = dgvCadastro.Rows.Add(); DataGridViewRow row = dgvCadastro.Rows[i]; row.Cells["isel"].Value = isel; DateTime data = DateTime.Parse(sel.Cells["Data"].Value.ToString()); short orcamento = CodOrcamento(sel.Cells["Orçamento"].Value.ToString()); float valor = Globais.StrToFloat(sel.Cells["Valor"].Value.ToString()); string fornecedor = sel.Cells["Fornecedor Orçamento"].Value.ToString(); string caracteristica = sel.Cells["Característica"].Value.ToString(); string venpro = "", venser = "", conpro = "", conser = "", filpro = "", filser = ""; carac.FormulasComissao(fornecedor, caracteristica, ref venpro, ref venser, ref conpro, ref conser, ref filpro, ref filser); float sinal = Globais.StrToFloat(sel.Cells["Sinal"].Value.ToString()); int cod_pedido = Globais.StrToInt(sel.Cells["CodPedido"].Value.ToString()); float vlr_frete = Globais.StrToFloat(sel.Cells["Valor Frete"].Value.ToString()); float vlr_frete_item = 0; float per_frete = 0; if (vlr_frete > 0) { vlr_frete_item = cPedidos.RateiaFrete(fornecedor, data, orcamento, (short)cod_pedido, ref vlr_frete); } else { per_frete = cCaracteristicas.Frete(fornecedor, caracteristica); } float per_pago = 0; bool pago = false; string formula = ""; if (rbtVendedor.Checked) { pago = sel.Cells["IdtVendedor"].Value.ToString().Equals("S"); per_pago = Globais.StrToFloat(sel.Cells["PerVendedor"].Value.ToString()); row.Cells["Justificativa"].Value = sel.Cells["JusVendedor"].Value.ToString(); if (cod_pedido == 1) { formula = venpro; } else { formula = venser; } } if (rbtConsultor.Checked) { pago = sel.Cells["IdtConsultor"].Value.ToString().Equals("S"); per_pago = Globais.StrToFloat(sel.Cells["PerConsultor"].Value.ToString()); row.Cells["Justificativa"].Value = sel.Cells["JusConsultor"].Value.ToString(); if (cod_pedido == 1) { formula = conpro; } else { formula = conser; } } if (rbtFilial.Checked) { pago = sel.Cells["IdtFilial"].Value.ToString().Equals("S"); per_pago = Globais.StrToFloat(sel.Cells["PerFilial"].Value.ToString()); row.Cells["Justificativa"].Value = sel.Cells["JusFilial"].Value.ToString(); if (cod_pedido == 1) { formula = venpro; } else { formula = venser; } } float valor_pedido = valor; Globais.CalculaFormula(ref valor, formula, 0, per_frete, vlr_frete_item); isel++; float per_calculo = 0; if (rbtConsultor.Checked) { per_calculo = Globais.StrToFloat(sel.Cells["Comissão Consultor"].Value.ToString()); } else if (rbtFilial.Checked) { if (cod_pedido == 1) { per_calculo = Globais.StrToFloat(sel.Cells["Comissão Filial"].Value.ToString()); } else { per_calculo = 100; } } else { per_calculo = comissao_limiar.Calcula(fornecedor, caracteristica, valor, sinal); } row.Cells["PG"].Value = pago; float valor_recalculo = valor; float per_recalculo = per_calculo; if (formula.Length > 0) { //calcula_itens(fornecedor, data, orcamento, formula, per_calculo, ref per_recalculo); } //if ((per_pago == 0) && !pago_zerado) if ((per_pago == 0) && !pago) { per_pago = per_calculo; } float comissao = per_pago * valor / 100f; bool pg = row.Cells["PG"].Value != null?bool.Parse(row.Cells["PG"].Value.ToString()) : false; tot_pedido += valor_pedido; tot_valor += valor; tot_calculo += per_calculo; tot_recalculo += per_recalculo; tot_pago += per_pago; tot_comissao += comissao; if (!pg) { valor_pagar += comissao; } else { valor_pago += comissao; } n++; row.Cells["Fornecedor"].Value = sel.Cells["Fornecedor"].Value.ToString(); row.Cells["FornecedorOrcamento"].Value = sel.Cells["Fornecedor Orçamento"].Value.ToString(); row.Cells["Data"].Value = DateTime.Parse(sel.Cells["Data"].Value.ToString()).ToString("d/M/yyyy"); row.Cells["Orcamento"].Value = sel.Cells["Orçamento"].Value.ToString(); row.Cells["Pedido"].Value = sel.Cells["Ped"].Value.ToString(); row.Cells["CodPedido"].Value = sel.Cells["CodPedido"].Value.ToString(); row.Cells["Cliente"].Value = sel.Cells["Cliente"].Value.ToString(); if (rbtVendedor.Checked || rbtFilial.Checked) { row.Cells["Vendedor"].Value = sel.Cells["Vendedor"].Value.ToString(); } else { row.Cells["Vendedor"].Value = sel.Cells["Consultor"].Value.ToString(); } row.Cells["ValorPedido"].Value = valor_pedido.ToString("#,###,##0.00"); row.Cells["Valor"].Value = valor.ToString("#,###,##0.00"); row.Cells["Calculo"].Value = per_calculo.ToString("#0.00"); //row.Cells["Recalculo"].Value = per_recalculo.ToString("#0.00"); row.Cells["Pago"].Value = per_pago.ToString("#0.00"); row.Cells["Comissao"].Value = comissao.ToString("#,###,##0.00"); if (rbtVendedor.Checked) { edtJustificativa.Text = sel.Cells["JusVendedor"].Value.ToString(); } if (rbtConsultor.Checked) { edtJustificativa.Text = sel.Cells["JusConsultor"].Value.ToString(); } if (rbtFilial.Checked) { edtJustificativa.Text = sel.Cells["JusFilial"].Value.ToString(); } } edtTotPedido.Text = tot_pedido.ToString("#,###,##0.00"); edtTotValor.Text = tot_valor.ToString("#,###,##0.00"); if (n > 0) { edtTotCalculo.Text = (tot_calculo / n).ToString("#0.00"); //edtTotRecalculo.Text= (tot_recalculo / n).ToString("#0.00"); edtTotPago.Text = (tot_pago / n).ToString("#0.00"); } else { edtTotCalculo.Text = 0.ToString("#0.00"); //edtTotRecalculo.Text= (tot_recalculo / n).ToString("#0.00"); edtTotPago.Text = 0.ToString("#0.00"); } edtTotComissao.Text = tot_comissao.ToString("#,###,##0.00"); edtValorPago.Text = valor_pago.ToString("#,###,##0.00"); edtValorPagar.Text = valor_pagar.ToString("#,###,##0.00"); }
void BtnConfirmaClick(object sender, EventArgs e) { string msg = ""; string cpf_cnpj; bool result; string codigo = edtCodigo.Text.Trim(); if (acao == 'I') { acao = 'i'; return; } if (acao == 'A') { acao = 'a'; return; } if (cbxEstados.Text.Trim().CompareTo("") != 0) { if (!cbxEstados.Items.Contains(cbxEstados.Text.Trim())) { MessageBox.Show(cbxEstados.Text, "Estado não Cadastrado", MessageBoxButtons.OK, MessageBoxIcon.Warning); cbxEstados.Focus(); return; } } if (!ckbCliente.Checked && !ckbFornecedor.Checked && !ckbConsultor.Checked) { MessageBox.Show("Tipo: cliente/fornecedor/consultor", "Campo Obrigatório", MessageBoxButtons.OK, MessageBoxIcon.Warning); ckbCliente.Focus(); return; } string cliente = (ckbCliente.Checked) ? "S" : "N"; string fornecedor = (ckbFornecedor.Checked) ? "S" : "N"; string consultor = (ckbConsultor.Checked) ? "S" : "N"; string pessoa = rbtFisica.Checked ? "F" : "J"; string ativo = ckbAtivo.Checked ? "S" : "N"; if (edtCNPJ.MaxLength == 14) { cpf_cnpj = CNPJ.TiraEdicao(edtCNPJ.Text); } else { cpf_cnpj = CPF.TiraEdicao(edtCNPJ.Text); } if (!cpf_cnpj.Replace("0", "").Equals("")) { string nomeCpfCnpj = parceiros.ProcuraPorCpfCnpj(cpf_cnpj); if (nomeCpfCnpj != null) { if ((acao != 'a') || (nomeAlteracao == null) || !nomeAlteracao.Equals(nomeCpfCnpj.Trim())) { MessageBox.Show("Já existe um parceiro com esse cpf/cnpj\r\n" + nomeCpfCnpj, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } if (acao == 'i') { result = parceiros.Inclui(codigo, edtDescricao.Text, cliente, fornecedor, consultor, pessoa, cpf_cnpj, edtInsEst.Text, edtInsMun.Text, edtLogradouro.Text, edtNumero.Text, edtComplemento.Text, edtBairro.Text, edtCidade.Text, cbxEstados.Text, CEP.TiraEdicao(edtCEP.Text), edtLogradouroEntrega.Text, edtNumeroEntrega.Text, edtComplementoEntrega.Text, edtBairroEntrega.Text, edtCidadeEntrega.Text, cbxEstadosEntrega.Text, CEP.TiraEdicao(edtCEPEntrega.Text), edtLogradouroCobranca.Text, edtNumeroCobranca.Text, edtComplementoCobranca.Text, edtBairroCobranca.Text, edtCidadeCobranca.Text, cbxEstadosCobranca.Text, CEP.TiraEdicao(edtCEPCobranca.Text), FONE.TiraEdicao(edtFone1.Text), FONE.TiraEdicao(edtFone2.Text), CELULAR.TiraEdicao(edtCelular.Text), FONE.TiraEdicao(edtFAX.Text), edtEmail.Text, dtpNascimento.Checked, dtpNascimento.Value, ativo, Globais.StrToInt(edtPedido.Text), ref msg); } else { result = parceiros.Altera(codigo, edtDescricao.Text, cliente, fornecedor, consultor, pessoa, cpf_cnpj, edtInsEst.Text, edtInsMun.Text, edtLogradouro.Text, edtNumero.Text, edtComplemento.Text, edtBairro.Text, edtCidade.Text, cbxEstados.Text, CEP.TiraEdicao(edtCEP.Text), edtLogradouroEntrega.Text, edtNumeroEntrega.Text, edtComplementoEntrega.Text, edtBairroEntrega.Text, edtCidadeEntrega.Text, cbxEstadosEntrega.Text, CEP.TiraEdicao(edtCEPEntrega.Text), edtLogradouroCobranca.Text, edtNumeroCobranca.Text, edtComplementoCobranca.Text, edtBairroCobranca.Text, edtCidadeCobranca.Text, cbxEstadosCobranca.Text, CEP.TiraEdicao(edtCEPCobranca.Text), FONE.TiraEdicao(edtFone1.Text), FONE.TiraEdicao(edtFone2.Text), CELULAR.TiraEdicao(edtCelular.Text), FONE.TiraEdicao(edtFAX.Text), edtEmail.Text, dtpNascimento.Checked, dtpNascimento.Value, ativo, Globais.StrToInt(edtPedido.Text), ref msg); } if (!result) { if (acao == 'i') { MessageBox.Show(codigo + "\n" + msg, "Erro na inclusão do parceiro", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(codigo + "\n" + msg, "Erro na alteração do parceiro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } this.Cursor = Cursors.WaitCursor; parceiros.Carrega(dgvCadastro, where); this.Cursor = Cursors.Default; int selecionado = Procura(codigo, true); if (selecionado >= 0) { dgvCadastro.Rows[selecionado].Cells[0].Selected = true; AtualizaDados(selecionado); AtualizaDadosLocal(selecionado); } DesabilitaEdicao(); SetaEdicaoLocal(false); }
private bool Confirma() { string fornecedor = edtFornecedor.Text.Trim(); if (fornecedor.CompareTo("") == 0) { MessageBox.Show("Fornecedor", "Campo obrigatório", MessageBoxButtons.OK, MessageBoxIcon.Warning); edtFornecedor.Focus(); return(false); } if (cbxUsuarios.Text.Trim().Length == 0) { MessageBox.Show("Vendedor", "Campo obrigatório", MessageBoxButtons.OK, MessageBoxIcon.Warning); cbxUsuarios.Focus(); return(false); } if (edtCliente.Text.Trim().Length == 0) { MessageBox.Show("Cliente", "Campo obrigatório", MessageBoxButtons.OK, MessageBoxIcon.Warning); edtCliente.Focus(); return(false); } if (cbxTabelas.Text.Trim().Length == 0) { MessageBox.Show("Tabela Preços", "Campo obrigatório", MessageBoxButtons.OK, MessageBoxIcon.Warning); cbxTabelas.Focus(); return(false); } if (cbxCaracteristicas.Text.Trim().Length == 0) { MessageBox.Show("Característica Venda", "Campo obrigatório", MessageBoxButtons.OK, MessageBoxIcon.Warning); cbxCaracteristicas.Focus(); return(false); } string msg = ""; int codigo = 0; cOrcamentos orcamentos = new cOrcamentos(); float per_consultor = Globais.StrToFloat(edtPerConsultor.Text); if (acao == 'i') { result = orcamentos.Inclui(fornecedor, dtpData.Value, cbxUsuarios.Text, edtCliente.Text, edtContato.Text, edtConsultor.Text, cbxTabelas.Text, cbxCaracteristicas.Text, edtResumo.Text, edtObservacao.Text, cbxSituacao.Text.Substring(0, 1), per_consultor, ref msg, ref codigo); edtCodigo.Text = codigo.ToString(); } else { codigo = Globais.StrToInt(edtCodigo.Text); result = orcamentos.Altera(fornecedor, dtpData.Value, codigo, cbxUsuarios.Text, edtCliente.Text, edtContato.Text, edtConsultor.Text, cbxTabelas.Text, cbxCaracteristicas.Text, Globais.StrToFloat(edtDesconto.Text), edtResumo.Text, edtObservacao.Text, cbxSituacao.Text.Substring(0, 1), per_consultor, ref msg); } if (!result) { if (acao == 'i') { MessageBox.Show(edtCodigo.Text + "\n" + msg, "Erro na inclusão do orçamento", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(edtCodigo.Text + "\n" + msg, "Erro na alteração do orçamento", MessageBoxButtons.OK, MessageBoxIcon.Error); } } return(result); }