<%@ WebHandler Language="C#" Class="setsccd" %> using System; using System.Web; using System.Data; using System.Data.SqlClient; using System.Web.SessionState; public class setsccd : IHttpHandler,IRequiresSessionState { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; string gn = context.Request.Form["nr"].ToString(); Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(HttpContext.Current.Session["user"]); string scmkmc = gn.Split('$')[0].ToString().Substring(0, gn.Split('$')[0].ToString().Length -2); string shan = string.Format("delete from nr_z_yh_kjcd where yonghu='{0}' and cdmc='{1}'", user.id, scmkmc); DBHlper.excutecmd(shan); //添加现有的 string cmd = string.Format("insert into nr_z_yh_kjcd ([yonghu],[cdmc],[cddz]) values ('{0}','{1}','{2}')", user.id, scmkmc, gn.Split('$')[1].ToString()); int msgval = DBHlper.excutecmd(cmd); context.Response.Write(msgval); } public bool IsReusable { get { return false; } } }