コード例 #1
0
ファイル: listadorol.cs プロジェクト: gtala/TP-GDD
 private void btnbuscar_Click(object sender, EventArgs e)
 {
     if (txtrolexacto.Text == "")
     {
         //buscar por like
         SqlConnection  unacon = new Conexiones().conectarse();
         SqlCommand     cmd    = new SqlCommand("select idRol,nombre,estado from gdd_maxi.Roles where nombre like '%" + txtrollike.Text + "%'", unacon);
         SqlDataAdapter da     = new SqlDataAdapter(cmd);
         DataTable      dt     = new DataTable();
         da.Fill(dt);
         dgvroles.DataSource = dt;
         unacon.Close();
     }
     if (txtrollike.Text == "")
     {
         //buscar por exacto
         SqlConnection  unacon = new Conexiones().conectarse();
         SqlCommand     cmd    = new SqlCommand("select idRol,nombre,estado from gdd_maxi.Roles where nombre = '" + txtrolexacto.Text + "'", unacon);
         SqlDataAdapter da     = new SqlDataAdapter(cmd);
         DataTable      dt     = new DataTable();
         da.Fill(dt);
         dgvroles.DataSource = dt;
         unacon.Close();
     }
 }
コード例 #2
0
ファイル: listadorol.cs プロジェクト: gtala/TP-GDD
        private void btneliminar_Click(object sender, EventArgs e)
        {
            int X1  = 0;
            int Row = 0;

            Row = dgvroles.CurrentRow.Index;
            X1  = (int)dgvroles[0, Row].Value;
            SqlConnection unacon = new Conexiones().conectarse();
            SqlCommand    cmd    = new SqlCommand("delete from gdd_maxi.Roles where idrol = " + X1, unacon);
            SqlCommand    cmd2   = new SqlCommand("delete from gdd_maxi.Rolxfuncionalidad where idrol = " + X1, unacon);
            SqlCommand    cmd3   = new SqlCommand("delete from gdd_maxi.usuarioxrol where idrol = " + X1, unacon);

            cmd2.ExecuteNonQuery();
            cmd3.ExecuteNonQuery();
            cmd.ExecuteNonQuery();
            MessageBox.Show("rol eliminado satisfactoriamente");

            /*
             * SqlCommand cmd3 = new SqlCommand("select idRol,nombre,estado from gdd_maxi.Roles",unacon);
             * SqlDataAdapter da = new SqlDataAdapter(cmd3);
             * DataTable dt = new DataTable();
             * da.Fill(dt);
             * dgvroles.DataSource = dt;
             */
            dgvroles.DataSource = null;
            unacon.Close();
        }
コード例 #3
0
ファイル: frmmodificarol.cs プロジェクト: gtala/TP-GDD
        private void btnmodif_Click(object sender, EventArgs e)
        {
            SqlConnection unacon = new Conexiones().conectarse();
            SqlCommand    cmd2   = new SqlCommand("delete from gdd_maxi.Rolxfuncionalidad where idrol = " + txtidrol.Text, unacon);

            cmd2.ExecuteNonQuery();
            int estado = 0;

            if (checkBoxhabilitado.Checked)
            {
                estado = 1;
            }

            SqlCommand cmd3 = new SqlCommand("update gdd_maxi.Roles set estado = " + estado.ToString() + " where idrol = " + txtidrol.Text, unacon);

            cmd3.ExecuteNonQuery();
            foreach (DataGridViewRow r in dgvfuncionalidades.Rows)
            {
                DataGridViewCheckBoxCell chk = r.Cells["habilitada"] as DataGridViewCheckBoxCell;

                if (Convert.ToBoolean(chk.Value) == true)
                {
                    SqlCommand cmd4 = new SqlCommand("gdd_maxi.sp_insertarolxfuncionalidad", unacon);

                    cmd4.CommandType = CommandType.StoredProcedure;
                    cmd4.Parameters.Add("@idrol", SqlDbType.Int).Value           = txtidrol.Text;
                    cmd4.Parameters.Add("@idfuncionalidad", SqlDbType.Int).Value = r.Cells["idfuncionalidad"].Value;
                    cmd4.ExecuteNonQuery();
                }
            }

            unacon.Close();
        }
