예제 #1
0
        private void AddOrEdit(PermDetailViewModel vmPerm)
        {
            var win = new PermissionDetailWindow(vmPerm);
            var rst = win.ShowDialog();

            if (rst != null && rst == true)
            {
                base.SearchCmd.Execute(null);
            }
        }
예제 #2
0
        private void Search(PagingArgs page)
        {
            base.Models = null;
            var rst = HttpUtils.PostResult(ApiUtils.GetApiUrl(ApiKeys.GetPerByPage),
                                           new
            {
                pageIndex  = page.PageIndex,
                pageSize   = page.PageSize,
                conditions = new Dictionary <string, string>
                {
                    { "per_code", Filter_PerCode },
                    { "per_name", Filter_PerName },
                    { "per_type", Filter_PerType == null?"":Filter_PerType.Id },
                    { "per_parent", Filter_PerParent },
                    { "per_parent_name", Filter_PerParent_Name },
                }
            },
                                           ClientContext.Token);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Search, rst.msg);
                return;
            }
            if (rst.data != null && rst.data.total != null)
            {
                page.RecordsCount = (int)rst.data.total;
                if (page.RecordsCount == 0)
                {
                    page.PageCount = 0;
                    page.PageIndex = 1;
                    return;
                }
                page.PageCount = Convert.ToInt32(Math.Ceiling(page.RecordsCount * 1.0 / page.PageSize));

                var datas = rst.data.rows as JArray;
                if (datas.IsNotEmpty())
                {
                    IEnumerable <PermDetailViewModel> perms = datas.Select(obj =>
                    {
                        PermDetailViewModel permVM = new PermDetailViewModel(needValidate: false);
                        var ins = JsonConvert.DeserializeObject(obj.ToString(), permVM.permdata.GetType());
                        (ins as IPermVM).CopyTo(permVM.permdata);
                        permVM.per_parent_name = obj["per_parent_name"].Value <string>();
                        permVM.per_type_name   = obj["per_type_name"].Value <string>();
                        return(permVM);
                    });

                    base.PageStart = page.Start;
                    base.Models    = (perms as IEnumerable <CheckableModel>).ToList();
                }
            }
        }