码迷,mamicode.com
首页 > 其他好文 > 详细

第一次迭代

时间:2016-12-23 00:54:18      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:顺序   toe   exec   oev   odi   runtime   charset   send   pil   

技术分享技术分享
技术分享
技术分享
 
 
 
 
 
 
 
 
脚本代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FootGame.aspx.cs" Inherits="FootGame" %>
<!DOCTYPE html>
<html xmlns="技术分享http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text技术分享ml; charset=utf-8"/>    
<title></title>
</head>
<body>  
   <form id="form1" runat="server">   
  <div>    
     <table>      
         <tr>     
         <td><asp:TextBox ID="txtAsum" runat="server"></asp:TextBox></td>   
         <td><asp:TextBox ID="txtBsum" runat="server"></asp:TextBox></td></tr>   
        <tr> <td><asp:Button ID="btnAsum" runat="server" Text="加分" OnClick="btnAsum_Click" /></td>    
        <td><asp:Button ID="btnBsum" runat="server" Text="加分" OnClick="btnBsum_Click" />      
       <asp:Button ID="btnSumClear" runat="server" Text="分数清除" OnClick="btnSumClear_Click" />     
       </td></tr>       
   </table>  
 </div>   
</form>
</body>
<技术分享ml>
 
 
 
 
 
 

后台代码:

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data.SqlClient;

using System.Data;

using System.Configuration;

public partial class FootGame : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e) 

   {   

     if(!this.Page.IsPostBack)

        {   

         InitGamePage();   

       }  

  }  

  public void InitGamePage() 

   {    

       string sql = "select FootMark from dbo.FootSum";  

       SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString); 

       SqlDataAdapter sda = new SqlDataAdapter(sql, con);   

       DataSet ds = new DataSet();   

       sda.Fill(ds); 

       if(ds.Tables[0].Rows.Count>0)     

     {          

       txtAsum.Text = ds.Tables[0].Rows[0]["FootMark"].ToString();     

       txtBsum.Text = ds.Tables[0].Rows[1]["FootMark"].ToString();  

      } 

   }   

  protected void btnAsum_Click(object sender, EventArgs e)   

{  

       string sql1 = "update dbo.FootSum set FootMark=FootMark+1 where FootID=1";   

      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);  

      SqlCommand cmd1 = new SqlCommand(sql1,con);   

      con.Open();   

      int flag = cmd1.ExecuteNonQuery();  

      con.Close();  

      string sql = "select FootMark from dbo.FootSum where FootID=1";    

      SqlDataAdapter sda = new SqlDataAdapter(sql, con);  

      DataSet ds = new DataSet();   

      sda.Fill(ds);  

      int values = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());  

      if (values >= 3)  

      {    

           Page.ClientScript.RegisterStartupScript(this.GetType(),"","<script>alert(‘巴西队获胜‘);</script>"); 

       }  

      InitGamePage();  

  }   

protected void btnBsum_Click(object sender, EventArgs e)   

{      

     string sql1 = "update dbo.FootSum set FootMark=FootMark+1 where FootID=2";    

      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString); 

      SqlCommand cmd1 = new SqlCommand(sql1, con);   

      con.Open(); 

      int flag = cmd1.ExecuteNonQuery();   

      con.Close();  

      string sql = "select FootMark from dbo.FootSum where FootID=2"; 

      SqlDataAdapter sda = new SqlDataAdapter(sql, con);  

      DataSet ds = new DataSet();  

      sda.Fill(ds);    

      int values = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());

         if (values >= 3)     

      {      

         Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert(‘阿根廷队获胜‘);</script>");  

      }  

      InitGamePage();  

 }  

  protected void btnSumClear_Click(object sender, EventArgs e) 

   {     

      string sql = "update dbo.FootSum set FootMark=0";  

      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);    

      SqlCommand cmd = new SqlCommand(sql, con);    

      con.Open();   

      int flag = cmd.ExecuteNonQuery();  

      con.Close();   

      Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert(‘分数清除成功‘);</script>");  

      InitGamePage();  

   }

}

 
数据库代码:创建数据库
create database FirstNum
go
use FirstNum
go
create table FootSum
( FootID int primary key identity(1,1),
FootName nvarchar(50),
FootMark int
)
insert into FootSum values(‘巴西足球队‘,0);
insert into FootSum values(‘阿根廷足球队‘,0);
 
 
服务器配置:
<?xml version="1.0" encoding="utf-8"?>
<!--   有关如何配置 ASP.NET 应用程序的详细信息,请访问   技术分享http://go.microsoft.com/fwlink/?LinkId=169433   -->
<configuration>
 
 
 
    <system.web>       <compilation debug="true" targetFramework="4.5" />       <httpRuntime targetFramework="4.5" />     </system.web>   <connectionStrings>     <add name="conn" connectionString="server=.;uid=sa;pwd=sa;database=FirstNum"/>   </connectionStrings> </configuration
技术分享
>技术分享
图片顺序为34125
="4.5" />     </system.web>   <connectionStrings>     <add name="conn" connectionString="server=.;uid=sa;pwd=sa;database=FirstNum"/>   </connectionStrings> </configuration>

第一次迭代

标签:顺序   toe   exec   oev   odi   runtime   charset   send   pil   

原文地址:http://www.cnblogs.com/zzyzzyzzy/p/6213161.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!