| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 811 人关注过本帖
标题:在线留言怎么做?
取消只看楼主 加入收藏
wushanshan1
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2013-4-8
结帖率:100%
收藏
 问题点数:0 回复次数:2 
在线留言怎么做?
121.zip (12.3 KB)

要实现这2个按钮的功能,类里的方法该怎么写?
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 int zzzz()
    {
        string str=""
        OleDbConnection cn = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString());
        cn.Open();
        OleDbCommand cm = new OleDbCommand();
    }
    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 ()==name)
            {
                ret = 1;
            }
        }
            if (ret == 1)
            {
                s = "留言已经存在。";
            }
            else
            {
                s = "留言成功。";
            }
            return s;
    }
    public static void insert1()
    {
        string str = "insert zxly into (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 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];
    }
}
这样写,对吗?
搜索更多相关主题的帖子: 在线留言 public 
2013-04-12 10:37
wushanshan1
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2013-4-8
收藏
得分:0 
就是不太会写长的代码。这是根据以前老师教的注册代码改的。哪里需要改进一下,请版主指导指导
2013-04-22 08:51
wushanshan1
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2013-4-8
收藏
得分:0 
还是不太会,版主能不能帮忙写个简单的例子借用一下。
2013-04-24 08:15
快速回复:在线留言怎么做?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025137 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved