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

📄 persenedit.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_PersenEdit : PageBaseUserCtrl
{
    public WYX.Dataport.Dataport dataport = new WYX.Dataport.Dataport();
    private int PersenId;
    private int ComId;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            PersenId = Convert.ToInt32(Request.QueryString["code"]);
            ComId = Convert.ToInt32(Request.QueryString["Com_ID"]);          
            GetFirstSex();
            SetData();
        }
    }
    /// <summary>
    /// 初始化数据

    /// </summary>
    protected void SetData()
    {
        string sql = " select * from ITSV_customer_person where code = " + PersenId + "";
        DataRow dr = null;
        try
        {
            dr = dataport.GetRowResult(sql);
        }
        catch
        {
            dr = null;
        }
        if (dr == null)
        {
            ShowAndClose("客户编号错误,请您重试!!", "");
            return;
        }
        this.txtFirstName.Text = dr["first_name"].ToString();
        this.txtFirstTel.Text = dr["first_tel"].ToString();
        this.ddlFirstSex.SelectedValue = dr["first_sex"].ToString();
        this.txtFirstDept.Text = dr["first_depart"].ToString();
        this.txtFirstDuty.Text = dr["first_duty"].ToString();
        this.txtFirstMobile.Text = dr["first_mobile"].ToString();
        this.txtFirstEmail.Text = dr["first_email"].ToString();
        this.txtFirstinterest.Text = dr["first_interest"].ToString();
    }
    /// <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["Com_ID"]);
            Response.Redirect("PersenManage.aspx?code=" + ComId);
        }
        else
        {
            ShowMessage("信息提交失败!");
            return;
        }
    }
    /// <summary>
    /// 数据提交操作
    /// </summary>
    /// <returns></returns>
    protected bool SubmitData()
    {
        PersenId = 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 = "Update ITSV_customer_person set ";
        sql += "first_name = '" + first_name + "', first_tel = '" + first_tel + "',first_sex = '" + first_sex + "',";
        sql += "first_depart = '" + first_depart + "', first_duty =  '" + first_duty + "', first_mobile = '" + first_mobile + "',";
        sql += "first_email = '" + first_email + "', first_interest = '" + first_interest + "'";
        sql += " where code = " + PersenId + " ";

        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["Com_ID"]);
        Response.Redirect("PersenManage.aspx?code="+ ComId);
    }
}

⌨️ 快捷键说明

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