private void btnSave_Click(object sender, System.EventArgs e) { string error = Validation(); if (!string.IsNullOrEmpty(error)) { MessageBox.Show(error, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DialogResult r = MessageBox.Show("Do you want to save?", "Confirmation", MessageBoxButtons.YesNo); if (r == DialogResult.Yes) { string fileName = DateTime.Now.Ticks.ToString() + "_" + openFileDialog.SafeFileName; tblPetDiary diary = new tblPetDiary { adopter = adopter.username, petId = (int)cboPetName.SelectedValue, diaryDetail = txtPetDiaryDetail.Text.Trim(), diaryImages = fileName, createDate = DateTime.Now, isRead = false }; bool result = TblPetDiaryDAO.Instance.CreatePetDiary(diary); if (result) { FileDAO.CopyImage(openFileDialog.FileName, fileName); MessageBox.Show("Saved successfully!", "Notification"); RefreshScreen(); } } }