예제 #1
0
    public void TabUserRights(Button save, Button print, int FeatureID, int TabID)
    {
        ICustomForm     mgrUserValidate = (ICustomForm)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BCustomForm, BusinessProcess.Clinical");
        IKNHStaticForms isTabSaved      = (IKNHStaticForms)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BKNHStaticForms, BusinessProcess.Clinical");

        //int iSavedUserID = mgrUserValidate.GetCustomFormSavedByUser(Convert.ToInt32(System.Web.HttpContext.Current.Session["PatientVisitId"]), TabID);

        //if user have view permission disable the buttons
        //AuthenticationManager Authentication = new AuthenticationManager();
        bool bCanView = !HasFunctionRight(FeatureID, TabID, FunctionAccess.View, (DataTable)System.Web.HttpContext.Current.Session["UserRight"]);

        //if user have view permission
        save.Enabled = bCanView;

        //first time  - new user form creation
        if (Convert.ToInt32(System.Web.HttpContext.Current.Session["PatientVisitId"]) == 0)
        {
            bool bCanAdd = HasFunctionRight(FeatureID, TabID, FunctionAccess.Add, (DataTable)System.Web.HttpContext.Current.Session["UserRight"]);

            save.Enabled = bCanAdd;
        }
        else if (Convert.ToInt32(System.Web.HttpContext.Current.Session["PatientVisitId"]) > 0)
        {
            DataSet tabSaved = isTabSaved.CheckIfTabSaved(TabID, Convert.ToInt32(System.Web.HttpContext.Current.Session["PatientVisitId"]));
            if (tabSaved.Tables[0].Rows.Count == 0)
            {
                bool bCanAdd = HasFunctionRight(FeatureID, TabID, FunctionAccess.Add, (DataTable)System.Web.HttpContext.Current.Session["UserRight"]);
                save.Enabled = bCanAdd;
            }
            else
            {
                bool bCanUpdate = HasFunctionRight(FeatureID, TabID, FunctionAccess.Update, (DataTable)System.Web.HttpContext.Current.Session["UserRight"]);
                //if (bCanUpdate == true)
                //{
                //    //if user is different from who already saved user.
                //    bCanUpdate = (iSavedUserID == Convert.ToInt32(System.Web.HttpContext.Current.Session["AppUserId"]));
                //}

                if (Convert.ToInt32(System.Web.HttpContext.Current.Session["AppUserID"]) == 1)
                {
                    bCanUpdate = true;
                }

                save.Enabled = bCanUpdate;
            }
        }

        print.Enabled = HasFunctionRight(FeatureID, TabID, FunctionAccess.Print, (DataTable)System.Web.HttpContext.Current.Session["UserRight"]);
    }