protected void btnUpdate_Click(object sender, EventArgs e) { DataLayer dl = new DataLayer(); DataTable dtCurrentEntry = dl.GetAJEntryBy_UserAndDate(User.Identity.Name, DateTime.Now.Date); if (dtCurrentEntry.Rows.Count > 0) { int iEntryID = Convert.ToInt32(dtCurrentEntry.Rows[0].ItemArray[0]); dl.UpdateAJEntry(iEntryID, tbxAppreciate.Text); Session["resultMessage"] = "Your entry for today was updated successfuly!"; } else { dl.AddAJEntry(User.Identity.Name, DateTime.Now.Date, tbxAppreciate.Text); Session["resultMessage"] = "Your entry for today was added successfuly!"; } Session["resultColor"] = "#007700"; Session["resultTitle"] = "Success"; Session["resultReturnURL"] = "AppreciationJournal.aspx"; Response.Redirect("Result.aspx", true); }