Пример #1
0
        public frmSenha()
        {
            InitializeComponent();



            AlteraVersao altera = new AlteraVersao();



            this.textBox1.KeyDown += new KeyEventHandler(textBox1_KeyDown);
        }
Пример #2
0
        public MDIParent1()
        {
            InitializeComponent();


            AlteraVersao altera = new AlteraVersao();

            //altera.gera_pagto_funcionario();

            toolMnuCadastro.LostFocus += new EventHandler(toolStripContainer1_LostFocus);


            //alerta de contas a pagar::

            DateTime dtini = DateTime.Now;
            DateTime dtfim = DateTime.Now.AddDays(5);

            String dtIni = dtini.ToString("yyyy-MM-dd");
            String dtFim = dtfim.ToString("yyyy-MM-dd");

            conexao c = new conexao();

            timer1.Enabled = true;
            int interval = int.Parse(c.RetornaQuery("select isnull(tempo,0) as tempo from tempo_fila_impressao", "tempo"));

            if (interval == 0)
            {
                timer1.Interval = 10000; //tempo padrao.. 10s
            }
            else
            {
                timer1.Interval = interval;
            }


            int qtt_ct_pagar_prox_vencto = int.Parse(c.RetornaQuery("select isnull(count(*),0) as 'ct' from contas_pagar where convert(date, vencimento, 103) >='" + dtIni + "' and convert(date, vencimento, 103)<='" + dtFim + "'", "ct"));

            if (qtt_ct_pagar_prox_vencto > 0)
            {
                notifyIcon1.Text    = "Ct Pagar Pliniao";
                notifyIcon1.Icon    = SystemIcons.Exclamation;
                notifyIcon1.Visible = true;
                notifyIcon1.ShowBalloonTip(4000, "Contas a Pagar", qtt_ct_pagar_prox_vencto.ToString() + " Contas próximas ao vencimento", ToolTipIcon.Info);
                notifyIcon1.Click += new EventHandler(notifyIcon1_Click);
            }
            //fim alerta contas a pagar....
        }
