Exemplo n.º 1
0
 private void TsmCreateUser_Click(object sender, EventArgs e)
 {
     if (!MyAuth.isAdmin)
     {
         IMLibrary3.Global.MsgShow("对不起,目前您没有此项管理权限!");
         return;
     }
     if (frmUserVcard == null || frmUserVcard.IsDisposed)
     {
         frmUserVcard = new FormUserVcard();
         frmUserVcard.Create += delegate(object sender1, UserVcard userVcard)
         { CreateUser(userVcard); };
     }
     frmUserVcard.IsCreate = true;//操作为创建 
     frmUserVcard.Show();
 }
Exemplo n.º 2
0
        /// <summary>
        /// 显示用户资料窗口
        /// </summary>
        /// <param name="user"></param>
        public void ShowUserVcard(exUser user)
        {
            FormUserVcard frm = getUserVcardForm(user.UserID);
            if (frm == null)
            {
                frm = new FormUserVcard();
                frmUserVcards.Add(user.UserID, frm);

                if (MyAuth.isAdmin)//如果是管理员,则添加更新事件
                    frm.UpdateVcard += delegate(object sender1, UserVcard userVcard)//更新事件
                    {
                        UpdateUser(userVcard);//更新用户资料
                    };
                else//如果不是管理员,则添加刷新事件
                    frm.RefreshVcard += delegate(object sender1, UserVcard userVcard)//刷新事件
                    {
                        //向服务器请求获得用户最新资料
                        userVcard.type = type.get;
                        SendMessageToServer(userVcard);
                    };

                frm.FormClosed += delegate(object sender1, FormClosedEventArgs e1)//窗口关闭事件
                {
                    frm.Dispose();
                    frmUserVcards.Remove(user.UserID);
                };

                frm.ChanagePassword += delegate(object sender2, ChangePassword e2)//密码修改事件
                {
                    if (!frm.isAdmin && e2.OldPassword != myPassword)
                    {
                        IMLibrary3.Global.MsgShow("旧密码不正确,请重新输入");
                        return;
                    }
                    SendMessageToServer((object)e2);
                };

                UserVcard card = OpeRecordDB.GetUserVcard(user.UserID);
                if (card == null)
                {
                    card = new UserVcard();
                    card.UserID = user.UserID;
                    card.UserName = user.UserName;
                    card.GroupID = user.GroupID;
                    card.OrderID = user.OrderID;

                    //向服务器请求获得用户最新资料
                    card.type = type.get;
                    SendMessageToServer(card);
                }
                frm.UserVcard = card;
            }

            if (MyAuth.isAdmin)//如果是管理员
                frm.Text = "修改 " + user.UserName + "(" + user.UserID + ")的资料";
            else
                frm.Text = "查看 " + user.UserName + "(" + user.UserID + ")的资料";

            frm.myUserID = MyAuth.UserID;
            frm.isAdmin = MyAuth.isAdmin;
            frm.IsCreate = false;
            frm.Show();
            frm.Activate ();
        }