コード例 #4
0
ファイル: frminsertausuario.cs プロジェクト: gtala/TP-GDD
        private void btnguardarusuario_Click(object sender, EventArgs e)
        {
            List <string> listadeusuarios;

            listadeusuarios = new Usuariosql().obtenerusuarios();


            if (listadeusuarios.Contains(txtusername.Text))
            {
                MessageBox.Show("el usuario ingresado ya existe");
            }
            else
            {
                string   username  = txtusername.Text;
                string   pass      = Encriptador(txtpass.Text);
                DateTime fecha1    = dateTimePicker1.Value;
                DateTime fecha2    = dateTimePicker2.Value;
                string   pregsecre = txtpregsecre.Text;
                string   respsecre = Encriptador(txtrespsecre.Text);

                SqlConnection unacon = new Conexiones().conectarse();
                SqlCommand    cmd    = new SqlCommand("gdd_maxi.sp_insertausuario", unacon);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@usuario", SqlDbType.NVarChar).Value         = username;
                cmd.Parameters.Add("@pass", SqlDbType.VarChar).Value             = pass;
                cmd.Parameters.Add("@fechacrea", SqlDbType.DateTime).Value       = dateTimePicker1.Value;
                cmd.Parameters.Add("@fechaultmod", SqlDbType.DateTime).Value     = dateTimePicker2.Value;
                cmd.Parameters.Add("@preguntasecreta", SqlDbType.VarChar).Value  = pregsecre;
                cmd.Parameters.Add("@respuestasecreta", SqlDbType.VarChar).Value = respsecre;
                cmd.Parameters.Add("@estado", SqlDbType.Int).Value = checkBox1.Checked;
                cmd.ExecuteNonQuery();


                foreach (DataGridViewRow r in dgvRoles.Rows)
                {
                    DataGridViewCheckBoxCell chk = r.Cells["seleccionado"] as DataGridViewCheckBoxCell;

                    if (Convert.ToBoolean(chk.Value) == true)
                    {
                        SqlCommand cmd2 = new SqlCommand("gdd_maxi.sp_insertarolxusuario", unacon);

                        cmd2.CommandType = CommandType.StoredProcedure;
                        cmd2.Parameters.Add("@usuario", SqlDbType.NVarChar).Value = txtusername.Text;
                        cmd2.Parameters.Add("@idrol", SqlDbType.Int).Value        = r.Cells["idrol"].Value;
                        cmd2.ExecuteNonQuery();
                    }
                }


                unacon.Close();
            }
        }
コード例 #5
0
ファイル: listusuario.cs プロジェクト: gtala/TP-GDD
        private void btneliminar_Click(object sender, EventArgs e)
        {
            SqlConnection unacon = new Conexiones().conectarse();

            string X1  = "";
            int    Row = 0;

            Row = dgvusuarios.CurrentRow.Index;
            X1  = (string)dgvusuarios[0, Row].Value;

            SqlCommand cmd = new SqlCommand("update gdd_maxi.usuarios set estado = 0 where username = '******'", unacon);

            cmd.ExecuteNonQuery();
            MessageBox.Show("usuario eliminado correctamente");
            unacon.Close();
        }
コード例 #6
0
ファイル: frminsertausuario.cs プロジェクト: gtala/TP-GDD
        public frminsertausuario()
        {
            InitializeComponent();

            SqlConnection  unacon = new Conexiones().conectarse();
            SqlCommand     cmd    = new SqlCommand("select * from gdd_maxi.V_nombrederoles", unacon);
            SqlDataAdapter da     = new SqlDataAdapter(cmd);
            DataTable      dt     = new DataTable();

            da.Fill(dt);
            dgvRoles.DataSource = dt;
            DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();

            chk.Name = "seleccionado";
            dgvRoles.Columns.Add(chk);
            unacon.Close();
        }
