예제 #1
0
 public ViewLibraryDCN(DCupNoteDataClassesDataContext _DDC)
 {
     InitializeComponent();
     DDC  = _DDC;
     _dcn = null;
     UpdateDCupNoteDGV();
 }
예제 #2
0
 public MainForm()
 {
     InitializeComponent();
     SetLayout();
     DDC = new DCupNoteDataClassesDataContext();
     //Dock = DockStyle.Fill;
     //DoubleBuffered = true;
 }
예제 #3
0
        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);
            }
        }