Exemplo n.º 1
0
        private void headpicture_Click(object sender, EventArgs e)
        {
            UserBLL        udb      = new UserBLL();
            bool           bSuccess = false;
            OpenFileDialog openfile = new OpenFileDialog();

            openfile.Filter           = "图片文件(*.jpg,*.gif,*.bmp)|*.jpg|*.gif|*.bmp";
            openfile.InitialDirectory = "C:\\";
            if (openfile.ShowDialog() == DialogResult.OK)
            {
                FileInfo pic = new FileInfo(openfile.FileName);
                string   dz  = s + "//" + pic.Name;
                pic.CopyTo(dz, true);
                bSuccess = udb.ChangeHeadPicture(dz, udb.user.UserID.ToString());
            }
            if (bSuccess)
            {
                MessageBox.Show("更换头像成功!");
                main_Load(sender, e);
            }
            else
            {
                MessageBox.Show("更换头像失败!");
            }
        }