コード例 #7
0
ファイル: frmmodifusuario.cs プロジェクト: gtala/TP-GDD
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection unacon = new Conexiones().conectarse();
            SqlCommand    cmd    = new SqlCommand("delete from gdd_maxi.usuarioxrol where username = '******'", unacon);

            cmd.ExecuteNonQuery();
            //update gdd_maxi.Usuarios set pass = '******',preguntasecreta = 'preguntasecreta',respuestasecreta = 'rps'
            //where username = '******'
            string passha;
            string respsha;
            int    estado = 0;

            if (checkBox1.Checked)
            {
                estado = 1;
            }
            passglobal           = txtpass.Text;
            txtpass.TextChanged += new EventHandler(txtpass_TextChanged);
            respsha              = Encriptador(txtrespsecre.Text);
            SqlCommand cmd2 = new SqlCommand("update gdd_maxi.usuarios set pass = '******',fechaultmod = '" + dateTimePicker2.Value.ToString() + "',preguntasecreta = '" + txtpregsecre.Text + "',respuestasecreta = '" + respsha + "',estado = '" + estado.ToString() + "' where username = '******'", unacon);

            cmd2.ExecuteNonQuery();
            foreach (DataGridViewRow r in dgvRoles.Rows)
            {
                DataGridViewCheckBoxCell chk = r.Cells["seleccionado"] as DataGridViewCheckBoxCell;

                if (Convert.ToBoolean(chk.Value) == true)
                {
                    SqlCommand cmd4 = new SqlCommand("gdd_maxi.sp_insertarolxusuario", unacon);

                    cmd4.CommandType = CommandType.StoredProcedure;
                    cmd4.Parameters.Add("@usuario", SqlDbType.NVarChar).Value = txtusername.Text;
                    cmd4.Parameters.Add("@idrol", SqlDbType.Int).Value        = r.Cells["idrol"].Value;
                    cmd4.ExecuteNonQuery();
                }
            }

            unacon.Close();
        }
コード例 #8
0
ファイル: listusuario.cs プロジェクト: gtala/TP-GDD
        private void btnbuscar_Click(object sender, EventArgs e)
        {
            SqlConnection unacon = new Conexiones().conectarse();

            if (textBox1.Text == "")
            {
                SqlCommand     cmd = new SqlCommand("select username,pass,fechacrea,fechaultmod,preguntasecreta,respuestasecreta,estado from gdd_maxi.usuarios where username like " + "'%" + textBox2.Text + "%'", unacon);
                SqlDataAdapter da  = new SqlDataAdapter(cmd);
                DataTable      dt  = new DataTable();
                da.Fill(dt);
                dgvusuarios.DataSource = dt;
            }
            if (textBox2.Text == "")
            {
                SqlCommand     cmd = new SqlCommand("select username,pass,fechacrea,fechaultmod,preguntasecreta,respuestasecreta,estado from gdd_maxi.usuarios where username = "******"'" + textBox1.Text + "'", unacon);
                SqlDataAdapter da  = new SqlDataAdapter(cmd);
                DataTable      dt  = new DataTable();
                da.Fill(dt);
                dgvusuarios.DataSource = dt;
            }


            unacon.Close();
        }
コード例 #9
0
ファイル: frmmodifusuario.cs プロジェクト: gtala/TP-GDD
        public frmmodifusuario(Usuario usr)
        {
            InitializeComponent();
            txtusername.Text              = usr.getusername();
            txtusername.Enabled           = false;
            txtpass.Text                  = usr.getpass();
            txtpass.UseSystemPasswordChar = true;
            txtpass.PasswordChar          = '*';
            dateTimePicker1.Value         = usr.getfechacrea();
            dateTimePicker1.Enabled       = false;
            dateTimePicker2.Value         = DateTime.Now;
            dateTimePicker2.Enabled       = false;
            txtpregsecre.Text             = usr.getpreguntasecreta();
            txtrespsecre.Text             = usr.getrespuestasecreta();
            SqlConnection unacon = new Conexiones().conectarse();
            SqlCommand    cmd    = new SqlCommand("gdd_maxi.sp_traerrolesactivos", unacon);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable      dt = new DataTable();

            da.Fill(dt);
            dgvRoles.DataSource          = dt;
            dgvRoles.AutoSizeRowsMode    = DataGridViewAutoSizeRowsMode.AllCells;
            dgvRoles.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            DataGridViewCheckBoxColumn check = new DataGridViewCheckBoxColumn();

            check.Name = "seleccionado";
            dgvRoles.Columns.Add(check);

            if (usr.estado == 1)
            {
                checkBox1.Checked = true;
            }
            unacon.Close();
        }
