الانتقال إلى المحتوى

عمل برنامج Security على الشاشات والتقارير


محمد جمعه

Recommended Posts

تحية طيبة لكل افراد المنتدي

ارجو المساعدة في عمل برنامج ( اعطاء بعض الأفكار ) يعطي للـ Administrator السماحية للمستخدمين Users في فتح الشاشات والتقارير في البرنامج .............. بمعني ان يقوم البرنامج قبل
فتح اي شاشة او تقرير بعمل Check على هذا المستخدم User هل مسموح بالفتح ام لا ؟
مع العلم انني لدي برنامج يعمل على التقارير يقوم بكتابة الرقم 9999999999.99 باللغه العربية
( التفقيط ) .
فعلى من يريده ارجو مراسلتي على
[email protected]
وسوف اقوم بإرساله لمن يرغب

شكراً لكم.

رابط هذا التعليق
شارك

  • بعد 3 أسابيع...

اعتقد ان هناك طريقتان :

1) اما باعطاء ومنح privilege الشاشة كاملة او اخفائها للمستخدم .

2) على مستوى كل شاشة او تقرير عمل flag معين يعمل check عليه اذا مسموح بالدخول على الشاشة او لا .

" واعتقد انه يفضل استخدام الطريقة الاولى لأنها اكثر فعالية and its more professional .

رابط هذا التعليق
شارك

  • بعد 1 شهر...

CREATE TABLE users (
user_id NUMBER(10) primary key
, user_name VARCHAR2(100) UNIQU
, pass_word VARCHAR2(100) NOT NULL
,creat_date DATE DEFAULT SYSDATE
,locked NUMBER(1) DEFAULT 0
) ;

CREATE TABLE FORMS
(
form_id NUMBER PRIMARY KEY
,form_name VARCHAR2(100)
,from_desc VARCHAR2(300)
);

CREATE TABLE reports
(
rep_id NUMBER PRIMARY KEY
,rep_name VARCHAR2(100)
,rep_desc VARCHAR2(300)
);

CREATE TABLE user_forms
(
user_id NUMBER (10) constraint user_fk references users( user_id)
,form_id NUMBER constaint form_fk references forms(form_id)
,status NUMBER(1) DEFAULT 1 -- 1 full access. 2 modify. 3 query only

,constraint us_frms_pk primary key (user_id , form_id));



CREATE TABLE user_reports
(
user_id NUMBER (10) constraint user_fk references users( user_id)
,rep_id NUMBER constaint form_fk references reports(rep_id)
,constraint us_reps_pk primary key (user_id , rep_id));


-- now create the user_app package

create or replace package user_app
is
FUNCTION exist ( user_name_in IN users.user_name%type
psw_in IN users.pass_word%type)
RETURN BOOLEAN ;
function get_id ( user_name_in IN users.user_name%type )
return users.user_id%type ;
function can_open_form (user_id_in IN us_forms.user_id%type
,form_id_in IN us_forms.form_id%type)
RETURN BOOLEAN ;


function can_open_rep (user_id_in IN us_forms.user_id%type
,rep_id_in IN us_forms.form_id%type)
RETURN BOOLEAN ;

FUNCTION get_form_status (user_id_in IN us_forms.user_id%type
,form_id_in IN us_forms.form_id%type)
RETURN CHAR ;

end user_app ;
/



create or replace package BODY user_app
is
FUNCTION exist ( user_name_in IN users.user_name%type
psw_in IN users.pass_word%type)
RETURN BOOLEAN
IS
retval BOOLEAN := FALSE ;
exi NUMBER(1) := 0 ;
BEGIN
SELECT 1
INTO exi
FROM users
WHERE upper(user_name) = upper(user_name_in)
AND upper(pass_word) = upper(psw_in ) ;

IF exi = 1
THEN
retval := TRUE ;
END IF ;
RETURN retval ;

EXCEPTION
WHEN no_data_found THE RETURN FALSE ;
END exist ;
-------------------------------------------------------------------------------------
function get_id ( user_name_in IN users.user_name%type )
return users.user_id%type
IS
retval users.user_id%type ;
BEGIN
SELECT user_id
INTO retval
FROM users
WHERE upper(user_name) = upper(user_name_in);
RETURN retval ;

END get_id ;
---------------------------------------------------------------------------
function can_open_form (user_id_in IN us_forms.user_id%type
,form_id_in IN us_forms.form_id%type)
RETURN BOOLEAN
IS
retval BOOLEAN := FALSE ;
exi NUMBER(1) := 0 ;
BEGIN
SELECT 1
INTO exi
FROM us_forms
WHERE user_id = user_id_in
AND form_id = form_id_in ;

IF exi = 1
THEN
retval := TRUE ;
END IF ;
RETURN retval ;

EXCEPTION
WHEN no_data_found THE RETURN FALSE ;
END can_open_form ;


function can_open_rep (user_id_in IN us_forms.user_id%type
,rep_id_in IN us_forms.form_id%type)
RETURN BOOLEAN

IS
retval BOOLEAN := FALSE ;
exi NUMBER(1) := 0 ;
BEGIN
SELECT 1
INTO exi
FROM us_reports
WHERE user_id = user_id_in
AND rep_id = rep_id_in ;

IF exi = 1
THEN
retval := TRUE ;
END IF ;
RETURN retval ;

EXCEPTION
WHEN no_data_found THE RETURN FALSE ;
END can_open_rep ;

FUNCTION get_form_status (user_id_in IN us_forms.user_id%type
,form_id_in IN us_forms.form_id%type)
RETURN CHAR
IS
retval CHAR ;
sts INTEGER ;
BEGIN
SELECT status
INTO sts
FROM us_forms
WHERE user_id = user_id_in
AND form_id = form_id_in ;

IF sts = 1
THEN
retval := 'F';
ELSIF sts = 2
THEN
retval := 'M';
ELSIF sts = 3
THEN
retval := 'Q' ;
END IF ;

RETURN retval ;

END get_form_status ;

end user_app ;
/


------------------------------------------------------------------------------------
------------------------------------------------------------------------------------

after runing the above script you should insert data into the users table
and the forms table and the us_forms and the us_reports .

after that it will be used in three steps :
1- on the login screen to check the existance of the user and also to
check that the user typed the correct user name and password .
ex : in forms builder
IF user_app.exist(:us_name , :psw)
THEN
:global.user_id := user_app.get_id(:us_name);
open_form('main');
ELSE
message('Wrong user name or password');
raise form_trigger_failure ;
END IF ;
2- on the main screen :
when the user is going to open any form or report to check that the user can open the specified form or report .
ex :
IF user_app.can_open_form (:global.user_id, 2)
THEN
open_form(2);
END IF ;

3 - while or before opening the form
to check the status of the user on the opend form, after that you can specify what the user can do on this form .

ex:
sts := user_app.get_status(:GLOBAL.user_id , 2) ;
IF sts = 'Q'
THEN
set_block_property('db_block_1',insert_allowed,property_false);
set_block_property('db_block_1',update_allowed,property_false);
set_block_property('db_block_1',delete_allowed,property_false);
END IF ;

تم تعديل بواسطة Mbadawy
رابط هذا التعليق
شارك

  • بعد 2 أسابيع...

هنالك طريقة الـ Security بإستخدام الـ Roles وهي أقل تكلفة في الزمن والمجهود
فقط قم بإنشاء Roles وقم بإعطاء الـ Roles الصلاحيات علي جداول النظام

رابط هذا التعليق
شارك

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   تمت استعادة المحتوى السابق الخاص بك.   مسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

جاري التحميل
×
×
  • أضف...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية