コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //判断权限
            if (!CheckGrant(global::Common.Enum.TravelPermission.短信中心_短信中心_栏目))
            {
                Utils.ResponseNoPermit(global::Common.Enum.TravelPermission.短信中心_短信中心_栏目, true);
                return;
            }
            string custId = Utils.GetQueryStringValue("custid"); //客户Id
            string method = Utils.GetFormValue("hidMethod");     //当前操作

            EyouSoft.BLL.SMSStructure.CustomerList custBll = new EyouSoft.BLL.SMSStructure.CustomerList();
            if (method != "")
            {
                #region 保存客户
                bool   result   = false;
                string showMess = "数据保存成功!";
                if (method == "save" || method == "continue")
                {
                    #region 保存客户
                    EyouSoft.Model.SMSStructure.CustomerList custModel = new EyouSoft.Model.SMSStructure.CustomerList();
                    custModel.CustomerCompanyName = Utils.InputText(txtCompanyName.Value); //单位名
                    custModel.MobileNumber        = Utils.InputText(txtMobile.Value);      //手机
                    custModel.ReMark = Utils.InputText(txtRemark.Value, 200);              //备注
                    custModel.CustomerContactName = Utils.InputText(txtUserName.Value);    //姓名
                    custModel.ClassID             = Utils.GetInt(Utils.GetFormValue(selClass.UniqueID));
                    custModel.CompanyID           = CurrentUserCompanyID;
                    custModel.IssueTime           = DateTime.Now;
                    custModel.UserID = SiteUserInfo.ID;
                    custModel.ID     = custId;

                    if (custBll.IsExistCustomerMobile(CurrentUserCompanyID, custId, custModel.MobileNumber))
                    {
                        MessageBox.Show(this, "该号码已经存在!");
                        IList <EyouSoft.Model.SMSStructure.CustomerClass> classList = custBll.GetCustomerClass(CurrentUserCompanyID);
                        if (classList != null && classList.Count > 0)
                        {
                            selClass.DataTextField  = "ClassName";
                            selClass.DataValueField = "ID";
                            selClass.DataSource     = classList;
                            selClass.DataBind();
                        }
                        selClass.Items.Insert(0, new ListItem("请选择", ""));
                        return;
                    }
                    if (custId != "")
                    {
                        result = custBll.UpdateCustomerList(custModel);
                    }
                    else
                    {
                        result = custBll.AddCustomerList(custModel);
                    }
                    if (!result)
                    {
                        showMess = "数据保存失败!";
                    }
                    if (method == "save")
                    {
                        MessageBox.ResponseScript(this, string.Format(";alert('{0}');window.parent.Boxy.getIframeDialog('{1}').hide();window.parent.location='/SMS/SmsCustomerList.aspx';", showMess, Utils.GetQueryStringValue("iframeId")));
                    }
                    else
                    {
                        MessageBox.ShowAndRedirect(this, showMess, "EditSmsCustomer.aspx");
                    }
                    return;

                    #endregion
                }
                if (method == "addClass")
                {
                    #region 添加客户类别
                    string className = Utils.GetFormValue("className");
                    EyouSoft.Model.SMSStructure.CustomerClass custClass =
                        new EyouSoft.Model.SMSStructure.CustomerClass
                    {
                        ClassName = className,
                        CompanyID = CurrentUserCompanyID,
                        IssueTime = DateTime.Now,
                        UserID    = SiteUserInfo.ID
                    };

                    int classId = custBll.AddCustomClass(custClass);
                    //添加类别
                    Utils.ResponseMeg(classId != 0, classId.ToString());
                    return;

                    #endregion
                }
                if (method == "delClass")
                {
                    #region  除客户类别
                    int classId = Utils.GetInt(Utils.GetFormValue("classId"));
                    //删除类别
                    result = custBll.DeleteCustomClass(classId);
                    Utils.ResponseMeg(result, string.Empty);
                    return;

                    #endregion
                }
                #endregion
            }
            else
            {
                #region 初始化客户
                //绑定客户类别
                IList <EyouSoft.Model.SMSStructure.CustomerClass> classList = custBll.GetCustomerClass(CurrentUserCompanyID);
                if (classList != null && classList.Count > 0)
                {
                    selClass.DataTextField  = "ClassName";
                    selClass.DataValueField = "ID";
                    selClass.DataSource     = classList;
                    selClass.DataBind();
                }
                selClass.Items.Insert(0, new ListItem("请选择", ""));
                //初始化客户
                if (custId != "")
                {
                    EyouSoft.Model.SMSStructure.CustomerList custModel = custBll.GetCustomer(custId);
                    if (custModel != null)
                    {
                        txtUserName.Value    = custModel.CustomerContactName;
                        txtRemark.Value      = custModel.ReMark;
                        txtMobile.Value      = custModel.MobileNumber;
                        txtCompanyName.Value = custModel.CustomerCompanyName;
                        selClass.Value       = custModel.ClassID.ToString();
                    }
                }
                #endregion
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //判断权限
            if (!CheckGrant(global::Common.Enum.TravelPermission.短信中心_短信中心_栏目))
            {
                Utils.ResponseNoPermit(global::Common.Enum.TravelPermission.短信中心_短信中心_栏目, true);
                return;
            }
            EyouSoft.BLL.SMSStructure.CustomerList custBll = new EyouSoft.BLL.SMSStructure.CustomerList();
            //绑定客户类别
            IList <EyouSoft.Model.SMSStructure.CustomerClass> classList = custBll.GetCustomerClass(CurrentUserCompanyID);

            if (classList != null && classList.Count > 0)
            {
                selCustType.DataTextField  = "ClassName";
                selCustType.DataValueField = "ID";
                selCustType.DataSource     = classList;
                selCustType.DataBind();
            }
            selCustType.Items.Insert(0, new ListItem("请选择", ""));

            string method = Utils.GetQueryStringValue("method");

            pageIndex = Utils.GetInt(Utils.GetQueryStringValue("Page"), 1);
            itemIndex = (pageIndex - 1) * pageSize + 1;
            //删除客户
            if (method == "del")
            {
                string custid = Utils.GetQueryStringValue("custid");
                bool   result = custBll.DeleteCustomerList(custid.Split(','));
                Utils.ResponseMeg(result, string.Empty);
                return;
            }
            //查询条件
            string userName = Request.QueryString["username"];//客户名

            userName = !string.IsNullOrEmpty(userName) ? Utils.InputText(Server.UrlDecode(userName)) : "";
            string mobile = Request.QueryString["mobile"];//手机号

            mobile = !string.IsNullOrEmpty(mobile) ? Utils.InputText(Server.UrlDecode(mobile)) : "";
            string companyname = Request.QueryString["companyname"];//单位名称

            companyname = !string.IsNullOrEmpty(companyname) ? Utils.InputText(Server.UrlDecode(companyname)) : "";
            string custtype = Utils.GetQueryStringValue("custtype");//客户类别
            //绑定客户列表
            IList <EyouSoft.Model.SMSStructure.CustomerList> list = custBll.GetList(pageSize, pageIndex, ref recordCount, CurrentUserCompanyID.ToString(), companyname, userName, mobile, Utils.GetInt(custtype));

            if (list != null && list.Count > 0)
            {
                rptCustomer.DataSource = list;
                rptCustomer.DataBind();
                BindExportPage();
            }
            else
            {
                rptCustomer.EmptyText   = "<tr><td colspan='7' align='center'>对不起,暂无客户信息!</td></tr>";
                ExportPageInfo1.Visible = false;
            }
            //恢复查询条件
            txtCompanyName.Value = companyname; //单位名称
            txtMobile.Value      = mobile;      //手机号
            selCustType.Value    = custtype;    //客户类别
            txtUserName.Value    = userName;    //客户名
        }