예제 #1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                ViewModel.tblComment newComment = new ViewModel.tblComment();
                newComment.Comment         = txtAdminComment.Text.FixFarsi();
                newComment.IDContent       = hfIDContent.Value.StringToGuid();
                newComment.ParentCommentID = hfIdComment.Value.StringToGuid();
                newComment.SenderEmail     = "";
                newComment.SenderWebSite   = "";
                newComment.SenderFName     = "";
                newComment.SenderLName     = "";
                newComment.SenderID        = Guid.Empty;
                newComment.Show            = true;
                newComment.Status          = 1;

                try
                {
                    bool ret;
                    if (((DataSet)Session["dsComment"]).Tables[0].Rows[0]["replyComment"].ToString() == "")
                    {
                        newComment.IDComment = Guid.NewGuid();
                        ret = BisComment.AddComment(newComment);
                    }
                    else
                    {
                        newComment.IDComment = Session["hfReplyID"].ToString().StringToGuid();
                        ret = BisComment.UpdateComment(newComment);
                    }
                    if (ret)
                    {
                        hfIdComment.Value = newComment.IDComment.ToString();
                        ScriptManager.RegisterStartupScript(this, GetType(), "OkMessage", "alert('اطلاعات ثبت شد!');", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('اشکال در ثبت اطلاعات!');", true);
                    }
                }
                catch
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "OkMessage", "alert('اشکال در برقراری ارتباط با دیتابیس!');", true);
                }
            }
        }
예제 #2
0
        protected void grdProductComment_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Guid IDComment = e.CommandArgument.ToString().StringToGuid(); //delete

            switch (e.CommandName)
            {
            case "EditProductCommentAdmin":
                try
                {
                    hfIdComment.Value = IDComment.ToString();
                    ViewModel.Search getComment = new ViewModel.Search();
                    getComment.Filter = " and tblComment.IDComment ='" + IDComment + "'";

                    DataSet ds = BisComment.GetCommentData(getComment);
                    if (!ds.Null_Ds())
                    {
                        txtFullName.Text     = ds.ReturnDataSetField("FullName");
                        txtEmail.Text        = ds.ReturnDataSetField("SenderEmail");
                        txtWebSite.Text      = ds.ReturnDataSetField("SenderWebSite");
                        txtUserComment.Text  = ds.ReturnDataSetField("Comment");
                        txtAdminComment.Text = ds.ReturnDataSetField("ReplyComment");
                        txtContent.Text      = ds.ReturnDataSetField("ProductName");
                        hfIDContent.Value    = ds.ReturnDataSetField("IDContent");

                        if (hfIDContent.Value == Guid.Empty.ToString())
                        {
                            divAdminComment.Visible = false;
                        }
                        else
                        {
                            divAdminComment.Visible = true;
                        }
                        Session["hfReplyID"]    = ((HiddenField)grdProductComment.Rows[((GridViewRow)(((Button)e.CommandSource).NamingContainer)).RowIndex].FindControl("hfReplyID")).Value;
                        divTable.Visible        = false;
                        divProductTable.Visible = false;
                        divInfo.Visible         = true;
                        Session["dsComment"]    = ds;
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('اشکال در واکشی اطلاعات!');", true);
                    }
                }
                catch
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "OkMessage", "alert('اشکال در برقراری ارتباط با دیتابیس!');", true);
                }
                break;

            case "DeleteProductCommentUser":

                try
                {
                    ViewModel.tblComment deleteCommentUser = new ViewModel.tblComment();
                    deleteCommentUser.IDContent       = null;
                    deleteCommentUser.SenderID        = null;
                    deleteCommentUser.ParentCommentID = null;
                    deleteCommentUser.IDComment       = IDComment;
                    bool retDel = BisComment.DeleteComment(deleteCommentUser);
                    if (retDel)
                    {
                        fillGrdProductComment();
                        ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('حذف اطلاعات با موفقیت انجام شد!');", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('اشکال در حذف اطلاعات!');", true);
                    }
                }
                catch
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "OkMessage", "alert('اشکال در برقراری ارتباط با دیتابیس!');", true);
                }
                break;

            case "DeleteProductCommentAdmin":

                try
                {
                    ViewModel.tblComment deleteCommentAdmin = new ViewModel.tblComment();

                    deleteCommentAdmin.IDContent       = null;
                    deleteCommentAdmin.SenderID        = null;
                    deleteCommentAdmin.ParentCommentID = null;
                    Session["hfReplyID"]         = ((HiddenField)grdProductComment.Rows[((GridViewRow)(((Button)e.CommandSource).NamingContainer)).RowIndex].FindControl("hfReplyID")).Value;
                    deleteCommentAdmin.IDComment = Session["hfReplyID"].ToString().StringToGuid();
                    if (deleteCommentAdmin.IDComment != Guid.Empty)
                    {
                        bool retDel = BisComment.DeleteComment(deleteCommentAdmin);
                        if (retDel)
                        {
                            fillGrdProductComment();
                            ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('حذف اطلاعات با موفقیت انجام شد!');", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('اشکال در حذف اطلاعات!');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('مدیر نظری ثبت نکرده است!');", true);
                    }
                }
                catch
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "OkMessage", "alert('اشکال در برقراری ارتباط با دیتابیس!');", true);
                }
                break;
            }
        }
예제 #3
0
 public void updateShowComment()
 {
     ViewModel.tblComment updateComment = new ViewModel.tblComment();
     BisComment.UpdateShowComment();
 }