投票系统-管理

投票系统管理界面:

 

 

 

其源代码:

 

代码
  1 <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ManageVote.ascx.cs" Inherits="ManageVote" %>
  2 <table style="width:800px; height:400px"   cellspacing="0">
  3     <tr>
  4        
  5         <td style="width:189px; background-image: url(image/login_1.gif);">
  6         </td>
  7          <td style="background-image: url(image/login_2.gif)">
  8            <table style="width:400px;  height:400px;">
  9             <tr >
 10                 <td style="width:100px;"></td>
 11                 <td style="width:195px;"></td>
 12                  <td style="width:100px;"></td>
 13             </tr>
 14              <tr >
 15                 <td style="width:100px;"></td>
 16                 <td style="width:195px;"></td>
 17                  <td style="width:100px;"></td>
 18             </tr>
 19              <tr >
 20                 <td style="width:100px;"></td>
 21                 <td style="width:195px;"></td>
 22                  <td style="width:100px;">
 23                      <asp:ImageButton ID="returnIndex" runat="server" ImageUrl="~/image/ruturnIndex.gif" OnClick="returnIndex_Click" />
 24                      </td>
 25             </tr>
 26              <tr >
 27                 <td style="width:100px; height: 26px;"></td>
 28                 <td style="width:195px; height: 26px;">
 29                 
 30                 
 31                 </td>
 32                  <td style="width:100px; height: 26px;"></td>
 33             </tr>
 34              <tr >
 35                 <td style="width:100px; height: 34px;"></td>
 36                 <td style="height: 34px; width:300px;" colspan="2">
 37                 
 38                 
 39                     <asp:DataList ID="DLVoteManage" runat="server" Height="66px" Width="300px" OnDeleteCommand="DLVoteManage_DeleteCommand" DataKeyField="VoteItem_id"  >
 40                        <ItemTemplate>
 41                            <table>
 42                                 <tr>
 43                                    <td style="width:200px;" align="left">
 44                                        <asp:Label ID="labTitle" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"VoteItem") %>' ForeColor="#C04000"></asp:Label>
 45                                    </td>
 46                                     
 47                                     <td>
 48                                         <asp:ImageButton ID="IBdelete" runat="server"  CommandArgument='<%# DataBinder.Eval(Container.DataItem,"VoteItem_id") %>'
 49                                             CommandName="delete"  ImageUrl="~/image/delete.gif" CausesValidation="False" OnLoad="IBdelete_Load"/>
 50                                     </td>
 51                                 </tr>
 52                               
 53                            </table>
 54                        
 55                        
 56                        
 57                        </ItemTemplate>
 58                     
 59                     
 60                     </asp:DataList>
 61                 
 62                 
 63                 
 64                 
 65                 
 66                 
 67                 </td>
 68                  
 69             </tr>
 70              <tr >
 71                 <td style="width:100px; height: 34px;"></td>
 72                 <td style="width:195px; height: 34px;"></td>
 73                  <td style="width:100px; height: 34px;"></td>
 74             </tr>
 75              <tr >
 76                 <td style="width:100px;"></td>
 77                 <td style="width:195px;"></td>
 78                  <td style="width:100px;"></td>
 79             </tr>
 80              <tr >
 81                 <td style="width:100px;"></td>
 82                 <td style="width:195px;"></td>
 83                  <td style="width:100px;"></td>
 84             </tr>
 85              <tr >
 86                 <td style="width:100px;"></td>
 87                 <td style="width:195px;"></td>
 88                  <td style="width:100px;"></td>
 89             </tr>
 90              <tr >
 91                 <td style="width:100px;"></td>
 92                 <td style="width:195px;"></td>
 93                  <td style="width:100px;"></td>
 94             </tr>
 95              <tr >
 96                 <td style="width:100px;"></td>
 97                 <td style="width:195px;"></td>
 98                  <td style="width:100px;"></td>
 99             </tr>
100            </table>
101          
102          
103          
104          
105         </td>
106          <td style="width:200px; background-image: url(image/login_3.gif);">
107          </td>
108     </tr>
109    
110 </table>
111 o
112 

 

 

 

 

后台代码:

 

代码
 1 using System;
 2 using System.Data;
 3 using System.Configuration;
 4 using System.Collections;
 5 using System.Web;
 6 using System.Web.Security;
 7 using System.Web.UI;
 8 using System.Web.UI.WebControls;
 9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11 
12 public partial class ManageVote : System.Web.UI.UserControl
13 {
14     BaseDb obj = new BaseDb();
15     protected void Page_Load(object sender, EventArgs e)
16     {
17         if (!IsPostBack)
18         {
19             Bind();
20         }
21 
22     }
23 
24     #region  对DataList进行数据绑定
25     public void Bind()
26     {
27         int userId = GetUserID();
28         DataSet ds = obj.getdatabydataset("select VoteItem_id,VoteItem from VoteItem where User_id = " +   userId  );
29         
30         DLVoteManage.DataSource = ds;
31         DLVoteManage.DataKeyField = "VoteItem_id";
32         DLVoteManage.DataBind();
33 
34     }
35 
36   #endregion
37 
38     #region  获得博客ID
39     public int GetBlogID()
40     {
41         int BlogID =3;
42         return BlogID;
43     }
44 
45     #endregion
46 
47     #region 获得用户ID
48     public int GetUserID()
49     {
50         int userID = 0;
51         int BlogId = GetBlogID();
52         try
53         {        //根据博客ID获取用户ID
54             DataSet ds = obj.getdatabydataset("select User_id from BlogManage where Blog_id=" + "'" + BlogId + "'");
55 
56             userID = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
57 
58         }
59         catch (Exception ee)
60         {
61             Response.Write("<script>alert('" + ee.Message + "');</script>");
62         }
63 
64         return userID;
65     }
66 
67     #endregion
68     protected void DLVoteManage_DeleteCommand(object source, DataListCommandEventArgs e)
69     {
70        int voteItemID = Convert.ToInt32(e.CommandArgument.ToString());
71         obj.ExecuteSql("DELETE FROM VoteItem where VoteItem_id = " + "'" + voteItemID + "'" )  ;
72         obj.ExecuteSql("DELETE FROM VoteSelect where VoteItem_id = " + "'" + voteItemID +"'");
73         Bind();
74     }
75 
76     #region  删除前给出提示信息
77     public void IBdelete_Load(object sender, EventArgs e)
78     {
79         
80         ((ImageButton)sender).Attributes["onclick"= "javascript:return confirm('你确认要删除该条记录吗?')";
81     }
82     #endregion
83     protected void returnIndex_Click(object sender, ImageClickEventArgs e)
84     {
85         Response.Redirect("~/VoteIndex.aspx");
86     }
87 }
88 

 

 

posted on 2010-04-11 22:48  wtq  阅读(478)  评论(0编辑  收藏  举报