Пример #3
0
        private void btnSalvaFuncionario_Click(object sender, EventArgs e)
        {
            String nome  = txtNomeFunc.Text;
            int    cargo = 0;

            if (cboCargo.SelectedValue != null)
            {
                cargo = int.Parse(cboCargo.SelectedValue.ToString());
            }

            //       MessageBox.Show("antes de converter: txtSalario.text:  "+ txtSalario.Text);

            double salario  = 0;
            String sSalario = "";

            if (txtSalario.Text != "")
            {
                salario  = double.Parse(txtSalario.Text, System.Globalization.CultureInfo.InvariantCulture);
                sSalario = salario.ToString().Replace(",", ".");
            }

            //   MessageBox.Show("depois de converter para double: salario = double.Parse  " + salario);

            String DiaPagto = txtDiaPagto.Value.ToString("MM-dd-yyyy");


            if (nome != "" && cargo > 0 && salario > 0)
            {
                //salvando...
                if (!updating_func)
                {
                    int id_func = int.Parse(c.RetornaQuery("select isnull(max(id),0) as id from funcionarios", "id"));
                    id_func = id_func + 1;

                    int i;

//                    MessageBox.Show("salvando.... " + salario.ToString("#.#0").Replace(",", "."));

                    try
                    {
                        c.ExecutaQuery("insert into funcionarios values(" + id_func + ", '" + nome + "', " + cargo.ToString() + ", " + sSalario + ", '" + DiaPagto + "', 0)");
                        for (i = 0; i < grdOutrosValores.RowCount; i++)
                        {
                            c.ExecutaQuery("insert into outros_gastos_funcionarios values(" + id_func + ", '" + grdOutrosValores.Rows[i].Cells["descricao"].Value.ToString() + "', " + grdOutrosValores.Rows[i].Cells["valor"].Value.ToString().Replace(",", ".") + ")");
                        }


                        btnLimparFunc_Click(new Object(), new EventArgs());
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
                else //atualizando...
                {
                    String SgrdOVQuery;

                    String Valor;

                    SgrdOVQuery  = "begin transaction declare @id_func as integer set @id_func=" + grdFuncionarios[0, grdFuncionarios.CurrentRow.Index].Value.ToString();
                    SgrdOVQuery += " delete from outros_gastos_funcionarios where id_func = @id_func ";

                    int i = 0;
                    int pospoint;
                    for (i = 0; i < grdOutrosValores.RowCount; i++)
                    {
                        Valor    = grdOutrosValores.Rows[i].Cells["valor"].Value.ToString().Replace(",", ".");
                        pospoint = Valor.IndexOf(".");
                        Valor    = Valor.Replace(".", "");
                        if (pospoint > 0)
                        {
                            Valor = Valor.Insert(Valor.Length - (Valor.Length - pospoint), ".");
                        }
                        //    MessageBox.Show(Valor);
                        SgrdOVQuery += "insert into outros_gastos_funcionarios values(@id_func, '" + grdOutrosValores.Rows[i].Cells["descricao"].Value.ToString() + "', " + Valor + ") ";
                    }
                    SgrdOVQuery += "commit";


                    int isInativo;

                    if (chkInativarFunc.Checked == true)
                    {
                        isInativo = 1;
                        if (MessageBox.Show("Inativar um funcionário o tira automaticamente do relatório de faturamento mensal.\n\nDeseja excluir o lançamento desse funcionário do relatório de faturamento do mês atual?\n\nPressione SIM para excluir e NAO para manter.\n\nEm caso de dúvidas, contate o programador fodão que fez o programa", "Faturamento Mensal", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            //YES
                            //excluir desse mes e todos futuros...
                            //id func = grdFuncionarios[0, grdFuncionarios.CurrentRow.Index].Value.ToString();
                            String data_ini = DateTime.Today.Year.ToString() + "-" + DateTime.Today.Month.ToString() + "-01";
                            c.ExecutaQuery("delete from pagar_funcionarios where id_func=" + grdFuncionarios[0, grdFuncionarios.CurrentRow.Index].Value.ToString() + " and convert(date, data_pagto, 103) >= '" + data_ini + "'");
                        }
                        else
                        {
                            //NO
                            //manter esse mes e apagar os futuros..
                            String dia_pagto = c.RetornaQuery("select dia_pagto from funcionarios where id=" + grdFuncionarios[0, grdFuncionarios.CurrentRow.Index].Value.ToString(), "dia_pagto");
                            c.ExecutaQuery("delete from pagar_funcionarios where id_func=" + grdFuncionarios[0, grdFuncionarios.CurrentRow.Index].Value.ToString() + " and convert(date, data_pagto, 103) > '" + DateTime.Today.Year.ToString() + "-" + DateTime.Today.Month.ToString() + "-" + dia_pagto + "'");
                        }
                    }
                    else
                    {
                        isInativo = 0;
                    }

                    //  MessageBox.Show("atualizando .... " + salario.ToString("#.#0").Replace(",", "."));

                    try
                    {
                        String Sal      = txtSalario.Text.Replace(",", ".");
                        int    posponto = Sal.IndexOf(".");
                        Sal = Sal.Replace(".", "");
                        if (posponto > 0)
                        {
                            Sal = Sal.Insert(Sal.Length - (Sal.Length - posponto), ".");
                        }

                        //   MessageBox.Show(Sal);
                        c.ExecutaQuery(SgrdOVQuery);
                        c.ExecutaQuery("update funcionarios set nome= '" + nome + "', id_cargo= " + cargo.ToString() + ", salario=" + Sal + ", dia_pagto='" + DiaPagto + "', isInativo=" + isInativo + " where id=" + grdFuncionarios[0, grdFuncionarios.CurrentRow.Index].Value.ToString());
                        btnLimparFunc_Click(new Object(), new EventArgs());


                        //String MesAtual = DateTime.Today.Month.ToString("#0");
                        //String AnoAtual = DateTime.Today.Year.ToString();
                        //String DaysNoMonth = DateTime.DaysInMonth(int.Parse(AnoAtual), int.Parse(MesAtual)).ToString();

                        //if (MessageBox.Show("Deseja fazer essas alterações para o mês atual ou apenas para os meses futuros?" + "\n" + "Pressione SIM para alterar o relatório de faturamento do mês atual\nPressione NAO para alterar apenas os relatorios futuros", "Faturamento", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        //{
                        //    c.ExecutaQuery("delete from pagar_funcionarios where id_func=" + grdFuncionarios[0, grdFuncionarios.CurrentRow.Index].Value.ToString() + " and data_pagto >= '" + AnoAtual + "-" + MesAtual + "-01' and data_pagto <= '" + AnoAtual + "-" + MesAtual + "-" + DaysNoMonth + "'");
                        //}
                    }

                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }



                updating_func = false;
                carregaGridFunc();

                AlteraVersao pagto_func = new AlteraVersao();
                //pagto_func.gera_pagto_funcionario();
            }
            else
            {
                MessageBox.Show("Preencha os campos", "erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }