Exemplo n.º 1
0
        private void FillDepartment()
        {
            if (!EnableDepartment)
            {
                return;
            }

            DepartmentListRequest departmentsRequest = new DepartmentListRequest();

            departmentsRequest.type = 0;
            ListResponse <Department> resp = _companyStructureService.ChildGetAll <Department>(departmentsRequest);

            if (!resp.Success)
            {
                Common.errorMessage(resp);
            }
            departmentStore.DataSource = resp.Items;
            departmentStore.DataBind();
            if (_systemService.SessionHelper.CheckIfIsAdmin())
            {
                return;
            }
            UserDataRecordRequest ud = new UserDataRecordRequest();

            ud.UserId   = _systemService.SessionHelper.GetCurrentUserId();
            ud.RecordID = "0";
            ud.classId  = ((ClassIdentifier)typeof(Department).GetCustomAttributes(true).Where(t => t is ClassIdentifier).ToList()[0]).ClassID;
            RecordResponse <UserDataAccess> udR = _accessControlService.ChildGetRecord <UserDataAccess>(ud);

            if (udR.result == null || !udR.result.hasAccess)
            {
                if (defaultDepartmentId == null)
                {
                    departmentId.Select(0);

                    departmentId.SetValue(resp.Items.Count != 0 ? resp.Items[0].recordId : null);
                }
                else
                {
                    departmentId.Select(defaultDepartmentId);

                    departmentId.SetValue(defaultDepartmentId);
                }
                X.Call("setDepartmentAllowBlank", true);
            }
        }
Exemplo n.º 2
0
        private void FillBranches()
        {
            branchStore.DataSource = GetBranches();
            branchStore.DataBind();
            if (_systemService.SessionHelper.CheckIfIsAdmin())
            {
                return;
            }
            UserDataRecordRequest ud = new UserDataRecordRequest();

            ud.UserId   = _systemService.SessionHelper.GetCurrentUserId();
            ud.RecordID = "0";
            ud.classId  = ((ClassIdentifier)typeof(Branch).GetCustomAttributes(true).Where(t => t is ClassIdentifier).ToList()[0]).ClassID;
            RecordResponse <UserDataAccess> udR = _accessControlService.ChildGetRecord <UserDataAccess>(ud);

            if (udR.result == null || !udR.result.hasAccess)
            {
                branchId.Select(0);
                X.Call("setBranchAllowBlank", true);
            }
        }