コード例 #10
0
        private void btnguardarrol_Click(object sender, EventArgs e)
        {
            SqlConnection unacon = new Conexiones().conectarse();
            List <int>    listaderoles;

            listaderoles = new Rolsql().obtenerRolescoleccion(unacon);
            if (listaderoles.Contains(int.Parse(txtidrol.Text)))
            {
                MessageBox.Show("el numero de rol ya existe");
            }
            else
            {
                SqlCommand cmd = new SqlCommand("gdd_maxi.sp_insertarol", unacon);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@id", SqlDbType.Int).Value          = txtidrol.Text;
                cmd.Parameters.Add("@nombre", SqlDbType.NVarChar).Value = txtnombrerol.Text;
                cmd.Parameters.Add("@estado", SqlDbType.Int).Value      = checkBoxhabilitado.Checked;
                cmd.ExecuteNonQuery();
                foreach (DataGridViewRow r in dgvfuncionalidades.Rows)
                {
                    DataGridViewCheckBoxCell chk = r.Cells["habilitada"] as DataGridViewCheckBoxCell;

                    if (Convert.ToBoolean(chk.Value) == true)
                    {
                        SqlCommand cmd2 = new SqlCommand("gdd_maxi.sp_insertarolxfuncionalidad", unacon);

                        cmd2.CommandType = CommandType.StoredProcedure;
                        cmd2.Parameters.Add("@idrol", SqlDbType.Int).Value           = txtidrol.Text;
                        cmd2.Parameters.Add("@idfuncionalidad", SqlDbType.Int).Value = r.Cells["idfuncionalidad"].Value;
                        cmd2.ExecuteNonQuery();
                    }
                }
            }

            unacon.Close();
        }
コード例 #11
0
ファイル: logueo1.cs プロジェクト: gtala/TP-GDD
        private void btnIngresar_Click(object sender, EventArgs e)
        {
            Usuario newuser = Usuariosql.obtenerusuario(txtUsuario.Text);

            if (txtUsuario.Text == "")
            {
                MessageBox.Show("escriba un usuario por favor");
                return;
            }


            if (txtContrasenia.Text == "")
            {
                MessageBox.Show("escriba una contraseña por favor");
                return;
            }



            if (newuser != null)
            {
                if (newuser.estado == 0)
                {
                    MessageBox.Show("usuario inhabilitado");
                }
                else
                {
                    if (newuser.getpass() == Usuario.encriptar(txtContrasenia.Text))
                    {
                        //auditoria correcto
                        SqlConnection unacon = new Conexiones().conectarse();
                        SqlCommand    cmd    = new SqlCommand("gdd_maxi.sp_insertalogin", unacon);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@fecha", SqlDbType.DateTime).Value    = DateTime.Now;
                        cmd.Parameters.Add("@correcto", SqlDbType.Char).Value     = "si";
                        cmd.Parameters.Add("@username", SqlDbType.NVarChar).Value = txtUsuario.Text;
                        cmd.ExecuteNonQuery();
                        unacon.Close();
                        MessageBox.Show("usuario validado ok");
                        this.Hide();
                        logueo2 formlogueo2 = new logueo2(this, newuser);
                        formlogueo2.Show();
                    }
                    else
                    {
                        intentos++;
                        MessageBox.Show("contraseña incorrecta");
                    }

                    if (intentos == 3)
                    {
                        //auditoria fallo
                        SqlConnection unacon = new Conexiones().conectarse();
                        SqlCommand    cmd    = new SqlCommand("gdd_maxi.sp_insertalogin", unacon);
                        SqlCommand    cmd2   = new SqlCommand("update gdd_maxi.usuarios set estado = 0 where username = '******'", unacon);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@fecha", SqlDbType.DateTime).Value    = DateTime.Now;
                        cmd.Parameters.Add("@correcto", SqlDbType.Char).Value     = "no";
                        cmd.Parameters.Add("@username", SqlDbType.NVarChar).Value = txtUsuario.Text;
                        cmd.ExecuteNonQuery();
                        cmd2.ExecuteNonQuery();


                        unacon.Close();

                        MessageBox.Show("usuario inhabilitado");
                        intentos = 0;
                    }
                }
            }
            else
            {
                MessageBox.Show("usuario no existente");
            }
        }