public void ShowAttachments(Attachment[] attachments) { if (attachments == null) { throw new ArgumentNullException("attachments"); } attachmentsListView.BeginUpdate(); attachmentsListView.Items.Clear(); foreach (var attachment in attachments) { ListViewItem lvi = new ListViewItem(); lvi.Text = attachment.Name; lvi.SubItems.Add(string.Format("{0}", attachment.Size)); lvi.Tag = attachment; attachmentsListView.Items.Add(lvi); } attachmentsListView.EndUpdate(); attachmentsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); return; }
public void RetrieveAttachment(Attachment attachment) { if (attachment == null) { throw new ArgumentNullException("attachment"); } attachment.Name = nameTextBox.Text; attachment.SetContents(contents); return; }
public void ShowAttachment(Attachment attachment) { if (attachment == null) { throw new ArgumentNullException("attachment"); } nameTextBox.Text = attachment.Name; sizeTextBox.Text = string.Format("{0}", attachment.Size); contents = attachment.GetContents(); return; }
public static Attachment GetAttachment(int id) { AttachmentsTableAdapter tableAdapter = Database.AttachmentsTableAdapter; PeygirDatabaseDataSet.AttachmentsDataTable rows = tableAdapter.GetDataByID(id); if (rows.Count == 1) { // Found. Attachment attachment = new Attachment(rows[0]); return attachment; } // Not found. return null; }
public static Attachment[] GetAttachmentsWithoutContents(int ticketID) { AttachmentsWithoutContentsTableAdapter tableAdapter = Database.AttachmentsWithoutContentsTableAdapter; PeygirDatabaseDataSet.AttachmentsWithoutContentsDataTable rows = tableAdapter.GetDataByTicketID(ticketID); // Create list. List<Attachment> attachments = new List<Attachment>(); foreach (var row in rows) { // Add. Attachment attachment = new Attachment(row); attachments.Add(attachment); } return attachments.ToArray(); }