private void btnAdd_Click(object sender, EventArgs e) { detail.AddDate = DateTime.Now; detail.Title = txtTitle.Text; detail.Rating = Convert.ToInt32(numerticRating.Value); detail.MemberID = Convert.ToInt32(cmbNames.SelectedValue); detail.CategoryID = Convert.ToInt32(cmbCategories.SelectedValue); detail.CommentContent = txtComment.Text; detail.IsApproved = cbIsApproved.Checked; if (detail.CategoryID == General.CommentCategory.meal) { detail.MealOptionID = Convert.ToInt32(cmbMeals.SelectedValue); } if (txtTitle.Text == "" || txtComment.Text == "") { MessageBox.Show("請輸入所有欄位"); } else { if (isUpdate) { commentBLL.Update(detail); MessageBox.Show("已修改評論"); } else { commentBLL.Add(detail); MessageBox.Show("已新增評論"); } frmComment.ShowComments(); this.Close(); } }
private void btnAdd_Click(object sender, EventArgs e) { if (!txtTitle.Enabled) { ClearTextboxes(); // Clear textboxes first. } else if (txtTitle.Text == "" || txtComment.Text == "") { MessageBox.Show("請填入所有欄位"); // Empty control. } else { detail = new CommentDetailDTO(); detail.Title = txtTitle.Text; detail.CommentContent = txtComment.Text; detail.CategoryID = Convert.ToInt32(cmbCategory.SelectedValue); detail.Rating = Convert.ToInt32(numericRating.Value); detail.MemberID = UserStatic.UserID; detail.IsApproved = false; detail.AddDate = DateTime.Now; if (detail.CategoryID == General.CommentCategory.meal) { detail.MealOptionID = Convert.ToInt32(cmbMeals.SelectedValue); } commentBLL.Add(detail); MessageBox.Show("已新增留言"); ClearTextboxes(); ShowComments(); // Refresh page. => Won't show comment before approved. } }
public void AddComment(CommentVM c) { Comment newC = new Comment(); newC.ID = Guid.NewGuid(); newC.TextContent = c.TextContent; newC.PostID = c.PostID; newC.UserID = new Guid(HttpContext.User.Identity.Name); commentBLL.Add(newC); if (postBLL.Get(c.PostID) != null) { postBLL.Get(c.PostID).Comments.Add(newC); } }
protected void Button1_Click(object sender, EventArgs e) { comM.description = txtContent.Text.Trim(); string name = Request.RawUrl.ToString(); comM.SendName = ViewState["loginName"].ToString(); comM.LinkMode = txtOther.Text.Trim(); comM.LinkName = txtName.Text.Trim(); if (comBll.Add(comM) > 0) { comM.description = ""; comM.SendName = ""; txtName.Text = ""; Response.Write("<script>alert('留言成功')</script>"); } else { Response.Write("<script>alert('留言失败')</script>"); } }