コード例 #1
0
        private void LoadData()
        {
            btnClose.OnClientClick = ActiveWindow.GetHideReference();

            int id = GetQueryIntValue("id");

            Infobasis.Data.DataEntity.User current = DB.Users
                                                     .Include("UserPermissionRoles")
                                                     .Where(u => u.ID == id).FirstOrDefault();
            if (current == null)
            {
                // 参数错误,首先弹出Alert对话框然后关闭弹出窗口
                Alert.Show("参数错误!", String.Empty, ActiveWindow.GetHideReference());
                return;
            }

            labName.Text     = current.Name;
            labRealName.Text = current.ChineseName;
            labEmail.Text    = current.Email;
            labRemark.Text   = current.Remark;
            labEnabled.Text  = current.Enabled ? "启用" : "禁用";

            // 用户所属角色
            labRole.Text = String.Join(",", DB.UserPermissionRoles.Where(item => item.UserID == id).Select(r => r.PermissionRole.Name).ToArray());
        }
コード例 #2
0
        protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
        {
            int userID = GetSelectedDataKeyID(Grid1);

            Infobasis.Data.DataEntity.User user = DB.Users.Where(item => item.ID == userID).FirstOrDefault();
            string userName = user.Name;

            if (e.CommandName == "Delete")
            {
                // 在操作之前进行权限检查

                if (user.IsClientAdmin)
                {
                    Alert.ShowInTop("不能删除默认的系统管理员(admin)!");
                }
                else
                {
                    //DB.Users.Where(u => u.ID == userID).Delete();
                    if (!_repository.Delete(user, out msg))
                    {
                        Alert.ShowInTop("删除失败!");
                    }

                    BindGrid();
                }
            }
        }
コード例 #3
0
        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            Infobasis.Data.DataEntity.User user = DB.Users.Find(UserInfo.Current.ID);
            user.ChineseName     = tbxUserName.Text;
            user.DefaultPageSize = Change.ToInt(ddlGridPageSize.SelectedValue);
            DB.SaveChanges();

            //PageContext.RegisterStartupScript("top.window.location.reload(false);");

            Alert.ShowInTop("修改配置成功, 需要重新登录系统!", String.Empty, "refreshTopWindow();");
        }
コード例 #4
0
        protected void btnSaveClose_Click(object sender, EventArgs e)
        {
            int id = GetQueryIntValue("id");

            Infobasis.Data.DataEntity.User item = DB.Users.Find(id);
            item.Password = PasswordUtil.CreateDbPassword(tbxPassword.Text.Trim());
            DB.SaveChanges();

            //Alert.Show("保存成功!", String.Empty, Alert.DefaultIcon, ActiveWindow.GetHidePostBackReference());
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }
コード例 #5
0
        protected void DataList1_ItemDataBound(object sender, FineUIPro.DataListItemEventArgs e)
        {
            Infobasis.Data.DataEntity.ClientTrace clientTrace = e.DataItem as Infobasis.Data.DataEntity.ClientTrace;
            Infobasis.Data.DataEntity.User        user        = DB.Users.Find(clientTrace.UserID);
            string userPortraitPath = Global.Default_User_Portrait_Path;

            if (user != null && !string.IsNullOrEmpty(user.UserPortraitPath))
            {
                userPortraitPath = user.UserPortraitPath;
            }
            e.Item.Text = String.Format(DATALIST_ITEM_TEMPLATE,
                                        ResolveUrl(userPortraitPath),
                                        clientTrace.UserDisplayName,
                                        clientTrace.CreateDatetime.ToString(),
                                        HtmlEncode(clientTrace.TraceDesc));
        }
コード例 #6
0
        private void LoadData()
        {
            int userID = UserInfo.Current.ID;

            Infobasis.Data.DataEntity.User user = DB.Users.Find(userID);
            tbxName.Text     = user.ChineseName;
            tbxUserName.Text = user.Name;
            if (string.IsNullOrEmpty(user.UserPortraitPath))
            {
                userPortrait.ImageUrl = Global.Default_User_Portrait_Path;
            }
            else
            {
                userPortrait.ImageUrl         = user.UserPortraitPath;
                userPortraitUpload.ButtonText = "修改头像";
            }
        }
