private void BtnExcluir_Click(object sender, EventArgs e) { if (GridDados.CurrentRow != null) { MvCotacao.IdCotacao = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); MvCotacao.LerDados(MvCotacao.IdCotacao); if (MvCotacao.Status == 1) { MessageBox.Show("Cotação já Encerrada, para poder excluir você deve cancelar a cotação", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (MessageBox.Show("Confirma a Exclusão do Registro", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes) { MvCotacao.IdCotacao = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); MvCotacao.Excluir(); PopularGrid(); LimpaDados(); GridDados.Focus(); } } } else { MessageBox.Show("Não existe Registro para Excluir", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void BtnConcluir_Click(object sender, EventArgs e) { if (GridDados.CurrentRow == null) { MessageBox.Show("Não existe Registro para Edição", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { IdVenda = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); if (GridDados.CurrentRow.Cells[1].Value.ToString() == "OK") { Vendas.LerDados(IdVenda); if (Vendas.VinculoVd != string.Format("{0:D6}", IdPV.ToString())) { MessageBox.Show("Ordem de Entrega já vinculado a venda de No.: " + Vendas.VinculoVd, "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (MessageBox.Show("Ordem de entrega já foi vinculada deseja continuar ?", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.No) { return; } } Controle.ExecutaSQL("Update MvVenda set VinculoVD='" + string.Format("{0:D6}", IdPV.ToString()) + "' WHERE ID_VENDA=" + IdVenda.ToString()); IncluirItens(); PopularGrid(); GridDados.Focus(); MessageBox.Show("Vinculo da ordem de entrega concluido", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void BtnExcluir_Click(object sender, EventArgs e) { if (GridDados.CurrentRow != null) { MvPedCompra.IdDocumento = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); MvPedCompra.LerDados(MvPedCompra.IdDocumento); if (MvPedCompra.Status == 1) { MessageBox.Show("Pedido de Compra já Concluído, para poder excluir você deve cancelar o Pedido de Compra", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (MvPedCompra.Status == 2) { MessageBox.Show("Pedido de Compra já Recebido", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (MessageBox.Show("Confirma a Exclusão do Registro", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes) { MvPedCompra.IdDocumento = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); FrmPrincipal.RegistrarAuditoria(this.Text, MvPedCompra.IdDocumento, MvPedCompra.NumPedido, 3, "Excluir Ped.: " + TxtFornecedor.Text); MvPedCompra.Excluir(); PopularGrid(); LimpaDados(); GridDados.Focus(); } } } else { MessageBox.Show("Não existe Registro para Excluir", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void FrmFechaMovimento_Shown(object sender, EventArgs e) { SqlDataReader Tabela; if (NumVd > 0) { Tabela = Controle.ConsultaSQL("SELECT * FROM LancFinanceiro WHERE Id_Venda > 0 and Id_Venda=" + NumVd.ToString()); } else { Tabela = Controle.ConsultaSQL("SELECT * FROM LancFinanceiro WHERE Id_Mov > 0 and Id_Mov=" + NumMov.ToString()); } int NParc = 0; DataTable TabLanc = CriarTabela(); while (Tabela.Read()) { NParc++; DateTime DtVenc = DateTime.Parse(Tabela["Vencimento"].ToString()); decimal VrParc = decimal.Parse(Tabela["VlrOriginal"].ToString()); TabLanc.Rows.Add(NParc, 0, DtVenc.Date, VrParc, int.Parse(Tabela["Id_TipoDocumento"].ToString())); } if (NParc > 0) { Source_Lanc.DataSource = TabLanc; Source_Lanc.DataMember = TabLanc.TableName; GridDados.DataSource = Source_Lanc; GridDados.Refresh(); GridDados.Focus(); } }
private void PopulaGrid() { DataSet Tabela = new DataSet(); string sSQL = "SELECT T3.Id_Produto,T3.Descricao,T3.Referencia,0 AS QTDE,T1.PrcSensacional,0.00 as VlrFinal,T1.PrcEspecial,T1.PrcVarejo,T1.PrcMinimo,T1.PrcAtacado FROM PromocaoProdutosItens T1" + " LEFT JOIN PromocaoProdutos T2 ON (T2.Id_Promocao=T1.Id_Promocao)" + " LEFT JOIN Produtos T3 ON (T3.Id_Produto=T1.Id_Produto)" + " WHERE T1.ATIVO=1 AND T1.Id_Promocao=" + IdPromocao.ToString() + " ORDER BY T3.DESCRICAO"; Tabela = Controle.ConsultaTabela(sSQL); GridDados.DataSource = Tabela; GridDados.DataMember = Tabela.Tables[0].TableName; if (GridDados.CurrentRow != null) { GridDados.Focus(); } GridDados.CurrentCell = GridDados.CurrentRow.Cells[3]; Promocao.LerDados(IdPromocao); if (GridDados.CurrentRow != null) { for (int I = 0; I <= GridDados.Rows.Count - 1; I++) { GridDados.Rows[I].Cells[5].Value = Math.Round(decimal.Parse(GridDados.Rows[I].Cells[4].Value.ToString()) * ((100 - Promocao.PDesc) / 100), 2); } } }
private void BtnExcluir_Click(object sender, EventArgs e) { if (GridDados.CurrentRow != null) { if (FrmPrincipal.Perfil_Usuario.AlterarInstalacao == 0) { MessageBox.Show("Usuário não Autorizado", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (MessageBox.Show("Confirma a Exclusão do Registro", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes) { MvInstalacao.IdLanc = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); MvInstalacao.Excluir(); PopularGrid(); LimpaDados(); GridDados.Focus(); } } } else { MessageBox.Show("Não existe Registro para Excluir", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void BtnExcluir_Click(object sender, EventArgs e) { if (GridDados.CurrentRow != null) { Mapa.IdMapa = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); Mapa.LerDados(Mapa.IdMapa); if (Mapa.Status == 1) { MessageBox.Show("Mapa já em Produção", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Mapa.Status == 2) { MessageBox.Show("Mapa já Concluido", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (FrmPrincipal.Perfil_Usuario.ExcluirReg == 0) { FrmAutorizacao Autorizacao = new FrmAutorizacao(); Autorizacao.FrmPrincipal = FrmPrincipal; Autorizacao.ShowDialog(); //Verificando se o Acesso foi liberado if (Autorizacao.AcessoOk) { if (Autorizacao.Usuario.ExcluirReg == 0) { MessageBox.Show("Autorização negada para esse usuário", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } else { MessageBox.Show("Autorização negada para esse usuário", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } StaFormEdicao = true; if (MessageBox.Show("Confirma a Exclusão do Mapa de Produção", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes) { Mapa.IdMapa = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); Mapa.Excluir(); //Registrando Movimento de Auditoria FrmPrincipal.RegistrarAuditoria(this.Text, Mapa.IdMapa, Mapa.IdProdProd.ToString(), 3, "Exclusão: " + LstProduto.SelectedText.ToString().Trim() + " Qtde: " + Mapa.Qtde.ToString()); PopularGrid(); LimpaDados(); GridDados.Focus(); StaFormEdicao = false; } } }
private void BtnExcluir_Click(object sender, EventArgs e) { if (GridDados.CurrentRow != null) { Mapa.IdMapa = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); Mapa.LerDados(Mapa.IdMapa); if (Mapa.Status > 0) { MessageBox.Show("Mapa já Concluido", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (FrmPrincipal.Perfil_Usuario.ExcluirReg == 0) { FrmAutorizacao Autorizacao = new FrmAutorizacao(); Autorizacao.FrmPrincipal = FrmPrincipal; Autorizacao.ShowDialog(); //Verificando se o Acesso foi liberado if (Autorizacao.AcessoOk) { if (Autorizacao.Usuario.ExcluirReg == 0) { MessageBox.Show("Autorização negada para esse usuário", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } else { MessageBox.Show("Autorização negada para esse usuário", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } if (MessageBox.Show("Confirma a Exclusão do Registro", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes) { Mapa.IdMapa = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); Mapa.Excluir(); //Registrando Movimento de Auditoria FrmPrincipal.RegistrarAuditoria(this.Text, Mapa.IdMapa, Mapa.IdEntregador.ToString(), 3, "Excluindo"); PopularGrid(); LimpaDados(); GridDados.Focus(); } } } else { MessageBox.Show("Não existe Registro para Excluir", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void BtnCancelar_Click(object sender, EventArgs e) { try { StaFormEdicao = false; FrmPrincipal.ControleBotoes(false); Paginas.SelectTab(0); GridDados.Focus(); LimpaDados(); } catch (Exception Error) { MessageBox.Show(Error.ToString()); } }
private void BtnExcluir_Click(object sender, EventArgs e) { if (GridDados.CurrentRow != null) { Grade.IdGrade = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); Grade.LerDados(Grade.IdGrade); if (MessageBox.Show("Confirma a Exclusão do Registro", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes) { Grade.Excluir(); PopularGrid(); LimpaDados(); GridDados.Focus(); } } }
private void BtnExcluir_Click(object sender, EventArgs e) { if (GridDados.CurrentRow != null) { if (FrmPrincipal.Perfil_Usuario.AlterarProduto == 0) { MessageBox.Show("Usuário não Autorizado", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (FrmPrincipal.Perfil_Usuario.ExcluirReg == 0) { FrmAutorizacao Autorizacao = new FrmAutorizacao(); Autorizacao.FrmPrincipal = FrmPrincipal; Autorizacao.ShowDialog(); //Verificando se o Acesso foi liberado if (Autorizacao.AcessoOk) { if (Autorizacao.Usuario.ExcluirReg == 0) { MessageBox.Show("Autorização negada para esse usuário", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } else { MessageBox.Show("Autorização negada para esse usuário", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } if (MessageBox.Show("Confirma a Exclusão do Registro", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes) { Produto.LerDados(int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString())); Produto.Excluir(); FrmPrincipal.RegistrarAuditoria(this.Text, Produto.IdProduto, Produto.Referencia, 3, "Exclusão do Produto"); PopularGrid(); LimpaDados(); GridDados.Focus(); } } } else { MessageBox.Show("Não existe Registro para Excluir", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void BtnExcluir_Click(object sender, EventArgs e) { if (GridDados.CurrentRow != null) { if (MessageBox.Show("Confirma a Exclusão do Registro", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes) { Departamento.IdDepartamento = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); Departamento.Excluir(); PopularGrid(); LimpaDados(); GridDados.Focus(); } } else { MessageBox.Show("Não existe Registro para Excluir", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void PopularGrid() { DataSet Tabela = new DataSet(); string sSQL = "SELECT T2.ID_MOV AS LANC,T2.DTENTSAI AS DATA,T4.DESCRICAO AS DESCMOV,T4.ESTOQUE,T2.DOCUMENTO,T2.NUMFORMULARIO AS NUMDOC,CASE T4.ESTOQUE WHEN 1 THEN T1.QTDE ELSE 0 END AS ENTRADA,CASE T4.ESTOQUE WHEN 2 THEN T1.QTDE ELSE 0 END AS SAIDA,T1.VLRUNITARIO,T1.P_IPI,T5.RAZAOSOCIAL,T6.FANTASIA AS FILIAL FROM MVESTOQUEITENS T1" + " LEFT JOIN MVESTOQUE T2 ON (T2.ID_MOV=T1.ID_MOV) " + " LEFT JOIN PRODUTOS T3 ON (T3.ID_PRODUTO=T1.ID_PRODUTO) " + " LEFT JOIN TABELASAUX T4 ON (T4.CHAVE=T2.TPMOV) " + " LEFT JOIN PESSOAS T5 ON (T5.ID_PESSOA=T2.ID_PESSOA) " + " LEFT JOIN EMPRESA_FILIAL T6 ON (T6.ID_FILIAL=T2.ID_FILIALORIGDEST) " + " WHERE T1.ID_PRODUTO=" + TxtCodPrd.Text + " AND (T4.ESTOQUE<>0 OR T4.CAMPO='TPMVEST') AND T2.STATUS=1 " + " AND T2.DTENTSAI >= Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) AND T2.DTENTSAI <= Convert(DateTime,'" + Dt2.Value.Date.ToString() + "',103)"; if (LstTpMv.SelectedValue.ToString() != "0") { sSQL = sSQL + "AND T2.TPMOV='" + LstTpMv.SelectedValue.ToString() + "'"; } sSQL = sSQL + "UNION " + "SELECT T2.ID_VENDA AS LANC,T2.PREVENTREGA AS DATA,T4.DESCRICAO AS DESCMOV,T4.ESTOQUE,'',T2.NUMDOCUMENTO AS NUMDOC,CASE T1.TIPOITEM WHEN 'E' THEN T1.QTDE ELSE 0 END AS ENTRADA,CASE T1.TIPOITEM WHEN 'S' THEN T1.QTDE ELSE 0 END AS SAIDA,T1.VLRUNITARIO,0 AS P_IPI,T5.RAZAOSOCIAL,T6.FANTASIA AS FILIAL FROM MVVENDAITENS T1" + " LEFT JOIN MVVENDA T2 ON (T2.ID_VENDA=T1.ID_VENDA)" + " LEFT JOIN PRODUTOS T3 ON (T3.ID_PRODUTO=T1.ID_PRODUTO) " + " LEFT JOIN TABELASAUX T4 ON (T4.CHAVE=T2.TPVENDA) " + " LEFT JOIN PESSOAS T5 ON (T5.ID_PESSOA=T2.ID_PESSOA) " + " LEFT JOIN EMPRESA_FILIAL T6 ON (T6.ID_FILIAL=T2.ID_FILIAL) " + " WHERE T1.ID_PRODUTO=" + TxtCodPrd.Text + " AND (T4.ESTOQUE<>0 OR T4.CAMPO='TPMVEST') AND T2.STATUS IN (1,2,3) " + " AND T2.PREVENTREGA >= Convert(DateTime,'" + Dt1.Value.Date.ToString() + "',103) AND T2.PREVENTREGA <= Convert(DateTime,'" + Dt2.Value.Date.ToString() + "',103)"; if (LstTpMv.SelectedValue.ToString() != "0") { sSQL = sSQL + "AND T2.TPVENDA='" + LstTpMv.SelectedValue.ToString() + "'"; } sSQL = sSQL + " ORDER BY 2 DESC"; Tabela = Controle.ConsultaTabela(sSQL); GridDados.DataSource = Tabela; GridDados.DataMember = Tabela.Tables[0].TableName; if (GridDados.CurrentRow != null) { GridDados.Focus(); } }
private void BtnExcluir_Click(object sender, EventArgs e) { if (GridDados.CurrentRow != null) { Promocao.IdPromocao = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); Promocao.LerDados(Promocao.IdPromocao); if (FrmPrincipal.Perfil_Usuario.ExcluirReg == 0) { FrmAutorizacao Autorizacao = new FrmAutorizacao(); Autorizacao.FrmPrincipal = FrmPrincipal; Autorizacao.ShowDialog(); //Verificando se o Acesso foi liberado if (Autorizacao.AcessoOk) { if (Autorizacao.Usuario.ExcluirReg == 0) { MessageBox.Show("Autorização negada para esse usuário", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } else { MessageBox.Show("Autorização negada para esse usuário", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } StaFormEdicao = true; if (MessageBox.Show("Confirma a Exclusão do Registro", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes) { Promocao.IdPromocao = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); Promocao.Excluir(); //Registrando Movimento de Auditoria FrmPrincipal.RegistrarAuditoria(this.Text, Promocao.IdPromocao, Promocao.IdPromocao.ToString(), 3, "Exclusão: " + TxtPromocao.Text); PopularGrid(); LimpaDados(); GridDados.Focus(); StaFormEdicao = false; } } }
private void CancelarVinculo() { if (GridDados.CurrentRow == null) { MessageBox.Show("Não existe Registro para Edição", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { IdVenda = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); if (GridDados.CurrentRow.Cells[1].Value.ToString() != "OK") { MessageBox.Show("Ordem de entrega não esta vinculada", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } Controle.ExecutaSQL("Update MvVenda set VinculoVD=' ' WHERE ID_VENDA=" + IdVenda.ToString()); Controle.ExecutaSQL("Delete From MvVendaItens WHERE Vinculado=" + IdVenda.ToString()); PopularGrid(); GridDados.Focus(); MessageBox.Show("Cancelamento do vinculo da ordem de entrega concluido", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void CalcularParcelas(int NumParc) { DataTable TabLanc = CriarTabela(); int NParc = 1; DateTime DtVenc = TxtDtBase.Value; decimal VrParc = LancFinanc.VlrOriginal; int dia = TxtDtBase.Value.Day; int mes = TxtDtBase.Value.Month; int ano = TxtDtBase.Value.Year; DtVenc = new DateTime(ano, mes, dia); while (NParc <= NumParc) { TabLanc.Rows.Add(NParc, DtVenc.Date, VrParc, LancFinanc.NumDoc.Trim()); DtVenc = DtVenc.AddMonths(1); dia = TxtDtBase.Value.Day; mes = DtVenc.Date.Month; ano = DtVenc.Date.Year; try { if (mes == 2 && dia > 28) { dia = 28; } DtVenc = new DateTime(ano, mes, dia); } catch { } NParc++; } Source_Lanc.DataSource = TabLanc; Source_Lanc.DataMember = TabLanc.TableName; GridDados.DataSource = Source_Lanc; GridDados.Refresh(); GridDados.Focus(); }
private void BtnExcluir_Click(object sender, EventArgs e) { if (GridDados.CurrentRow != null) { if (int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()) <= 10) { MessageBox.Show("Evento resevado pelo sistema, não pode ser excluido", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (MessageBox.Show("Confirma a Exclusão do Registro", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes) { Eventos.IdCodigo = int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString()); Eventos.Excluir(); PopularGrid(); LimpaDados(); GridDados.Focus(); } } else { MessageBox.Show("Não existe Registro para Excluir", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void TxtPesquisa_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { BtnFicha.Enabled = false; BtnUltCompra.Enabled = false; if (TxtPesquisa.Text.Trim() != "") { try { string sSQL = "SELECT T1.Id_Pessoa,CASE CLIE_FORN WHEN 0 THEN 'Cliente' WHEN 1 THEN 'Fornecedor' WHEN 2 THEN 'Cliente e Fornecedor' WHEN 3 THEN 'Distribuidor' " + " WHEN 4 THEN 'Rede ou Grupo' WHEN 5 THEN 'Funcionário' WHEN 6 THEN 'Revenda' WHEN 6 THEN 'Representante' ELSE '' END AS TipoCad,T1.Cnpj,T1.RazaoSocial," + "T1.Fantasia,T1.LimiteCredito,T1.Credito,T1.Fone,T1.CONTATO,T2.VENDEDOR,Rtrim(T1.Endereco)+','+RTrim(T1.Numero)+' '+Rtrim(T1.Complemento)+' '+RTrim(T1.Cep)+' '+RTrim(T1.Bairro)+' '+Rtrim(T1.Cidade) as Logradouro,T1.DATACADASTRO AS DTCADASTRO FROM Pessoas T1 LEFT JOIN VENDEDORES T2 ON (T2.ID_VENDEDOR=T1.ID_VENDEDOR) "; if (RedeGrp) { sSQL = sSQL + " WHERE T1.CLIE_FORN=4 AND"; } else { sSQL = sSQL + " WHERE"; } DataSet Tabela = new DataSet(); if (LstPesquisa.SelectedIndex == 0) { Tabela = Controle.ConsultaTabela(string.Format(sSQL + " T1.Ativo=1 and T1.Cnpj LIKE '%{0}%' order by T1.Cnpj", TxtPesquisa.Text.Trim())); } else if (LstPesquisa.SelectedIndex == 1) { Tabela = Controle.ConsultaTabela(string.Format(sSQL + " T1.Ativo=1 and T1.RazaoSocial LIKE '%{0}%' order by T1.RazaoSocial", TxtPesquisa.Text.Trim())); } else if (LstPesquisa.SelectedIndex == 2) { Tabela = Controle.ConsultaTabela(string.Format(sSQL + " T1.Ativo=1 and T1.Fantasia LIKE '%{0}%' order by T1.Fantasia", TxtPesquisa.Text.Trim())); } else if (LstPesquisa.SelectedIndex == 3) { Tabela = Controle.ConsultaTabela(string.Format(sSQL + " T1.Ativo=1 and T1.Endereco LIKE '%{0}%' order by T1.Fantasia", TxtPesquisa.Text.Trim())); } else if (LstPesquisa.SelectedIndex == 4) { Tabela = Controle.ConsultaTabela(string.Format(sSQL + " T1.Ativo=1 and T1.Fone LIKE '%{0}%' order by T1.Fone", TxtPesquisa.Text.Trim())); } GridDados.DataSource = Tabela; GridDados.DataMember = Tabela.Tables[0].TableName; if (GridDados.CurrentRow != null) { GridDados.Focus(); BtnFicha.Enabled = true; BtnUltCompra.Enabled = true && !FrmPrincipal.VersaoDistribuidor; } else { MessageBox.Show("Nenhum registro foi localizado", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtPesquisa.Focus(); } } catch { MessageBox.Show("Erro ao pesquisar verifique o conteúdo da pesquisa", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void BtnConcluir_Click(object sender, EventArgs e) { decimal Total = 0; bool TpDoc = false; for (int I = 0; I <= GridDados.RowCount - 1; I++) { Total = Total + decimal.Parse(GridDados.Rows[I].Cells[3].Value.ToString()); if (int.Parse(GridDados.Rows[I].Cells[4].Value.ToString()) == 0) { TpDoc = true; } } if (TpDoc) { MessageBox.Show("Favor informar o Tipo de Documento", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information); GridDados.Focus(); return; } if (Math.Round(Total, 2) != Math.Round(TxtVlrTotal.Value, 2)) { MessageBox.Show("Soma das Parcela(s) diferente do total do movimento", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information); GridDados.Focus(); } else { MvVenda Venda = new MvVenda(); Venda.Controle = Controle; Venda.LerDados(NumVd); if (Venda.Status == 2 && Venda.IdEntregador != 0 && !FechaPDV) { MessageBox.Show("Movimento já Faturado e em Rota", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (Venda.Status == 3) { MessageBox.Show("Movimento já Entregue", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (MessageBox.Show("Confirma o Fechamento do Movimento", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { BtnConcluir.Enabled = false; FrmPrincipal.BSta_BarProcesso.Value = 0; FrmPrincipal.BSta_BarProcesso.Maximum = Source_Lanc.Count; // if (NumMov > 0) { Controle.ExecutaSQL("DELETE FROM LANCFINANCEIRO WHERE ID_MOV=" + NumMov.ToString()); } else if (NumVd > 0) { Controle.ExecutaSQL("DELETE FROM LANCFINANCEIRO WHERE ID_VENDA=" + NumVd.ToString()); } // Financeiro MvFinanc = new Financeiro(); Pessoas Pessoa = new Pessoas(); Pessoa.Controle = Controle; MvFinanc.Controle = Controle; Pessoa.LerDados(IdPessoa); // Processando os Dados for (int i = 0; i <= Source_Lanc.Count - 1; i++) { if (decimal.Parse(GridDados.Rows[i].Cells[3].Value.ToString()) > 0) { MvFinanc.LerDados(0); MvFinanc.PagRec = PagRec; MvFinanc.IdMov = NumMov; MvFinanc.IdVenda = NumVd; MvFinanc.IdPessoa = IdPessoa; if (IdFilial > 0) { MvFinanc.IdFilial = IdFilial; } else { MvFinanc.IdFilial = FrmPrincipal.Perfil_Usuario.IdFilial; } MvFinanc.Vencimento = DateTime.Parse(GridDados.Rows[i].Cells[2].Value.ToString()); MvFinanc.VlrOriginal = decimal.Parse(GridDados.Rows[i].Cells[3].Value.ToString()); MvFinanc.IdTipoDocumento = int.Parse(GridDados.Rows[i].Cells[4].Value.ToString()); MvFinanc.IdCusto = Pessoa.IdCusto; MvFinanc.IdDepartamento = Pessoa.IdDepartamento; MvFinanc.IdVendedor = Venda.IdVendedor; MvFinanc.IdFormaPgto = int.Parse(LstFormaPgto.SelectedValue.ToString()); MvFinanc.IdAgente = int.Parse(LstAgente.SelectedValue.ToString()); MvFinanc.NumDoc = NumDoc.Trim() + "/" + string.Format("{0:D2}", i + 1); MvFinanc.Referente = Referente; MvFinanc.NotaFiscal = NotaFiscal; MvFinanc.IdUsuLanc = FrmPrincipal.Perfil_Usuario.IdUsuario; MvFinanc.Observacao = Obs; MvFinanc.GravarDados(); if (FrmPgto.Baixa == 1 && FrmPrincipal.Perfil_Usuario.UsuCaixaLj == 1) { MvFinanc.DtBaixa = MvFinanc.Vencimento; MvFinanc.VlrBaixa = MvFinanc.VlrOriginal; MvFinanc.Baixar(); } } FrmPrincipal.BSta_BarProcesso.Value = FrmPrincipal.BSta_BarProcesso.Value + 1; } FrmPrincipal.BSta_BarProcesso.Value = 0; Concluido = true; Close(); } catch { MessageBox.Show("Ocorreu um erro ao tentar confirmar tente novamento", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information); if (NumMov > 0) { Controle.ExecutaSQL("DELETE FROM LANCFINANCEIRO WHERE ID_MOV=" + NumMov.ToString()); } else if (NumVd > 0) { Controle.ExecutaSQL("DELETE FROM LANCFINANCEIRO WHERE ID_VENDA=" + NumVd.ToString()); } BtnConcluir.Enabled = true; FrmPrincipal.BSta_BarProcesso.Value = 0; } } } }
private void CalcularParcelas(int IdFormaPgto, int NumParc) { TxtNumParc.Enabled = true; FrmPgto.LerDados(IdFormaPgto); Venda.LerDados(NumVd); CadPessoa.LerDados(Venda.IdPessoa); if (FrmPgto.IdFormaPgto > 0) { if (FrmPgto.BloqPF == 1 && CadPessoa.Tipo == 1 && Venda.IdUsuboleto == 0 && NumVd > 0) { MessageBox.Show("Atenção: Forma de pagamento não autorizada para Pessoa Fisica.", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information); LstFormaPgto.SelectedValue = Venda.IdFormaPgto.ToString(); return; } DataTable TabLanc = CriarTabela(); int NParc = 1; int NumParcelas = 1; NumParcelas = FrmPgto.NumParcelas; if (NumParc > 0) { NumParcelas = NumParc; } TxtNumParc.Value = NumParcelas; DateTime DtVenc = TxtDtBase.Value.AddDays(FrmPgto.PrimParcela); decimal VrParc = Math.Round(TxtVlrTotal.Value / NumParcelas, 2); decimal VrPrimParc = VrParc + (TxtVlrTotal.Value - (Math.Round(VrParc * NumParcelas, 2))); int Dias = FrmPgto.PrimParcela; decimal Rentab = 0; if (NumVd > 0) { Rentab = VerificaRentab(NumVd); } while (NParc <= NumParcelas) { TabLanc.Rows.Add(NParc, Dias, DtVenc.Date, VrPrimParc, FrmPgto.IdTpDocumento); if (FrmPgto.Intervalo == 0) { if (CadPessoa.NaoVerPrazoPg == 0 && TxtVlrTotal.Value <= FrmPgto.VlrParcelamento && Venda.TpVenda == "PV" && Venda.IdUsuLibParc == 0 && !FrmPrincipal.VersaoDistribuidor) { DtVenc = DtVenc; Dias = Dias; } else if (CadPessoa.NaoVerPrazoPg == 0 && NumVd > 0 && Rentab <= decimal.Parse("2,40") && Venda.TpVenda == "PV" && Venda.IdUsuLibParc == 0 && !FrmPrincipal.VersaoDistribuidor) { DtVenc = DtVenc; Dias = Dias; } else { DtVenc = DtVenc.AddDays(30); Dias = Dias + 30; } } else { if (CadPessoa.NaoVerPrazoPg == 0 && TxtVlrTotal.Value <= FrmPgto.VlrParcelamento && Venda.TpVenda == "PV" && Venda.IdUsuLibParc == 0 && !FrmPrincipal.VersaoDistribuidor) { DtVenc = DtVenc; Dias = Dias; } else if (CadPessoa.NaoVerPrazoPg == 0 && NumVd > 0 && Rentab <= decimal.Parse("2,40") && Venda.TpVenda == "PV" && Venda.IdUsuLibParc == 0 && !FrmPrincipal.VersaoDistribuidor) { DtVenc = DtVenc; Dias = Dias; } else { DtVenc = DtVenc.AddDays(FrmPgto.Intervalo); Dias = Dias + FrmPgto.Intervalo; } } VrPrimParc = VrParc; NParc++; } Source_Lanc.DataSource = TabLanc; Source_Lanc.DataMember = TabLanc.TableName; GridDados.DataSource = Source_Lanc; GridDados.Refresh(); GridDados.Focus(); } }
private void PesquisaProduto() { if (TxtReferencia.Text.Trim() != "" || TxtDescricao.Text.Trim() != "" || TxtRefFornecedor.Text.Trim() != "" || int.Parse(ListaGrupo.SelectedValue.ToString()) > 0) { //" (SELECT TOP 1 PED1.PREVENTREGA FROM PEDCOMPRA PED1 " + DataSet Tabela = new DataSet(); string sSQL = "SELECT T1.Id_Produto,T1.Descricao,T1.Referencia,GRPPRD.GRUPO, CASE T1.PRODUTOKIT WHEN 0 THEN T1.SaldoEstoque ELSE (SELECT MIN(KT2.SALDOESTOQUE) FROM PRODUTOSKIT KT1 " + " LEFT JOIN PRODUTOS KT2 ON (KT2.ID_PRODUTO=KT1.ID_PRODUTO) WHERE KT1.ID_PRDMASTER=T1.ID_PRODUTO) END AS SALDOESTOQUE," + " (SELECT TOP 1 rtrim(convert(char,PED1.PREVENTREGA,103))+' Qtde: '+' Qtde:'+ Rtrim(convert(int,(SELECT SUM(Ped3.Qtde) FROM PEDCOMPRAITENS PED3 LEFT JOIN PEDCOMPRA PED4 ON (PED4.ID_DOCUMENTO=PED3.ID_DOCUMENTO) WHERE PED3.ID_PRODUTO=T1.ID_PRODUTO AND PED4.STATUS=1 AND PED4.PrevEntrega=PED1.PrevEntrega))) FROM PEDCOMPRA PED1" + " LEFT JOIN PEDCOMPRAITENS PED2 ON (PED2.ID_DOCUMENTO=PED1.ID_DOCUMENTO) WHERE PED2.ID_PRODUTO=T1.ID_PRODUTO AND PED1.STATUS=1 ORDER BY PED1.PREVENTREGA) AS PREVENTREGA,0 as Qtde," + "T1.PrcSensacional,T1.PrcEspecial,T1.PrcVarejo,T1.PrcMinimo,T1.PrcAtacado,T1.PrcEspDist,T1.NCM, 0 AS IDPROMOCAO, T1.ATIVO, 0.00 as P_Sensacional,0.00 AS P_Especial,0.00 AS P_Varejo,0.00 AS P_Minimo,0.00 AS P_Atacado,'' as NmPromocao,0 as PromQtdeitem," + "(SELECT TOP 1 B2.DATA FROM BalancoItens B1 left join Balanco B2 on (B2.Id_Balanco=B1.Id_Balanco) where B1.Id_Produto=T1.ID_PRODUTO and B2.Status=1 order by B2.Data desc) AS UltBalanco, 0.00 as PComPromocao," + "(SELECT TOP 1 CONVERT(CHAR,M2.DATA,103) FROM MvEstoqueItens M1 LEFT JOIN MvEstoque M2 on(M2.Id_Mov = M1.Id_Mov) where M2.Status = 1 and M2.TPMov = 'COMPR' AND M1.Id_Produto=T1.Id_Produto ORDER BY M2.ID_MOV DESC) AS DTULTCOMPRA"; sSQL = sSQL + " FROM Produtos T1 LEFT JOIN GRUPOPRODUTO GRPPRD ON (GRPPRD.ID_GRUPO=T1.ID_GRUPO) "; if (LstMvEst) { sSQL = sSQL + " WHERE GRPPRD.Ativo=1 "; } else { sSQL = sSQL + " WHERE T1.Ativo=1 AND GRPPRD.Ativo=1 "; } if (TxtReferencia.Text.Trim() != "") { if (TxtReferencia.Text.Length > 11) { sSQL = sSQL + string.Format(" and T1.CodBarra LIKE '%{0}%' ", TxtReferencia.Text.Trim()); } else { sSQL = sSQL + string.Format(" and T1.Referencia LIKE '%{0}%' ", TxtReferencia.Text.Trim()); } } if (TxtDescricao.Text.Trim() != "") { sSQL = string.Format(sSQL + " and T1.Descricao LIKE '%{0}%' ", TxtDescricao.Text.Trim()); } if (TxtRefFornecedor.Text.Trim() != "") { sSQL = string.Format(sSQL + " and T1.RefFornecedor LIKE '%{0}%' ", TxtRefFornecedor.Text.Trim()); } if (int.Parse(ListaGrupo.SelectedValue.ToString()) > 0) { sSQL = sSQL + " AND T1.ID_GRUPO=" + ListaGrupo.SelectedValue.ToString(); } if (VerGrpLstVenda) { sSQL = sSQL + " AND GRPPRD.LISTAVENDA=1"; } if (TxtReferencia.Text.Trim() != "") { sSQL = sSQL + " ORDER BY T1.Referencia"; } else { sSQL = sSQL + " ORDER BY T1.Descricao"; } TabItens = Controle.ConsultaTabela(sSQL); Source_Itens.DataSource = TabItens; Source_Itens.DataMember = TabItens.Tables[0].TableName; GridDados.DataSource = Source_Itens; if (GridDados.CurrentRow != null) { GridDados.Focus(); } else { TxtReferencia.Text = ""; } if (!LstMvEst) { VerificaPromocao(); } //MostraSldEstDep(); } }
private void TxtPesquisa_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (TxtPesquisa.Text.Trim() != "") { try { DataSet Tabela = new DataSet(); string sSQL = "SELECT T1.ID_FUNC,T1.MATRICULA,T1.NOME,T2.DEPARTAMENTO,T3.FILIAL AS LotFilial FROM FUNCIONARIOS T1 " + " LEFT JOIN Departamentos T2 ON (T2.Id_Departamento=T1.Id_Departamento)" + " LEFT JOIN Empresa_Filial T3 ON (T3.Id_Filial=T1.Id_FilialTrab) WHERE T1.DTDEMISSAO IS NULL AND T3.ID_FILIAL<>2"; if (TxtPesquisa.Text.Trim() != "") { try { if (LstPesquisa.SelectedIndex == 0) { Tabela = Controle.ConsultaTabela(string.Format(sSQL + " AND T1.NOME LIKE '%{0}%' order by T1.NOME", TxtPesquisa.Text.Trim())); } else if (LstPesquisa.SelectedIndex == 1) { Tabela = Controle.ConsultaTabela(string.Format(sSQL + " AND T1.MATRICULA LIKE '%{0}%' order by T1.MATRICULA", TxtPesquisa.Text.Trim())); } else if (LstPesquisa.SelectedIndex == 2) { Tabela = Controle.ConsultaTabela(string.Format(sSQL + " AND T1.CPF LIKE '%{0}%' order by T1.CPF", TxtPesquisa.Text.Trim())); } } catch { MessageBox.Show("Erro ao pesquisar verifique o conteúdo da pesquisa", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { Tabela = Controle.ConsultaTabela(sSQL + " ORDER BY T1.NOME"); } BindingSource Source = new BindingSource(); Source.DataSource = Tabela; Source.DataMember = Tabela.Tables[0].TableName; GridDados.DataSource = Source; int item = Source.Find("Id_Func", CadFunc.IdFunc); Source.Position = item; if (GridDados.CurrentRow != null) { GridDados.Focus(); } else { MessageBox.Show("Nenhum registro foi localizado", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtPesquisa.Focus(); } } catch { } } } }
private void BtnExcluir_Click(object sender, EventArgs e) { if (GridDados.CurrentRow != null) { MvLivroCxa.LerDados(int.Parse(GridDados.CurrentRow.Cells[0].Value.ToString())); if (MvLivroCxa.Status == 1) { MessageBox.Show("Lançamento já Cancelamento", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (MvLivroCxa.StatusLivroCxa(MvLivroCxa.IdCaixa, MvLivroCxa.Data) == 1) { MessageBox.Show("Atenção: Data do Livro Caixa encerrada", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (MvLivroCxa.IdLancOrig > 0) { MessageBox.Show("Estorno nao pode ser efetuado, Lançamento Gerado pelo Financeiro", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } /*if (MessageBox.Show("Confirma o Cancelamento do Lançamento", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes) * { * if (MvLivroCxa.IdLanc > 0) * { * MvLivroCxa.Descricao = "ESTORNO <-> Ref. Lanç.: " + MvLivroCxa.IdLanc.ToString(); * MvLivroCxa.IdLanc = 0; * MvLivroCxa.Data = DateTime.Now; * MvLivroCxa.IdUsuario = FrmPrincipal.Perfil_Usuario.IdUsuario; * if (MvLivroCxa.TpLanc == 1) MvLivroCxa.TpLanc = 2; else MvLivroCxa.TpLanc = 1; * MvLivroCxa.GravarDados(); * MvLivroCxa.Estorno(); * PopularGrid(); * LimpaDados(); * GridDados.Focus(); * } * }*/ if (MessageBox.Show("Confirma o Cancelamento do Lançamento", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (MvLivroCxa.IdLanc > 0) { int TpLanc = MvLivroCxa.TpLanc; MvLivroCxa.Status = 1; MvLivroCxa.IdUsuario = FrmPrincipal.Perfil_Usuario.IdUsuario; if (MvLivroCxa.TpLanc == 1) { TpLanc = 2; } else { TpLanc = 1; } MvLivroCxa.GravarDados(); MvLivroCxa.Atlz_SaldoContaCaixa(TpLanc, MvLivroCxa.IdCaixa, MvLivroCxa.IdDocumento, MvLivroCxa.Data, MvLivroCxa.Valor); PopularGrid(); LimpaDados(); GridDados.Focus(); } } } else { MessageBox.Show("Não existe Registro para Excluir", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }