Beispiel #1
0
        public int deletePermiso(string _action, perfil oPerfil)
        {
            int result = -99;
            string sql = "";

            using (SqlConnection _conn = Program.sqlConn())
            {
                try
                {
                    switch (_action)
                    {
                        case "0":
                            sql = string.Format("DELETE perfiles where id_grupo = {0} and id_formulario = {1} and id_permiso = {2}", oPerfil.Id_grupo, oPerfil.Id_formulario, oPerfil.Id_permiso);
                            break;
                        default:
                            break;
                    }
                    using (SqlCommand aCommand = new SqlCommand(sql, _conn))
                    {
                        // Excecute Query
                        result = aCommand.ExecuteNonQuery();
                    }
                }
                catch
                {

                }
            }
            return result;
        }
Beispiel #2
0
        //int _idgrupo, int id_formulario, int id_permiso,int id_menu)
        public int Create(string _action, perfil oPerfil)
        {
            int result = -99;
            string sql = "";

            using (SqlConnection _conn = Program.sqlConn())
            {
                try
                {
                    switch (_action)
                    {
                        case "0":
                            sql = string.Format("INSERT INTO perfiles ( id_grupo, id_formulario, id_permiso,id_menu) values ('{0}','{1}','{2}',{3})", oPerfil.Id_grupo, oPerfil.Id_formulario, oPerfil.Id_permiso, oPerfil.Id_menu);
                            break;
                        default:
                            break;
                    }
                    using (SqlCommand aCommand = new SqlCommand(sql, _conn))
                    {
                        // Excecute Query
                        result = aCommand.ExecuteNonQuery();
                    }
                }
                catch
                {

                }
            }
            return result;
        }
Beispiel #3
0
        public perfil[] Getform_perm(string _action, int id_form, int id_grupo, int id_permiso)
        {
            string sql = "";
            List<perfil> _form_permisos = new List<perfil>();

            using (SqlConnection _conn = Program.sqlConn())
            {
                try
                {
                    switch (_action)
                    {
                        case "0":
                            sql = string.Format("SELECT * FROM perfiles where id_formulario = {0} and id_grupo = {1} and id_permiso = {2}", id_form, id_grupo, id_permiso);
                            break;
                        case "1":
                            sql = string.Format("SELECT * FROM perfiles where id_formulario = {0} and id_grupo = {1}", id_form, id_grupo);
                            break;
                        default:
                            break;
                    }
                    using (SqlCommand aCommand = new SqlCommand(sql, _conn))
                    {
                        using (SqlDataReader aReader = aCommand.ExecuteReader())
                        {
                            if (aReader.HasRows)
                            {
                                perfil _oform_perm;
                                while (aReader.Read())
                                {
                                    _oform_perm = new perfil();
                                    _oform_perm.Id_grupo = int.Parse(aReader["id_grupo"].ToString());
                                    _oform_perm.Id_formulario = int.Parse(aReader["id_formulario"].ToString());
                                    _oform_perm.Id_permiso = int.Parse(aReader["id_permiso"].ToString());
                                    _form_permisos.Add(_oform_perm);
                                }
                            }
                        }

                    }

                }
                catch
                {

                }
                return _form_permisos.ToArray();
            }
        }
Beispiel #4
0
        public perfil GetformComp(string _action, int id_grupo, int id_formulario,int id_permiso)
        {
            string sql = "";
            perfil _form_permiso = new perfil();

            using (SqlConnection _conn = Program.sqlConn())
            {
                try
                {
                    switch (_action)
                    {
                        case "0":
                            sql = string.Format("SELECT * FROM perfiles where id_grupo = {0} and id_formulario = {1} and id_permiso = {2}", id_grupo, id_formulario, id_permiso);
                            break;
                        default:
                            break;
                    }
                    using (SqlCommand aCommand = new SqlCommand(sql, _conn))
                    {
                        using (SqlDataReader aReader = aCommand.ExecuteReader())
                        {
                            if (aReader.HasRows)
                            {
                                while (aReader.Read())
                                {
                                    _form_permiso.Id_grupo = int.Parse(aReader["id_grupo"].ToString());
                                    _form_permiso.Id_formulario = int.Parse(aReader["id_formulario"].ToString());
                                    _form_permiso.Id_permiso = int.Parse(aReader["id_permiso"].ToString());
                                }
                            }
                        }

                    }

                }
                catch
                {

                }
                return _form_permiso;
            }
        }