コード例 #7
0
        private void LoadData()
        {
            btnClose.OnClientClick = ActiveWindow.GetHideReference();

            int id = GetQueryIntValue("id");

            Infobasis.Data.DataEntity.User current = DB.Users.Find(id);
            if (current == null)
            {
                // 参数错误,首先弹出Alert对话框然后关闭弹出窗口
                Alert.Show("参数错误!", String.Empty, ActiveWindow.GetHideReference());
                return;
            }

            if (current.IsClientAdmin && UserInfo.Current.IsSysAdmin)
            {
                Alert.Show("你无权编辑超级管理员!", String.Empty, ActiveWindow.GetHideReference());
                return;
            }

            labUserName.Text     = current.Name;
            labUserRealName.Text = current.ChineseName;
        }
コード例 #8
0
        protected void userPortraitUpload_FileSelected(object sender, EventArgs e)
        {
            if (userPortraitUpload.HasFile)
            {
                int companyID = UserInfo.Current.CompanyID;
                int userID    = UserInfo.Current.ID;

                string fileOriginalName = userPortraitUpload.ShortFileName;

                if (!ValidateFileType(fileOriginalName))
                {
                    ShowNotify("无效的文件类型!");
                    return;
                }

                string uploadPath = Global.UploadFolderPath;
                if (uploadPath.StartsWith("~") || uploadPath.StartsWith(".")) //相对路径
                {
                    uploadPath = HttpContext.Current.Server.MapPath(uploadPath + "/images/" + companyID.ToString());
                }
                else
                {
                    uploadPath = uploadPath + "/images/" + companyID;
                }

                string originalFolderPath  = Path.Combine(uploadPath, DateTime.Now.ToString("yyyyMM") + "/original");
                string thumbnailFolderPath = Path.Combine(uploadPath, DateTime.Now.ToString("yyyyMM") + "/thumbnail");

                bool folderExists = Directory.Exists(originalFolderPath);
                if (!folderExists)
                {
                    Directory.CreateDirectory(originalFolderPath);
                }

                folderExists = Directory.Exists(thumbnailFolderPath);
                if (!folderExists)
                {
                    Directory.CreateDirectory(thumbnailFolderPath);
                }

                string fileType             = fileOriginalName.Substring(fileOriginalName.LastIndexOf("."));
                string fileName             = DateTime.Now.Ticks.ToString();
                string fileOriginalSavePath = Path.Combine(originalFolderPath, fileName + fileType);

                userPortraitUpload.SaveAs(fileOriginalSavePath);

                Image  originalImage         = StreamHelper.ImagePath2Img(fileOriginalSavePath);
                string fileThumbnailSavePath = Path.Combine(thumbnailFolderPath, fileName + fileType);
                Image  newImage = ImageHelper.GetThumbNailImage(originalImage, 160, 160);
                newImage.Save(fileThumbnailSavePath);

                string savedPath = Global.UploadFolderVirualPath + "/images/" + companyID.ToString() + "/" + DateTime.Now.ToString("yyyyMM") + "/thumbnail/" + fileName + fileType;
                Infobasis.Data.DataEntity.User user = DB.Users.Find(userID);
                user.UserPortraitPath = savedPath;
                DB.SaveChanges();

                userPortrait.ImageUrl = savedPath;

                // 清空文件上传组件(上传后要记着清空,否则点击提交表单时会再次上传!!)
                userPortraitUpload.Reset();
            }
        }
コード例 #9
0
 // 超级管理员(admin)不可编辑,也不会检索出来
 protected void Grid1_PreRowDataBound(object sender, FineUIPro.GridPreRowEventArgs e)
 {
     Infobasis.Data.DataEntity.User user = e.DataItem as Infobasis.Data.DataEntity.User;
 }