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);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                if (Editar)
                {
                    sql = String.Format(@"delete from ITEMMOVIMENTO where IDITEM = '{0}'", IDITEM);

                    MetodosSql.ExecQuery(sql);
                }
                else
                {
                    produtos.RemoveAt(int.Parse(IDITEM));
                }

                btnExcluir.Visible          = false;
                btnSelecionaProduto.Enabled = true;

                IDITEM = null;

                AtualizaGrid();
                LimpaCampos();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#4
0
        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;
            }
        }
示例#5
0
 private void Update()
 {
     try
     {
         string sql = String.Format(@"UPDATE VENDEDORES SET NOME = '{0}', SOBRENOME = '{1}', CPF = '{2}', DTANASCIMENTO = '{3}', SEXO = '{4}', TELEFONE1 = '{5}',
                                      TELEFONE2 = '{6}', CELULAR = '{7}', CELULAR2 = '{8}', EMAIL = '{9}', EMAIL2 = '{10}', RUA = '{11}', LOGRADOURO = '{12}',
                                      NUMERO = '{13}', BAIRRO = '{14}', CIDADE = '{15}', CEP = '{16}', ESTADO = '{17}', COMPLEMENTO = '{18}', OBSERVACAO = '{19}' WHERE IDVENDEDOR = '{20}'",
                                    /*{0}*/ txtNome.Text,
                                    /*{1}*/ txtSobrenome.Text,
                                    /*{2}*/ txtCpf.Text,
                                    /*{3}*/ txtDataNasc.Text,
                                    /*{4}*/ txtSexo.Text,
                                    /*{5}*/ txtTelefone.Text,
                                    /*{6}*/ txtTelefone2.Text,
                                    /*{7}*/ txtCelular.Text,
                                    /*{8}*/ txtCelular2.Text,
                                    /*{9}*/ txtEmail.Text,
                                    /*{10}*/ txtEmail2.Text,
                                    /*{11}*/ txtRua.Text,
                                    /*{12}*/ txtLogradouro.Text,
                                    /*{13}*/ txtNumero.Text,
                                    /*{14}*/ txtBairro.Text,
                                    /*{15}*/ txtCidade.Text,
                                    /*{16}*/ txtCep.Text,
                                    /*{17}*/ txtEstado.Text,
                                    /*{18}*/ txtComplemento.Text,
                                    /*{19}*/ txtObservacao.Text,
                                    /*{20}*/ Cod);
         MetodosSql.ExecQuery(sql);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#6
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                var rowHandle = gridView1.FocusedRowHandle;

                var obj    = gridView1.GetRowCellValue(rowHandle, "IDORDEM");
                var status = gridView1.GetRowCellValue(rowHandle, "STATUS");



                if (status.ToString() == "F")
                {
                    MessageBox.Show("Você Não Pode Excluir um Orçamento Faturado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    if (DialogResult.Yes == MessageBox.Show("Deseja mesmo exluir?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        MetodosSql.ExecQuery(String.Format(@"delete from ORDEM where IDORDEM = {0}", obj.ToString()));
                        AtualizaGrid();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            gridView1.BestFitColumns();
        }
示例#7
0
        private void Cadastro()
        {
            try
            {
                Validar();
                string SQL = String.Format(@"insert into ENTRADAPRODUTO (IDPRODUTO , IDFCFO , VALORUNENTRADA , QUANTIDADEENTRADA , CHAVENFE , DOCUMENTO , OBSERVACAO , DATAINCLUSAO) values ('{0}' , '{1}' , REPLACE('{2}',',','.'), REPLACE('{3}',',','.'), '{4}' , '{5}' , '{6}' , CONVERT(varchar,CONVERT(DATETIME, '{7}', 103), 121) ) select SCOPE_IDENTITY()"
                                           , txtCodigoProduto.Text, txtCodigoFornecedor.Text, txtValorEntrada.Text.Replace(".", "").Replace(",", "."), txtQuantidadeEntrada.Text, txtChaveNfe.Text, txtDocumento.Text, txtObservacao.Text, txtDataInclusao.Text);

                string sql = String.Format(@"update produto set PRECOUNENTRADA = {0} WHERE IDPRODUTO = {1}", txtValorEntrada.Text.Replace(".", "").Replace(",", "."), txtCodigoProduto.Text);
                MetodosSql.ExecQuery(sql);
                InsereEstoque();



                object Ncad = MetodosSql.ExecScalar(SQL);
                txtCodigo.Text = Ncad.ToString();


                Editar = true;
            }
            catch (Exception)
            {
                MessageBox.Show("A(s) Coluna(s) de Texto Não Foram Preenchida(s) Corretamente ");
            }
        }
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                var rowHandle = gridView1.FocusedRowHandle;

                var obj = gridView1.GetRowCellValue(rowHandle, "IDENTRADA");

                if (obj != null)
                {
                    if (DialogResult.Yes == MessageBox.Show("Deseja mesmo exluir?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        MetodosSql.ExecQuery(String.Format(@"delete from ENTRADAPRODUTO where IDENTRADA = {0}", obj.ToString()));
                        AtualizaGrid();
                    }
                }
                else
                {
                    MessageBox.Show(@"Por favor, selecione um registro para ser excluido", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#9
0
        private void Salvar()
        {
            try
            {
                if (Editar)
                {
                    AlteraEstoque();
                    Validar();
                    string SQL = String.Format(@"update ENTRADAPRODUTO
	                                             set IDPRODUTO = ('{0}'),
			                                         IDFCFO = ('{1}'),
                                                     VALORUNENTRADA = REPLACE('{2}',',','.'),  
                                                     QUANTIDADEENTRADA = REPLACE('{3}',',','.'),
                                                     CHAVENFE = ('{4}'),
                                                     DOCUMENTO = ('{5}'),
                                                     OBSERVACAO = ('{6}'),
                                                     DATAINCLUSAO = CONVERT(DATETIME, '{7}', 103)
                                                     where IDENTRADA = '{8}'

                                                     
		                                             
                                                   ", txtCodigoProduto.Text, txtCodigoFornecedor.Text,
                                               txtValorEntrada.Text.Replace(".", "").Replace(",", "."), txtQuantidadeEntrada.Text, txtChaveNfe.Text, txtDocumento.Text, txtObservacao.Text, txtDataInclusao.Text, txtCodigo.Text);

                    string sql = String.Format(@"update produto set PRECOUNENTRADA = {0} , MARGEMVENDA = {2} WHERE IDPRODUTO = {1}", txtValorEntrada.Text.Replace(".", "").Replace(",", "."), txtCodigoProduto.Text, txtMargemVenda.Text.Replace(".", "").Replace(",", "."));
                    MetodosSql.ExecQuery(sql);


                    Clipboard.SetText(SQL);


                    MetodosSql.ExecQuery(SQL);
                }
                else
                {
                    Validar();
                    string SQL = String.Format(@"insert into ENTRADAPRODUTO (IDPRODUTO , IDFCFO , VALORUNENTRADA , QUANTIDADEENTRADA , CHAVENFE , DOCUMENTO , OBSERVACAO , DATAINCLUSAO) values ('{0}' , '{1}' , REPLACE('{2}',',','.'), REPLACE('{3}',',','.'), '{4}' , '{5}' , '{6}' , CONVERT(varchar,CONVERT(DATETIME, '{7}', 103), 121) ) select SCOPE_IDENTITY()"
                                               , txtCodigoProduto.Text, txtCodigoFornecedor.Text, txtValorEntrada.Text.Replace(".", "").Replace(",", "."), txtQuantidadeEntrada.Text, txtChaveNfe.Text, txtDocumento.Text, txtObservacao.Text, txtDataInclusao.Text);

                    string sql = String.Format(@"update produto set PRECOUNENTRADA = {0} WHERE IDPRODUTO = {1}", txtValorEntrada.Text.Replace(".", "").Replace(",", "."), txtCodigoProduto.Text);
                    InsereEstoque();
                    MetodosSql.ExecQuery(sql);



                    object Ncad = MetodosSql.ExecScalar(SQL);
                    txtCodigo.Text = Ncad.ToString();


                    Editar = true;
                }

                InsereEstoque();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Cadastro()
        {
            try
            {
                if (Editar)
                {
                    string sql = String.Format(@"UPDATE FCFOSEGURADORA SET NOME = '{0}', NOMEFANTASIA = '{1}', CPF = '{2}', CNPJ = '{3}', RG = '{4}', OBSDOCUMENTO = '{5}',
                                                 TELEFONE1 = '{6}', TELEFONE2 = '{7}', CELULAR = '{8}', CELULAR2 = '{9}', EMAIL = '{10}', EMAIL2 = '{11}',
                                                 OBSERVACAO = '{12}' WHERE IDSEGURADORA = '{13}'",
                                               /*{0}*/ txtNome.Text,
                                               /*{1}*/ txtNomeFantasia.Text,
                                               /*{2}*/ txtCpf.Text,
                                               /*{3}*/ txtCNPJ.Text,
                                               /*{4}*/ txtRg.Text,
                                               /*{5}*/ txtObservacaoDocumento.Text,
                                               /*{6}*/ txtTelefone.Text,
                                               /*{7}*/ txtTelefone2.Text,
                                               /*{8}*/ txtCelular.Text,
                                               /*{9}*/ txtCelular2.Text,
                                               /*{10}*/ txtEmail.Text,
                                               /*{11}*/ txtEmail2.Text,
                                               /*{12}*/ txtObservacao.Text,
                                               /*{13}*/ Cod);



                    MetodosSql.ExecQuery(sql);
                }
                else
                {
                    string sql = String.Format(@"INSERT INTO FCFOSEGURADORA VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}',
                                                '{10}', '{11}', '{12}', getdate())",
                                               /*{0}*/ txtNome.Text,
                                               /*{1}*/ txtNomeFantasia.Text,
                                               /*{2}*/ txtCpf.Text,
                                               /*{3}*/ txtCNPJ.Text,
                                               /*{4}*/ txtRg.Text,
                                               /*{5}*/ txtObservacaoDocumento.Text,
                                               /*{6}*/ txtTelefone.Text,
                                               /*{7}*/ txtTelefone2.Text,
                                               /*{8}*/ txtCelular.Text,
                                               /*{9}*/ txtCelular2.Text,
                                               /*{10}*/ txtEmail.Text,
                                               /*{11}*/ txtEmail2.Text,
                                               /*{12}*/ txtObservacao.Text);



                    MetodosSql.ExecQuery(sql);
                    Editar = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        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();
        }
示例#12
0
        public void AtualizaGrid()
        {
            string sql = String.Format(@"select IDPRODUTO, DESCRICAO, TIPOSEGURO, CIASEGURADORA, NUMEROQUIVER,  
                                        OBSERVACAO, DATAINCLUSAO
                                        from PRODUTO 
						                ORDER BY PRODUTO.IDPRODUTO"                        );

            gridControl1.DataSource = MetodosSql.GetDT(sql);
            MetodosSql.ExecQuery(sql);
        }
示例#13
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            var rowHandle = gridView1.FocusedRowHandle;
            var obj       = gridView1.GetRowCellValue(rowHandle, "IDVENDEDOR");

            if (DialogResult.Yes == MessageBox.Show("Tem certeza que deseja excluir este vendedor?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                string sql = String.Format(@"DELETE FROM VENDEDORES WHERE IDVENDEDOR = '{0}'", obj.ToString());
                MetodosSql.ExecQuery(sql);
                AtualizaGrid();
            }
        }
示例#14
0
        private void grdVisaoUsuario_DoubleClick(object sender, EventArgs e)
        {
            var rowHandle = gridView1.FocusedRowHandle;
            var cod       = gridView1.GetRowCellValue(rowHandle, "ID");

            if (DialogResult.Yes == MessageBox.Show("Tem certeza que deseja excluir este usuário?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                string sql = String.Format(@"DELETE FROM LOGIN WHERE ID = '{0}'", cod);
                MetodosSql.ExecQuery(sql);
            }
            AtualizaGrid();
        }
示例#15
0
        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);
            }
        }
示例#16
0
        private void InsereEstoque()
        {
            string sql = String.Empty;

            if (String.IsNullOrWhiteSpace(txtCodigo.Text))
            {
                sql = String.Format(@"update ESTOQUE
                                             set QUANTIDADE = QUANTIDADE + {0}
                                             where IDPRODUTO = '{1}'", txtQuantidadeEntrada.Text, txtCodigoProduto.Text);
                MetodosSql.ExecQuery(sql);
            }
        }
示例#17
0
        private void AlteraEstoque()
        {
            string sql = String.Empty;

            if (Editar)
            {
                sql = String.Format(@"update ESTOQUE
                                             set QUANTIDADE = QUANTIDADE - (select QUANTIDADEENTRADA from ENTRADAPRODUTO where IDENTRADA = '{0}')
                                             where IDPRODUTO = '{1}'", txtCodigo.Text, txtCodigoProduto.Text);
                MetodosSql.ExecQuery(sql);
            }
        }
示例#18
0
        public void AtualizaGrid()
        {
            string sql = String.Format(@"select IDPRODUTO, DESCRICAO, TIPOSEGURO, CIASEGURADORA, NUMEROQUIVER,  
                        CAST(PRECOUNENTRADA as DECIMAL(10, 2)) AS PRECOUNENTRADA,
                        CAST(MARGEMVENDA as DECIMAL(10, 2)) AS MARGEMVENDA,
                        CAST(PRECOUNVENDA as DECIMAL(10, 2)) AS PRECOUNVENDA,
                        OBSERVACAO, DATAINCLUSAO
                        from PRODUTO 
						ORDER BY PRODUTO.IDPRODUTO"                        );

            gridControl1.DataSource = MetodosSql.GetDT(sql);
            MetodosSql.ExecQuery(sql);
        }
 private void btnSalvar_Click(object sender, EventArgs e)
 {
     try
     {
         string sql = String.Format(@"UPDATE PARCELA SET DATAPAGAMENTO = CONVERT(DATETIME, CONVERT(VARCHAR, '{0}', 121), 103) WHERE IDPARCELA = '{1}'", txtDataVencimentoParcela.Text, Cod);
         MetodosSql.ExecQuery(sql);
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#20
0
        private void InsereEstoque(String IDVENDA)
        {
            String sql = String.Format(@"select IDPRODUTO, QUANTIDADE from ITEMMOVIMENTO where IDVENDA = '{0}'", IDVENDA);

            DataTable Produtos = MetodosSql.GetDT(sql);

            foreach (DataRow Produto in Produtos.Rows)
            {
                sql = String.Format(@"update ESTOQUE
                                             set QUANTIDADE = QUANTIDADE - {0}
                                             where IDPRODUTO = '{1}'", Produto["QUANTIDADE"].ToString().Replace(",", "."), Produto["IDPRODUTO"].ToString());
                MetodosSql.ExecQuery(sql);
            }
        }
示例#21
0
        private void Cadastro()
        {
            try
            {
                if (Editar)
                {
                    string SQL = String.Format(@"update ORDEM
                                                      set IDFCFO = '{0}' ,
                                                      DESCRICAO = '{1}' ,                  
                                                      CONCLUSAO = '{2}'  ,  
                                                      OBSERVACAO = '{3}'  ,
                                                      STATUS = '{4}' , 
                                                      DATAINCLUSAO = getdate()
                                                      where IDORDEM = '{5}' ", txtCodigoFcfo.Text, txtDescricao.Text, txtConclusao.Text, txtObservacao.Text,
                                               txtStatus.Text, Cod);
                    Clipboard.SetText(SQL);
                    MetodosSql.ExecQuery(SQL);
                }
                else
                {
                    sql = String.Format(@"insert into ORDEM (IDFCFO , DESCRICAO , CONCLUSAO , OBSERVACAO , STATUS , DATAINCLUSAO ) values
                  ('{0}' , '{1}' , '{2}' , '{3}' , 'A' , getdate()) select SCOPE_IDENTITY() ", txtCodigoFcfo.Text, txtDescricao.Text, txtConclusao.Text, txtObservacao.Text, txtStatus.Text, txtDataInclusao.Text);


                    object IDORDEM = MetodosSql.ExecScalar(sql);
                    txtCodigo.Text = IDORDEM.ToString();



                    foreach (Produto p in produtos)
                    {
                        sql = String.Format("insert into ITEMMOVIMENTO (IDORDEM, IDPRODUTO, VALOR, QUANTIDADE, DATAINCLUSAO) values ('{0}','{1}','{2}','{3}', GETDATE())",
                                            /*{0}*/ IDORDEM.ToString(),
                                            /*{1}*/ p.IDPRODUTO,
                                            /*{2}*/ p.PRECOUNITARIO.Replace(".", "").Replace(",", "."),
                                            /*{3}*/ p.QUANTIDADE.Replace(",", "."));

                        MetodosSql.ExecQuery(sql);
                    }


                    Editar = true;
                    AtualizaGrid();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#22
0
        private void AlteraEstoque()
        {
            string SQL = String.Format(@"select IDPRODUTO, QUANTIDADE from ITEMMOVIMENTO where IDVENDA = '{0}'", txtCodigo.Text);

            DataTable Produtos = MetodosSql.GetDT(sql);

            foreach (DataRow Produto in Produtos.Rows)
            {
                SQL = String.Format(@"update ESTOQUE
                                             set QUANTIDADE = QUANTIDADE + {0}
                                             where IDPRODUTO = '{1}'", Produto["QUANTIDADE"].ToString().Replace(",", "."), Produto["IDPRODUTO"].ToString());
                MetodosSql.ExecQuery(sql);
            }
        }
 private void Cadastro()
 {
     if (Editar)
     {
         string sql = String.Format(@"UPDATE LOGIN SET NOME = '{0}', USUARIO = '{1}', SENHA = '{2}' WHERE ID = '{3}'", txtNome.Text, txtUsuario.Text, txtSenha.Text, Cod);
         MetodosSql.ExecQuery(sql);
     }
     else
     {
         string sql = String.Format(@"INSERT INTO LOGIN VALUES('{0}', '{1}', '{2}', getdate())", txtNome.Text, txtUsuario.Text, txtSenha.Text);
         MetodosSql.ExecQuery(sql);
         Editar = true;
     }
 }
示例#24
0
        private void btnReceber_Click(object sender, EventArgs e)
        {
            if (Editar)
            {
                string sql = String.Format(@"UPDATE RECEBIMENTO SET VALORDINHEIRO = '{0}', VALORCHEQUE = '{1}', VALORCARTAODEBITO = '{2}', VALORCARTAOCREDITO = '{3}' WHERE IDPARCELA = '{4}'",
                                           /*{0}*/ txtValorDinheiro.Text.Replace(".", "").Replace(",", "."),
                                           /*{1}*/ txtValorCheque.Text.Replace(".", "").Replace(",", "."),
                                           /*{2}*/ txtValorDebito.Text.Replace(".", "").Replace(",", "."),
                                           /*{3}*/ txtValorCredito.Text.Replace(".", "").Replace(",", "."),
                                           /*{4}*/ CodParcela);

                MetodosSql.ExecQuery(sql);
                this.Close();
            }
        }
        private void btnEditarPagamento_Click(object sender, EventArgs e)
        {
            var rowHandle  = gridView1.FocusedRowHandle;
            var codParcela = gridView1.GetRowCellValue(rowHandle, "IDPARCELA");


            if (DialogResult.Yes == MessageBox.Show("Deseja estornar este pagamento?", "Pergunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                string sql = String.Format(@"UPDATE RECEBIMENTO SET EXTORNO = 1 WHERE IDPARCELA = '{0}'", codParcela);
                MetodosSql.ExecQuery(sql);
                sql = String.Format(@"UPDATE PARCELA SET STATUS  = 'A', DATAPAGAMENTO = NULL WHERE IDPARCELA = '{0}'", codParcela);
                MetodosSql.ExecQuery(sql);
                MessageBox.Show("Êxito ao estornar o pagamento!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                AtualizaGrid();
            }
        }
示例#26
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                string sql = String.Format(@"UPDATE PORCENTAGENS SET PERCIMPOSTONOTA = '{0}', PERCSEGURALTA = '{1}' WHERE IDPORCENTAGEM = '{2}'",
                                           /*{0}*/ txtPorcentagemNota.Text.Replace(".", "").Replace(",", "."),
                                           /*{1}*/ txtPorcentagemCorretora.Text.Replace(".", "").Replace(",", "."),
                                           /*{2}*/ txtCod.Text);

                MetodosSql.ExecQuery(sql);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#27
0
        private void Cadastro()
        {
            try
            {
                if (String.IsNullOrWhiteSpace(txtDesconto.Text))
                {
                    txtDesconto.Text = "0";
                }
                string SQL = String.Format(@"UPDATE VENDA SET DESCONTO = {2} , TIPOPAGAMENTO = {0} , STATUS = 'A' , DATAINCLUSAO = GETDATE() WHERE IDVENDA = {1}", txtCodigoPagamento.Text, CODVENDA, txtDesconto.Text.Replace(",", "."));
                MetodosSql.ExecQuery(SQL);

                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) Select SCOPE_IDENTITY()", parcela, CODVENDA, idCliente, totalVenda.Replace(".", "").Replace(",", "."), NParcelas);
                    object CodParcela = MetodosSql.ExecScalar(sql);
                    Cod = CodParcela.ToString();
                }

                frmIdPagamento frm = new frmIdPagamento(false, null);
                frm.CODIGOCLIENTE = idCliente.ToString();
                frm.CODIGOPARCELA = Cod.ToString();
                frm.CODIGOVENDA   = CODVENDA.ToString();
                frm.ShowDialog();

                Editar = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#28
0
        private void Alterar()
        {
            try
            {
                string SQL = String.Format(@"UPDATE ESTOQUE SET QUANTIDADE = '{0}' , OBSERVACAO = '{2}' where IDPRODUTO = '{1}'", txtQuantidade.Text, txtCodigoProduto.Text, txtObservacao.Text);



                Clipboard.SetText(SQL);
                Editar = true;

                MetodosSql.ExecQuery(SQL);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#29
0
        private void CadastroRecebimento()
        {
            try
            {
                string SQL = String.Format(@"update PARCELA set STATUS = '{0}' where IDPARCELA = {1} ", STATUS, txtCodigoParcela.Text);
                MetodosSql.ExecQuery(SQL);

                if (Editar)
                {
                    SQL = String.Format(@"update RECEBIMENTO Set VALORDINHEIRO = '{0}' , 
                                                                        VALORCHEQUE = '{1}' , 
                                                                        VALORCARTAOCREDITO = '{2}' , 
                                                                        VALORCARTAODEBITO = '{3}'
                                                                         where IDRECEBIMENTO = '{4}' ", txtValorDinheiro.Text, txtValorCheque.Text, txtValorCredito.Text, txtValorDebito.Text, Cod);
                    MetodosSql.ExecQuery(SQL);
                }
                else
                {
                    txtCodigo.Text = Cod;

                    SQL = String.Format(@"insert into RECEBIMENTO(IDVENDA , IDFCFO , IDPARCELA , VALORDINHEIRO , VALORCHEQUE, VALORCARTAOCREDITO , VALORCARTAODEBITO , OBSERVACAO )
                                                                       values ('{0}' , '{6}' , '{1}' , '{2}' , '{3}' , '{4}' , '{5}', NULL )select SCOPE_IDENTITY()", txtCodigoVenda.Text, txtCodigoParcela.Text, txtValorDinheiro.Text, txtValorCheque.Text,
                                        txtValorCredito.Text, txtValorDebito.Text, CODIGOCLIENTE);


                    object IDRECEBIMENTO = MetodosSql.ExecScalar(SQL);

                    double ValorPagamento = Convert.ToDouble(txtValorCheque.Text.Replace(".", ",")) + Convert.ToDouble(txtValorCredito.Text.Replace(".", ",")) + Convert.ToDouble(txtValorDebito.Text.Replace(".", ",")) + Convert.ToDouble(txtValorDinheiro.Text.Replace(".", ","));

                    if (ValorPagamento.ToString() != "0")
                    {
                        string sql = String.Format(@"UPDATE VENDA set DATAPAGAMENTO = getdate() where IDVENDA = {0}", txtCodigoVenda.Text);
                        Clipboard.SetText(sql);
                        MetodosSql.ExecQuery(sql);
                    }
                }

                Editar = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#30
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            var rowHandle = gridView1.FocusedRowHandle;
            var cod       = gridView1.GetRowCellValue(rowHandle, "ID");

            if (cod == null)
            {
                MessageBox.Show("Por favor, selecione um registro", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (DialogResult.Yes == MessageBox.Show("Tem certeza que deseja excluir este usuário?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    string sql = String.Format(@"DELETE FROM LOGIN WHERE ID = '{0}'", cod);
                    MetodosSql.ExecQuery(sql);
                    AtualizaGrid();
                }
            }
        }