Пример #1
0
        //EMPLEADOS DENTRO DE LA EMPRESA
        private void button4_Click(object sender, EventArgs e)
        {
            var dt = ConexionBD.ExecuteQuery($"SELECT * FROM REGISTRO WHERE" +
                                             $" entrada ='{"true"}'");

            dataGridView2.DataSource = dt;
        }
Пример #2
0
        private void Administrador_Load(object sender, EventArgs e)
        {
            var dt = ConexionBD.ExecuteQuery("SELECT * FROM DEPARTAMENTO");

            comboBox1_Load();
            comboBox2_Load();
        }
Пример #3
0
        //DEPARTAMENTO MAS CONCURRIDO
        private void button5_Click(object sender, EventArgs e)
        {
            var dt = ConexionBD.ExecuteQuery("SELECT d.nombre, count(u.id_departamento) as frecuencia " +
                                             "FROM REGISTRO r, DEPARTAMENTO d, USUARIO u " +
                                             "WHERE r.id_usuario = u.id_usuario AND d.id_departamento = u.id_departamento " +
                                             "GROUP BY d.id_departamento " +
                                             "ORDER BY frecuencia DESC LIMIT 1");

            dataGridView3.DataSource = dt;
        }
Пример #4
0
 private void Form1_Load(object sender, EventArgs e)
 {
     try
     {
         var dt = ConexionBD.ExecuteQuery("SELECT * FROM USUARIO");
         ComboBox1_Load();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ha ocurrido un problema");
     }
 }
Пример #5
0
        private void comboBox2_Load()
        {
            var users = ConexionBD.ExecuteQuery("SELECT nombre FROM USUARIO");

            var usersCombo = new List <string>();

            usersCombo.Add("");
            foreach (DataRow dr in users.Rows)
            {
                usersCombo.Add(dr[0].ToString());
            }
            comboBox2.DataSource = usersCombo;
        }
