/// <summary> /// 登录按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLogin_Click(object sender, RoutedEventArgs e) { //如果用户名或授权码文本框为空 if (txtUserName.Text.Equals("") || txtAuthCode.Password.Equals("")) { MessageBox.Show("用户名或授权码不能为空!", "空的用户名或授权码", MessageBoxButton.OK, MessageBoxImage.Error); return; } //按用户名从缓存中获得用户对象 User user = App.GetUserByUserName(txtUserName.Text.ToString()); //验证用户登录并接收结果 bool verifyResult = null != user && user.AuthorizationCode.Equals(Encrypt.GetCiphertext(txtAuthCode.Password, user.SecurityStamp)); //如果登录失败 if (!verifyResult) { MessageBox.Show("用户名或授权码错误。", "登入系统失败", MessageBoxButton.OK, MessageBoxImage.Error); return; } //创建并初始化数据窗口 DataWindow dataWindow = new DataWindow(user); //显示数据窗口 dataWindow.Show(); //关闭本窗口 Close(); }
/// <summary> /// 全参构造函数 /// </summary> /// <param name="ParentWindow">数据窗口对象</param> /// <param name="HeadTeacher">主管老师用户对象</param> /// <param name="User">系统当前使用者用户对象</param> public AddStuffWindow(DataWindow ParentWindow, User HeadTeacher, User User) { parentWindow = ParentWindow; headTeacher = HeadTeacher; user = User; //系统初始化组件函数 InitializeComponent(); //初始化文本框组件内容 txtOwner.Text = user.UserName; }
/// <summary> /// 全参构造函数 /// </summary> /// <param name="ParentWindow">数据窗口对象</param> /// <param name="Stuff">当前物资对象</param> /// <param name="Owner">当前物资拥有者用户对象</param> /// <param name="User">系统当前使用者用户对象</param> public BorrowWindow(DataWindow ParentWindow, Stuff Stuff, User Owner, User User) { parentWindow = ParentWindow; stuff = Stuff; owner = Owner; user = User; //系统初始化组件函数 InitializeComponent(); //初始化文本框组件内容 txtStuffName.Text = stuff.StuffName; txtValueOfAssessment.Text = stuff.ValueOfAssessment.ToString(); txtOwner.Text = stuff.Owner; }