updatecustomer.aspx.cs

来自「该服务平台解决了计算机网络与移动网络之间信息交换问题」· CS 代码 · 共 234 行

CS
234
字号




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 Customermanangement_Updatecustomer : System.Web.UI.Page
{
    private DataAccess.TableAccessor.UserInfo userInfoAccessor;
    private DataAccess.TableAccessor.CountyVillage countyVillageAccessor;
    private DataAccess.TableAccessor.UserOperation userOperation;
    private DataAccess.TableAccessor.UserConporation userCorporation;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
           // int pageindex = 0;
            
            int systemUserID = 0;
           //// try
           // {
           //     pageindex = int.Parse(Request.QueryString[1].ToString());
           // }
           //// catch
           // //{ Response.Close(); }
            //try
            {
                //int coperationID = int.Parse(Request.QueryString[1].ToString);
                systemUserID = int.Parse(Request.QueryString[0].ToString());
                int arID = int.Parse(Request.QueryString["arID"].ToString());
               //string  departID = Request.QueryString["departID"].ToString();
               int  departID = int.Parse(Request.QueryString["departID"].ToString());
            }
            //catch
            //{
            //    Response.Write("<script language='javascript'>alert('接收参数错误!');</script>");
            //    return;
            //}
            FillArea();
            FillControls();
           }
    }
   

    private void FillArea()
    {
        countyVillageAccessor = new DataAccess.TableAccessor.CountyVillage();
        this.cbArea.DataSource = countyVillageAccessor.GetcoustomertypeInfo();
        this.cbArea.DataTextField = "TypeName";
        this.cbArea.DataValueField = "TypeID";
        this.cbArea.DataBind();
        ListItem listArea = new ListItem("全部", "0");
        this.cbArea.Items.Insert(0, listArea);
    }

    private void FillCorporation(int areaID)
    {
        userCorporation = new DataAccess.TableAccessor.UserConporation();
        this.cbCorporation.DataSource = userCorporation.GetGroupInfoByTypeID(areaID);
        this.cbCorporation.DataTextField = "GroupName";
        this.cbCorporation.DataValueField = "GroupID";
        this.cbCorporation.DataBind();
    }

    private void FillControls()
    {
        userInfoAccessor = new DataAccess.TableAccessor.UserInfo();
        userOperation = new DataAccess.TableAccessor.UserOperation();
        userCorporation = new DataAccess.TableAccessor.UserConporation();

        DataTable dt = userInfoAccessor.GetSingleCustomerInfo(int.Parse(Request.QueryString[0].ToString()));
        this.tbUserDefineID.Text = dt.Rows[0]["CustomerDefineID"].ToString();
        this.tbName.Text = dt.Rows[0]["Name"].ToString();
        this.tbMobile.Text = dt.Rows[0]["Mobile"].ToString();
        this.tbHomeAddress.Text = dt.Rows[0]["Unit"].ToString();
       
        this.tbDuty.Text = dt.Rows[0]["Duty"].ToString();
       
        this.cbSex.SelectedValue = dt.Rows[0]["Sex"].ToString();


        this.tbcard.Text = dt.Rows[0]["IDcard"].ToString();

        this.tbregist.Text = dt.Rows[0]["HomeAddress"].ToString();
        this.tbNowaddress.Text = dt.Rows[0]["UnitAddress"].ToString();
        this.tbtime.Text = dt.Rows[0]["JoinDate"].ToString();
        this.tbbeizhu.Text = dt.Rows[0]["Beizhu"].ToString();
        this.tbBirthday.Text = dt.Rows[0]["Birthday"].ToString();
       

        ListItem listArea = new ListItem();
        listArea.Text = "当前为:"+dt.Rows[0]["TypeName"].ToString();
        listArea.Value = dt.Rows[0]["TypeID"].ToString();
        cbArea.Items.Insert(0, listArea);

        FillCorporation(int.Parse(this.cbArea.SelectedValue));
        ListItem listCorporation = new ListItem();
        listCorporation.Text = "当前为:" + dt.Rows[0]["GroupName"].ToString();
        listCorporation.Value = dt.Rows[0]["GroupID"].ToString();
        cbCorporation.Items.Insert(0, listCorporation);

        int tradeid = int.Parse(dt.Rows[0]["TradeID"].ToString());
        this.cbTrader.SelectedValue = tradeid.ToString(); ;// int.Parse(dt.Rows[0]["TradeID"].ToString());
        if (tradeid == 0)
        {
            this.cbTrader.Visible = true;
            this.cbTrader.Text = "农迅通";
        }
        else if (tradeid == 1)
        {
            this.cbTrader.Visible = true;
            this.cbTrader.Text = "小灵通";
        }
        else
        {
            this.cbTrader.Visible = true;
            
        }
        DataTable dtUserOperation = userOperation.GetSimpMan(int.Parse(Request.QueryString[0].ToString())); 
    }

    protected void btnOK_Click(object sender, EventArgs e)
    {

        int arID = int.Parse(Request.QueryString["arID"].ToString());
        string departID = Request.QueryString["departID"].ToString();
        if (tbMobile.Text != "")
        {
            userInfoAccessor = new DataAccess.TableAccessor.UserInfo();
            userCorporation = new DataAccess.TableAccessor.UserConporation();
            
            int areaID = 0;
            try
            {
                areaID = int.Parse(cbArea.SelectedValue);
            }
            catch
            {
                Response.Write("<script language='javascript'>alert('用户组未选择!');</script>");
                string goUrl = string.Format("<script language='javascript'>window.location.href = 'Updatecustomer.aspx?smsID={0}'; </script>", int.Parse(Request.QueryString[0].ToString()));
                Response.Write(goUrl);
                return;
            }
            int countyID = 0;
          //  int villageID = 0;
            string name = tbName.Text;
            string defineID = tbUserDefineID.Text;
            int sex = int.Parse(cbSex.SelectedValue);
            string birthday = tbBirthday.Text;;
            //if (tbBirthday.Text.Length == 4)
            //{
            //    birthday = 
            //}
            string unit = tbHomeAddress.Text;
            string mobile = tbMobile.Text;
            int trade = int.Parse (cbTrader.SelectedValue);
            int userFuncation =  int.Parse(cbTrader.SelectedValue);
          
            string duty = tbDuty.Text;
         
            int userID = int.Parse(Request.QueryString[0].ToString());
            int corporationID = 0;

            string idcard = tbcard.Text;
       
            string homeaddress = tbregist.Text;
            string unitaddress = tbNowaddress.Text;
            string joindate = tbtime.Text;
            string beizhu = tbbeizhu.Text;

            try
            {
                corporationID = int.Parse(this.cbCorporation.SelectedValue);
            }
            catch
            {
                Response.Write("<script language='javascript'>alert('部门单位未选择!');</script>");
                string goUrl = string.Format("<script language='javascript'>window.location.href = 'Updatecustomer.aspx?smsID={0}'; </script>", int.Parse(Request.QueryString[0].ToString()));
                Response.Write(goUrl);
                return;
            }
            try
            {
                userInfoAccessor.UpdateCutomerInfo(areaID, corporationID, defineID, name, sex, birthday, homeaddress, unit, mobile,
                    trade, userFuncation, userID, duty, idcard, unitaddress, joindate, beizhu);
                //userCorporation.UpdateUserCorporation(corporationID, userID);
                Response.Write("<script language='javascript'>alert('更新用户信息成功!');</script>");
                string goUrl = string.Format("<script language='javascript'>window.location.href = 'Updatecustomer.aspx?smsID={0}&arID={1}&departID={2}'; </script>", int.Parse(Request.QueryString[0].ToString()), arID, departID);
                Response.Write(goUrl);
                return;
            }
            catch
            {
                Response.Write("<script language='javascript'>alert('更新用户信息失败!');</script>");
                string goUrl = string.Format("<script language='javascript'>window.location.href = 'Updatecustomer.aspx?smsID={0}&arID={1}&departID={2}'; </script>", int.Parse(Request.QueryString[0].ToString()), arID, departID);
                Response.Write(goUrl);
                return;
            }
        }
        else
        {
            Response.Write("<script language='javascript'>alert('手机号未输入!');</script>");
            string goUrl = string.Format("<script language='javascript'>window.location.href = 'Updatecustomer.aspx?smsID={0}&arID={1}&departID={2}'; </script>",
                    int.Parse(Request.QueryString[0].ToString()), arID, departID);
            Response.Write(goUrl);
            return;
        }
    }
    protected void btnRetrun_Click(object sender, EventArgs e)
    {

        int departID = int.Parse(Request.QueryString["departID"].ToString());
        int arID = int.Parse(Request.QueryString["arID"].ToString());
        //string departID = Request.QueryString["departID"].ToString();
        string goUrl = string.Format("<script>window.location.href = 'Customermanage.aspx?arID={0}&departID={1}'</script>", arID, departID);
        Response.Write(goUrl);
        
    }
    protected void cbArea_SelectedIndexChanged(object sender, EventArgs e)
    {
        FillCorporation(int.Parse(this.cbArea.SelectedValue));
    }
   
}

⌨️ 快捷键说明

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