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

📄 persenadd.ascx.cs

📁 CRM管理系统 CRM管理系统
💻 CS
字号:
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_PersenAdd : PageBaseUserCtrl
{
    public WYX.Dataport.Dataport dataport = new WYX.Dataport.Dataport();
    private int ComId;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ComId = Convert.ToInt32(Request.QueryString["code"]);
            GetFirstSex();
        }
    }
     /// <summary>
    /// 联系人性别
    /// </summary>
    private void GetFirstSex()
    {
        this.BindDictionary(this.ddlFirstSex, "112", true);
    }
    /// <summary>
    /// 数据验证
    /// </summary>
    protected bool CheckData()
    {
        this.msg = String.Empty;
        if (this.txtFirstName.Text.Trim().Replace("'", "\"").Length < 0 || this.txtFirstName.Text == "")
        {
            msg += "联系人姓名不能为空\\r\\n";
        }
        else
        {
            if (this.txtFirstName.Text.Trim().Replace("'", "\"").Length > 16)
            {
                msg += "联系人姓名长度填写不能大于16\\r\\n";
            }
        }
        if (this.txtFirstDept.Text.Trim().Replace("'", "\"").Length > 25)
        {
            msg += "联系人所在单位长度填写不能大于25\\r\\n";
        }
        if (this.txtFirstDept.Text.Trim().Replace("'", "\"").Length > 25)
        {
            msg += "联系人职务长度填写不能大于25\\r\\n";
        }
        if (this.txtFirstinterest.Text.Trim().Replace("'", "\"").Length > 100)
        {
            msg += "联系人兴趣爱好长度填写不能大于100\\r\\n";
        }
        if (this.txtFirstTel.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(txtFirstTel.Text.Trim());
            if (!match.Success)
            {
                msg += "联系人电话填写格式错误\\r\\n";
            }
        }
        if (this.txtFirstMobile.Text.Trim().Replace("'", "\"").Length > 0)
        {
            if (txtFirstMobile.Text.Trim().Replace("'", "\"").Length > 11)
            {
                msg += "联系人移动电话填写必须为11为数字\\r\\n";
            }
            else
            {
                String express = @"\d{11}";
                System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(express);
                System.Text.RegularExpressions.Match match = reg.Match(txtFirstMobile.Text.Trim());
                if (!match.Success)
                {
                    msg += "联系人移动电话填写格式错误\\r\\n";
                }
            }
        }
        if (this.txtFirstEmail.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(txtFirstEmail.Text.Trim());
            if (!match.Success)
            {
                msg += "联系人邮件地址填写格式错误\\r\\n";
            }
        }
        if (msg == String.Empty)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    /// <summary>
    /// 提交
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!(CheckData()))
        {
            ShowMessage(msg);
            return;
        }
        if (SubmitData())
        {
            ShowMessage("信息提交成功!");
            ComId = Convert.ToInt32(Request.QueryString["code"]);
            Response.Redirect("PersenManage.aspx?code=" + ComId);
        }
        else
        {
            ShowMessage("信息提交失败!");
            return;
        }
    }
    /// <summary>
    /// 数据提交操作
    /// </summary>
    /// <returns></returns>
    protected bool SubmitData()
    {
        ComId = Convert.ToInt32(Request.QueryString["code"]);
        String first_sex;

        String first_name = this.txtFirstName.Text.Trim().Replace("'", "\"");
        String first_tel = this.txtFirstTel.Text.Trim().Replace("'", "\"");
        if (ddlFirstSex.SelectedIndex > 0)
        {
            first_sex = ddlFirstSex.SelectedValue;
        }
        else
        {
            first_sex = "";
        }
        String first_depart = this.txtFirstDept.Text.Trim().Replace("'", "\"");
        String first_duty = this.txtFirstDuty.Text.Trim().Replace("'", "\"");
        String first_mobile = this.txtFirstMobile.Text.Trim().Replace("'", "\"");
        String first_email = this.txtFirstEmail.Text.Trim().Replace("'", "\"");
        String first_interest = this.txtFirstinterest.Text.Trim().Replace("'", "\"");

        String sql = @"INSERT INTO ITSV_customer_person
                              (customer_id,first_name, first_tel, first_sex, first_depart, first_duty, first_mobile, first_email, first_interest
                              )
                       VALUES (" + ComId + ",'" + first_name + "', '" + first_tel + "', '" + first_sex + "', '" + first_depart + "', '" + first_duty + "', '" + first_mobile + "', '" + first_email + "', '" + first_interest + "')";
        bool falg = dataport.ExeSql(sql);
        if (falg)
        {
            this.WriteUserAction("添加联系人\"" + first_name + "\"资料");
            return true;
        }
        else
        {
            return false;
        }
    }
    /// <summary>
    /// 取消
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        ComId = Convert.ToInt32(Request.QueryString["code"]);
        Response.Redirect("PersenManage.aspx?code=" + ComId);
    }
}

⌨️ 快捷键说明

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