日期:2014-05-18 浏览次数:20807 次
[WebMethod] protected DataSet tip_details(string username) { SqlConnection sqlconnection = new SqlConnection(ConnectionString); sqlconnection.Open(); string cmdstring = "select title,details,id,time from [tip] "; SqlDataAdapter sqlAdapteruser = new SqlDataAdapter(cmdstring, sqlconnection); DataSet ds = new DataSet(); sqlAdapteruser.Fill(ds, "tip"); sqlconnection.Close(); return ds; } [WebMethod ] public DataSet send_tips(string username) //环保小贴士 { DataSet ds = new DataSet(); ds = tip_details (username); return ds; }
[WebMethod] public Boolean ValidLogin(string username, string password) //验证登陆名与密码是否匹配 { Boolean flag = false; SqlConnection sqlconnection = new SqlConnection(ConnectionString); sqlconnection.Open(); string cmdcount="select count(username) from [user] where username=" + "'" + username + "'"; SqlCommand cmdd = new SqlCommand(cmdcount, sqlconnection); int cc = (int)cmdd.ExecuteScalar(); if(cc==0) return false; string cmdString = "select password from [user] where username=" + "'" + username + "'"; SqlCommand cmd = new SqlCommand(cmdString, sqlconnection); string pas = (string)cmd.ExecuteScalar(); sqlconnection.Close(); if ((pas.Trim() != password.Trim()) || pas.Trim () == null) { flag = false; } else { flag = true; } return flag; }
public static object InvokeWebService(string url, string classname, string methodname, object[] args) { if (classname == null || classname == "") { classname = WebServiceHelper.GetClassName(url); } //获取服务描述语言(WSDL) WebClient wc = new WebClient(); Stream stream = wc.OpenRead(url + ComUtil.WSDL);//【1】 ServiceDescription sd = ServiceDescription.Read(stream);//【2】 ServiceDescriptionImporter sdi = new ServiceDescriptionImporter();//【3】 sdi.AddServiceDescription(sd, "", ""); CodeNamespace cn = new CodeNamespace(WebServiceNS);//【4】 //生成客户端代理类代码 CodeCompileUnit ccu = new CodeCompileUnit();//【5】 ccu.Namespaces.Add(cn); sdi.Import(cn, ccu); CSharpCodeProvider csc = new CSharpCodeProvider();//【6】 ICodeCompiler icc = csc.CreateCompiler();//【7】 //设定编译器的参数 CompilerParameters cplist = new CompilerParameters();//【8】 cplist.GenerateExecutable = false; cplist.GenerateInMemory = true; cplist.ReferencedAssemblies.Add("System.dll"); cplist.ReferencedAssemblies.Add("System.XML.dll"); cplist.ReferencedAssemblies.Add("System.Web.Services.dll"); cplist.ReferencedAssemblies.Add("System.Data.dll"); //编译代理类 CompilerResults cr = icc.CompileAssemblyFromDom(cplist, ccu);//【9】 if (true == cr.Errors.HasErrors) { System.Text.StringBuilder sb = new StringBuilder(); foreach