留言是不是这么写的类?
1.zip
(23.72 KB)
程序代码:
using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data .OleDb ; /// <summary> ///zxly 的摘要说明 /// </summary> public class zxly { public zxly() { // //TODO: 在此处添加构造函数逻辑 // } private static string id; public string Id { get { return id; } set { id = value; } } private static string name; public string Name { get { return name; } set { name = value; } } private static string comname; public string Comname { get{return comname;} set { comname = value; } } private static string phone; public string Phone { get { return phone; } set { phone = value; } } private static string email; public string Email { get { return email; } set { email = value; } } private static string add; public string Add { get { return add; } set { add = value; } } private static string title; public string Title { get { return title; } set { title = value; } } private static string content; public string Content { get { return content; } set { content = value; } } private static DateTime lysj; public DateTime Lysj { get { return lysj; } set { lysj = value; } } private static int flg; public int Flg { get { return flg; } set { flg = value; } } public static string sel() { string s=""; OleDbConnection cn = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString()); OleDbDataAdapter da = new OleDbDataAdapter("select name from zxly", cn); DataSet ds = new DataSet(); da.Fill(ds); int ret = 0; for (int i = 0; i <= zxly.count() - 1; i++) { string s1 = ds.Tables[0].Rows[i]["name"].ToString(); if (s1.Trim ()==id ) { ret = 1; } } if (ret == 1) { s = "留言已经存在。"; } else { s = "留言成功。"; } return s; } public static void insert1() { string str = "insert into zxly(id,name,comname,phone,email,add,title,content,lysj,flg) valuese ('" + id + "','" + name + "','" + comname + "','" + phone + "','" + email + "','" + add + "','" + title + "','" + content + "','" + lysj + "','" + flg + "')"; OleDbConnection cn = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString()); OleDbCommand com = new OleDbCommand(str, cn); cn.Open(); int ret = com.ExecuteNonQuery(); cn.Close(); } public static string selectname() { string s = ""; string str = "select name from zxly"; OleDbConnection cn = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString()); OleDbDataAdapter da = new OleDbDataAdapter(str,cn); DataSet ds = new DataSet(); da.Fill(ds); int set = 0; for(int i=0;i<=zxly .count ()-1;i++) { string s1=ds.Tables [0].Rows [i]["name"].ToString (); if (id == s1.Trim()) str = 1; } if (set == 1) { s = selectid().Trim().ToString(); } else { s = "没有该用户"; } return s; } public static string selectid() { string s = ""; string sql = "select id from zxly"; OleDbConnection cn = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString()); OleDbDataAdapter da = new OleDbDataAdapter(sql, cn); DataSet ds = new DataSet(); da.Fill(ds); int ret = 0; for (int i = 0; i <= zxly .count ()-1; i++) { string s1 = ds.Tables[0].Rows[i]["id"].ToString(); if (mima == s1) ret = 1; } return s; } public static int count() { OleDbConnection cn = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString()); OleDbDataAdapter da = new OleDbDataAdapter("select count(*) as a1 from zxly", cn); DataSet ds = new DataSet(); da.Fill(ds); int c1 = Convert.ToInt32(ds.Tables[0].Rows[0]["a1"].ToString()); return c1; } public static DataTable td(String sql) { OleDbConnection cn = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString()); OleDbDataAdapter da = new OleDbDataAdapter(sql, cn); DataSet ds = new DataSet(); da.Fill(ds); return ds.Tables[0]; } public static DataTable cr(String sql) { OleDbConnection cn = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString()); OleDbDataAdapter da = new OleDbDataAdapter(sql, cn); DataSet ds = new DataSet(); da.Fill(ds); return ds.Tables[0]; } }在线留言的类,是这么写的吗?求高手帮我看看。