示例#1
0
        private void FillMyChild(TblAuthPermissionViewModel tblAuthPermission, List <TblAuthPermission> result)
        {
            var query = (from x in result
                         where x.ParentPerm == tblAuthPermission.Iserial
                         select x).OrderBy(x => x.PermOrder).ToList();

            if (query.Count > 0)
            {
                GenericMapper.InjectFromObCollection(tblAuthPermission.SubPermissionsList, query);
                foreach (var authPermission in tblAuthPermission.SubPermissionsList)
                {
                    FillMyChild(new TblAuthPermissionViewModel().InjectFrom(authPermission) as TblAuthPermissionViewModel, result);
                }
            }

            GetImageListKey(tblAuthPermission, tblAuthPermission.PermissionTyp);

            // var a = TblAuthPermissionsList.Where(x=>x.SubPermissionsList.Where(s=>x.Ename.Contains("fabric Insp"));
        }
示例#2
0
        private void FillToSave(TblAuthPermissionViewModel row, ObservableCollection <TblAuthJobPermission> listToSave, ObservableCollection <TblAuthJobPermission> listToDelete)
        {
            if (row.Iserial == 304)
            {
            }

            foreach (var currentPerm in row.SubPermissionsList)
            {
                if (row.PermissionTyp == "F")
                {
                    switch (currentPerm.Ename)
                    {
                    case "Add":
                        row.AllowNew = currentPerm.IsSelected != null && (bool)currentPerm.IsSelected;

                        break;

                    case "Update":
                        row.AllowUpdate = currentPerm.IsSelected != null && (bool)currentPerm.IsSelected;

                        break;

                    case "Delete":
                        row.AllowDelete = currentPerm.IsSelected != null && (bool)currentPerm.IsSelected;
                        break;
                    }
                }

                //if (row.PermissionTyp == "F" && currentPerm.PermissionTyp == null)
                //{
                //    if (currentPerm.IsSelected == false)
                //    {
                //        listToDelete.Add(new TblAuthJobPermission
                //        {
                //            TblPermission = row.Iserial,
                //            Tbljob = SelectedJob.Iserial,
                //        });
                //    }
                //    else
                //    {
                //        listToSave.Add(new TblAuthJobPermission
                //        {
                //            TblPermission = row.Iserial,
                //            Tbljob = SelectedJob.Iserial,
                //            AllowDelete = row.AllowDelete,
                //            AllowNew = row.AllowNew,
                //            AllowUpdate = row.AllowUpdate,
                //        });
                //    }
                //}
                if (currentPerm.PermissionTyp != null)
                {
                    FillToSave(currentPerm, listToSave, listToDelete);
                }
            }

            if (row.PermissionTyp != null)
            {
                if (row.IsSelected == false)
                {
                    listToDelete.Add(new TblAuthJobPermission
                    {
                        TblPermission = row.Iserial,
                        Tbljob        = SelectedJob.Iserial,
                    });
                }
                else
                {
                    listToSave.Add(new TblAuthJobPermission
                    {
                        TblPermission = row.Iserial,
                        Tbljob        = SelectedJob.Iserial,
                        AllowDelete   = row.AllowDelete,
                        AllowUpdate   = row.AllowUpdate,
                        AllowNew      = row.AllowNew
                    });
                }
            }
        }
示例#3
0
        private void GetImageListKey(TblAuthPermissionViewModel tblAuthPermission, string permissionType)
        {
            if (tblAuthPermission.Iserial == 569)
            {
            }
            const string src       = "/CCWFM;component/Images/ImageListIcons/";
            var          converter = new ImageSourceConverter();

            var iconKey = "";

            switch (permissionType.ToUpper().Trim())
            {
            case "F":
                iconKey = "FormIcon";
                break;

            case "FU":
                iconKey = "DetailsIcon";
                break;

            case "FD":
                iconKey = "TransIcon";
                break;

            case "C":
                iconKey = "ChildIcon";
                break;

            case "M":
                iconKey = "MenuIcon";
                break;

            case "R":
                iconKey = "ReportIcon";
                break;
            }
            tblAuthPermission.ImageKey = iconKey;

            switch (iconKey)
            {
            case "MenuIcon":
                tblAuthPermission.SelectedImage = (ImageSource)converter.ConvertFromString(src + "Menu.png");

                break;

            case "FormIcon":
                tblAuthPermission.SelectedImage = (ImageSource)converter.ConvertFromString(src + "Form.png");

                //CCWFM;component/Images/ImageListIcons/Form.png
                tblAuthPermission.SubPermissionsList.Add(new TblAuthPermissionViewModel
                {
                    Ename    = "Add",
                    ImageKey = "Add",

                    SelectedImage = (ImageSource)converter.ConvertFromString(src + "Add.png")
                });
                tblAuthPermission.SubPermissionsList.Add(new TblAuthPermissionViewModel
                {
                    Ename         = "Update",
                    ImageKey      = "Update",
                    SelectedImage = (ImageSource)converter.ConvertFromString(src + "Update.png")
                });
                tblAuthPermission.SubPermissionsList.Add(new TblAuthPermissionViewModel
                {
                    Ename         = "Delete",
                    ImageKey      = "Delete",
                    SelectedImage = (ImageSource)converter.ConvertFromString(src + "Delete.png")
                });
                break;

            case "DetailsIcon":
                tblAuthPermission.SubPermissionsList.Add(new TblAuthPermissionViewModel
                {
                    Ename         = "Update",
                    ImageKey      = "Update",
                    SelectedImage = (ImageSource)converter.ConvertFromString(src + "Update.png")
                });
                break;

            case "TransIcon":
                tblAuthPermission.SubPermissionsList.Add(new TblAuthPermissionViewModel
                {
                    Ename         = "Add",
                    ImageKey      = "Add",
                    SelectedImage = (ImageSource)converter.ConvertFromString(src + "Add.png")
                });
                tblAuthPermission.SubPermissionsList.Add(new TblAuthPermissionViewModel
                {
                    Ename         = "Update",
                    ImageKey      = "Update",
                    SelectedImage = (ImageSource)converter.ConvertFromString(src + "Update.png")
                });
                break;
            }
        }