随笔-468  评论-936  文章-3  trackbacks-21
总算是把这个东东写完了。做这个的目的就是为了系统的练习一下最近学的一些知识。并且在一开始就定了一些规则,比如可以用datareader就不用dataset,留言本的主体用repeater。下面把遇到的问题说一下。
首先最大的问题就是确定留言编号的问题,这个编号主要是用来进行回复或删除的时候用来确定具体的记录。可能是有些repeater的属性我还没有学到吧,我实在是想不出来到底该怎么做才可以在点击每条留言都可以顺便返回一个记录编号的办法。也想到过commandname等,可以这个也没有办法啊。最后只好加了一个textbox,手动添加编号进去。如果哪位大侠知道方法的话,请一定要告诉我啊。
接下来的问题就是因为第一个问题引起的,我把delete、reply和add这三个按纽都放到了一起,结果出现的麻烦就是不可以随便的换功能,因为每一个都是submit,一换的话就引发验证控件工作,然后就没有办法转换过去了。
还有就是各个控件的visible属性的控制,也着实让我头痛了好一阵子……
就说这么多。刚才火箭绝地大反击,得分超过掘金啦~~~~

<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ import namespace="System.Data"%>
<%@ import namespace="System.Data.OleDb"%>
<script language="c#" runat="server">
string connstr=ConfigurationSettings.AppSettings["color"];
OleDbConnection conn;
//页面初始化
private void Page_Load(object sender,System.EventArgs e){
if(!Page.IsPostBack){
showguest();
if(Session["login"]=="yes"){
pen4.Visible=false;
del.Visible=true;
rep.Visible=true;
quit.Visible=true;
}
else{
del.Visible=false;
rep.Visible=false;
quit.Visible=false;
}
}
}

//给rep1绑定数据
private void showguest(){
conn=new OleDbConnection(connstr);
string sql="select top 4 * from guestbook order by id desc";
OleDbCommand cmd=new OleDbCommand(sql,conn);
conn.Open();
rep1.DataSource=cmd.ExecuteReader();
rep1.DataBind();
conn.Close();
}

//点击留言按纽后响应的事件
private void bt2_click(object source,System.EventArgs e){
rep1.Visible=false;
pan1.Visible=true;
pan2.Visible=false;
button2.Visible=false;
}

//回复时响应的事件
private void bt4_click(object source,System.EventArgs e){
if(Page.IsValid){
conn=new OleDbConnection(connstr);
string sql="select * from guestbook";
OleDbDataAdapter ada=new OleDbDataAdapter(sql,conn);
OleDbCommandBuilder cb=new OleDbCommandBuilder(ada);
DataSet ds=new DataSet();
ada.Fill(ds,"gbook");
DataTable dt4=ds.Tables["gbook"];
dt4.PrimaryKey=new DataColumn[]{dt4.Columns["id"]};
int ids=Int32.Parse(tbs5.Text);
DataRow dr=dt4.Rows.Find(ids);
dr["reply"]=tbs6.Text;
ada.Update(ds,"gbook");
pan2.Visible=false;
rep1.Visible=true;
showguest();
}

//添加新留言时响应的事件
}
private void bt1_click(object source,System.EventArgs e){
if(Page.IsValid){
conn=new OleDbConnection(connstr);
string sql="select * from guestbook order by ddate desc";
OleDbDataAdapter ada=new OleDbDataAdapter(sql,conn);
OleDbCommandBuilder cb=new OleDbCommandBuilder(ada);
DataSet ds=new DataSet();
ada.Fill(ds,"gbook");
DataTable dt1=ds.Tables["gbook"];
DataRow dr1=dt1.NewRow();
dr1["dname"]=tbs1.Text;
dr1["homepage"]=tbs2.Text;
dr1["dbody"]=tbs4.Text;
dr1["ddate"]=System.DateTime.Now;
dt1.Rows.Add(dr1);
ada.Update(ds,"gbook");
pan1.Visible=false;
pan2.Visible=false;
rep1.Visible=true;
button2.Visible=true;
showguest();

}
}

