public ViewLibraryDCN(DCupNoteDataClassesDataContext _DDC) { InitializeComponent(); DDC = _DDC; _dcn = null; UpdateDCupNoteDGV(); }
public MainForm() { InitializeComponent(); SetLayout(); DDC = new DCupNoteDataClassesDataContext(); //Dock = DockStyle.Fill; //DoubleBuffered = true; }
private void okBtn_Click(object sender, EventArgs e) { try { if (String.IsNullOrWhiteSpace(idTB.Text) || pictureBox1.Image == null) { string message = ""; if (String.IsNullOrWhiteSpace(idTB.Text)) { message += "The ID must be filled.\n"; } if (pictureBox1.Image == null) { message += "The Image must be filled."; } MessageBox.Show(message, "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { DCupNoteDataClassesDataContext DDC = new DCupNoteDataClassesDataContext(); DCupNote dcupnote = (from p in DDC.DCupNotes where p.ID_DCupNote == idTB.Text select p).FirstOrDefault(); if (dcupnote != null && _dcn == null) { MessageBox.Show("The ID have been used by another data. Please use another ID.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { if (_dcn == null) { _dcn = new DCupNote(); _dcn.ID_DCupNote = idTB.Text; } _dcn.Title = titleTB.Text; _dcn.Notes_DCN = notesTB.Text; if (pictureBox1.Image != null) { fileByte = ImageToByteArray(pictureBox1.Image); fileBinary = new Binary(fileByte); _dcn.Image = fileBinary; } else { _dcn.Image = null; } this.DialogResult = DialogResult.OK; this.Close(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }