2
schangxiang@126.com
2024-08-16 b47c50a2a514def7374b32d7194b2c599cba5625
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
using System;
using FineUIPro;
using System.Collections.Generic;
using FineUIPro.iWareWms;
 
using iWareCommon.Utils;
using iWareCommon.Common.Entity;
 
using Newtonsoft.Json;
using FineUIPro.iWareWms.File;
using iWareDataCore.RBAC.Entity;
using iWareDataCore.RBAC.Service;
 
namespace iWareWms.View.RBAC.User
{
    /// <summary>
    /// 许艺潇
    /// 2018.06
    /// 个人信息管理操作界面
    /// </summary>
    public partial class UserInfo : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var user = GetLoginPerson();
                btnChangePassword.OnClientClick = Window1.GetShowReference(string.Format("~/View/RBAC/User/ChangePassword.aspx?Id={0}", user.Id), "修改密码");
 
               
                Label1.Text = string.IsNullOrEmpty(user.Photo) ? _defaultUserLogo : user.Photo;
                Label2.Text = "user.jpg";
                Image1.ImageUrl = _fileServerBaseAddress + "/file/download?path=" + Label1.Text.Trim();
                userName.Text = user.Username;
                Id.Text = user.Id.ToString();
                Label1.Text = user.Photo;
                realName.Text = user.Name;
                position.Text = user.Position;
                workNo.Text = user.WorkNo;
                status.Text = user.Status.ToString();
                tel.Text = user.Tel;
                userRole.Text = user.DisplayRoleNames;
            }
        }
 
        
 
 
        protected void btnSaveClose_Click(object sender, EventArgs e)
        {
            var user = GetLoginPerson();
            user.Username = userName.Text.Trim();
            user.Position = position.Text.Trim();
            user.WorkNo = workNo.Text.Trim();
            user.Tel = tel.Text.Trim();
            user.Photo = Label1.Text.Trim();
            user.Name = realName.Text.Trim();
            
            string msg;
            UserService.GetInstance().Update(user, out msg);
            Alert.ShowInTop(string.IsNullOrEmpty(msg) ? "修改成功" : msg);
 
            if (string.IsNullOrEmpty(msg))
            {
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }  
        }
 
        /// <summary>
        ///上传图片 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void UploadFile(object sender, EventArgs e)
        {
            if (!FileUpload1.HasFile)
            {
                Alert.Show("请选择上传文件!");
                return;
            }
 
            if (!FileHelper.IsImage(FileUpload1.PostedFile.FileName))
            {
                Alert.ShowInTop("请选择一个图片文件!");
                return;
            }
 
 
            var _token = Session[_tokenCookieName].ToString();
 
            var url = _fileServerBaseAddress + "/file/upload?rootPath=ksmy/user&fileName=" + FileUpload1.PostedFile.FileName;
 
            var resStr = HttpHelper.HttpUploadFile(url, FileUpload1.PostedFile, null, 5000);
 
            var res = JsonConvert.DeserializeObject<ResponseSimpleDataEntity<FileInfo>>(resStr);
 
 
 
            if (string.IsNullOrEmpty(res.msg))
            {
                Label1.Text = res.data.PathOnServer;
                Label2.Text = res.data.OriginalFileName;
                Image1.ImageUrl = _fileServerBaseAddress + "/file/download?path=" + Label1.Text.Trim();
            }
            else
            {
                Alert.ShowInTop(res.msg);
            }
          
        }
 
        protected override void WindowClose(object sender, EventArgs e)
        {
            string msg;
            var user = GetLoginPerson();
            var users = UserService.GetInstance().QueryByParam(new QueryParam { Filter = new Dictionary<string, object> { { "Id", user.Id } } }, out msg);
            if (users.Count > 0)
            {
                Session["UserInfo"] = users[0];
 
            }
            
        }
 
        
 
    }
}