Exemplo n.º 1
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Deseja cancelar o pedido?", "Certeza?", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (txtIdPed.Text != "")
                {
                    conexao c       = new conexao();
                    int     idvenda = Convert.ToInt32(txtIdPed.Text);

                    String forma_pagto = c.RetornaQuery("SELECT FORMA_PAGTO FROM VENDAS WHERE ID = " + idvenda.ToString(), "FORMA_PAGTO");

                    if (forma_pagto == "5")
                    {
                        if (MessageBox.Show("Essa venda debitou creditos do cliente e eles serão ESTORNADOS automaticamente. Continuar?", "Continuar?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            c.ExecutaQuery("update vendas set isCancelado=1 where id=" + idvenda.ToString());
                            MessageBox.Show("CANCELADO!", "Canceled", MessageBoxButtons.OK);
                        }
                    }
                    else
                    {
                        c.ExecutaQuery("update vendas set isCancelado=1 where id=" + idvenda.ToString());
                        MessageBox.Show("CANCELADO!", "Canceled", MessageBoxButtons.OK);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void btnSalvarCliAg_Click(object sender, EventArgs e)
        {
            if (txtNomeTicket.Text == "")
            {
                MessageBox.Show("O campo Nome do ticket é obrigatório", "Preencha nome", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                String nome_ticket = txtNomeTicket.Text;

                if (!is_editing) //salvando..
                {
                    try
                    {
                        c.ExecutaQuery("insert into tp_tickets values('" + nome_ticket + "')");
                        preencheGrid();
                        txtNomeTicket.Text = "";
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
                else //editando...
                {
                    c.ExecutaQuery("update tp_tickets set ticket='" + nome_ticket + "' where id =" + grdTickets[0, grdTickets.CurrentRow.Index].Value.ToString());
                    preencheGrid();
                }
            }

            is_editing = false;
        }
Exemplo n.º 3
0
        private void btnSalvarCliAg_Click(object sender, EventArgs e)
        {
            if (txtNomeCliAg.Text == "")
            {
                MessageBox.Show("O campo Nome é obrigatório", "Preencha nome", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                String nome     = txtNomeCliAg.Text;
                String endereco = txtEndCliAg.Text;
                String telefone = txtTelCliAg.Text;

                if (!is_editing) //salvando..
                {
                    try
                    {
                        c.ExecutaQuery("insert into agenda values('" + nome + "', '" + endereco + "', '" + telefone + "')");
                        preencheGrid();
                        btnLimparCliAg_Click(new Object(), new EventArgs());
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
                else //editando...
                {
                    c.ExecutaQuery("update agenda set nome='" + nome + "', endereco= '" + endereco + "', telefone= '" + telefone + "' where id =" + grdClientesAg[0, grdClientesAg.CurrentRow.Index].Value.ToString());
                    preencheGrid();
                    btnLimparCliAg_Click(new Object(), new EventArgs());
                }
            }

            is_editing = false;
        }
Exemplo n.º 4
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                FileStream   fs     = File.Create(@"c:\pliniao\prefmaq.dat");
                StreamWriter sw     = new StreamWriter(fs);
                String       sTpMaq = "SER";
                if (rdTpEstacao.Checked)
                {
                    sTpMaq = "EST";
                }
                sw.Write(sTpMaq);
                sw.Close();
            }
            catch (Exception ev)
            {
                MessageBox.Show("erro criando arquivo dat " + ev.Message);
            }

            conexao c = new conexao();

            try {
                c.ExecutaQuery("update tempo_fila_impressao set tempo=" + txtTempo.Text + " where id=1");
            }
            catch
            {
                MessageBox.Show("insira valor numerico");
            }
            MessageBox.Show("Concluído");
        }
Exemplo n.º 5
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            //if (MessageBox.Show("Deseja cancelar o pedido?", "Certeza?", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (txtIdPed.Text != "")
                {
                    conexao c       = new conexao();
                    int     idvenda = Convert.ToInt32(txtIdPed.Text);

                    String forma_pagto    = c.RetornaQuery("SELECT FORMA_PAGTO FROM VENDAS WHERE ID = " + idvenda.ToString(), "FORMA_PAGTO");
                    String is2formasPagto = c.RetornaQuery("SELECT is2Formaspagto_PagtoPend_Credito FROM VENDAS WHERE ID = " + idvenda.ToString(), "is2Formaspagto_PagtoPend_Credito");

                    if (forma_pagto == "5" || is2formasPagto == "1")
                    {
                        if (MessageBox.Show("Essa venda debitou creditos do cliente e eles serão ESTORNADOS automaticamente. Continuar?", "Continuar?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                        {
                            if (is2formasPagto == "1")
                            {
                                credito_usado = double.Parse(c.RetornaQuery("SELECT valor_credito_utilizado FROM auxCreditosUtilizados WHERE id_venda=" + idvenda.ToString(), "valor_credito_utilizado"));
                            }
                            else
                            {
                                credito_usado = double.Parse(c.RetornaQuery("SELECT preco_total FROM vendas WHERE id=" + idvenda.ToString(), "preco_total"));
                            }
                            // c.ExecutaQuery("update vendas set isCancelado=1 where id=" + idvenda.ToString());
                            // MessageBox.Show("CANCELADO!", "Canceled", MessageBoxButtons.OK);
                        }

                        String data = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.fff");
                        c.ExecutaQuery("insert into historico_credito_dado values(" + id_cli + "," + credito_usado.ToString().Replace(",", ".") + ",'" + data + "', 'Estorno pedido " + idvenda.ToString() + "', 0, null)");
                        c.ExecutaQuery("update historico_credito_utilizado set obs='Estornado' where id_venda=" + idvenda.ToString());
                        c.ExecutaQuery("insert into extratoCreditoCli values(" + id_cli + "," + credito_usado.ToString().Replace(",", ".") + ",'" + data + "', 'Estorno pedido " + idvenda.ToString() + "')");
                        MessageBox.Show("R$ " + credito_usado.ToString("#.00") + " foram estornados para " + txtNome.Text);
                        c.ExecutaQuery("update vendas set isCancelado=1 where id=" + idvenda.ToString());
                        MessageBox.Show("CANCELADO!", "Canceled", MessageBoxButtons.OK);
                        lblCancelado.Visible = true;
                    }
                    else
                    {
                        c.ExecutaQuery("update vendas set isCancelado=1 where id=" + idvenda.ToString());
                        MessageBox.Show("CANCELADO!", "Canceled", MessageBoxButtons.OK);
                        lblCancelado.Visible = true;
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            if (!clicouEditar)
            {
                c.ExecutaQuery("insert into tipo_contas_pagar values('" + txtTipoConta.Text.ToString() + "')");
                PreencheGrid();
            }
            else
            {
                c.ExecutaQuery("update tipo_contas_pagar set descricao='" + txtTipoConta.Text.ToString() + "' where id=" + dataGridView1[0, dataGridView1.CurrentRow.Index].Value.ToString());
                PreencheGrid();
            }

            if (cboTp != null)
            {
                c.fillCombo(cboTp, "select id, descricao from tipo_contas_pagar", "id", "descricao");
                cboTp.SelectedIndex = -1;
            }
            //...
            btnDeletar.Enabled = false;
            btnEditar.Enabled  = false;
            clicouEditar       = false;
            txtTipoConta.Text  = "";
        }
Exemplo n.º 7
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            conexao Con = new conexao();
            String  sQuery;

            sQuery = "delete from produto where id=" + cboProcurarProduto.SelectedValue.ToString();

            if (MessageBox.Show("Tem certeza que deseja DELETAR ?", "Deletar?", MessageBoxButtons.YesNoCancel,
                                MessageBoxIcon.Information) == DialogResult.Yes)
            {
                Con.ExecutaQuery(sQuery);
                btnLimpar2_Click(sender, e);
                btnDel.Enabled = false;

                Con.fillCombo(this.cboProcurarProduto, "select * from produto", "id", "descr");
            }
        }
Exemplo n.º 8
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (txtNomeProd_ed.Text != "" && cboTipo_ed.Text != "" && txtPreco_ed.Text != "  .")
            {
                txtPreco_ed.Text = txtPreco_ed.Text.Replace(",", ".");

                conexao Con = new conexao();
                String  sQuery;
                sQuery = "update produto set descr='" + txtNomeProd_ed.Text + "', preco=" + txtPreco_ed.Text + ", tipo=" + cboTipo_ed.SelectedIndex + " where id=" + cboProcurarProduto.SelectedValue;
                if (Con.ExecutaQuery(sQuery))
                {
                    MessageBox.Show("Concluido");
                }
            }
            else
            {
                MessageBox.Show("Nome, tipo e preço devem ser preenchidos!", "Preencha os campos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 9
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            if (txtNewNome.Text != "" && cboTipoProd.Text != "" && txtNewPreco2.Text != "")
            {
                txtNewPreco2.Text = txtNewPreco2.Text.Replace(",", ".");

                conexao Con = new conexao();


                String sQuery;
                sQuery = "insert into produto(descr, preco, tipo) values('" + txtNewNome.Text + "'," + txtNewPreco2.Text + "," + cboTipoProd.SelectedIndex + ")";
                if (Con.ExecutaQuery(sQuery))
                {
                    txtNewCode.Text = Con.RetornaQuery("select max(id) as id from produto", "id");
                    MessageBox.Show("Concluido");
                    btnLimpar_Click(sender, e);
                }
            }
            else
            {
                MessageBox.Show("Nome, tipo e preço devem ser preenchidos!", "Preencha os campos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 10
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (File.Exists(@"c:\pliniao\prefmaq.dat"))
            {
                String tpMaq = File.ReadAllText(@"c:\pliniao\prefmaq.dat");

                if (tpMaq == "SER")
                {
                    conexao c = new conexao();

                    //abrirPortaUSBToolStrip();
                    //iRetorno = InterfaceEpsonNF.Le_Status();


                    var conn = new OdbcConnection();
                    conn.ConnectionString =
                        "Dsn=odbc_pliniao;" +
                        "Uid=sa;" +
                        "Pwd=chico110388;";

                    try
                    {
                        conn.Open();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Erro ao conectar no banco de dados.\n" + ex);
                    }

                    String         query = "select * from fila_impressao where status='na fila' or status='erro'";
                    OdbcCommand    cmd   = new OdbcCommand(query, conn);
                    OdbcDataReader dr    = cmd.ExecuteReader();

                    String id_item_fila;
                    String texto_impressao_cli;
                    String texto_impressao_empresa;

                    while (dr.Read())
                    {
                        id_item_fila            = dr["id"].ToString();
                        texto_impressao_cli     = dr["textocli"].ToString();
                        texto_impressao_empresa = dr["textoemp"].ToString();

                        ImprimeTicket i = new ImprimeTicket();
                        try
                        {
                            i.ImprimeTkt(texto_impressao_cli, texto_impressao_empresa);
                            c.ExecutaQuery("update fila_impressao set status='impresso' where id=" + id_item_fila);
                        }
                        catch
                        {
                            c.ExecutaQuery("update fila_impressao set status='erro' where id=" + id_item_fila);
                        }
                    }
                }
            }


            // AlteraVersao altera = new AlteraVersao();

            //   private void atualiza_tabela_pagar_func(object sender, EventArgs e)
            //   {
            // altera.gera_pagto_funcionario();
            // MessageBox.Show(DateTime.Now.ToString());
            //    }
        }
Exemplo n.º 11
0
        private void btnQuitarSel_Click(object sender, EventArgs e)
        {
            string szTextoCli_itens = "";

            if (chkDin.Checked == true || chkDebito.Checked == true || chkCredito.Checked == true)
            {
                if (MessageBox.Show("Quitar Selecionados ?", "Ctz?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    try
                    {
                        foreach (DataGridViewRow r in grdQuitarPagtosPendentes.SelectedRows)
                        {
                            String data_do_ped = c.RetornaQuery("select data from vendas where id=" + grdQuitarPagtosPendentes[0, r.Index].Value.ToString(), "data").Replace("-", "/");
                            String data_pedido_impressao;
                            data_do_ped = data_do_ped.Remove(10);
                            DateTime dt_pedo = DateTime.Parse(data_do_ped);
                            data_pedido_impressao = dt_pedo.ToString("dd/MM/yyyy");
                            data_do_ped           = dt_pedo.ToString("MM-dd-yyyy");
                            data_do_ped           = data_do_ped + " 00:00:00";

                            String   d_hoje;
                            DateTime dt_hoje = DateTime.Now;
                            d_hoje = dt_hoje.ToString("MM-dd-yyyy");

                            String dinheiroRecebido = "0";

                            if (txtDin.Text != "")
                            {
                                dinheiroRecebido = txtDin.Text;
                            }

                            //============================FORMA PAGTO CODIGOS===============================
                            int formaPagto = 0;
                            //1 ->Dinheiro
                            //6 ->Cartao Débito
                            //7 ->Cartao Crédito
                            //============================FORMA PAGTO CODIGOS===============================

                            if (chkDin.Checked == true)
                            {
                                formaPagto = 1;
                            }
                            else if (chkDebito.Checked == true)
                            {
                                formaPagto = 6;
                            }
                            else if (chkCredito.Checked == true)
                            {
                                formaPagto = 7;
                            }


                            c.ExecutaQuery("begin transaction declare @id int set @id=" + grdQuitarPagtosPendentes[0, r.Index].Value.ToString() + " update vendas set is_pagto_pendente=0, forma_pagto=" + formaPagto.ToString() + ", dinheiro_recebido=" + dinheiroRecebido + " where id=@id insert into pedidos_pendentes_quitados values(@id, '" + d_hoje + "') commit");


                            if (chkImprimeRecibo.Checked)
                            {
                                szTextoCli_itens += "<c>    " + grdQuitarPagtosPendentes[0, r.Index].Value.ToString() + "           " + data_pedido_impressao + "        " + grdQuitarPagtosPendentes[2, r.Index].Value.ToString() + "</c>\n";
                            }
                        }

                        if (chkImprimeRecibo.Checked)
                        {
                            ImprimeTicket imprime = new ImprimeTicket();



                            String szTextoCli = "";


                            szTextoCli  = "<ce>------------------------------------------\n</ce>";
                            szTextoCli += "<ce><c><e><b>MARMITARIA PLINIÃO</b></e>\n";
                            szTextoCli += "CNPJ: 22.095.906/0001-70   Inscrição Estadual: 181.233.395.114\n";
                            szTextoCli += "Rua: Mario Ybarra de Almeida, 295   Bairro: Centro\n";
                            szTextoCli += "<b>Tel: (16) 3472-0905</b>   Cidade: Araraquara/SP\n";
                            szTextoCli += "--------------------------------------------------------\n\n";
                            szTextoCli += "<e><b><s>RECIBO</s></b></e>\n\n";
                            szTextoCli += "</c></ce><c>----------------------------------------------------------------\n";
                            szTextoCli += "Num. Pedido       Data Pedido       Total Pedido\n";
                            szTextoCli += "----------------------------------------------------------------\n</c>";

                            szTextoCli += szTextoCli_itens;

                            szTextoCli += "<c>----------------------------------------------------------------</c>\n";
                            szTextoCli += "<b><ad>VALOR TOTAL: " + txtTotalSelecionado.Text.ToString() + "</ad></b>\n";

                            szTextoCli += "<c>----------------------------------------------------------------</c>\n";
                            szTextoCli += "<c><ce>";
                            szTextoCli += "Emissão " + DateTime.Now.ToString("g") + "</c></ce>\n\n";
                            szTextoCli += "<ce><b></c><c><b>Cliente:</c></b>\n";
                            szTextoCli += "<c><e><s>" + label1.Text + "</s></e></c>\n\n";
                            szTextoCli += "</b></ce><c><ce>Cardápio diário em:</c>\n";
                            szTextoCli += "<c>www.facebook.com/marmitariapliniao \n";
                            szTextoCli += "";
                            szTextoCli += "</ce></c>";
                            szTextoCli += "<c><ce>--------------------------------------------------------</ce></c>\n";
                            szTextoCli += "<c><ce><b>OBRIGADO PELA PREFERÊNCIA, VOLTE SEMPRE</b></ce></c>\n";
                            szTextoCli += "<c><ce>--------------------------------------------------------</ce></c>\n";
                            szTextoCli += "<gui></gui>";

                            imprime.ImprimeTkt(szTextoCli, "");

                            if (MessageBox.Show("Imprimir 2a via?", "Outra via?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                imprime.ImprimeTkt(szTextoCli, "");
                            }
                        }


                        preencheGrid(grdQuitarPagtosPendentes, sQuery);
                        CalculaValorTotal();
                        btnQuitarSel.Enabled = false;

                        txtTotalSelecionado.Enabled = false;
                        txtTotalSelecionado.Text    = "";
                        lblRSsel.Enabled            = false;
                        lblTotalSelecionado.Enabled = false;
                        preencheGrid(grdResumoQuitar, sQuery2);
                        lblTroco.Visible = false;
                        txtDin.Visible   = false;
                        txtDin.Text      = "";

                        chkDebito.Checked  = false;
                        chkDin.Checked     = false;
                        chkCredito.Checked = false;



                        grdQuitarPagtosPendentes.ClearSelection();

                        //atualiza grid do form PagtosPendentes.. (tela anterior)

                        if (grdPagtosPendentes_formAnterior != null)
                        {
                            String sPP = "select c.nome as 'Cliente', concat('R$ ',convert(varchar, cast(sum(v.preco_total - (v.preco_total*v.desconto)) as money),1)) as 'Valor Total', c.id from vendas v left outer join clientes c on c.id=v.id_cliente where v.is_pagto_pendente=1 and v.isCancelado<>1 group by c.id, c.nome";
                            preencheGrid(grdPagtosPendentes_formAnterior, sPP);

                            int    rowscount = grdPagtosPendentes_formAnterior.Rows.Count;
                            double preco_total;

                            preco_total = 0;

                            for (int i = 0; i < rowscount; i++)
                            {
                                preco_total = preco_total + double.Parse(grdPagtosPendentes_formAnterior.Rows[i].Cells[1].Value.ToString().Replace("R$ ", ""), System.Globalization.CultureInfo.InvariantCulture);
                            }

                            txtValorTotalPagtosPendentes_formAnterior.Text = String.Format("{0:n2}", preco_total).Replace(",", ".");

                            //fim atualiza grid do form PagtosPendentes.. (tela anterior)
                        }
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(exc.ToString());
                    }
                }
            }
            else
            {
                MessageBox.Show("Selecione a forma de pagamento !");
            }
        }
Exemplo n.º 12
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            if (cboTipo.SelectedIndex == -1 || txtValor.Text == "")
            {
                if (cboTipo.SelectedIndex == -1)
                {
                    MessageBox.Show("Selecione um tipo da lista", "erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (txtValor.Text == "")
                {
                    MessageBox.Show("Preencha o Valor", "erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                txtValor.Text = txtValor.Text.Replace(",", ".");

                int alerta     = 0;
                int custo_fixo = 0;


                if (chkAlerta.Checked)
                {
                    alerta = 1;
                }

                if (chkCustoFixo.Checked)
                {
                    custo_fixo = 1;
                }
                double price;
                price = double.Parse(txtValor.Text, System.Globalization.CultureInfo.InvariantCulture);
                String sPrice = price.ToString().Replace(",", ".");

                DateTime dtVenc;
                dtVenc = DateTime.Parse(txtDtVenc.Text);

                bool gravar_12_registros = false;

                int id_ref = 0;

                if (chkCustoFixo.Checked == true)
                {
                    gravar_12_registros = true;
                }

                if (!isEditing)
                {
                    try
                    {
                        c.ExecutaQuery("insert into contas_pagar values('" + cboTipo.GetItemText(cboTipo.SelectedItem).ToString() + "'," + sPrice + ",'" + dtVenc.ToString("MM-dd-yyyy") + "'," + alerta + "," + custo_fixo + "," + id_ref + ")");
                        preenche_grid();

                        if (gravar_12_registros)
                        {
                            id_ref = int.Parse(c.RetornaQuery("select max(id) as id from contas_pagar", "id"));
                            DateTime dt1 = Convert.ToDateTime(dtVenc.ToString("yyyy-MM-dd"));
                            int      i;
                            for (i = 0; i < 12; i++)
                            {
                                dt1 = dt1.AddMonths(1);
                                c.ExecutaQuery("insert into contas_pagar values('" + cboTipo.GetItemText(cboTipo.SelectedItem).ToString() + "'," + sPrice + ",'" + dt1.ToString("MM-dd-yyyy") + "'," + alerta + "," + custo_fixo + "," + id_ref + ")");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Erro ao gravar no banco de dados\n" + ex);
                        return;
                    }

                    //string[] row1 = new string[] { cboTipo.GetItemText(cboTipo.SelectedItem).ToString(), "R$ " + price.ToString("#.#0"), txtDtVenc.Text };
                    //grdContasPagar.Rows.Add(row1);
                }
                else
                {
                    //codigo editar..........

                    try
                    {
                        int estava_ticado_custo_fixo = 0;
                        if (!gravar_12_registros)
                        {
                            estava_ticado_custo_fixo = int.Parse(c.RetornaQuery("select isDespesaFixa from contas_pagar where id=" + grdContasPagar[0, grdContasPagar.CurrentRow.Index].Value.ToString(), "isDespesaFixa"));

                            if (estava_ticado_custo_fixo != 0)
                            {
                                if (MessageBox.Show("Isso irá remover os lançamentos futuros registrados para essa conta. \nContinuar?", "Lançamentos Futuros", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    String   id_ref2  = c.RetornaQuery("select id_ref from contas_pagar where id=" + grdContasPagar[0, grdContasPagar.CurrentRow.Index].Value.ToString(), "id_ref");
                                    DateTime dataVenc = Convert.ToDateTime(grdContasPagar[3, grdContasPagar.CurrentRow.Index].Value.ToString());
                                    String   dtvenc   = dataVenc.ToString("yyyy-MM-dd");

                                    if (id_ref2 == "0")
                                    {
                                        id_ref2 = grdContasPagar[0, grdContasPagar.CurrentRow.Index].Value.ToString();
                                    }


                                    c.ExecutaQuery("delete from contas_pagar where id_ref=" + id_ref2 + "and convert(date, vencimento, 103) >'" + dtvenc + "'");


                                    //c.ExecutaQuery("delete from contas_pagar where id_ref=" + grdContasPagar[0, grdContasPagar.CurrentRow.Index].Value.ToString());
                                }
                            }
                        }
                        else //esta marcado custo fixo
                        {
                            estava_ticado_custo_fixo = int.Parse(c.RetornaQuery("select isDespesaFixa from contas_pagar where id=" + grdContasPagar[0, grdContasPagar.CurrentRow.Index].Value.ToString(), "isDespesaFixa"));
                            if (estava_ticado_custo_fixo != 0)
                            {
                                if (MessageBox.Show("Deseja alterar, também, os lançamentos futuros registrados para essa conta?\n\nAperte 'não' para alterar apenas esse lançamento.", "Lançamentos Futuros", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    String   id_ref2  = c.RetornaQuery("select id_ref from contas_pagar where id=" + grdContasPagar[0, grdContasPagar.CurrentRow.Index].Value.ToString(), "id_ref");
                                    DateTime dataVenc = Convert.ToDateTime(grdContasPagar[3, grdContasPagar.CurrentRow.Index].Value.ToString());
                                    String   dtvenc   = dataVenc.ToString("yyyy-MM-dd");



                                    if (id_ref2 == "0")
                                    {
                                        id_ref2 = grdContasPagar[0, grdContasPagar.CurrentRow.Index].Value.ToString();
                                    }


                                    // tem que atualizar a data de venc add 1 mes.. mas como ? (done)
                                    //sugest: selecionar quantas linhas tem o id_ref.. ai fazer um for com essa qtt e vai atualizando
                                    //Fazer o while do select e atualizar where id=idSel e id_ref=id_ref2...
                                    String query2 = "select id from contas_pagar where id_ref=" + id_ref2 + " and convert(date, vencimento, 103) >'" + dtvenc + "' order by id";
                                    var    conn   = new OdbcConnection();
                                    conn.ConnectionString =
                                        "Dsn=odbc_pliniao;" +
                                        "Uid=sa;" +
                                        "Pwd=chico110388;";
                                    try
                                    {
                                        conn.Open();
                                    }
                                    catch (Exception exx)
                                    {
                                        MessageBox.Show("Erro ao conectar no banco de dados.\n" + exx);
                                    }

                                    OdbcCommand    cmd2 = new OdbcCommand(query2, conn);
                                    OdbcDataReader dr2  = cmd2.ExecuteReader();

                                    while (dr2.Read())
                                    {
                                        dtVenc = dtVenc.AddMonths(1);
                                        c.ExecutaQuery("update contas_pagar set tipo='" + cboTipo.GetItemText(cboTipo.SelectedItem).ToString() + "', valor=" + sPrice + ",vencimento= '" + dtVenc.ToString("MM-dd-yyyy") + "', alertar=" + alerta + ", isDespesaFixa=" + custo_fixo + "where id=" + dr2["id"] + " and id_ref=" + id_ref2);   // + "and convert(date, vencimento, 103) >='" + dtvenc + "'");
                                    }

                                    dr2.Close();
                                    conn.Close();
                                    //aqui acaba a Sugest aí comentada acima...deu certo ;)
                                }
                            }
                            else //nao estava ticado custo fixo
                            {
                                if (gravar_12_registros)
                                {
                                    id_ref = int.Parse(grdContasPagar[0, grdContasPagar.CurrentRow.Index].Value.ToString());
                                    DateTime dt1 = Convert.ToDateTime(dtVenc.ToString("yyyy-MM-dd"));
                                    int      i;
                                    for (i = 0; i < 12; i++)
                                    {
                                        dt1 = dt1.AddMonths(1);
                                        c.ExecutaQuery("insert into contas_pagar values('" + cboTipo.GetItemText(cboTipo.SelectedItem).ToString() + "'," + sPrice + ",'" + dt1.ToString("MM-dd-yyyy") + "'," + alerta + "," + custo_fixo + "," + id_ref + ")");
                                    }
                                }
                            }
                        }
                        //aqui pega novamente a data do txtBox pq incrementei-a acima
                        dtVenc = DateTime.Parse(txtDtVenc.Text);
                        c.ExecutaQuery("update contas_pagar set tipo='" + cboTipo.GetItemText(cboTipo.SelectedItem).ToString() + "', valor=" + sPrice + ",vencimento= '" + dtVenc.ToString("MM-dd-yyyy") + "', alertar=" + alerta + ", isDespesaFixa=" + custo_fixo + "where id=" + grdContasPagar[0, grdContasPagar.CurrentRow.Index].Value.ToString());
                        preenche_grid();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Erro ao gravar no banco de dados\n" + ex);
                        return;
                    }

                    //...
                    isEditing = false;
                }



                btnLimpar_Click(new Object(), new EventArgs());
            }
        }
Exemplo n.º 13
0
        private void btnAddCredito_Click(object sender, EventArgs e)
        {
            //double valor_credito_dado;
            string sValor;
            string data;
            int    formaPagto   = 0;
            int    id_tp_ticket = 0;

            if (chkDin.Checked || chkCredito.Checked || chkDebito_.Checked || chkTickets.Checked)
            {
                if (txtValorDado.Text == "")
                {
                    MessageBox.Show("Valor não pode ser branco");
                }
                else
                {
                    data   = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.fff");
                    sValor = txtValorDado.Text.Replace(",", ".");

                    if (chkDin.Checked == true)
                    {
                        formaPagto = 1;
                    }
                    else if (chkDebito_.Checked == true)
                    {
                        formaPagto = 6;
                    }
                    else if (chkCredito.Checked == true)
                    {
                        formaPagto = 7;
                    }
                    else if (chkTickets.Checked == true)
                    {
                        formaPagto = 8;  //voucher / ticket - olhar coluna id_tp_ticket para saber qual

                        if (cboTickets.SelectedIndex.ToString() == "0")
                        {
                            MessageBox.Show("Atenção: Nenhum voucher selecionado !!", "Pode näo !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            goto DEUERRO;
                        }
                        else
                        {
                            id_tp_ticket = cboTickets.SelectedIndex;
                        }
                    }


                    c.ExecutaQuery("insert into historico_credito_dado values(" + id_cli + "," + sValor + ",'" + data + "', ''," + formaPagto.ToString() + "," + id_tp_ticket + ")" +
                                   " insert into extratoCreditoCli values(" + id_cli + "," + sValor + ",'" + data + "', '')");


                    preenche_grid(grdHistoricoCreditoDado, id_cli);
                    txtValorDado.Text = "";
                    groupBox2.Visible = true;
                    getSaldoCli();


                    if (chkImprimir.Checked)
                    {
                        ImprimeTicket imprimir = new ImprimeTicket();

                        imprimir.ImprimeReciboCreditoCli(c.RetornaQuery("select nome from clientes where id=" + id_cli, "nome"), "R$ " + sValor, c.getSaldoCreditoCliente(id_cli.ToString()), int.Parse(qttVias.Value.ToString()));
                    }
                }
            }
            else
            {
                MessageBox.Show("Selecione a forma de pagamento !", "Oooppps", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            DEUERRO : int a = 1;
        }
Exemplo n.º 14
0
        public AlteraVersao()
        {
            //  MessageBox.Show("teste2");

            //coluna forma_pagto - tabela vendas
            c.ExecutaQuery("if not exists(select 1 from syscolumns where id = object_id('vendas') and name = 'forma_pagto') ALTER TABLE vendas ADD forma_pagto INT null");

            //tabela tipo_contas_pagar
            c.ExecutaQuery("if not exists(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'tipo_contas_pagar') CREATE TABLE [dbo].[tipo_contas_pagar]([id] [int] IDENTITY(1,1) NOT NULL, [descricao] [varchar](50) NOT NULL)");

            //tabela contas_pagar
            c.ExecutaQuery("if not exists(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'contas_pagar') CREATE TABLE [dbo].[contas_pagar]( [id] [int] IDENTITY(1,1) NOT NULL, [tipo] [varchar](50) NOT NULL, [valor] [float] NOT NULL,	[vencimento] [date] NOT NULL, [alertar] [int] NOT NULL,	[isDespesaFixa] [int] NOT NULL, [id_ref] [int] not null)");

            //senha form
            c.ExecutaQuery("if not exists(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'senha_form') CREATE TABLE [dbo].[senha_form]([id] [int] IDENTITY(1,1) NOT NULL, [senha] [varchar](50) NOT NULL)");
            c.ExecutaQuery("if not exists(SELECT senha FROM senha_form) insert into senha_form values ('azarito92')");

            //tabela cargo funcionarios
            c.ExecutaQuery("if not exists(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'cargos_func') CREATE TABLE [dbo].[cargos_func]([id] [int] IDENTITY(1,1) NOT NULL, [descricao] [varchar](50) NOT NULL)");

            //tabela funcionarios
            c.ExecutaQuery("if not exists(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'funcionarios') CREATE TABLE [dbo].[funcionarios] ([id] [int] NOT NULL, [nome] [varchar](50) NOT NULL, [id_cargo] [int] not null, [salario] [float] not null, [dia_pagto] [int] not null, [isInativo] [int] default 0)");

            //tabela outros gastos funcionarios
            c.ExecutaQuery("if not exists(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'outros_gastos_funcionarios') CREATE TABLE [dbo].[outros_gastos_funcionarios] ([id] [int] IDENTITY(1,1) NOT NULL, [id_func] [int] not null, [descricao] [varchar](50) not null, [valor] [float] not null)");

            //tabela despesas gerais
            c.ExecutaQuery("if not exists(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'despesas_gerais') CREATE TABLE [dbo].[despesas_gerais] ([id] [int] IDENTITY(1,1) NOT NULL,  [descricao] [varchar](50) not null, [valor] [float] not null, [data] [datetime] not null)");

            //tabela cadastro clientes
            c.ExecutaQuery("if not exists(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'clientes') CREATE TABLE [dbo].[clientes] ([id] [int] IDENTITY(1,1) NOT NULL,  nome [varchar](50) not null, [endereco] [text], [telefone] [varchar](50), [hora_entrega] [varchar](50))");

            //coluna is_pagto_pendente
            c.ExecutaQuery("if not exists(select 1 from syscolumns where id = object_id('vendas') and name = 'is_pagto_pendente') ALTER TABLE vendas ADD is_pagto_pendente INT null default 0");


            //coluna id cliente
            c.ExecutaQuery("if not exists(select 1 from syscolumns where id = object_id('vendas') and name = 'id_cliente') ALTER TABLE vendas ADD id_cliente INT null default 0");

            //tabela pedidos_pendentes_quitados
            c.ExecutaQuery("if not exists(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'pedidos_pendentes_quitados') CREATE TABLE [dbo].[pedidos_pendentes_quitados] ([id] [int] IDENTITY(1,1) NOT NULL,  id_pedido [int] not null, data_quitacao [datetime] not null )");

            //tabela pagar_funcionarios
            c.ExecutaQuery("if not exists(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'pagar_funcionarios') CREATE TABLE [dbo].[pagar_funcionarios]( [id] [int] IDENTITY(1,1) NOT NULL, [id_func] [int] NOT NULL, [valor_total_func] [float] NOT NULL, [data_pagto] [date] NOT NULL)");


            //tabela cadastro clientes
            c.ExecutaQuery("if not exists(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'agenda') CREATE TABLE [dbo].[agenda] ([id] [int] IDENTITY(1,1) NOT NULL,  nome [varchar](50) not null, [endereco] [text], [telefone] [varchar](50))");

            //campo troco
            c.ExecutaQuery("if not exists(select 1 from syscolumns where id = object_id('vendas') and name = 'dinheiro_recebido') ALTER TABLE vendas ADD dinheiro_recebido float default 0");

            //     MessageBox.Show("teste3");

            //tabela tempo_fila_impressao
            c.ExecutaQuery("if not exists(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'tempo_fila_impressao') begin CREATE TABLE[dbo].[tempo_fila_impressao] (id int default 1, tempo int default 10000) insert into tempo_fila_impressao values(1,10000) end");

            //     MessageBox.Show("teste4");

            //tabela fila_impressao
            c.ExecutaQuery("if not exists(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'fila_impressao') create table fila_impressao(id int IDENTITY(1,1) NOT NULL, id_pedido int, textocli text, textoemp text, status varchar(50))");

            // MessageBox.Show("teste5");
        }