private void EnablePictureControls(bool enable) { if (enable == false) { labelPIB.Text = "Виберіть потрібний запис у таблиці"; pictureBox1.Image = null; m_bUploadPending = false; m_rowPicture = null; m_nRecordID = 0; } pictureBox1.Enabled = enable; buttonOpen.Enabled = enable; buttonUpload.Enabled = enable & m_bUploadPending; buttonDelete.Enabled = enable & (m_rowPicture != null); buttonSaveImageAs.Enabled = enable & (m_rowPicture != null); }
private void ReadPictureFromDB() { MriyaUserDataDataSet.UserPhotoDataTable tablePhoto = new MriyaUserDataDataSet.UserPhotoDataTable(); MriyaUserDataDataSetTableAdapters.UserPhotoTableAdapter tablePhotoAdapter = new MriyaUserDataDataSetTableAdapters.UserPhotoTableAdapter(); m_rowPicture = null; pictureBox1.Image = null; if (m_nRecordID < 1) { return; } tablePhoto.Clear(); try { tablePhotoAdapter.FillById(tablePhoto, m_nRecordID); } catch (Exception ex) { MessageBox.Show("Помилка завантаження фотографії:\r\n" + ex.Message, "Загрузка фото", MessageBoxButtons.OK, MessageBoxIcon.Warning); pictureBox1.Refresh(); return; } if (tablePhoto.Rows.Count > 0) { m_rowPicture = tablePhoto.Rows[0] as MriyaUserDataDataSet.UserPhotoRow; } if (m_rowPicture != null) { System.IO.MemoryStream streamMem = new System.IO.MemoryStream(m_rowPicture.PhotoBinary); pictureBox1.Image = System.Drawing.Image.FromStream(streamMem); } else { pictureBox1.Refresh(); } m_bUploadPending = false; buttonUpload.Enabled = false; buttonDelete.Enabled = (m_rowPicture != null); buttonSaveImageAs.Enabled = (m_rowPicture != null); }
private void ReadPictureFromDB() { MriyaUserDataDataSet.UserPhotoDataTable tablePhoto = new MriyaUserDataDataSet.UserPhotoDataTable(); MriyaUserDataDataSetTableAdapters.UserPhotoTableAdapter tablePhotoAdapter = new MriyaUserDataDataSetTableAdapters.UserPhotoTableAdapter(); m_rowPicture = null; pictureBox1.Image = null; if (m_nRecordID < 1) return; tablePhoto.Clear(); try { tablePhotoAdapter.FillById(tablePhoto, m_nRecordID); } catch(Exception ex) { MessageBox.Show("Помилка завантаження фотографії:\r\n" + ex.Message, "Загрузка фото", MessageBoxButtons.OK, MessageBoxIcon.Warning); pictureBox1.Refresh(); return; } if (tablePhoto.Rows.Count > 0) m_rowPicture = tablePhoto.Rows[0] as MriyaUserDataDataSet.UserPhotoRow; if (m_rowPicture != null) { System.IO.MemoryStream streamMem = new System.IO.MemoryStream(m_rowPicture.PhotoBinary); pictureBox1.Image = System.Drawing.Image.FromStream(streamMem); } else { pictureBox1.Refresh(); } m_bUploadPending = false; buttonUpload.Enabled = false; buttonDelete.Enabled = (m_rowPicture != null); buttonSaveImageAs.Enabled = (m_rowPicture != null); }
private void EnablePictureControls(bool enable) { if (enable == false) { labelPIB.Text = "Виберіть потрібний запис у таблиці"; pictureBox1.Image = null; m_bUploadPending = false; m_rowPicture = null; m_nRecordID = 0; } pictureBox1.Enabled = enable; buttonOpen.Enabled = enable; buttonUpload.Enabled = enable & m_bUploadPending; buttonDelete.Enabled = enable & (m_rowPicture != null); buttonSaveImageAs.Enabled = enable & (m_rowPicture != null); }