private void btnAddRow_Click(object sender, EventArgs e) { NoticeAttachmentDto dto = new NoticeAttachmentDto(); dto.StatusType = 'I'; dataHandler.AddRow(dto); }
//下载文件 private void btnDownFile_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { NoticeAttachmentDto dto = grvAttachment.GetRow(grvAttachment.FocusedRowHandle) as NoticeAttachmentDto; if (dto.FileExist == false) { return; } SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.Filter = "All Files|*.*"; saveDialog.FileName = dto.AttachName; DialogResult result = saveDialog.ShowDialog(); if (result == DialogResult.OK) { byte[] filebyte = webService.DownNoticeAttachment(NoticeID, dto.AttachName); if (filebyte != null) { MemoryStream buf = new MemoryStream(filebyte); FileStream fs = new FileStream(saveDialog.FileName, FileMode.OpenOrCreate); buf.WriteTo(fs); buf.Close(); fs.Close(); buf = null; fs = null; } } }
private void grvAttachment_ShowingEditor(object sender, CancelEventArgs e) { NoticeAttachmentDto dto = grvAttachment.GetRow(grvAttachment.FocusedRowHandle) as NoticeAttachmentDto; if (grvAttachment.FocusedColumn == gcAttachName || (grvAttachment.FocusedColumn == gcSelectFile && dto.FileExist == true)) { e.Cancel = true; } }
private void SearchNotice(string noticeID) { DataSet ds1 = webService.GetNoticeByNoticeID(noticeID); List <NoticeDto> noteList = new List <NoticeDto>(); if (ds1.Tables[0].Rows.Count > 0) { NoticeDto dto = new NoticeDto(); dto.NoticeID = ds1.Tables[0].Rows[0]["NoticeID"].ToString(); dto.NoticeTitle = ds1.Tables[0].Rows[0]["NoticeTitle"].ToString(); dto.NoticeContent = ds1.Tables[0].Rows[0]["NoticeContent"].ToString(); this.NoticeID = dto.NoticeID; txtTitle.Text = dto.NoticeTitle; txtContent.Text = dto.NoticeContent; } DataSet ds2 = webService.GetAllNoticeAttachment(NoticeID); List <NoticeAttachmentDto> noticeAttachmentList = new List <NoticeAttachmentDto>(); if (ds2.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds2.Tables[0].Rows.Count; i++) { NoticeAttachmentDto dto = new NoticeAttachmentDto(); dto.AttachName = ds2.Tables[0].Rows[i]["AttachName"].ToString(); dto.SeqNO = Convert.ToInt32(ds2.Tables[0].Rows[i]["SeqNO"]); if (!string.IsNullOrEmpty(dto.AttachName)) { dto.FileExist = true; } else { dto.FileExist = false; } noticeAttachmentList.Add(dto); } } grcAttachment.DataSource = noticeAttachmentList; }