Пример #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            SiAdmin sia = new SiAdmin();
            SiVigi  siv = new SiVigi();
            SiEmple sie = new SiEmple();

            try
            {
                string Aquery = $"SELECT typeAdmin FROM USUARIO WHERE" +
                                $" nombre ='{comboBox1.SelectedItem.ToString()}'AND " +
                                $" contraseña ='{textBox1.Text}'";

                var dt    = ConexionBD.ExecuteQuery(Aquery);
                var dr    = dt.Rows[0];
                var admin = Convert.ToString(dr[0].ToString());

                string Vquery = $"SELECT typeVigi FROM USUARIO WHERE" +
                                $" nombre ='{comboBox1.SelectedItem.ToString()}'AND " +
                                $" contraseña ='{textBox1.Text}'";

                var dtt  = ConexionBD.ExecuteQuery(Vquery);
                var drr  = dtt.Rows[0];
                var vigi = Convert.ToString(drr[0].ToString());

                if (admin.Equals("true", StringComparison.OrdinalIgnoreCase))
                {
                    sia.Show();
                    this.Hide();
                }
                else if (vigi.Equals("true", StringComparison.OrdinalIgnoreCase))
                {
                    siv.Show();
                    this.Hide();
                }
                else
                {
                    sie.Show();
                    this.Hide();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Usuario no registrado o los datos ingresados incorrectos",
                                "Error de inicio de sesion", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #7
0
        private void ComboBox1_Load()
        {
            try
            {
                var users      = ConexionBD.ExecuteQuery("SELECT nombre FROM USUARIO");
                var usersCombo = new List <string>();
                usersCombo.Add("");
                foreach (DataRow dr in users.Rows)
                {
                    usersCombo.Add(dr[0].ToString());
                }

                comboBox1.DataSource = usersCombo;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Пример #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
            {
                admin1 = true;
                emple1 = false;
                vigi1  = false;
            }
            else if (radioButton2.Checked == true)
            {
                admin1 = false;
                emple1 = true;
                vigi1  = false;
            }
            else if (radioButton3.Checked == true)
            {
                admin1 = false;
                emple1 = false;
                vigi1  = true;
            }

            if (textBox1.Text.Equals("") ||
                textBox2.Text.Equals("") ||
                textBox3.Text.Equals("") ||
                textBox4.Text.Equals("") ||
                textBox5.Text.Equals(""))
            {
                MessageBox.Show("No se pueden dejar campos vacios ");
            }
            else
            {
                try
                {
                    var num = $"SELECT id_departamento FROM DEPARTAMENTO WHERE" +
                              $" nombre ='{comboBox1.SelectedItem.ToString()}'";

                    var dtt   = ConexionBD.ExecuteQuery(num);
                    var drr   = dtt.Rows[0];
                    var mynum = int.Parse(drr[0].ToString());

                    ConexionBD.ExecuteNonQuery($"INSERT INTO USUARIO(id_departamento, contraseña, nombre," +
                                               $" apellido, dui, typeAdmin, typeVigi, typeEmple, fechaNacimiento) " +
                                               $"VALUES (" +
                                               $"{mynum}," +
                                               $"'{textBox1.Text}'," +
                                               $"'{textBox2.Text}'," +
                                               $"'{textBox3.Text}'," +
                                               $"'{textBox4.Text}'," +
                                               $"'{admin1}'," +
                                               $"'{vigi1}'," +
                                               $"'{emple1}'," +
                                               $"'{Convert.ToDateTime(textBox5.Text)}')");

                    MessageBox.Show("Se ha realizado el registro");
                    comboBox1_Load();
                    comboBox2_Load();
                    textBox1.Clear();
                    textBox2.Clear();
                    textBox3.Clear();
                    textBox4.Clear();
                    textBox5.Clear();
                    radioButton2.Checked = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error");
                }
            }
        }
Пример #9
0
        //REGISTRO COMPLETO
        private void button3_Click(object sender, EventArgs e)
        {
            var dt = ConexionBD.ExecuteQuery("SELECT * FROM REGISTRO ");

            dataGridView1.DataSource = dt;
        }
Пример #10
0
        private void button1_Click(object sender, EventArgs e)
        {
            int value;

            if (radioButton1.Checked == true)
            {
                entrada = true;
                salida  = false;
            }
            else if (radioButton2.Checked == true)
            {
                entrada = false;
                salida  = true;
            }

            if (textBox1.Text.Equals("") ||
                textBox2.Text.Equals("") ||
                textBox3.Text.Equals(""))
            {
                MessageBox.Show("No se pueden dejar campos vacios ");
            }
            else if (Int32.TryParse(textBox3.Text, out value))
            {
                if (value >= 37)
                {
                    MessageBox.Show("Su temperatura es demasiado alta, no puede ingresar a las instalaciones ");
                }
                else
                {
                    try
                    {
                        var num = $"SELECT id_usuario FROM USUARIO WHERE" +
                                  $" nombre ='{comboBox1.SelectedItem.ToString()}'";

                        var dtt   = ConexionBD.ExecuteQuery(num);
                        var drr   = dtt.Rows[0];
                        var mynum = int.Parse(drr[0].ToString());

                        ConexionBD.ExecuteNonQuery($"INSERT INTO REGISTRO(id_usuario, entrada, salida, fecha," +
                                                   $" hora, temperatura) VALUES (" +
                                                   $"{mynum}," +
                                                   $"'{entrada}'," +
                                                   $"'{salida}'," +
                                                   $"'{Convert.ToDateTime(textBox1.Text)}'," +
                                                   $"'{Convert.ToDateTime(textBox2.Text)}'," +
                                                   $"{Convert.ToInt32(textBox3.Text)})");

                        MessageBox.Show("Se ha realizado el registro");

                        var dt = ConexionBD.ExecuteQuery("SELECT * FROM REGISTRO");
                        dataGridView1.DataSource = dt;

                        comboBox1_Load();
                        textBox1.Clear();
                        textBox2.Clear();
                        textBox3.Clear();
                        radioButton2.Checked = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Ha ocurrido un error");
                    }
                }
            }
        }
Пример #11
0
        private void Control_Load(object sender, EventArgs e)
        {
            var dt = ConexionBD.ExecuteQuery("SELECT * FROM USUARIO");

            comboBox1_Load();
        }