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

📄 serviceui.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.WebSite.Admin.Crm
{
    using PowerEasy.Accessories;
    using PowerEasy.Common;
    using PowerEasy.Components;
    using PowerEasy.Controls;
    using PowerEasy.Crm;
    using PowerEasy.Model.Crm;
    using PowerEasy.ModelControls;
    using PowerEasy.Web.UI;
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class ServiceUI : AdminPage, ICallbackEventHandler
    {
        protected Button BtnReturn;
        protected Button BtnSave;
        private string contacter;
        protected DateValidator DateValidator1;
        protected DropDownList DropContacterID;
        protected DropDownList DropServiceMode;
        protected DropDownList DropServiceResult;
        protected DropDownList DropServiceType;
        protected DropDownList DropTakeTime;
        protected HiddenField HdnAction;
        protected HiddenField HdnItemId;
        protected Literal LtrTitle;
        protected CrmSelectControl SelectClient;
        protected CrmSelectControl SelectProcessor;
        protected ScriptManager SmgeProperties;
        protected ExtendedSiteMapPath SmpNavigator;
        protected TextBox TxtFeedback;
        protected TextBox TxtRemark;
        protected TextBox TxtServiceContent;
        protected TextBox TxtServiceTime;
        protected TextBox TxtServiceTitle;
        protected PowerEasy.Controls.RequiredFieldValidator ValrClientName;
        protected PowerEasy.Controls.RequiredFieldValidator ValrTitle;

        protected void BtnReturn_Click(object sender, EventArgs e)
        {
            int num = BasePage.RequestInt32("OrderID");
            if (num > 0)
            {
                BasePage.ResponseRedirect("../Shop/OrderManage.aspx?OrderID=" + num);
            }
            else
            {
                BasePage.ResponseRedirect("ServiceManage.aspx");
            }
        }

        protected void BtnSave_Click(object sender, EventArgs e)
        {
            if (!base.IsValid)
            {
                AdminPage.WriteErrMsg("错误,无效操作!", "");
            }
            else
            {
                ServiceInfo info;
                if (this.ViewState["serviceInfo"] == null)
                {
                    info = new ServiceInfo();
                    info.Inputer = PEContext.Current.Admin.AdminName;
                }
                else
                {
                    info = this.ViewState["serviceInfo"] as ServiceInfo;
                }
                info.ClientId = DataConverter.CLng(this.SelectClient.DataKey);
                info.ContacterId = DataConverter.CLng(base.Request.Form[this.DropContacterID.UniqueID]);
                info.ServiceTime = DataConverter.CDate(this.TxtServiceTime.Text);
                info.ServiceType = this.DropServiceType.SelectedValue;
                info.ServiceMode = this.DropServiceMode.SelectedValue;
                info.ServiceTitle = this.TxtServiceTitle.Text;
                info.ServiceContent = this.TxtServiceContent.Text;
                info.ServiceResult = DataConverter.CLng(this.DropServiceResult.SelectedValue);
                info.TakeTime = DataConverter.CLng(this.DropTakeTime.SelectedValue);
                info.Processor = this.SelectProcessor.Text;
                info.Feedback = this.TxtFeedback.Text;
                info.ConfirmScore = -1;
                info.Remark = this.TxtRemark.Text;
                bool ok = false;
                string strMsg = "";
                string str2 = this.HdnAction.Value;
                if (str2 != null)
                {
                    if (!(str2 == "Modify"))
                    {
                        if (str2 == "Add")
                        {
                            ok = Service.Add(info);
                            strMsg = "添加";
                        }
                    }
                    else
                    {
                        int num = DataConverter.CLng(this.HdnItemId.Value);
                        if (num != 0)
                        {
                            info.ItemId = num;
                            ok = Service.Update(info);
                            strMsg = "修改";
                        }
                    }
                }
                this.WriteMsg(ok, strMsg);
            }
        }

        private void DropContacterIdBind(int clientId)
        {
            Dictionary<int, string> contacterListByClientId = Contacter.GetContacterListByClientId(clientId);
            if (contacterListByClientId.Count > 0)
            {
                this.DropContacterID.DataSource = contacterListByClientId;
                this.DropContacterID.DataValueField = "key";
                this.DropContacterID.DataTextField = "value";
                this.DropContacterID.DataBind();
            }
        }

        protected void DropControlsDataBind()
        {
            Choiceset.DropDownListDataBind("PE_ServiceItem", "ServiceType", this.DropServiceType);
            Choiceset.DropDownListDataBind("PE_ServiceItem", "ServiceMode", this.DropServiceMode);
            Choiceset.DropDownListDataBind("PE_ServiceItem", "TakeTime", this.DropTakeTime);
            Choiceset.DropDownListDataBind("PE_ServiceItem", "Result", this.DropServiceResult);
        }

        public string GetCallbackResult()
        {
            return this.contacter;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                this.DropControlsDataBind();
                if (BasePage.RequestString("Action") == "Modify")
                {
                    int itemId = BasePage.RequestInt32("ItemID");
                    if (itemId == 0)
                    {
                        AdminPage.WriteErrMsg("请指定要修改的服务记录的ID!", "");
                    }
                    else
                    {
                        this.LtrTitle.Text = "修改客户服务记录";
                        this.HdnAction.Value = "Modify";
                        this.ShowModify(itemId);
                    }
                }
                else
                {
                    this.LtrTitle.Text = "添加客户服务记录";
                    this.SelectProcessor.Text = PEContext.Current.Admin.AdminName;
                    this.HdnAction.Value = "Add";
                    this.TxtServiceTime.Text = DateTime.Now.ToString();
                    int clientId = BasePage.RequestInt32("ClientID");
                    if (clientId > 0)
                    {
                        this.ShowAddInfo(clientId);
                    }
                }
                string str = base.ClientScript.GetCallbackEventReference(this, "arg", "BindContacterList", "context");
                string script = "function GetContacterList(arg,context){" + str + ";}";
                base.ClientScript.RegisterClientScriptBlock(base.GetType(), "GetContacterList", script, true);
            }
        }

        public void RaiseCallbackEvent(string eventArgument)
        {
            Dictionary<int, string> contacterListByClientId = Contacter.GetContacterListByClientId(DataConverter.CLng(eventArgument));
            StringBuilder builder = new StringBuilder(0x100);
            builder.Append("<select name='" + this.DropContacterID.UniqueID + "' id='" + this.DropContacterID.ClientID + "'>");
            foreach (KeyValuePair<int, string> pair in contacterListByClientId)
            {
                builder.Append("<option value='" + pair.Key.ToString() + "'>" + pair.Value + "</option>");
            }
            builder.Append("</select>");
            this.contacter = builder.ToString();
        }

        private void ShowAddInfo(int clientId)
        {
            this.SelectClient.Text = Client.GetClientNameById(clientId);
            this.SelectClient.DataKey = clientId.ToString();
            this.DropContacterIdBind(clientId);
        }

        private void ShowModify(int itemId)
        {
            ServiceInfo serviceById = Service.GetServiceById(itemId);
            this.ViewState["serviceInfo"] = serviceById;
            this.SelectClient.DataKey = serviceById.ClientId.ToString();
            this.HdnItemId.Value = itemId.ToString();
            this.SelectClient.Text = DataSecurity.HtmlDecode(serviceById.ClientName);
            this.TxtServiceTime.Text = DataSecurity.HtmlDecode(serviceById.ServiceTime.ToString());
            this.TxtServiceTitle.Text = DataSecurity.HtmlDecode(serviceById.ServiceTitle);
            this.TxtServiceContent.Text = DataSecurity.HtmlDecode(serviceById.ServiceContent);
            this.SelectProcessor.Text = DataSecurity.HtmlDecode(serviceById.Processor);
            this.SelectProcessor.UrlArgs = "DefaultValue=" + this.SelectProcessor.Text;
            this.TxtFeedback.Text = DataSecurity.HtmlDecode(serviceById.Feedback);
            this.TxtRemark.Text = DataSecurity.HtmlDecode(serviceById.Remark);
            this.DropServiceType.SelectedValue = serviceById.ServiceType;
            this.DropServiceMode.SelectedValue = serviceById.ServiceMode;
            this.DropServiceResult.SelectedValue = serviceById.ServiceResult.ToString();
            this.DropTakeTime.SelectedValue = serviceById.TakeTime.ToString();
            this.DropContacterIdBind(serviceById.ClientId);
            this.DropContacterID.SelectedValue = serviceById.ContacterId.ToString();
        }

        private void WriteMsg(bool ok, string strMsg)
        {
            if (ok)
            {
                int num = BasePage.RequestInt32("OrderID");
                string returnurl = "";
                if (num > 0)
                {
                    returnurl = "../Shop/OrderManage.aspx?OrderID=" + num;
                }
                else
                {
                    returnurl = "ServiceManage.aspx";
                }
                AdminPage.WriteSuccessMsg("恭喜," + strMsg + "服务成功!", returnurl);
            }
            else
            {
                AdminPage.WriteErrMsg("错误," + strMsg + "失败!", "");
            }
        }
    }
}

⌨️ 快捷键说明

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