public void LoadHeader() { Maticsoft.DAL.user userDAL = new Maticsoft.DAL.user(); Maticsoft.Model.user userModel = userDAL.GetModel(UserInfo.id); // 如果用户设置过头像 if (userModel.header != null) { Image header = Image.FromStream(new MemoryStream(userModel.header)); this.picImage.BackgroundImage = header; } }
private void confirmButton_Click(object sender, EventArgs e) { if (this.pickedImage != null) { // 将头像信息存储到UserInfo类中 UserInfo.header = this.pickedImage; // 将头像图片存入数据库 Maticsoft.DAL.user userDAL = new Maticsoft.DAL.user(); Maticsoft.Model.user userModel = userDAL.GetModel(UserInfo.id); userModel.header = ImageToBytes(this.pickedImage); userDAL.Update(userModel); // 在主界面中更新头像 Form1.form1.LoadHeader(); this.Close(); } else { MessageBox.Show("请先选择头像!"); } }