//点击回复时响应的事件
private void bt3_click(object source,System.EventArgs e){
pan2.Visible=true;
//rep1.Vislble=false;
pan1.Visible=false;
}
private void bt5_click(object source,System.EventArgs e){
pan3.Visible=true;
}

//删除留言
private void bt6_click(object source,System.EventArgs e){
if(Page.IsValid){
conn=new OleDbConnection(connstr);
string sql="delete * from guestbook where id="+tbs7.Text;
OleDbCommand cmd=new OleDbCommand(sql,conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
pan3.Visible=false;
showguest();
}
}

//点击进入后的事件
private void bt7_click(object source,System.EventArgs e){
pen4.Visible=true;
}

//登陆处理
private void bt8_click(object source,System.EventArgs e){
if(Page.IsValid){
conn=new OleDbConnection(connstr);
string sql="select * from duser where dname='"+tbs8.Text+"'";
OleDbCommand cmd=new OleDbCommand(sql,conn);
conn.Open();
OleDbDataReader dr=cmd.ExecuteReader();
if(dr.Read()){
if(dr["dpd"].ToString()==tbs9.Text){
Session["login"]="yes";
lb1.Text=Session["login"].ToString();
pen4.Visible=false;
del.Visible=true;
rep.Visible=true;
quit.Visible=true;
}
else{
lb1.Text="not well";
del.Visible=false;
rep.Visible=false;
quit.Visible=false;
}
}
}
}

//退出系统
private void bt9_click(object source,System.EventArgs e){
Session["login"]="no";
del.Visible=false;
rep.Visible=false;
quit.Visible=false;
lb1.Text="";
}
</script>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>留言本实验</title>
</head>
<style>
td { font-size: 12px; line-height: 20px; color:#6E0808;font-family:"宋体";}
</style>
<body>
<form runat="server">
<asp:Label id="lb1" runat="server"/>
<asp:panel id="pen4" runat="server" Visible="false">
id:<asp:TextBox id="tbs8" runat="server"/>
<asp:RequiredFieldValidator ControlToValidate="tbs8" runat="server" id="r8" ErrorMessage="error!"/><br>
pd:<asp:TextBox id="tbs9" runat="server" textmode="Password"/>
<asp:RequiredFieldValidator ControlToValidate="tbs9" runat="server" id="r9" ErrorMessage="error!"/><br>
<asp:linkButton id="button8" runat="server" OnClick="bt8_click" Text="gooooo"/>
</asp:panel>
<asp:linkButton id="button7" runat="server" OnClick="bt7_click" Text=" login"/>
<asp:linkButton id="button2" runat="server" OnClick="bt2_click" text="write"/>
<asp:linkButton runat="server" OnClick="bt5_click" text="del" Visible="false" id="del"/>
<asp:linkButton runat="server" OnClick="bt3_click" text="reply" Visible="false" id="rep"/>
<asp:linkButton runat="server" OnClick="bt9_click" text="quit" Visible="false" id="quit"/>
<asp:Repeater id="rep1" runat="server">
<headertemplate>
<table width="200" border="0" cellpadding="0" cellspacing="0">
</headertemplate>
<itemtemplate>
<tr>
<td height="20" colspan="2" valign="top" bgcolor="#00CCFF"><%# DataBinder.Eval(Container,"DataItem.dname")%><br><%# DataBinder.Eval(Container,"DataItem.id")%></td>
<td width="30" valign="top" bgcolor="#CC6633"><a href="<%# DataBinder.Eval(Container,"DataItem.homepage")%>" target="_blank">hp</a></td>
<td width="90" valign="top" bgcolor="#CC6633"><%# DataBinder.Eval(Container,"DataItem.ddate")%></td>
</tr>
<tr>
<td height="20" colspan="4" valign="top" bgcolor="#CCFFCC"><%# DataBinder.Eval(Container,"DataItem.dbody")%></td>
</tr>
<tr>
<td width="30" height="20" valign="top" bgcolor="#999999">reply
</td>
<td colspan="3" valign="top" bgcolor="#D4D0C8"><%# DataBinder.Eval(Container,"DataItem.reply")%></td>
</tr>
<tr>
<td height="1"></td>
<td width="30"></td>
<td></td>
<td></td>
</tr>
</itemtemplate>
<footertemplate>
</table>
</footertemplate>
</asp:Repeater>

<asp:Panel Visible="false" runat="server" id="pan1">
id*:<asp:TextBox id="tbs1" runat="server"/>
<asp:RequiredFieldValidator ControlToValidate="tbs1" runat="server" id="r1" ErrorMessage="error!"/><br>
homepage*:<asp:TextBox id="tbs2" runat="server"/>
<asp:RequiredFieldValidator ControlToValidate="tbs2" runat="server" id="r2" ErrorMessage="error!"/><br>
qq:<asp:TextBox id="tbs3" runat="server"/><br>
body*:<asp:TextBox id="tbs4" TextMode="MultiLine" runat="server"/>
<asp:RequiredFieldValidator ControlToValidate="tbs4" runat="server" id="r4" ErrorMessage="error!"/><br>
<asp:Button id="button1" OnClick="bt1_click" text="ok let us go" runat="server"/><br>
</asp:Panel>

<asp:panel id="pan2" Visible="false" runat="server">
id*:<asp:TextBox id="tbs5" runat="server"/>
<asp:RequiredFieldValidator ControlToValidate="tbs5" runat="server" id="r5" ErrorMessage="error!"/><br>
rebody:<asp:TextBox id="tbs6" TextMode="MultiLine" runat="server"/>
<asp:Button id="button4" OnClick="bt4_click" text="ok let us go" runat="server"/><br>
</asp:panel>
<asp:panel id="pan3" Visible="false" runat="server">
id*:<asp:TextBox id="tbs7" runat="server"/>
<asp:RequiredFieldValidator ControlToValidate="tbs7" runat="server" id="r7" ErrorMessage="error!"/><br>
<asp:Button id="button6" OnClick="bt6_click" text="delete" runat="server"/><br>
</asp:panel>
</form>

</body>
</html>

posted on 2006-06-26 13:38 Notus|南色的风 阅读(171) 评论(9)  编辑 收藏 所属分类: Happy Programming

评论:
#3楼  2008-06-19 15:56 | spring 0611 [未注册用户]
Corporate Solution Provider, provides one-stop solution to the investors or businessmen with professional, quality-guaranteed portfolios, facilities and aftercare services through all stages of investment process. Tannet is designed to quickly connect you to the people and information and the assistance you need for success in Hong Kong, PRC China, offshore and overseas jurisdictions.

We provide the Overseas / Offshore Company Registration as follows :
Overseas Company Registration
USA Corporate Formation (Delaware Company Formation), UK Corporate Formation, UAE Corporate Formation (United Arab Emirates), France Corporate Formation, Swiss Corporate Formation, Italy Corporate Formation, Germany Corporate Formation, Netherlands Corporate Formation, Macau Corporate Formation, Malaysia Corporate Formation, Singapore Corporate Formation, Korea Corporate Formation, Japan Corporate Formation, Argentina Corporate Formation, Vietnam Corporate Formation, Russia Corporate Formation

Offshore Company Registration
Samoa Company Registration, The British Virgin Islands Company Registration (BVI Company), Cayman Company Registration, Anguilla Company Registration, Bermuda Company Registration, Brunei Company Registration, Labuan Company Registration, Seychelles Company Registration,Mauritius Company Registration,Bahamas Company Registration, Marshall Company Registration.

For the further information, don’t hesitate to contact us
Contact:Spring
Tel:86-10-58674406
Email: tannetcn@hotmail.com or visit our
Website: http://www.beijing-company.net/ http://www.for-beijing.net/ http://beijing.tannet.net/En.aspx
Add:Room 609, Block B, Free Town, Dongshanhuan South Rd 58, ChaoYang District,BJ,China
北京朝阳区东三环南路58号富顿中心B座609室


  回复  引用    
#4楼  2008-06-19 15:56 | spring 0611 [未注册用户]
BEIJING TANNET Consulting Company is one of the world’s largest consulting institutions in corporate formation, management and planning, we are equipped with a team of excellent,professional accountants,financial engineers from home and abroad, who are ready to provide you with quality-guaranteed service.

Information OF HK company tax return
Hong Kong taxes are among the lowest in the world, and our tax regime is simple and predictable. Hong Kong sourced income can be taxed in three ways, Profits Tax, Salaries Tax and Property Tax.
The mode for tax return
If the company have not business actually, they can carry out zero tax return; if the unlimited company have some operations, they should first work up account and then carry out tax return; if the limited company has normal business operation ,they should work up account, audit by the certified public accountant (CPA) and then tax return.
We and help you doing the book-keeping and tax return according your requirements

For the further information, don’t hesitate to contact us
Contact:Spring
Tel:86-10-58674406
Email: tannetcn@hotmail.com or visit our
Website: http://www.beijing-company.net/ http://www.for-beijing.net/ http://beijing.tannet.net/En.aspx
Add:Room 609, Block B, Free Town, Dongshanhuan South Rd 58, ChaoYang District,BJ,China
北京朝阳区东三环南路58号富顿中心B座609室
  回复  引用    
#5楼  2008-06-20 14:50 | spring 0611 [未注册用户]
Tannet Consulting Company is one of the world’s largest consulting institutions in corporate formation, management and planning, we are an quality-guaranteed institute with many offices worldwide. Services the world of business, professional and trustworthy.
Beijing Tannet can provide services as follows:
HK Company Registration
Beijing Representative Office
Wholly Foreign Owned Enterprises
Offshore Company Registration
Beijing Co-operative Joint Venture (CJV)
Equity Joint Venture (EJV)
BVI/Britain/Samoa/USA Delaware Company Resgitration.
Global Trademark Design and Registration
Brand Name Promotion
Accounting, annual returns and auditing, financial and tax planning
For the further information, don’t hesitate to contact us
Contact:Spring
Tel:86-10-58674406
Email: tannetcn@hotmail.com or visit our
Website: http://www.beijing-company.net/ http://www.for-beijing.net/ http://beijing.tannet.net/En.aspx
Add:Room609, BlockB, Free Town, Dongshanhuan South Rd 58, CY District ,BJ
北京朝阳区东三环南路58号富顿中心B座609室



  回复  引用    
#6楼  2008-06-20 14:50 | spring 0611 [未注册用户]
Tannet — Corporate Solution Provider, provides one-stop solution to the investors or businessmen with professional, quality-guaranteed portfolios, facilities and aftercare services through all stages of investment process. Tannet is designed to quickly connect you to the people and information and the assistance you need for success in Hong Kong, PRC China, offshore and overseas jurisdictions.

We provide the Overseas / Offshore Company Registration as follows :
Overseas Company Registration
USA Corporate Formation (Delaware Company Formation), UK Corporate Formation, UAE Corporate Formation (United Arab Emirates), France Corporate Formation, Swiss Corporate Formation, Italy Corporate Formation, Germany Corporate Formation, Netherlands Corporate Formation, Macau Corporate Formation, Malaysia Corporate Formation, Singapore Corporate Formation, Korea Corporate Formation, Japan Corporate Formation, Argentina Corporate Formation, Vietnam Corporate Formation, Russia Corporate Formation

Offshore Company Registration
Samoa Company Registration, The British Virgin Islands Company Registration (BVI Company), Cayman Company Registration, Anguilla Company Registration, Bermuda Company Registration, Brunei Company Registration, Labuan Company Registration, Seychelles Company Registration,Mauritius Company Registration,Bahamas Company Registration, Marshall Company Registration.

For the further information, don’t hesitate to contact us
Contact:Spring
Tel:86-10-58674406
Email: tannetcn@hotmail.com or visit our
Website: http://www.beijing-company.net/ http://www.for-beijing.net/ http://beijing.tannet.net/En.aspx
Add:Room 609, Block B, Free Town, Dongshanhuan South Rd 58, ChaoYang District,BJ,China
北京朝阳区东三环南路58号富顿中心B座609室

  回复  引用    
#7楼  2008-07-10 13:19 | spring 0611 [未注册用户]
BEIJING TANNET Consulting Company is one of the world's largest consulting institutions in corporate formation, management and planning. We are equipped with a team of excellent,professional accountants, financial engineers from home and abroad, who are ready to provide you with satisfaction and quality guaranteed service.

Beijing Tannet can provide the following services:
Hong Kong Company Registration
Offshore Company Registration
Overseas Company Registration
Beijing Representative Office
Wholly Foreign Owned Enterprises(WFOE)
Beijing Co-operative Joint Venture (CJV)
Equity Joint Venture (EJV)
BVI/Britain/Samoa/USA Delaware Company Resgitration.
Global Trademark Design and Registration
Brand Name Promotion
Accounting, annual returns and auditing, financial and tax planning If you or other contacts are interested and seeking international consulting services or partners,donot hesitate to contact us,it is our pleasure to give you consult and advice.

Contact:Spring
Tel:86-10-58674406
Email: tannetcn@hotmail.com or visit our
Website: http://www.beijing-company.net/
http://www.for-beijing.net/ http://beijing.tannet.net/En.aspx
Add:Room609, BlockB, Free Town, Dongshanhuan South Rd 58, CY District ,BJ
北京朝阳区东三环南路58号富顿中心B座609室
  回复  引用    
#8楼  2008-07-21 11:44 | spring 0611 [未注册用户]
BEIJING TANNET Consulting Company is one of the world's largest consulting institutions in corporate formation, management and planning. We are equipped with a team of excellent,professional accountants, financial engineers from home and abroad, who are ready to provide you with satisfaction and quality guaranteed service.

Beijing Tannet can provide the following services:
Hong Kong Company Registration
Offshore Company Registration
Overseas Company Registration
Beijing Representative Office
Wholly Foreign Owned Enterprises(WFOE)
Beijing Co-operative Joint Venture (CJV)
Equity Joint Venture (EJV)
BVI/Britain/Samoa/USA Delaware Company Resgitration.
Global Trademark Design and Registration
Brand Name Promotion
Accounting, annual returns and auditing, financial and tax planning If you or other contacts are interested and seeking international consulting services or partners,donot hesitate to contact us,it is our pleasure to give you consult and advice.

Contact:Spring
Tel:86-10-58674406
Email: tannetcn@hotmail.com or visit our
Website: http://www.beijing-company.net/
http://www.for-beijing.net/ http://beijing.tannet.net/En.aspx
Add:Room609, BlockB, Free Town, Dongshanhuan South Rd 58, CY District ,BJ
北京朝阳区东三环南路58号富顿中心B座609室
  回复  引用    
#9楼  2008-07-30 15:16 | spring 0611 [未注册用户]
BEIJING TANNET Consulting Company is one of the world's largest consulting institutions in corporate Formation,management and planning. We are equipped with a team of excellent,professional accountants and financial engineers from home and abroad, who are ready to provide you with satisfied and qualified guaranteed service.

Beijing Tannet can provide the following services:
Hong Kong Company Registration
Offshore Company Registration
Overseas Company Registration
Beijing Representative Office
Wholly Foreign Owned Enterprises(WFOE)
Beijing Co-operative Joint Venture (CJV)
Equity Joint Venture (EJV)
BVI/Britain/Samoa/USA Delaware Company Registration.
Global Trademark Design and Registration
Brand Name Promotion
Accounting, annual returns and auditing, financial and tax planning If you or other contacts are interested and seeking international consulting services or partners,please do not hesitate to contact us,it is our pleasure to give you professional consultancy and advice.

Contact:Spring
Tel:86-10-58674406
Email: tannetcn@hotmail.com or visit our
Website: http://www.beijing-company.net/
http://www.for-beijing.net/
http://beijing.tannet.net/En.aspx
Add:Room609, BlockB, Free Town, Dongshanhuan South Rd 58, CY District ,BJ
北京朝阳区东三环南路58号富顿中心B座609室
  回复  引用