public ViewLibraryDCN(DCupNoteDataClassesDataContext _DDC) { InitializeComponent(); DDC = _DDC; _dcn = null; UpdateDCupNoteDGV(); }
private void SetAfterNewOrOpen(string id_dcupnote) { try { dcnOpen = (from dcn in DDC.DCupNotes where dcn.ID_DCupNote == id_dcupnote select dcn).FirstOrDefault(); if (dcnOpen.Image != null) { pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; pictureBox1.Image = ByteArrayToImage(dcnOpen.Image.ToArray()); } editBtn.Enabled = true; titleTB.Text = dcnOpen.Title; notesTB.Text = dcnOpen.Notes_DCN; UpdateNotesFLP(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void deleteBtn_Click(object sender, EventArgs e) { try { if (dCupNoteDGV.CurrentRow != null) { string selectedID = (string)dCupNoteDGV.CurrentRow.Cells[0].Value; if (MessageBox.Show("Do you want to delete this D'Cup Note?", "Question [Delete]", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { List <TagNote> listTN = (from tn in DDC.TagNotes where tn.ID_DCupNote == selectedID select tn).ToList(); if (listTN.Count > 0) { DDC.TagNotes.DeleteAllOnSubmit(listTN); } _dcn = (from d in DDC.DCupNotes where d.ID_DCupNote == selectedID select d).FirstOrDefault(); DDC.DCupNotes.DeleteOnSubmit(_dcn); DDC.SubmitChanges(); UpdateDCupNoteDGV(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void openBtn_Click(object sender, EventArgs e) { try { if (dCupNoteDGV.CurrentRow != null) { string selectedID = (string)dCupNoteDGV.CurrentRow.Cells[0].Value; _dcn = (from d in DDC.DCupNotes where d.ID_DCupNote == selectedID select d).FirstOrDefault(); this.DialogResult = DialogResult.OK; this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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); } }
public CreateNew() { InitializeComponent(); _dcn = null; setID(); }
partial void DeleteDCupNote(DCupNote instance);
partial void UpdateDCupNote(DCupNote instance);
partial void InsertDCupNote(DCupNote instance);