⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 replyquestion.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.WebSite.Admin.Crm
{
    using PowerEasy.AccessManage;
    using PowerEasy.Common;
    using PowerEasy.Components;
    using PowerEasy.Controls;
    using PowerEasy.Controls.Editor;
    using PowerEasy.Crm;
    using PowerEasy.Enumerations;
    using PowerEasy.Model.Crm;
    using PowerEasy.Model.UserManage;
    using PowerEasy.UserManage;
    using PowerEasy.Web.UI;
    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Xml;

    public class ReplyQuestion : AdminPage
    {
        protected Button BtnCancle2;
        protected ImageButton btnDel;
        protected Button BtnReply;
        protected Button BtnReturn;
        protected Button BtnSaveSetting;
        protected CheckBox ChkIsPublic;
        protected CheckBox ChkIsPublic2;
        protected CheckBox ChkIsSolved;
        protected CheckBox ChkIsSolved2;
        protected CheckBox ChkNoScore;
        protected DropDownList DropQueryReplyText;
        protected DropDownList DropQuestionType;
        protected DropDownList DropScore;
        protected FckEditorValidator FevReplyContent;
        protected HiddenField HdnOldSolved;
        protected HiddenField HdnQuestionCreator;
        protected ImageButton IbtnEditUserQuestion;
        protected Image ImgReply2;
        protected Label Lbl_IP;
        protected Label LblAntiVirus;
        protected Label LblCreateTime;
        protected Label LblDBType;
        protected Label LblErrorCode;
        protected Label LblFireWall;
        protected Label LblProblemTips;
        protected Label LblProductVersion;
        protected Label LblQuestionContent;
        protected Label LblQuestionType;
        protected Label LblStatus;
        protected Label LblSystemType;
        protected Label LblTitle;
        protected Label LblUrl;
        protected HyperLink LnkCreator;
        protected HyperLink LnkUserQuestion;
        private bool m_IsSolved;
        protected ObjectDataSource OdsReply;
        protected Panel PnlReplyContent;
        protected Repeater RptReply;
        protected ExtendedSiteMapPath SmpNavigator;
        protected PEeditor TxtQuestionContent;

        protected void BtnDel_Click(object sender, ImageClickEventArgs e)
        {
            int questionId = BasePage.RequestInt32("ID");
            if (Question.Delete(questionId))
            {
                Reply.DeleteByQuestionId(questionId);
                AdminPage.WriteSuccessMsg("问题删除成功!", "ServiceCenterManage.aspx");
            }
            else
            {
                AdminPage.WriteErrMsg("问题删除失败!");
            }
        }

        protected void BtnReply_Click(object sender, EventArgs e)
        {
            if (base.IsValid)
            {
                bool flag = false;
                ReplyInfo info = new ReplyInfo();
                info.Id = Reply.GetMaxId() + 1;
                info.QuestionId = BasePage.RequestInt32("ID");
                info.ReplyCreator = PEContext.Current.Admin.AdminName;
                info.ReplyTime = DateTime.Now;
                info.ReplyContent = this.TxtQuestionContent.Value;
                if (Reply.Add(info))
                {
                    int score = DataConverter.CLng(this.DropScore.SelectedValue);
                    if (this.ChkNoScore.Checked)
                    {
                        score = 0;
                    }
                    flag = Question.Update(info.QuestionId, info.ReplyCreator, info.ReplyTime, true, this.ChkIsPublic.Checked, this.ChkIsSolved.Checked, score);
                }
                if (flag)
                {
                    if (!this.ChkNoScore.Checked)
                    {
                        this.ProcessUserPoint(this.ChkIsSolved.Checked);
                    }
                    this.InitControls();
                    this.RptReply.DataBind();
                    this.TxtQuestionContent.Value = string.Empty;
                }
                else
                {
                    AdminPage.WriteErrMsg("回复失败,请认真检查!");
                }
            }
        }

        protected void BtnSaveSetting_Click(object sender, EventArgs e)
        {
            int questionId = BasePage.RequestInt32("ID");
            if (Question.SaveQuestionSetting(questionId, DataConverter.CLng(this.DropQuestionType.SelectedValue), DataConverter.CLng(this.DropScore.SelectedValue), this.ChkIsPublic2.Checked, this.ChkIsSolved2.Checked))
            {
                this.ProcessUserPoint(this.ChkIsSolved2.Checked);
                AdminPage.WriteSuccessMsg("问题设置成功!", "ReplyQuestion.aspx?ID=" + questionId.ToString());
            }
            else
            {
                AdminPage.WriteErrMsg("问题设置失败!");
            }
        }

        private void DropDownListDataBind()
        {
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath("~/Config/Question.Config"));
            XmlNodeList list = document.SelectNodes("Config/QuestionDifficulty/Item");
            this.DropScore.Items.Add(new ListItem("不扣动易币", "0"));
            foreach (XmlNode node in list)
            {
                this.DropScore.Items.Add(new ListItem(node.Attributes["Text"].Value, node.Attributes["Value"].Value.Trim()));
            }
            XmlNodeList list2 = document.SelectNodes("Config/QueryReplyText/Item");
            if (list2.Count <= 0)
            {
                this.DropQueryReplyText.Visible = false;
            }
            else
            {
                this.DropQueryReplyText.Items.Add(new ListItem("快速回复...", "0"));
                foreach (XmlNode node2 in list2)
                {
                    string demand = node2.Attributes["Text"].Value;
                    string text = StringHelper.SubString(demand, 30, "...");
                    this.DropQueryReplyText.Items.Add(new ListItem(text, demand));
                }
            }
            this.DropQuestionType.DataSource = PowerEasy.Crm.QuestionType.GetTypeList();
            this.DropQuestionType.DataBind();
        }

        protected void IbtnEditUserProblem_Click(object sender, ImageClickEventArgs e)
        {
            BasePage.ResponseRedirect("EditQuestion.aspx?ID=" + BasePage.RequestInt32("ID").ToString());
        }

        private void InitControls()
        {
            QuestionInfo questionById = Question.GetQuestionById(BasePage.RequestInt32("ID"));
            if (questionById.IsReply)
            {
                this.DropScore.Enabled = RolePermissions.AccessCheck(OperateCode.ModifyQuestionDiff);
            }
            BasePage.SetSelectedIndexByValue(this.DropQuestionType, questionById.TypeId.ToString());
            BasePage.SetSelectedIndexByValue(this.DropScore, questionById.Score.ToString());
            if (this.DropScore.SelectedValue == "0")
            {
                this.ChkNoScore.Checked = true;
            }
            else
            {
                this.ValidEditProblemUserPoint(questionById.QuestionCreator, questionById.Score);
            }
            this.Lbl_IP.Text = questionById.IP;
            this.LblAntiVirus.Text = questionById.AntiVirus;
            this.LblCreateTime.Text = questionById.QuestionCreateTime.ToString("yyyy-MM-dd HH:mm:ss");
            this.LblDBType.Text = questionById.ProductDBType;
            this.LblErrorCode.Text = questionById.ErrorCode;
            this.LblQuestionType.Text = questionById.TypeName;
            this.LblFireWall.Text = questionById.FireWall;
            this.LblQuestionContent.Text = questionById.QuestionContent;
            this.LblProblemTips.Text = questionById.ErrorText;
            this.LnkCreator.Text = questionById.QuestionCreator;
            this.HdnQuestionCreator.Value = questionById.QuestionCreator;
            this.LnkCreator.NavigateUrl = "../../User/UserShow.aspx?UserName=" + questionById.QuestionCreator;
            this.LnkUserQuestion.NavigateUrl = "ServiceCenterManage.aspx?SearchType=8&Keyword=" + questionById.QuestionCreator;
            this.LblProductVersion.Text = questionById.ProductVersion;
            this.LblStatus.Text = questionById.IsSolved ? "已解决" : "未解决";
            this.m_IsSolved = questionById.IsSolved;
            this.HdnOldSolved.Value = questionById.IsSolved.ToString();
            this.ImgReply2.Visible = !questionById.IsSolved;
            this.LblSystemType.Text = questionById.SystemType;
            this.LblTitle.Text = questionById.QuestionTitle;
            this.LblUrl.Text = !string.IsNullOrEmpty(questionById.Url) ? ("<a href='" + questionById.Url + "' target='_blank'>" + questionById.Url + "</a>") : "";
            this.ChkIsSolved.Checked = this.ChkIsSolved2.Checked = questionById.IsSolved;
            this.ChkIsPublic.Checked = this.ChkIsPublic2.Checked = questionById.IsPublic;
            this.BtnCancle2.Visible = questionById.IsSolved;
            this.PnlReplyContent.Visible = !questionById.IsSolved;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                if (BasePage.RequestInt32("ID") <= 0)
                {
                    AdminPage.WriteErrMsg("请选择要查看的客户问题!");
                }
                else
                {
                    this.DropDownListDataBind();
                    this.InitControls();
                }
            }
        }

        private void ProcessUserPoint(bool newIsSolved)
        {
            bool flag = DataConverter.CBool(this.HdnOldSolved.Value);
            if (newIsSolved)
            {
                if (!flag)
                {
                    UserInfo usersByUserName = Users.GetUsersByUserName(this.LnkCreator.Text);
                    IEncourageStrategy<int> strategy = new UserPoint();
                    strategy.IncreaseForUsers(usersByUserName.UserId.ToString(), -Math.Abs(DataConverter.CLng(this.DropScore.SelectedValue)), "客服中心的提问得到解决,扣除相应的动易币。", true, "");
                }
            }
            else if (flag)
            {
                UserInfo info2 = Users.GetUsersByUserName(this.LnkCreator.Text);
                IEncourageStrategy<int> strategy2 = new UserPoint();
                strategy2.IncreaseForUsers(info2.UserId.ToString(), Math.Abs(DataConverter.CLng(this.DropScore.SelectedValue)), "客服中心提交的问题从解决状态恢复到未解决,返还相应的动易币。", true, "");
            }
        }

        protected void RptReply_ItemCommand(object source, CommandEventArgs e)
        {
            if ((e.CommandName == "Delete") && Reply.DeleteById(DataConverter.CLng(e.CommandArgument)))
            {
                int questionId = BasePage.RequestInt32("ID");
                ReplyInfo lastReplyById = Reply.GetLastReplyById(questionId);
                if (lastReplyById.IsNull)
                {
                    QuestionInfo questionById = Question.GetQuestionById(questionId);
                    questionById.IsReply = false;
                    questionById.IsSolved = false;
                    questionById.ReplyCreator = string.Empty;
                    questionById.ReplyTime = null;
                    Question.Update(questionById);
                }
                else
                {
                    QuestionInfo info = Question.GetQuestionById(questionId);
                    info.ReplyCreator = lastReplyById.ReplyCreator;
                    info.ReplyTime = new DateTime?(lastReplyById.ReplyTime);
                    Question.Update(info);
                }
                this.RptReply.DataBind();
            }
        }

        protected void RptReply_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
            {
                ReplyInfo dataItem = (ReplyInfo) e.Item.DataItem;
                if (!dataItem.IsNull)
                {
                    Literal literal = (Literal) e.Item.FindControl("LtrReplyTitle");
                    if (string.Compare(dataItem.ReplyCreator, this.HdnQuestionCreator.Value, true) == 0)
                    {
                        literal.Text = "<img border='0' src='../../../Admin/images/Male.gif' />用户<b>" + dataItem.ReplyCreator + "&nbsp;&nbsp;</b>于<b>" + dataItem.ReplyTime.ToString("yyyy-MM-dd HH:mm:ss") + "</b>继续提问";
                    }
                    else
                    {
                        literal.Text = "<img border='0' src='../../../Admin/images/Admin.gif' />管理员<b>" + dataItem.ReplyCreator + "&nbsp;&nbsp;</b>于<b>" + dataItem.ReplyTime.ToString("yyyy-MM-dd HH:mm:ss") + "</b>回复";
                    }
                    Image image = (Image) e.Item.FindControl("ImgReply");
                    image.Visible = !this.m_IsSolved;
                    Label label = (Label) e.Item.FindControl("ReplyContentLabel");
                    label.Text = dataItem.ReplyContent;
                }
            }
        }

        private void ValidEditProblemUserPoint(string userName, int currentProbolemPoint)
        {
            int num = Question.GetUserPointByUserName(userName) + currentProbolemPoint;
            foreach (ListItem item in this.DropScore.Items)
            {
                if (DataConverter.CLng(item.Value) > num)
                {
                    item.Enabled = false;
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -