示例#1
0
        //verificar cajas abiertas
        private void caja_abierta()
        {
            base_datos con = new base_datos();

            if (con.existe_dato("SELECT * FROM caja WHERE estado = 'ABIERTO' ORDER BY fapertura ASC") == 1)
            {
                estado_caja = "ABIERTO";

                //id caja abierta
                caja_actual = con.consulta_dato("SELECT id_caja FROM caja WHERE estado = 'ABIERTO' ");
            }
            else
            {
                estado_caja = "CERRADO";
                //consulta si existe cajas
                if (con.existe_dato("SELECT * FROM caja") == 1)
                {
                    //nueva id
                    caja_actual = con.consulta_dato("SELECT MAX(id_caja)+1 FROM caja WHERE estado = 'CERRADO' ");
                }
                else                //si no existe sera la primera
                {
                    caja_actual = "1";
                }
            }

            //titulo
            lb_estado_caja.Text = "ESTADO: " + estado_caja;
        }
        //boton conectar
        void Sesion_btn_conectarClick(object sender, EventArgs e)
        {
            if (sesion_tb_pass.Text == "root741963" && sesion_tb_rut.Text == "root741963")
            {
                Panel aux = new Panel();
                aux.Show();
                aux.set_empleado("root", "root");

                this.Hide();
            }
            else if (sesion_tb_pass.Text != string.Empty && sesion_tb_rut.Text != string.Empty)
            {
                base_datos con = new base_datos();

                string query;
                query = "SELECT * FROM trabajador WHERE rut = '" + sesion_tb_rut.Text + "' AND pass = '******'";

                if (con.existe_dato(query) == 1)                 //existe usuario
                {
                    Panel aux = new Panel();
                    aux.Show();
                    aux.set_empleado(sesion_tb_rut.Text, sesion_tb_pass.Text);

                    this.Hide();
                }
                else
                {
                    MessageBox.Show("pass incorrecta!!");
                }
            }
            else
            {
                MessageBox.Show("ID o Contraseña incorrecta!!");
            }
        }
示例#3
0
        //carga los datos del empleado
        public void set_empleado(string id, string pass)
        {
            this.menu_lb_usuario.Text = id;
            this.menu_lb_pass.Text    = pass;

            base_datos con = new base_datos();

            if (con.existe_dato("SELECT * FROM trabajador WHERE rut = '" + id + "' AND pass = '******' AND tipo = 'ADMIN' ") == 1)
            {
                this.menu_lb_tipo.Text = "ADMINISTRADOR";

                //esconde elementos que son de administracion
                lb_empleado.Visible        = true;
                menu_btn_empleados.Visible = true;
                lb_finanza.Visible         = true;
                menu_btn_finanza.Visible   = true;
                lb_config.Visible          = true;
                menu_btn_config.Visible    = true;
            }
            else
            {
                this.menu_lb_tipo.Text = "NORMAL";

                //esconde elementos que son de administracion
                lb_empleado.Visible        = false;
                menu_btn_empleados.Visible = false;
                lb_finanza.Visible         = false;
                menu_btn_finanza.Visible   = false;
                lb_config.Visible          = false;
                menu_btn_config.Visible    = false;
            }
        }