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

📄 customeradd.ascx.cs

📁 CRM管理系统 CRM管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class CustomerManage_Ctrls_CustomerAdd : PageBaseUserCtrl
{
    public WYX.Dataport.Dataport dataport = new WYX.Dataport.Dataport();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            GetComType();
            GetRelation();
            GetIndustry();
            GetComResource();
            GetNation();
            GetCity();
            GetCompanyType();
            GetCompanySize();
            GetTrack();
            Setdata();

            InitDdl();
        }
    }

    #region 初始化ddl
    /// <summary>
    /// 初始化ddl
    /// </summary>
    private void InitDdl()
    {
        ddlCity.SelectedValue = "109006";
        ddlCompanySize.SelectedValue = "111004";
        ddlComType.SelectedValue = "105009";
        ddlComResource.SelectedValue = "107004";
        ddlCompanyType.SelectedValue = "110005";
        ddlnation.SelectedValue = "108001";
        ddlRelation.SelectedValue = "104001";
        ddlWay.SelectedValue = "106006";
    }
    #endregion

    #region  绑定数据
    /// <summary>
    /// 绑定客户类型
    /// </summary>
    private void GetComType()
    {
        this.BindDictionary(this.ddlComType, "105", true);
    }
    /// <summary>
    /// 绑定关系程度
    /// </summary>
    private void GetRelation()
    {
        this.BindDictionary(this.ddlRelation, "104", true);
    }
    /// <summary>
    /// 绑定行业
    /// </summary>
    private void GetIndustry()
    {
        this.BindDictionary(this.ddlWay, "106", true);
    }
    /// <summary>
    /// 客户来源
    /// </summary>
    private void GetComResource()
    {
        this.BindDictionary(this.ddlComResource, "107", true);
    }
    /// <summary>
    /// 国家
    /// </summary>
    private void GetNation()
    {
        this.BindDictionary(this.ddlnation, "108", true);
    }
    /// <summary>
    /// 城市
    /// </summary>
    private void GetCity()
    {
        this.BindDictionary(this.ddlCity, "109", true);
    }
    /// <summary>
    /// 公司性质
    /// </summary>
    private void GetCompanyType()
    {
        this.BindDictionary(this.ddlCompanyType, "110", true);
    }
    /// <summary>
    /// 公司规模
    /// </summary>
    private void GetCompanySize()
    {
        this.BindDictionary(this.ddlCompanySize, "111", true);
    }
    /// <summary>
    /// 跟踪人员
    /// </summary>
    protected void GetTrack()
    {
        string sql = null;
        if (GetSystemRole(this.CurrentUser.account))
        {
            sql = " SELECT user_id,account,name FROM Users";
        }
        else
        {
            sql = " SELECT user_id,account,name FROM Users where account = '" + this.CurrentUser.account + "'";
        }
        DataTable dt = null;
        try
        {
            dt = dataport.GetTableResult(sql);
        }
        catch
        {
            dt = null;
        }
        if (dt == null || dt.Rows.Count == 0)
        {
            ddlTrack.DataSource = dt;
            ddlTrack.DataBind();
            ddlTrack.Items.Add("请选择...");
            return;
        }
        ddlTrack.DataSource = dt;
        ddlTrack.DataTextField = "name";
        ddlTrack.DataValueField = "user_id";
        ddlTrack.DataBind();
        ddlTrack.Items.Insert(0, new ListItem("请选择...", "0"));
    }
    #endregion

    /// <summary>
    /// 获取用户ID
    /// </summary>
    /// <param name="Code"></param>
    /// <returns></returns>
    protected string GetUserID(string UserCode)
    {
        if (UserCode.Trim().Replace("'", "\"").Length > 0)
        {
            string sql = " select user_id from users where account = '" + UserCode + "'";
            try
            {
                return dataport.GetRowResultID(sql);
            }
            catch
            {
                return "0";
            }
        }
        else
        {
            return "0";
        }
    }
    /// <summary>
    /// 初始化数据

    /// </summary>
    protected void Setdata()
    {
        this.ddlIsUse.SelectedIndex = 1;
        this.txtAddTime.Text = DateTime.Now.ToString();
        this.ddlTrack.SelectedValue = GetUserID(this.CurrentUser.account);
    }
    /// <summary>
    /// 数据验证
    /// </summary>
    protected bool CheckData()
    {
        this.msg = String.Empty;
        if (this.txtComName.Text.Trim().Replace("'", "\"").Length < 0 || this.txtComName.Text == "")
        {
            msg += "客户名称不能为空\\r\\n";
        }
        else
        {
            if (this.txtComName.Text.Trim().Replace("'", "\"").Length > 50)
            {
                msg += "客户名称长度填写不能大于50\\r\\n";
            }
        }
        if (this.ddlRelation.SelectedIndex == 0 || this.ddlRelation.SelectedItem.Value.Trim().Length <= 0)
        {
            msg += "关系程度不能为空\\r\\n";
        }
        if (this.ddlComType.SelectedIndex == 0 || this.ddlComType.SelectedItem.Value.Trim().Length <= 0)
        {
            msg += "客户类型不能为空\\r\\n";
        }
        if (this.ddlTrack.SelectedIndex == 0 || this.ddlTrack.SelectedItem.Value.Trim().Length <= 0)
        {
            msg += "跟踪人员不能为空\\r\\n";
        }
        if (this.ddlIsUse.SelectedIndex == 0 || this.ddlIsUse.SelectedItem.Value.Trim().Length <= 0)
        {
            msg += "有效性不能为空\\r\\n";
        }
        if (this.txtAdress.Text.Trim().Replace("'", "\"").Length > 50)
        {
            msg += "详细地址长度填写不能大于50\\r\\n";
        }
        if (this.txtHomePage.Text.Trim().Replace("'", "\"").Length > 25)
        {
            msg += "公司主页长度填写不能大于25\\r\\n";
        }
        if (this.txtRemark.Text.Trim().Replace("'", "\"").Length > 250)
        {
            msg += "备注长度填写不能大于250\\r\\n";
        }
        if (this.txtZip.Text.Trim().Replace("'", "\"").Length > 0)
        {
            if (txtZip.Text.Trim().Replace("'", "\"").Length > 6)
            {
                msg += "邮编填写必须为6为数字\\r\\n";
            }
            else
            {
                String express = @"\d{6}";
                System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(express);
                System.Text.RegularExpressions.Match match = reg.Match(txtZip.Text.Trim());
                if (!match.Success)
                {
                    msg += "邮编必须为6位数字\\r\\n";
                }
            }
        }
        if (this.txtCompanyTel.Text.Trim().Replace("'", "\"").Length > 0)
        {
            String express = @"(\(\d{3}\)|\d{3}-)?\d{8}";
            System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(express);
            System.Text.RegularExpressions.Match match = reg.Match(txtCompanyTel.Text.Trim());
            if (!match.Success)
            {
                msg += "公司电话填写格式错误\\r\\n";
            }
        }
        if (this.txtFax.Text.Trim().Replace("'", "\"").Length > 0)
        {
            String express = @"(\(\d{3}\)|\d{3}-)?\d{8}";
            System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(express);
            System.Text.RegularExpressions.Match match = reg.Match(txtFax.Text.Trim());
            if (!match.Success)
            {
                msg += "公司传真填写格式错误\\r\\n";
            }
        }
        if (this.txtEmail.Text.Trim().Replace("'", "\"").Length > 0)
        {
            String express = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
            System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(express);
            System.Text.RegularExpressions.Match match = reg.Match(txtEmail.Text.Trim());
            if (!match.Success)
            {
                msg += "公司邮件地址填写格式错误\\r\\n";
            }
        }
        HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
        int accCount = 0;
        for (int i = 0; i < files.Count; i++)
        {
            HttpPostedFile postFile = files[i];

            if (postFile.FileName.Trim().Length > 0)
            {
                string fileName, fileExtension;
                fileName = System.IO.Path.GetFileName(postFile.FileName);
                if (fileName != "")
                {
                    fileExtension = System.IO.Path.GetExtension(fileName).Replace(".", "");
                    if (!CheckExtension(fileExtension))
                    {
                        msg += "存在不允许上传的文件类型:" + fileExtension + "\\r\\n";
                    }
                    else if (postFile.ContentLength > 10240000)

⌨️ 快捷键说明

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