private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.txtPicPath.Text) || !File.Exists(this.openFileDialog1.FileName)) {
                MessageBox.Show("请选择文件!");
                return;
            }

            var pic = new PeoplePic();
            pic.PicTitle = this.txtPicTitle.Text;
            pic.PicPath = this.openFileDialog1.FileName;

            var bll = new PeoplePicBLL();
            CResult<bool> result = new CResult<bool>(false);
            if (this._isEdit) {
                pic.PicID = this._currentPicID.Value;
                result = bll.UpdatePeoplePic(pic);
            } else {
                pic.PeopleID = this._peopleID.Value;
                result = bll.InsertPeoplePic(pic);
            }

            MessageHelper.ShowSaveDbResultMessage(result);
            if (result.Code == 0) {
                this.Dispose();
                if (callbackEvent != null) {
                    callbackEvent.Invoke();
                }
            }
        }
 private void dgvPicList_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     int columnIndex = e.ColumnIndex;
     int rowIndex = e.RowIndex;
     //AddCode
     if (rowIndex == -1) {
         return;
     }
     //AddCode
     if (this.dgvPicList.Columns[columnIndex] == this.dgvPicList.Columns[_delColumnName]) {
         var dialogResult = MessageBox.Show("确定要删除吗?", SystemInfo.ReminderStr, MessageBoxButtons.OKCancel);
         if (dialogResult == DialogResult.OK) {
             var PicID = (int)dgvPicList.Rows[rowIndex].Cells["PicID"].Value;
             var result = new PeoplePicBLL().DeletePeoplePicByID(PicID);
             if (result.Code > 0) {
                 MessageBox.Show(result.Message, SystemInfo.ErrorReminderStr, MessageBoxButtons.OK);
             }
             BindDataList();
         }
     } else if (this.dgvPicList.Columns[columnIndex] == this.dgvPicList.Columns[_editColumName]) {
         var PicID = (int)dgvPicList.Rows[rowIndex].Cells["PicID"].Value;
         var form = new PeoplePicInfoForm(true, PicID, null);
         form.callbackEvent += delegate {
             BindDataList();
         };
         form.ShowDialog();
     } else if (this.dgvPicList.Columns[columnIndex] == this.dgvPicList.Columns[_downloadColumName]) {
         var picID = (int)dgvPicList.Rows[rowIndex].Cells["PicID"].Value;
         var pic = new PeoplePicBLL().GetPeoplePicByID(picID).Data;
         if (pic == null) {
             MessageBox.Show("文件不存在!");
         }
         var projectDir = Path.GetDirectoryName(Path.GetDirectoryName(Application.StartupPath));
         var picPath = Path.Combine(projectDir, pic.PicPath);
         var saveFileDlg = new SaveFileDialog();
         saveFileDlg.Filter = SystemInfo.FileFilter;
         if (saveFileDlg.ShowDialog() == DialogResult.OK) {
             var stream = saveFileDlg.OpenFile();
             var sourceFileStream = new FileStream(picPath, FileMode.Open, FileAccess.Read);
             sourceFileStream.CopyTo(stream);
             stream.Close();
             sourceFileStream.Close();
         }
     }
 }
 private void InitControlValue()
 {
     if (this._currentPicID.HasValue) {
         var pic = new PeoplePicBLL().GetPeoplePicByID(this._currentPicID.Value).Data;
         this.txtPicTitle.Text = pic.PicTitle;
         this.txtPicPath.Text = Path.GetFileName(pic.PicPath);
         this.openFileDialog1.FileName = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(Application.StartupPath)), pic.PicPath);
     }
 }