Beispiel #1
0
        private void adicionarTempoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            relogio.Enabled = false;

            frm_add add = new frm_add();

            if (add.ShowDialog() == DialogResult.OK)
            {
                NpgsqlCommand    sel_rest  = new NpgsqlCommand("select tmp_rest from espera where nick = '" + grid_espera.SelectedCells[0].Value + "'", kronos_con);
                NpgsqlDataReader drSelhora = sel_rest.ExecuteReader();

                if (drSelhora.Read())
                {
                    DateTime      res_h     = Convert.ToDateTime(drSelhora[0]);
                    DateTime      total     = res_h.AddMinutes(Convert.ToInt32(add.hora.Text));
                    NpgsqlCommand upd_tempo = new NpgsqlCommand("update espera set tmp_add = '" + total.ToString("HH:mm:ss") + "', tmp_rest = '" + total.ToString("HH:mm:ss") + "' where nick = '" + grid_espera.SelectedCells[0].Value + "'", kronos_con);

                    Int32 upd_result = upd_tempo.ExecuteNonQuery();
                    if (upd_result != 0)
                    {
                        MessageBox.Show("Adicionado " + res_h.ToString("HH:mm") + " total de " + total.ToString("HH:mm"));
                    }
                    else
                    {
                        MessageBox.Show("Ocorreu erro ao adicionar tempo para " + grid_espera.SelectedCells[0].Value);
                    }
                }
            }
            verifica_maquinas();
            verifica_espera();
            relogio.Enabled = true;
        }
Beispiel #2
0
        private void adicionarHoraToolStripMenuItem_Click(object sender, EventArgs e)
        {
            relogio.Enabled = false;

            if (grid_espera.RowCount != 0)
            {
                if (MessageBox.Show("Existe usuário na lista de espera. Deseja adicionar tempo assim mesmo?", "ATENÇÃO", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    frm_add add = new frm_add();

                    if (add.ShowDialog() == DialogResult.OK)
                    {
                        String           qry_selhora = "select tmp_rest from atividade where nick = '" + grid_user.SelectedCells[0].Value + "'";
                        NpgsqlCommand    sel_rest    = new NpgsqlCommand(qry_selhora, kronos_con);
                        NpgsqlDataReader drSelhora   = sel_rest.ExecuteReader();

                        if (drSelhora.Read())
                        {
                            DateTime      res_h         = Convert.ToDateTime(drSelhora[0]);
                            DateTime      total         = res_h.AddMinutes(Convert.ToInt32(add.hora.Text));
                            String        qry_upd_tempo = "update atividade set tmp_add = '" + total.ToString("HH:mm:ss") + "', tmp_rest = '" + total.ToString("HH:mm:ss") + "' where nick = '" + grid_user.SelectedCells[0].Value + "'";
                            NpgsqlCommand upd_tempo     = new NpgsqlCommand(qry_upd_tempo, kronos_con);

                            Int32 upd_result = upd_tempo.ExecuteNonQuery();
                            if (upd_result != 0)
                            {
                                MessageBox.Show("Adicionado " + res_h.ToString("HH:mm") + " total de " + total.ToString("HH:mm"));
                            }
                            else
                            {
                                MessageBox.Show("Ocorreu erro ao adicionar tempo para " + grid_user.SelectedCells[0].Value);
                            }
                        }
                        drSelhora.Close();
                    }
                }
            }
            else
            {
                frm_add add = new frm_add();

                if (add.ShowDialog() == DialogResult.OK)
                {
                    String           qry_selhora = "select tmp_rest from atividade where nick = '" + grid_user.SelectedCells[0].Value + "'";
                    NpgsqlCommand    sel_rest    = new NpgsqlCommand(qry_selhora, kronos_con);
                    NpgsqlDataReader drSelhora   = sel_rest.ExecuteReader();

                    if (drSelhora.Read())
                    {
                        DateTime      res_h         = Convert.ToDateTime(drSelhora[0]);
                        DateTime      total         = res_h.AddMinutes(Convert.ToInt32(add.hora.Text));
                        String        qry_upd_tempo = "update atividade set tmp_add = '" + total.ToString("HH:mm:ss") + "', tmp_rest = '" + total.ToString("HH:mm:ss") + "' where nick = '" + grid_user.SelectedCells[0].Value + "'";
                        NpgsqlCommand upd_tempo     = new NpgsqlCommand(qry_upd_tempo, kronos_con);

                        Int32 upd_result = upd_tempo.ExecuteNonQuery();
                        if (upd_result != 0)
                        {
                            MessageBox.Show("Adicionado " + res_h.ToString("HH:mm") + " total de " + total.ToString("HH:mm"));
                        }
                        else
                        {
                            MessageBox.Show("Ocorreu erro ao adicionar tempo para " + grid_user.SelectedCells[0].Value);
                        }
                    }
                    drSelhora.Close();
                }
            }

            verifica_maquinas();
            relogio.Enabled = true;
        }