public frmPrincipal() { InitializeComponent(); string sql = String.Format(@"SELECT * FROM PROPRIETARIO"); this.Text = MetodosSql.GetField(sql, "NOMEFANTASIA"); }
private void btnExcluir_Click(object sender, EventArgs e) { try { int quant; var rowHandle = gridView1.FocusedRowHandle; var obj = gridView1.GetRowCellValue(rowHandle, "IDPRODUTO"); if (obj != null) { quant = int.Parse(MetodosSql.GetField(String.Format(@"SELECT COUNT(IDPRODUTO) AS PRODUTO FROM ITEMMOVIMENTO WHERE IDPRODUTO= '{0}'", obj.ToString()), "PRODUTO")); if (DialogResult.Yes == MessageBox.Show("Deseja mesmo exluir?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { if (quant > 0) { MessageBox.Show("Existe uma venda que contém este seguro. Você não poderá excluir seguros que estão cadastrados em vendas.", "Aviso.", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MetodosSql.ExecQuery(String.Format(@"delete from PRODUTO where IDPRODUTO = {0}", obj.ToString())); AtualizaGrid(); } } } else { MessageBox.Show("Por favor, selecione um registro", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void frmCadastroVenda_Load(object sender, EventArgs e) { try { if (Editar) { txtCodigo.Text = Cod; sql = String.Format(@"select * from VENDA where IDVENDA = {0}", Cod); idVendedor = MetodosSql.GetField(sql, "IDVENDEDOR"); txtDesconto.Text = MetodosSql.GetField(sql, "DESCONTO"); txtIdCliente.Text = MetodosSql.GetField(sql, "IDFCFO"); txtIdOrdem.Text = MetodosSql.GetField(sql, "IDORDEM"); txtTipoPagamento.Text = MetodosSql.GetField(sql, "TIPOPAGAMENTO"); txtObservacao.Text = MetodosSql.GetField(sql, "OBSERVACAO"); txtStatus.Text = status; txtDataInclusao.Text = MetodosSql.GetField(String.Format(@"select CONVERT(varchar, CONVERT(varchar, DATAINCLUSAO, 103)) as 'Nasc' from VENDA where IDVENDA = {0}", Cod), "Nasc"); txtNome.Text = MetodosSql.GetField(String.Format(@"select NOME from FCFO where IDFCFO = '{0}'", txtIdCliente.Text), "NOME"); txtSobrenome.Text = MetodosSql.GetField(String.Format(@"select NOMEFANTASIA FROM FCFO WHERE IDFCFO = {0}", txtIdCliente.Text), "NOMEFANTASIA"); sql = String.Format(@"select NOME, SOBRENOME FROM VENDEDORES WHERE IDVENDEDOR = '{0}'", idVendedor.ToString()); txtNomeVendedor.Text = MetodosSql.GetField(sql, "NOME"); txtSobrenomeVendedor.Text = MetodosSql.GetField(sql, "SOBRENOME"); txtIdVendedor.Text = idVendedor.ToString(); sql = String.Format(@"select DESCRICAO from TIPOPAGAMENTO WHERE IDTIPOPAGAMENTO = {0}", txtTipoPagamento.Text); txtDescricaoTipoPagamento.Text = MetodosSql.GetField(sql, "DESCRICAO"); txtDataVencimento.Text = MetodosSql.GetField(String.Format(@"select CONVERT(varchar, CONVERT(varchar, DATAVENCIMENTO, 103)) as 'Vencimento' from VENDA where IDVENDA = {0}", Cod), "Vencimento"); } AtualizaGrid(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void frmCadastroVendedores_Load(object sender, EventArgs e) { if (Editar) { string sql = String.Format(@"SELECT * FROM VENDEDORES WHERE IDVENDEDOR = {0}", Cod); txtCodigo.Text = Cod; txtNome.Text = MetodosSql.GetField(sql, "NOME"); txtSobrenome.Text = MetodosSql.GetField(sql, "SOBRENOME"); txtCpf.Text = MetodosSql.GetField(sql, "CPF"); txtDataNasc.Text = MetodosSql.GetField(sql, "DTANASCIMENTO"); txtSexo.Text = MetodosSql.GetField(sql, "SEXO"); txtTelefone.Text = MetodosSql.GetField(sql, "TELEFONE1"); txtTelefone2.Text = MetodosSql.GetField(sql, "TELEFONE2"); txtCelular.Text = MetodosSql.GetField(sql, "CELULAR"); txtCelular2.Text = MetodosSql.GetField(sql, "CELULAR2"); txtEmail.Text = MetodosSql.GetField(sql, "EMAIL"); txtEmail2.Text = MetodosSql.GetField(sql, "EMAIL2"); txtRua.Text = MetodosSql.GetField(sql, "RUA"); txtLogradouro.Text = MetodosSql.GetField(sql, "LOGRADOURO"); txtNumero.Text = MetodosSql.GetField(sql, "NUMERO"); txtBairro.Text = MetodosSql.GetField(sql, "BAIRRO"); txtCidade.Text = MetodosSql.GetField(sql, "CIDADE"); txtCep.Text = MetodosSql.GetField(sql, "CEP"); txtEstado.Text = MetodosSql.GetField(sql, "ESTADO"); txtComplemento.Text = MetodosSql.GetField(sql, "COMPLEMENTO"); txtObservacao.Text = MetodosSql.GetField(sql, "OBSERVACAO"); txtDataInclusao.Text = MetodosSql.GetField(sql, "DATAINCLUSAO"); } }
private void InsertParcela() { string[] vet = data1.Split('/'); dia = int.Parse(vet[0]); mes = int.Parse(vet[1]); ano = int.Parse(vet[2]); sql = String.Format(@"select PARCELAS from TIPOPAGAMENTO where IDTIPOPAGAMENTO = {0}", txtTipoPagamento.Text); int NParcelas = int.Parse(MetodosSql.GetField(sql, "PARCELAS")); for (int parcela = 1; parcela <= NParcelas; parcela++) { sql = String.Format(@"insert into PARCELA(NPARCELA, IDVENDA, IDFCFO, VALOR, DATAVENCIMENTO) values ({0},{1},{2},cast({3} as numeric(20,2))/{4}, CONVERT(DATETIME, CONVERT(VARCHAR,'{5}', 121),103)) select SCOPE_IDENTITY()", parcela, txtCodigo.Text, txtIdCliente.Text, txtTotalVenda.Text.Replace(".", "").Replace(",", "."), NParcelas, data1); object Codparcela = MetodosSql.ExecScalar(sql); Cod = Codparcela.ToString(); if (mes == 12) { ano += 1; mes = 1; } else { mes += 1; } data1 = (dia + "/" + mes + "/" + ano); } }
private void frmCadastroProprietario_Load(object sender, EventArgs e) { try { string sql = String.Format(@"select * from PROPRIETARIO"); txtNome.Text = MetodosSql.GetField(sql, "NOME"); txtNomeFantasia.Text = MetodosSql.GetField(sql, "NOMEFANTASIA"); txtCpf.Text = MetodosSql.GetField(sql, "CPF"); txtCnpj.Text = MetodosSql.GetField(sql, "CNPJ"); txtTelefone.Text = MetodosSql.GetField(sql, "TELEFONE"); txtTelefone2.Text = MetodosSql.GetField(sql, "TELEFONE2"); txtCelular.Text = MetodosSql.GetField(sql, "CELULAR"); txtCelular2.Text = MetodosSql.GetField(sql, "CELULAR2"); txtEmail.Text = MetodosSql.GetField(sql, "EMAIL"); txtEmail2.Text = MetodosSql.GetField(sql, "EMAIL2"); txtContato.Text = MetodosSql.GetField(sql, "CONTATO"); txtRua.Text = MetodosSql.GetField(sql, "RUA"); txtLogradouro.Text = MetodosSql.GetField(sql, "LOGRADOURO"); txtNumero.Text = MetodosSql.GetField(sql, "NUMERO"); txtBairro.Text = MetodosSql.GetField(sql, "BAIRRO"); txtCidade.Text = MetodosSql.GetField(sql, "CIDADE"); txtCep.Text = MetodosSql.GetField(sql, "CEP"); txtEstado.Text = MetodosSql.GetField(sql, "ESTADO"); txtComplemento.Text = MetodosSql.GetField(sql, "COMPLEMENTO"); txtDataInclusao.Text = MetodosSql.GetField(String.Format(@"select CONVERT(varchar, CONVERT(DATETIME , DATAINCLUSAO, 121) , 103) AS 'Nasc' from PROPRIETARIO"), "Nasc"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void frmCadastroCiaSeguradora_Load(object sender, EventArgs e) { try { if (Editar) { string sql = String.Format(@"SELECT * FROM FCFOSEGURADORA WHERE IDSEGURADORA = '{0}'", Cod); txtNome.Text = MetodosSql.GetField(sql, "NOME"); txtNomeFantasia.Text = MetodosSql.GetField(sql, "NOMEFANTASIA"); txtSexo.Text = MetodosSql.GetField(sql, "SEXO"); txtCelular.Text = MetodosSql.GetField(sql, "CELULAR"); txtCelular2.Text = MetodosSql.GetField(sql, "CELULAR2"); txtTelefone.Text = MetodosSql.GetField(sql, "TELEFONE1"); txtTelefone2.Text = MetodosSql.GetField(sql, "TELEFONE2"); txtEmail.Text = MetodosSql.GetField(sql, "EMAIL"); txtEmail2.Text = MetodosSql.GetField(sql, "EMAIL2"); txtObservacao.Text = MetodosSql.GetField(sql, "OBSERVACAO"); txtCpf.Text = MetodosSql.GetField(sql, "CPF"); txtCNPJ.Text = MetodosSql.GetField(sql, "CNPJ"); txtRg.Text = MetodosSql.GetField(sql, "RG"); txtObservacaoDocumento.Text = MetodosSql.GetField(sql, "OBSDOCUMENTO"); txtTipoPessoa.Text = MetodosSql.GetField(sql, "TIPOPESSOA"); txtDataInclusao.Text = MetodosSql.GetField(String.Format(@"SELECT CONVERT(VARCHAR, DATAINCLUSAO, 103) AS DATAINCLUSAO FROM FCFOSEGURADORA WHERE IDSEGURADORA = '{0}'", Cod), "DATAINCLUSAO"); txtCodigo.Text = MetodosSql.GetField(sql, "IDSEGURADORA"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void CarregaNome() { txtCodigoCliente.Text = Cod; txtNomeCliente.Text = MetodosSql.GetField(String.Format("select NOME from FCFO where IDFCFO = '{0}'", Cod), "NOME"); txtSobrenome.Text = MetodosSql.GetField(String.Format("select NOMEFANTASIA from FCFO where IDFCFO = '{0}'", Cod), "NOMEFANTASIA"); AtualizaGrid(); }
private Boolean TestaUpdate() { Boolean Validar; double Valor; string sql = String.Format(@"SELECT SUM(ISNULL(VALORDINHEIRO, 0) + ISNULL(VALORCHEQUE, 0) + ISNULL(VALORCARTAOCREDITO, 0) + ISNULL(VALORCARTAODEBITO, 0)) AS VALOR FROM RECEBIMENTO WHERE IDVENDA = '{0}' AND EXTORNO = 0", IDVENDA); if (MetodosSql.GetField(sql, "VALOR") == "") { Valor = 0; } else { Valor = double.Parse(MetodosSql.GetField(sql, "VALOR")); } if (Valor == 0) { Validar = true; } else { Validar = false; } return(Validar); }
private void Recebimento() { try { ValorPagamento(); double ValorTotalRestante = Convert.ToDouble(txtValorTotal.Text.Replace(".", ",")) - (Convert.ToDouble(txtValorCheque.Text.Replace(".", ",")) + Convert.ToDouble(txtValorCredito.Text.Replace(".", ",")) + Convert.ToDouble(txtValorDebito.Text.Replace(".", ",")) + Convert.ToDouble(txtValorDinheiro.Text.Replace(".", ","))); txtValorRestante.Text = ValorTotalRestante.ToString(); double ValorTotal = Convert.ToDouble(txtValorTotal.Text.Replace(".", ",")); txtValorTotal.Text = ValorTotal.ToString(); string sql = String.Format(@"insert into RECEBIMENTO(IDVENDA, IDFCFO , VALORDINHEIRO , VALORCHEQUE , VALORCARTAOCREDITO , VALORCARTAODEBITO) VALUES ({0}, {1} , {2} , {3} , {4} , {5})", Entrada, IDCLIENTE, txtValorDinheiro.Text.Replace(",", "."), txtValorCheque.Text.Replace(",", "."), txtValorCredito.Text.Replace(",", "."), txtValorDebito.Text.Replace(",", ".")); MetodosSql.ExecQuery(sql); sql = String.Format(@"select PARCELAS from TIPOPAGAMENTO where IDTIPOPAGAMENTO = {0}", TipoPagamento); int NParcelas = int.Parse(MetodosSql.GetField(sql, "PARCELAS")); for (int parcela = 1; parcela <= NParcelas; parcela++) { sql = String.Format(@"insert into PARCELA values ({0},{1},{2},{3}/{4},'A')", parcela, Entrada, IDCLIENTE, ValorTotalRestante, NParcelas); MetodosSql.ExecQuery(sql); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void frmServico_Load(object sender, EventArgs e) { txtCodigo.Text = Cod; try { if (Editar) { txtCodigo.Text = Cod; string sql = String.Format(@"select * from ORDEM where IDORDEM = {0}", Cod); txtCodigoFcfo.Text = MetodosSql.GetField(sql, "IDFCFO"); txtDescricao.Text = MetodosSql.GetField(sql, "DESCRICAO"); txtConclusao.Text = MetodosSql.GetField(sql, "CONCLUSAO"); txtObservacao.Text = MetodosSql.GetField(sql, "OBSERVACAO"); txtStatus.Text = MetodosSql.GetField(sql, "STATUS"); txtNomeCliente.Text = MetodosSql.GetField(String.Format(@"select * from ORDEM INNER JOIN FCFO ON FCFO.IDFCFO = ORDEM.IDFCFO WHERE IDORDEM = {0}", Cod), "NOME"); txtSobrenome.Text = MetodosSql.GetField(String.Format(@"select * from ORDEM inner join FCFO ON FCFO.IDFCFO = ORDEM.IDFCFO WHERE IDORDEM = {0}", Cod), "NOMEFANTASIA"); txtDataInclusao.Text = MetodosSql.GetField(String.Format(@"select DATAINCLUSAO as 'Nasc' from ORDEM where IDORDEM = {0}", Cod), "Nasc"); AtualizaGrid(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void frmFCFO_Load(object sender, EventArgs e) { txtCodigo.Text = Cod; validaBtn1 = false; validaBtn2 = false; txtTipoPessoa.Select(); try { if (Editar) { string sql = String.Format(@"select * from FCFO where IDFCFO = {0}", Cod); txtNome.Text = MetodosSql.GetField(sql, "NOME"); txtTipoPessoa.Text = MetodosSql.GetField(sql, "TIPOPESSOA"); txtNomeFantasia.Text = MetodosSql.GetField(sql, "NOMEFANTASIA"); txtCpf.Text = MetodosSql.GetField(sql, "CPF"); txtCNPJ.Text = MetodosSql.GetField(sql, "CNPJ"); txtDataNasc.Text = MetodosSql.GetField(sql, "DTANASCIMENTO"); txtSexo.Text = MetodosSql.GetField(sql, "SEXO"); txtTelefone.Text = MetodosSql.GetField(sql, "TELEFONE1"); txtTelefone2.Text = MetodosSql.GetField(sql, "TELEFONE2"); txtCelular.Text = MetodosSql.GetField(sql, "CELULAR"); txtCelular2.Text = MetodosSql.GetField(sql, "CELULAR2"); txtEmail.Text = MetodosSql.GetField(sql, "EMAIL"); txtEmail2.Text = MetodosSql.GetField(sql, "EMAIL2"); txtRua.Text = MetodosSql.GetField(sql, "RUA"); txtLogradouro.Text = MetodosSql.GetField(sql, "LOGRADOURO"); txtNumero.Text = MetodosSql.GetField(sql, "NUMERO"); txtBairro.Text = MetodosSql.GetField(sql, "BAIRRO"); txtCidade.Text = MetodosSql.GetField(sql, "CIDADE"); txtCep.Text = MetodosSql.GetField(sql, "CEP"); txtEstado.Text = MetodosSql.GetField(sql, "ESTADO"); txtComplemento.Text = MetodosSql.GetField(sql, "COMPLEMENTO"); txtObservacao.Text = MetodosSql.GetField(sql, "OBSERVACAO"); txtRg.Text = MetodosSql.GetField(sql, "RG"); txtCnh.Text = MetodosSql.GetField(sql, "CNH"); txtEstadoCivil.Text = MetodosSql.GetField(sql, "ESTADOCIVIL"); txtApolice.Text = MetodosSql.GetField(sql, "APOLICE"); txtTipoResidencia.Text = MetodosSql.GetField(sql, "TIPORESIDENCIA"); txtObservacaoDocumento.Text = MetodosSql.GetField(sql, "OBSDOCUMENTO"); sql = String.Format("SELECT * FROM FCFOIMAGEM WHERE IDFCFO = {0}", Cod); valida = MetodosSql.GetField(sql, "IMAGEM1"); if (valida != "") { pbImagemDoc1.Image = Image.FromStream(MetodosSql.GetImage(sql, "IMAGEM1")); } valida = MetodosSql.GetField(sql, "IMAGEM2"); if (valida != "") { pbDoc2.Image = Image.FromStream(MetodosSql.GetImage(sql, "IMAGEM2")); } txtDataInclusao.Text = MetodosSql.GetField(String.Format(@"select CONVERT(varchar, CONVERT(DATETIME, DATAINCLUSAO, 121), 103) as 'Nasc' from FCFO where IDFCFO = {0}", Cod), "Nasc"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void frmCadastroProdutos_Load(object sender, EventArgs e) { try { if (String.IsNullOrWhiteSpace(txtCodigo.Text)) { if (Editar) { txtCodigo.Text = Cod; string sql = String.Format(@"select * from PRODUTO where IDPRODUTO = {0}", Cod); txtDescricao.Text = MetodosSql.GetField(sql, "DESCRICAO"); //txtPrecoEntrada.Text = MetodosSql.GetField(sql, "PRECOUNENTRADA"); //txtPrecoEntrada.Text = MetodosSql.GetField(String.Format(@"select CAST(PRECOUNENTRADA as numeric(20,2))as 'PE' from PRODUTO where IDPRODUTO = {0}", Cod), "PE"); //txtMargemVenda.Text = MetodosSql.GetField(sql, "MARGEMVENDA"); //txtMargemVenda.Text = MetodosSql.GetField(String.Format(@"select CAST(MARGEMVENDA as numeric(20,2))as 'MA' from PRODUTO where IDPRODUTO = {0}", Cod), "MA"); txtObservacao.Text = MetodosSql.GetField(sql, "OBSERVACAO"); txtDataInclusao.Text = MetodosSql.GetField(String.Format(@"select CONVERT(varchar, CONVERT(DATETIME, DATAINCLUSAO, 121), 103) as 'Nasc' from PRODUTO where IDPRODUTO = {0}", Cod), "Nasc"); //txtPrecoVenda.Text = MetodosSql.GetField(sql, "PRECOUNVENDA"); //txtPrecoVenda.Text = MetodosSql.GetField(String.Format(@"select CAST(PRECOUNVENDA as numeric(20,2))as 'PV' from PRODUTO where IDPRODUTO = {0}", Cod), "PV"); txtTipoSeguro.Text = MetodosSql.GetField(sql, "TIPOSEGURO"); txtCiaSeguradora.Text = MetodosSql.GetField(sql, "CIASEGURADORA"); txtNumeroQuiver.Text = MetodosSql.GetField(sql, "NUMEROQUIVER"); } } else { LimpaCampos(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void InsertParcela() { if (Editar) { string sql = String.Format(@"select PARCELAS from TIPOPAGAMENTO where IDTIPOPAGAMENTO = {0}", txtCodigoPagamento.Text); int NParcelas = int.Parse(MetodosSql.GetField(sql, "PARCELAS")); sql = String.Format(@"select sum(ITEMMOVIMENTO.VALOR * ITEMMOVIMENTO.QUANTIDADE) - VENDA.DESCONTO as 'TOTAL' from ITEMMOVIMENTO INNER JOIN VENDA ON ITEMMOVIMENTO.IDVENDA = VENDA.IDVENDA Where VENDA.IDVENDA = {0} GROUP BY VENDA.DESCONTO", CODVENDA); string totalVenda = MetodosSql.GetField(sql, "TOTAL"); sql = String.Format(@"select IDFCFO from VENDA where IDVENDA = '{0}'", CODVENDA); string idCliente = MetodosSql.GetField(sql, "IDFCFO"); for (int parcela = 1; parcela <= NParcelas; parcela++) { sql = String.Format(@"insert into PARCELA values ({0},{1},{2},{3}/{4},null)", parcela, CODVENDA, idCliente, totalVenda.Replace(".", "").Replace(",", "."), NParcelas); MetodosSql.ExecQuery(sql); } Editar = true; } }
public frmPrincipal(string nome, string usuario) { InitializeComponent(); bsUsuario.Caption = "• " + nome; string sql = String.Format(@"SELECT * FROM PROPRIETARIO"); this.Text = MetodosSql.GetField(sql, "NOMEFANTASIA"); }
private void frmCadastroPorcentagens_Load(object sender, EventArgs e) { string sql = String.Format(@"SELECT * FROM PORCENTAGENS"); txtPorcentagemNota.Text = MetodosSql.GetField(sql, "PERCIMPOSTONOTA"); txtPorcentagemCorretora.Text = MetodosSql.GetField(sql, "PERCSEGURALTA"); txtCod.Text = MetodosSql.GetField(sql, "IDPORCENTAGEM"); }
private void frmIdPagamento_Load(object sender, EventArgs e) { txtValorRestante.Text = RESTANTE; txtCodigoVenda.Text = CODIGOVENDA; txtCodigoParcela.Text = CODIGOPARCELA; sql = String.Format(@"select cast(VALOR as numeric(20,2)) as 'VALOR' from PARCELA where IDPARCELA = '{0}'", CODIGOPARCELA); txtValorParcela.Text = MetodosSql.GetField(sql, "VALOR"); }
private void frmAlteraQuantidade_Load(object sender, EventArgs e) { txtCodigoProduto.Text = Cod; string sql = String.Format(@"select * from ESTOQUE where IDPRODUTO = {0}", Cod); txtQuantidade.Text = MetodosSql.GetField(sql, "QUANTIDADE"); txtObservacao.Text = MetodosSql.GetField(sql, "OBSERVACAO"); }
private void btnExcluir_Click(object sender, EventArgs e) { try { var rowHandle = gridView1.FocusedRowHandle; var obj = gridView1.GetRowCellValue(rowHandle, "IDVENDA"); int LINHA, IDITEM, IDPRODUTO; double QUANTIDADE; if (obj != null) { if (DialogResult.Yes == MessageBox.Show("Deseja mesmo exluir?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { string sql = String.Format(@"select count(IDITEM) as LINHA FROM ITEMMOVIMENTO WHERE IDVENDA = {0}", obj); LINHA = int.Parse(MetodosSql.GetField(sql, "LINHA")); sql = String.Format(@"SELECT MIN(IDITEM) AS MINIDITEM FROM ITEMMOVIMENTO WHERE IDVENDA = {0}", obj); IDITEM = int.Parse(MetodosSql.GetField(sql, "MINIDITEM")); for (int i = 1; i <= LINHA; i++) { sql = String.Format(@"SELECT IDPRODUTO, QUANTIDADE FROM ITEMMOVIMENTO WHERE IDITEM = {0}", IDITEM); IDPRODUTO = int.Parse(MetodosSql.GetField(sql, "IDPRODUTO")); QUANTIDADE = double.Parse(MetodosSql.GetField(sql, "QUANTIDADE")); string estoque = String.Format(@"UPDATE ESTOQUE SET QUANTIDADE = QUANTIDADE + {0} WHERE IDPRODUTO = {1} ", QUANTIDADE, IDPRODUTO); IDITEM++; MetodosSql.ExecQuery(sql); MetodosSql.ExecQuery(estoque); } MetodosSql.ExecQuery(String.Format(@"DELETE FROM PARCELA WHERE IDVENDA = {0}", obj)); MetodosSql.ExecQuery(String.Format(@"delete from VENDA where IDVENDA = {0}", obj.ToString())); AtualizaGrid(); } else { MessageBox.Show("Por favor, selecione um registro", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Por favor, selecione um registro", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message); } gridView1.BestFitColumns(); }
//private void txtPrecoEntrada_Leave(object sender, EventArgs e) //{ // if (String.IsNullOrWhiteSpace(txtPrecoEntrada.Text)) // { // txtPrecoEntrada.Text = "0,00"; // } //} private void simpleButton1_Click(object sender, EventArgs e) { frmVisaoSelecionaCiaSeuradora frm = new frmVisaoSelecionaCiaSeuradora(); frm.ShowDialog(); if (!String.IsNullOrWhiteSpace(frm.Codigo)) { codCliente = frm.Codigo; txtCiaSeguradora.Text = MetodosSql.GetField(String.Format("SELECT NOMEFANTASIA FROM FCFOSEGURADORA WHERE IDSEGURADORA = {0}", codCliente), "NOMEFANTASIA"); } }
private void frmEdiçãoParcela_Load(object sender, EventArgs e) { if (Editar) { string dinheiro, cheque, debito, credito; string sql = String.Format(@"SELECT cast(VALORDINHEIRO as numeric(20,2)) AS VALORDINHEIRO, CAST(VALORCHEQUE AS NUMERIC(20,2)) AS VALORCHEQUE, CAST(VALORCARTAODEBITO AS NUMERIC(20,2)) AS VALORCARTAODEBITO, CAST(VALORCARTAOCREDITO AS NUMERIC(20,2)) AS VALORCARTAOCREDITO FROM RECEBIMENTO WHERE IDPARCELA = '{0}'", CodParcela); dinheiro = MetodosSql.GetField(sql, "VALORDINHEIRO"); cheque = MetodosSql.GetField(sql, "VALORCHEQUE"); debito = MetodosSql.GetField(sql, "VALORCARTAODEBITO"); credito = MetodosSql.GetField(sql, "VALORCARTAOCREDITO"); if (dinheiro != "0,00") { txtValorDinheiro.Text = dinheiro; txtValorCheque.Text = "0,00"; txtValorDebito.Text = "0,00"; txtValorCredito.Text = "0,00"; } else if (cheque != "0,00") { txtValorDinheiro.Text = "0,00"; txtValorCheque.Text = cheque; txtValorDebito.Text = "0,00"; txtValorCredito.Text = "0,00"; } else if (debito != "0,00") { txtValorDinheiro.Text = "0,00"; txtValorCheque.Text = "0,00"; txtValorDebito.Text = debito; txtValorCredito.Text = "0,00"; } else if (credito != "0,00") { txtValorDinheiro.Text = "0,00"; txtValorCheque.Text = "0,00"; txtValorDebito.Text = "0,00"; txtValorCredito.Text = credito; } else { txtValorDinheiro.Text = "0,00"; txtValorCheque.Text = "0,00"; txtValorDebito.Text = "0,00"; txtValorCredito.Text = "0,00"; } txtCodigoVenda.Text = CodVenda; txtCodigoParcela.Text = CodParcela; txtValorParcela.Text = ValorParcela; txtValorRestante.Text = Restante; } }
private void frmCadastroUsuario_Load(object sender, EventArgs e) { if (Editar) { string sql = String.Format(@"SELECT * FROM LOGIN WHERE ID = '{0}'", Cod); txtNome.Text = MetodosSql.GetField(sql, "NOME"); txtUsuario.Text = MetodosSql.GetField(sql, "USUARIO"); txtSenha.Text = MetodosSql.GetField(sql, "SENHA"); txtConfirmarSenha.Text = MetodosSql.GetField(sql, "SENHA"); txtCod.Text = Cod; } }
private void btnExcluir_Click_1(object sender, EventArgs e) { try { if (gridView1.SelectedRowsCount > 0) { var rowHandle = gridView1.FocusedRowHandle; var id = gridView1.GetRowCellValue(rowHandle, "IDCLIENTE"); if (id == null) { MessageBox.Show("Selecione um registro", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { string sql = String.Format(@"select IDFCFO from VENDA WHERE IDFCFO = " + id.ToString()); string teste = MetodosSql.GetField(sql, "IDFCFO"); string SQL = String.Format(@"SELECT IDFCFO FROM ORDEM where IDFCFO = " + id.ToString()); string IdFcfo = MetodosSql.GetField(SQL, "IDFCFO"); if (id.ToString() == teste.ToString()) { MessageBox.Show("Há uma Venda no Nome Deste Cliente", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { if (id.ToString() == IdFcfo.ToString()) { MessageBox.Show("Há uma Ordem de Serviço no Nome Deste Cliente", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { if (DialogResult.Yes == MessageBox.Show("Deseja Excluir Este Cliente?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { sql = String.Format(@"DELETE from FCFO WHERE IDFCFO = " + id.ToString()); MetodosSql.ExecQuery(sql); AtualizaGrid(); } } } } } else { MessageBox.Show("Selecione um registro", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void frmCadastroVenda_Load(object sender, EventArgs e) { try { double valorLiquido, iof, valorTotal, comissaoVenda; if (Editar) { txtCodigo.Text = Cod; btnSalvar.Enabled = false; sql = String.Format(@"select * from VENDA where IDVENDA = {0}", Cod); idVendedor = MetodosSql.GetField(sql, "IDVENDEDOR"); txtIdCliente.Text = MetodosSql.GetField(sql, "IDFCFO"); txtIdOrdem.Text = MetodosSql.GetField(sql, "IDORDEM"); txtTipoPagamento.Text = MetodosSql.GetField(sql, "TIPOPAGAMENTO"); txtObservacao.Text = MetodosSql.GetField(sql, "OBSERVACAO"); txtStatus.Text = status; txtDataInclusao.Text = MetodosSql.GetField(String.Format(@"select CONVERT(varchar, CONVERT(varchar, DATAINCLUSAO, 103)) as 'Nasc' from VENDA where IDVENDA = {0}", Cod), "Nasc"); txtNome.Text = MetodosSql.GetField(String.Format(@"select NOME from FCFO where IDFCFO = '{0}'", txtIdCliente.Text), "NOME"); txtSobrenome.Text = MetodosSql.GetField(String.Format(@"select NOMEFANTASIA FROM FCFO WHERE IDFCFO = {0}", txtIdCliente.Text), "NOMEFANTASIA"); sql = String.Format(@"select NOME, SOBRENOME FROM VENDEDORES WHERE IDVENDEDOR = '{0}'", idVendedor.ToString()); txtNomeVendedor.Text = MetodosSql.GetField(sql, "NOME"); txtSobrenomeVendedor.Text = MetodosSql.GetField(sql, "SOBRENOME"); txtIdVendedor.Text = idVendedor.ToString(); sql = String.Format(@"select DESCRICAO from TIPOPAGAMENTO WHERE IDTIPOPAGAMENTO = {0}", txtTipoPagamento.Text); txtDescricaoTipoPagamento.Text = MetodosSql.GetField(sql, "DESCRICAO"); txtDataVencimento.Text = MetodosSql.GetField(String.Format(@"select CONVERT(varchar, CONVERT(varchar, DATAVENCIMENTO, 103)) as 'Vencimento' from VENDA where IDVENDA = {0}", Cod), "Vencimento"); sql = String.Format(@"SELECT * FROM VENDACOMISSAO WHERE IDVENDA = '{0}'", Cod); valorLiquido = double.Parse(MetodosSql.GetField(sql, "VALORLIQUIDO")); txtValorLiquido.Text = valorLiquido.ToString("F2"); iof = double.Parse(MetodosSql.GetField(sql, "IOF")); txtIof.Text = iof.ToString("F2"); comissaoVenda = double.Parse(MetodosSql.GetField(sql, "COMISSAO")); txtComissao.Text = comissaoVenda.ToString("F2"); valorTotal = double.Parse(MetodosSql.GetField(sql, "TOTALVENDA")); txtTotalVenda.Text = valorTotal.ToString("F2"); txtValorTotal.Text = txtTotalVenda.Text; comissaoVenda = double.Parse(MetodosSql.GetField(sql, "COMISSAOVENDA")); txtComissaoVenda.Text = comissaoVenda.ToString("F2"); string desconto = String.Format(@"select * from VENDA where IDVENDA = {0}", Cod); double Desconto = double.Parse(MetodosSql.GetField(desconto, "DESCONTO")); txtDesconto.Text = Desconto.ToString("F2"); if (MetodosSql.GetField(sql, "COCORRETAGEM") == "S") { cbCoCorretagem.Checked = true; } } AtualizaGrid(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Validar() { try { if (String.IsNullOrWhiteSpace(txtValorDinheiro.Text)) { txtValorDinheiro.Text = "0"; } if (String.IsNullOrWhiteSpace(txtValorCheque.Text)) { txtValorCheque.Text = "0"; } if (String.IsNullOrWhiteSpace(txtValorDebito.Text)) { txtValorDebito.Text = "0"; } if (String.IsNullOrWhiteSpace(txtValorCredito.Text)) { txtValorCredito.Text = "0"; } string sql = String.Format(@"select cast(isnull(P.TOTAL,0) - isnull(R.PAGO,0)as numeric (20,2)) as 'DEVENDO' from (select IDPARCELA, cast(sum(isnull(VALOR,0))as numeric(20,2) ) as 'TOTAL' from PARCELA group by IDPARCELA) P left join (select IDPARCELA, cast(sum(isnull(VALORDINHEIRO,0) + isnull(VALORCHEQUE,0) + isnull(VALORCARTAODEBITO,0) + isnull(VALORCARTAOCREDITO,0))as numeric (20,2)) as 'PAGO' from RECEBIMENTO WHERE EXTORNO != 1 group by IDPARCELA) R on R.IDPARCELA = P.IDPARCELA where P.IDPARCELA = '{0}' ", txtCodigoParcela.Text); double Restante = Convert.ToDouble(MetodosSql.GetField(sql, "DEVENDO")); double Resultado = Convert.ToDouble(txtValorCheque.Text.Replace(".", ",")) + Convert.ToDouble(txtValorCredito.Text.Replace(".", ",")) + Convert.ToDouble(txtValorDebito.Text.Replace(".", ",")) + Convert.ToDouble(txtValorDinheiro.Text.Replace(".", ",")); double ValorRestante = Convert.ToDouble(Restante) - Convert.ToDouble(Resultado); if (ValorRestante == 0) { this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void frmPrincipal_Load(object sender, EventArgs e) { try { string sql = String.Format(@"SELECT * FROM PROPRIETARIO"); this.Text = MetodosSql.GetField(sql, "NOMEFANTASIA"); defaultLookAndFeel1.LookAndFeel.SkinName = Properties.Settings.Default.Skin; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnSelecionaVendedor_Click(object sender, EventArgs e) { frmVisaoVendedoresVenda frm = new frmVisaoVendedoresVenda(); frm.ShowDialog(); if (!String.IsNullOrWhiteSpace(frm.CodVendedor)) { idVendedor = frm.CodVendedor.ToString(); string sql = String.Format(@"SELECT NOME, SOBRENOME FROM VENDEDORES WHERE IDVENDEDOR = '{0}'", idVendedor); txtIdVendedor.Text = idVendedor.ToString(); txtNomeVendedor.Text = MetodosSql.GetField(sql, "NOME"); txtSobrenomeVendedor.Text = MetodosSql.GetField(sql, "SOBRENOME"); } }
private void btnSelecionaProduto_Click(object sender, EventArgs e) { frmVisaoSelecionaProduto frm = new frmVisaoSelecionaProduto(); frm.ShowDialog(); txtCodigoProduto.Text = frm.CODIGO; txtDescricaoProduto.Text = frm.DESCRICAO; sql = String.Format(@"select * from PRODUTO where IDPRODUTO = '{0}'", frm.CODIGO); txtValorUnitario.Text = MetodosSql.GetField(sql, "PRECOUNVENDA"); CalculaTotal(); }
private void frmEntradaProduto_Load(object sender, EventArgs e) { try { if (Editar) { txtCodigo.Text = Cod; string sql = String.Format(@"select EP.*, CAST((EP.VALORUNENTRADA*EP.QUANTIDADEENTRADA) as numeric(20,2)) as 'VALORTOTAL', P.DESCRICAO, C.NOME, C.NOMEFANTASIA from ENTRADAPRODUTO EP inner join PRODUTO P on P.IDPRODUTO = EP.IDPRODUTO inner join FCFO C on C.IDFCFO = EP.IDFCFO and C.TIPO = 'F' where IDENTRADA = {0}", Cod); txtCodigoProduto.Text = MetodosSql.GetField(sql, "IDPRODUTO"); txtCodigoFornecedor.Text = MetodosSql.GetField(sql, "IDFCFO"); //txtValorEntrada.Text = MetodosSql.GetField(sql, "VALORUNENTRADA"); txtValorEntrada.Text = MetodosSql.GetField(String.Format(@"select CAST(VALORUNENTRADA as numeric(20,2))as 'VE' from ENTRADAPRODUTO where IDENTRADA = {0}", Cod), "VE"); //txtQuantidadeEntrada.Text = MetodosSql.GetField(sql, "QUANTIDADEENTRADA"); txtQuantidadeEntrada.Text = MetodosSql.GetField(String.Format(@"select CAST(QUANTIDADEENTRADA as numeric(20,2))as 'QE' from ENTRADAPRODUTO where IDENTRADA = {0}", Cod), "QE"); txtChaveNfe.Text = MetodosSql.GetField(sql, "CHAVENFE"); txtDocumento.Text = MetodosSql.GetField(sql, "DOCUMENTO"); txtObservacao.Text = MetodosSql.GetField(sql, "OBSERVACAO"); txtDescricaoProduto.Text = MetodosSql.GetField(sql, "DESCRICAO"); txtNomeFornecedor.Text = MetodosSql.GetField(sql, "NOME"); txtNomeFantasia.Text = MetodosSql.GetField(sql, "NOMEFANTASIA"); txtPrecoVenda.Text = MetodosSql.GetField(String.Format("select PRECOUNVENDA FROM PRODUTO where IDPRODUTO = {0}", txtCodigoProduto.Text), "PRECOUNVENDA"); txtPrecoEntrada.Text = MetodosSql.GetField(String.Format("select PRECOUNENTRADA FROM PRODUTO WHERE IDPRODUTO = {0}", txtCodigoProduto.Text), "PRECOUNENTRADA"); txtDataInclusao.Text = MetodosSql.GetField(String.Format(@"select CONVERT(varchar, CONVERT(DATETIME, DATAINCLUSAO, 121), 103) as 'Nasc' from ENTRADAPRODUTO where IDENTRADA = {0}", Cod), "Nasc"); txtValorTotal.Text = MetodosSql.GetField(sql, "VALORTOTAL"); double precovenda = Convert.ToDouble(txtPrecoVenda.Text); double valorUnitario = Convert.ToDouble(txtValorEntrada.Text); double porcentagem = ((precovenda * 100) / valorUnitario) - 100; txtMargemVenda.Text = porcentagem.ToString(); txtMargemVenda.Text = String.Format("{0:N}", porcentagem); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AtualizaGrid() { try { if (Editar) { gridView1.Columns.Clear(); gridControl1.DataSource = MetodosSql.GetDT(String.Format(@"select IM.IDITEM, IM.IDPRODUTO, cast(IM.QUANTIDADE as numeric(20,2)) as 'QUANTIDADE', P.DESCRICAO, cast(IM.VALOR as numeric(20,2)) as 'VALOR UNITARIO', cast((IM.QUANTIDADE*IM.VALOR) as numeric(20,2)) as 'TOTAL' from ITEMMOVIMENTO IM inner join PRODUTO P on P.IDPRODUTO = IM.IDPRODUTO where IDVENDA = '{0}' ORDER BY IDITEM DESC", txtCodigo.Text)); gridView1.BestFitColumns(); txtTotalVenda.Text = MetodosSql.GetField(String.Format(@"select cast(sum(QUANTIDADE* VALOR) as numeric(20, 2)) as 'TOTAL' from ITEMMOVIMENTO where IDVENDA = '{0}'", txtCodigo.Text), "TOTAL"); txtTotalDesconto.Text = MetodosSql.GetField(String.Format(@"SELECT VD.IDVENDA, VD.IDFCFO, cast(SUM(IT.VALOR * IT.QUANTIDADE) - VD.DESCONTO as numeric(20,2)) AS TOTAL_VENDA FROM VENDA VD INNER JOIN ITEMMOVIMENTO IT ON IT.IDVENDA = VD.IDVENDA WHERE VD.IDVENDA IS NOT NULL AND VD.IDVENDA = {0} GROUP BY VD.DESCONTO, VD.IDVENDA, VD.IDFCFO", txtCodigo.Text), "TOTAL_VENDA"); } else { gridView1.ClearDocument(); gridControl1.DataSource = produtos; gridControl1.RefreshDataSource(); double Total = 0; foreach (Produto P in produtos) { Total += Convert.ToDouble(P.VALORTOTAL); } txtTotalVenda.Text = String.Format("{0:N}", Total); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }