1.首先要在项目里建一个SNWebService.asmx:
SNWebService.cs的代码:
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Collections.Generic;
using System.Collections.Specialized;
using AjaxControlToolkit;
using System.Data.sqlClient;
using System.Data;
/// <summary>
/// SNWebService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]一定要加上这一句,以后应用的时候..
public class SNWebService : System.Web.Services.WebService
{
public SNWebService()
{
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
/// <summary>
/// 获取省份数据
/// </summary>
/// <param name="kNownCategoryValues"></param>
/// <param name="category"></param>
/// <returns></returns>
[WebMethod]
public CascadingDropDownNameValue[] GetProvinceContents(string kNownCategoryValues,string category)
{
List<CascadingDropDownNameValue> provinceList = new List<CascadingDropDownNameValue>();
try
{
// string connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
string connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
//string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WorkDataConnectionString1"];
sqlConnection sqlConn = new sqlConnection(connectionString);
string strsql = "Select * From Provice";
sqlCommand sqlCmd = new sqlCommand(strsql,sqlConn);
sqlDataReader dtrProvince = sqlCmd.ExecuteReader();
while (dtrProvince.Read())
{
provinceList.Add(new CascadingDropDownNameValue(dtrProvince["ProName"].ToString(),dtrProvince["ProId"].ToString()));
}
dtrProvince.Close();
sqlConn.Close();
}
catch (Exception ex)
{
throw;
}
return provinceList.ToArray();
}
/// <summary>
/// 获取市数据
/// </summary>
/// <param name="kNownCategoryValues"></param>
/// <param name="category"></param>
/// <returns></returns>
[WebMethod]
public CascadingDropDownNameValue[] GetCityContents(string kNownCategoryValues,string category)
{
StringDictionary provinceList = CascadingDropDown.ParseKNownCategoryValuesstring(kNownCategoryValues);
//string connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
string connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
sqlConnection sqlConn = new sqlConnection(connectionString);
string strsql = "Select * From city Where ProId=" + provinceList["Province"] + "";
sqlCommand sqlCmd = new sqlCommand(strsql,sqlConn);
sqlDataReader dtrCity = sqlCmd.ExecuteReader();
List<CascadingDropDownNameValue> cityList = new List<CascadingDropDownNameValue>();
while (dtrCity.Read())
{
cityList.Add(new CascadingDropDownNameValue(dtrCity["CityName"].ToString(),dtrCity["CityID"].ToString()));
}
dtrCity.Close();
return cityList.ToArray();
}
/// <summary>
/// 获取乡镇数据
/// </summary>
/// <param name="kNownCategoryValues"></param>
/// <param name="category"></param>
/// <returns></returns>
[WebMethod]
public CascadingDropDownNameValue[] GetViliageContents(string kNownCategoryValues,string category)
{
StringDictionary cityList = CascadingDropDown.ParseKNownCategoryValuesstring(kNownCategoryValues);
string connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
sqlConnection sqlConn = new sqlConnection(connectionString);
string strsql = "Select * From County Where CityId='" + cityList["City"] + "'";
sqlCommand sqlCmd = new sqlCommand(strsql,sqlConn);
sqlDataReader dtrViliage = sqlCmd.ExecuteReader();
List<CascadingDropDownNameValue> viliageList = new List<CascadingDropDownNameValue>();
while (dtrViliage.Read())
{
viliageList.Add(new CascadingDropDownNameValue(dtrViliage["CountyName"].ToString(),dtrViliage["Countyid"].ToString()));
}
dtrViliage.Close();
return viliageList.ToArray();
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AgentCenterinformation.aspx.cs"
Inherits="zhigouwang_web_AgentCenterinformation" EnableEventValidation="false" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>代理管理中心--修改/补充代理商信息</title>
<link href="css/css.css" type="text/css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<!-- right begin-->
<div class="agent_right">
<div class="agent_right_list">
<p>
</p>
</div>
<div class="agent_right_list">
<li>
<p>
<table style="width: 494px; height: 281px">
<tr>
<td colspan="3">
<h4>
修改补充代理商个人信息</h4>
</td>
</tr>
<tr>
<td style="width: 86px">
代理商名:</td>
<td style="width: 84px">
<asp:TextBox ID="TextBox1" runat="server" Height="20px"></asp:TextBox></td>
<td style="width: 188px">
<img src="images/icon_18.gif" />
用户的姓名
</td>
</tr>
<tr>
<td style="width: 86px">
真实姓名:</td>
<td style="width: 84px">
<asp:TextBox ID="TextBox2" runat="server" Height="20px"></asp:TextBox></td>
<td style="width: 188px">
<img src="images/icon_18.gif" />用户的真实姓名</td>
</tr>
<tr>
<td style="width: 86px; height: 1px;">
性 别:</td>
<td style="width: 84px; height: 1px;">
<asp:RadioButtonList ID="Radio" runat="server" Font-Size="12px" Width="89px" Height="44px"
RepeatDirection="Horizontal">
<asp:ListItem Value="男" Selected="True">男</asp:ListItem>
<asp:ListItem Value="女">女</asp:ListItem>
</asp:RadioButtonList></td>
<td style="width: 188px; height: 1px;">
<img src="images/icon_18.gif" />
用户的性别</td>
</tr>
<tr>
<td style="width: 86px">
手机号码:</td>
<td style="width: 84px">
<asp:TextBox ID="TextBox3" runat="server" Height="20px"></asp:TextBox></td>
<td style="width: 188px">
<img src="images/icon_18.gif" />
用户的手机号码</td>
</tr>
<tr>
<td style="width: 86px">
电子邮件:</td>
<td style="width: 84px">
<asp:TextBox ID="TextBox4" runat="server" Height="20px"></asp:TextBox></td>
<td style="width: 188px">
<img src="images/icon_18.gif" />
必填请输入有效的电子邮件地址
</td>
</tr>
<tr>
<td style="width: 86px">
出生年月:</td>
<td style="width: 84px">
<asp:TextBox ID="TextBox5" runat="server" Height="20px"></asp:TextBox></td>
<td style="width: 188px">
<img src="images/icon_18.gif" />
用户的出生日期</td>
</tr>
<tr>
<td style="width: 86px">
身份证号:</td>
<td style="width: 84px">
<asp:TextBox ID="TextBox6" runat="server" Height="20px"></asp:TextBox></td>
<td style="width: 188px">
<img src="images/icon_18.gif" />
用户的身份证号码</td>
</tr>
<tr>
<td style="width: 86px">
是否修改地址:</td>
<td colspan="2">
<asp:RadioButton ID="rabtrue" runat="server" AutopostBack="True" GroupName="0" OnCheckedChanged="rabtrue_CheckedChanged" />是
<asp:RadioButton ID="rabfalse" runat="server" AutopostBack="True" Checked="True"
GroupName="0" OnCheckedChanged="rabfalse_CheckedChanged" />否 </td>
</tr>
<tr>
<td colspan="3">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
所在地区: <asp:DropDownList ID="ddlProvince" runat="server">
</asp:DropDownList>省<asp:DropDownList ID="ddlCity" runat="server">
</asp:DropDownList>市<asp:DropDownList ID="ddlVilliage" runat="server">
</asp:DropDownList>区
<cc1:CascadingDropDown ID="CascadingDropDown2" runat="server" TargetControlID="ddlProvince"
ServicePath="SNWebService.asmx" ServiceMethod="GetProvinceContents" Category="Province"
PromptText="请选择省份" LoadingText="省份加载中...">
</cc1:CascadingDropDown>
<cc1:CascadingDropDown ID="CascadingDropDown1" runat="server" ParentControlID="ddlProvince"
ServicePath="SNWebService.asmx" ServiceMethod="GetCityContents" Category="City"
TargetControlID="ddlCity" PromptText="请选择城市" LoadingText="城市加载中...">
</cc1:CascadingDropDown>
<cc1:CascadingDropDown ID="CascadingDropDown3" runat="server" Category="Villiage"
LoadingText="区县加载中..." ParentControlID="ddlCity" PromptText="请选择区县" ServiceMethod="GetViliageContents"
ServicePath="SNWebService.asmx" TargetControlID="ddlVilliage">
</cc1:CascadingDropDown>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td style="width: 86px">
联系地址:</td>
<td style="width: 84px">
<asp:TextBox ID="TextBox7" runat="server" Height="20px"></asp:TextBox></td>
<td style="width: 188px">
<img src="images/icon_18.gif" />
用户的详细地址
</td>
</tr>
<tr>
<td style="width: 86px">
</td>
<td style="width: 84px">
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="images/icon_20.gif" OnClick="ImageButton1_Click" /></td>
<td style="width: 188px">
</td>
</tr>
</table>
</p>
</li>
</div>
</div>
<!-- right end-->
</div>
</form>
</body>
</html>
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;
using System.Data.sqlClient;
using OurWork.DataServer;
public partial class zhigouwang_web_AgentCenterinformation : System.Web.UI.Page
{
protected void Page_Load(object sender,EventArgs e)
{
if (!IsPostBack)
{
this.UpdatePanel1.Visible = false;
if (Session["agentname"] == null)
{
Response.Write("<script language='JavaScript'>");
Response.Write("alert('请先登录!')");
Response.Write("</script>");
Response.End();
return;
}
try
{
string agentname = Session["agentname"].ToString();
string sql = "SELECT * FROM Shop_Dls where DlsName='" + agentname + "'";
sqlDataReader dr = DbHelpersql.ExecuteReader1(sql);
if (dr.Read())
{
TextBox1.Text = dr["DlsName"].ToString();
TextBox2.Text = dr["DlsRN"].ToString();
Radio.SelectedValue = dr["DlsSex"].ToString();
TextBox3.Text = dr["DlsPhone"].ToString();
TextBox4.Text = dr["DlsEmail"].ToString();
TextBox5.Text = dr["DlsBirthday"].ToString();
TextBox6.Text = dr["Dlssfzh"].ToString();
TextBox7.Text = dr["DlsAdd"].ToString();
dr.Close();
}
else
{
Response.Write("<script language='JavaScript'>");
Response.Write("alert('没有该用户!')");
Response.Write("</script>");
return;
}
}
catch (Exception)
{
throw;
}
}
}
protected void ImageButton1_Click(object sender,ImageClickEventArgs e)
{
string AgentName,TrueName,sex,phone,email,birthday,idcard,address;
AgentName = TextBox1.Text;
TrueName = TextBox2.Text;
sex = Radio.SelectedItem.Value;
phone = TextBox3.Text;
email = TextBox4.Text;
birthday = TextBox5.Text;
idcard = TextBox6.Text;
string provice = this.ddlProvince.SelectedValue;
string city = this.ddlCity.SelectedValue;
string villliage = this.ddlVilliage.SelectedValue;
string xiaddres = "";
if (provice != null && provice != "请选择省份" && provice != "")
{
xiaddres += this.ddlProvince.SelectedItem.Text;
}
if (city != null && city != "请选择城市" && city != "")
{
xiaddres += this.ddlCity.SelectedItem.Text;
}
if (villliage != null && villliage != "请选择区县" && villliage != "")
{
xiaddres += this.ddlVilliage.SelectedItem.Text;
}
address = xiaddres;
this.TextBox7.Text = address;
//执行sql更新命令
string sql2 = "update Shop_Dls set DlsName='" + AgentName + "',DlsRN='" + TrueName + "',DlsSex='" + sex + "',DlsPhone='" + phone + "',DlsEmail='" + email + "',DlsBirthday='" + birthday + "',Dlssfzh='" + idcard + "',DlsAdd='" + address + "' where DlsName='" + AgentName + "'";
DbHelpersql.ExecuteReader1(sql2);
Response.Write("<script language='JavaScript'>");
Response.Write("alert('修改成功!')");
Response.Write("</script>");
}
protected void rabtrue_CheckedChanged(object sender,EventArgs e)
{
this.UpdatePanel1.Visible = true;
} protected void rabfalse_CheckedChanged(object sender,EventArgs e) { this.UpdatePanel1.Visible = false; }}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。