<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ClassInfor.aspx.cs" Inherits="ClassInfor" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    
<title>班级管理</title>
<script src ="JS/JScript.js" type ="text/javascript"></script>
<link href="css/css.css" rel="stylesheet" type="text/css" />
</head>
<body  class ="csBody">
<form id="form1" runat="server">
<table width="795" border="0" cellspacing="0" cellpadding="0">
  
<tr>
    
<td width="799" height="4"></td>
  
</tr>
  
<tr>
    
<td height="32" background="images/010.gif">&nbsp;</td>
  
</tr>
  
<tr>
    
<td height="447" valign="top" background="images/012.gif"><table width="744" height="110" border="0" align="center" cellpadding="0" cellspacing="0">
      
<tr  class="SubMenu_Item">
        
<td valign="top" background="images/015.gif"><table border="0" cellspacing="0" cellpadding="0">
          
<tr>
            
<td class="Current_Item" style="height: 26px"><href="ClassInfor.aspx">班级列表 ▼</a></td>
            
<td width="9" style="height: 26px"></td>
            
<td class="Default_Item" style="height: 26px"><href="ClassAdd.aspx?action=add">添加班级 ▼</a></td>
          
</tr>
        
</table></td>
      
</tr>
      
<tr>
        
<td style="height: 28px"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          
<tr>
            
<td width="40%">
              
<span class="hei"><asp:RadioButton ID="rbTName" runat="server" Checked="True" GroupName="select" Text="班级名" />
                  
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
              
</span></td>
            
<td width="40%">
              
<span class="hei"><asp:RadioButton ID="rbTID" runat="server" GroupName="select" Text="班级编号" />
                  
<asp:TextBox ID="txtID" runat="server"></asp:TextBox>
              
</span></td>
            
<td width="20%"><asp:Button ID="btSelect" class="anniu"  runat="server" Text="查询" OnClick="btSelect_Click" /></td>
          
</tr>
        
</table></td>
      
</tr>
      
<tr>
        
<td valign="top">
        
<!---->
       
<table width="100%" border="0" cellspacing="0" cellpadding="0">
        
<tr><td>
        
<asp:Repeater ID="Repeater1" runat="server">
        
<HeaderTemplate><%--这里是头模板--%>
         
<table width="100%" border="0" cellspacing="0" cellpadding="0">
        
<tr class="bg01">
        
<td>
                 
<input id="chkAll" type="checkbox"onclick="checkAll(this, 'chkOne')" />全选
                            
</td>
                             
<td>
                                 班级名
</td>
                            
<td>
                                 人数
</td>
                            
<td>
                               所属级部
</td>
                            
<td>
                              所在教室
</td>
                             
<td>
                               班主任
</td>
                               
<td>
                                  操作
</td>
        
</tr>
        
</HeaderTemplate>
        
<ItemTemplate><%--项模板--%>
        
<tr onMouseOver="this.style.background='#AFD1DD'" onMouseOut="this.style.background='#F2FAFC';" bgcolor="#F2FAFC" class="bg05">
<td>
  
<input id="chkOne" name ="chkOne" type="checkbox" value="<%#Eval("ID") %>" /></td>
                            
<td>
                                
<%#   DataBinder.Eval(Container.DataItem, "Name").ToString().Replace(" """)%>
                            
</td>
                            
<td>
                                
<%#   DataBinder.Eval(Container.DataItem, "PersonCount")%>
                            
</td>
                            
<td>
                                
<%#   DataBinder.Eval(Container.DataItem, "DName").ToString().Replace(" ","")%>
                            
</td>
                            
<td>
                                
<%#   DataBinder.Eval(Container.DataItem, "rName")%>
                            
</td>
                            
<td>
                                
<%#   DataBinder.Eval(Container.DataItem, "tName")%>
                            
</td>
                            
<td>
                             

                             
<style="text-decoration:none" href = "Class_CourseInfor.aspx?ID=<%#Eval("ID")%>&name=<%# Server.UrlEncode(Eval("name").ToString())%>">添加科目</a>
                                
<style="text-decoration:none" href = "ClassAdd.aspx?ID=<%#Eval("ID")%>" ><img border="0" src="images/028.gif" /></a>
                            
</td>
        
</tr>
        
</ItemTemplate>
        
<SeparatorTemplate><%--分隔符模板--%>
        
</SeparatorTemplate>
        
<FooterTemplate><%--页脚模板--%>
        
</table>
        
</FooterTemplate>
        
</asp:Repeater>
        
</td></tr>
        
        
<tr><td >
                    
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Web/images/027.gif" OnClientClick ="return checkTest()"  OnClick="ImageButton1_Click" />
            
&nbsp; &nbsp; &nbsp;
            
<span style="font-size: 10pt"></span><asp:Literal ID="LtCount" runat="server"></asp:Literal><span
                
style="font-size: 10pt">页 &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; 当前第</span><asp:Label ID="lbCount" runat="server" Text="Label" Font-Size="10pt" ForeColor="#FF8000"></asp:Label><span style="font-size: 10pt">
                        
&nbsp;</span> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<asp:HyperLink ID="hlTop" runat="server" ImageUrl="~/Web/images/016.gif">第一页</asp:HyperLink>
            
&nbsp;<asp:HyperLink ID="hlBack" runat="server" ImageUrl="~/Web/images/018.gif">上一页</asp:HyperLink>&nbsp;
            
&nbsp;<asp:HyperLink ID="hlNext" runat="server" ImageUrl="~/Web/images/019.gif">下一页</asp:HyperLink>
            
&nbsp; &nbsp;<asp:HyperLink ID="hlBoot" runat="server" ImageUrl="~/Web/images/017.gif">最后一页</asp:HyperLink>
            
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="font-size: 10pt">转到</span><span class="hei"><asp:DropDownList ID="dpPage"
                            runat
="server" Width="40px" AutoPostBack="True" OnSelectedIndexChanged="dpPage_SelectedIndexChanged" Font-Size="9pt">
                        
</asp:DropDownList><span style="font-size: 10pt"></span></td></tr>
        
        
</table>
        
<!---->
      
</td>
      
</tr>
    
</table>
        
<asp:Label ID="lbScript" runat="server"></asp:Label></td>
  
</tr>
  
<tr>
    
<td height="4" background="images/011.gif"></td>
  
</tr>
</table>
</form>
</body>
</html>

后台

 

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SchoolOA.BLL;
using SchoolOA.Model;

public partial class ClassInfor : System.Web.UI.Page
{
    
protected void Page_Load(object sender, EventArgs e)
    
{
        
if (!IsPostBack)
        
{
            Bind(
"1=1");
            
if (Request.QueryString["Page"!= null)
            
{
                
this.dpPage.SelectedIndex = Convert.ToInt32(Request.QueryString["Page"]) - 1;
            }

        }

    }


    
// 绑定
    private void Bind(string strWhere)
    
{
        DClass_Info dci 
= new  DClass_Info();
        DataSet ds 
= dci.GetList(strWhere);


        
//创建分页类:
        PagedDataSource objPage = new PagedDataSource();

        
//设置数据源
        objPage.DataSource = ds.Tables[0].DefaultView;

        
//允许分页:
        objPage.AllowPaging = true;

        
//设置每页显示条数:
        objPage.PageSize = 10;

        
int pageSize = objPage.PageCount;
        
//定义变量用来保存当前页索引:
        int curPage;
        
this.LtCount.Text = pageSize.ToString();

        
this.dpPage.Items.Clear();
        
for (int i = 1; i <= pageSize; i++)
        
{
            
this.dpPage.Items.Add(i.ToString());
        }


        
//判断是否有页面跳转请求:
        if (Request.QueryString["Page"!= null)
        
{
            curPage 
= Convert.ToInt32(Request.QueryString["Page"]);

        }

        
else
        
{
            curPage 
= 1;
        }


        objPage.CurrentPageIndex 
= curPage - 1;
        
this.lbCount.Text = curPage.ToString();
        
this.hlTop.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1";
        
this.hlNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(curPage + 1);
        
this.hlBack.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(curPage - 1);
        
this.hlBoot.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + pageSize.ToString();
        
if (objPage.IsFirstPage)
        
{
            
this.hlTop.Enabled = false;
            
this.hlBack.Enabled = false;
            
this.hlBoot.Enabled = true;
            
this.hlNext.Enabled = true;
        }

        
else if (objPage.IsLastPage)
        
{
            
this.hlTop.Enabled = true;
            
this.hlBack.Enabled = true;
            
this.hlBoot.Enabled = false;
            
this.hlNext.Enabled = false;
        }

        
else
        
{
            
this.hlTop.Enabled = true;
            
this.hlBack.Enabled = true;
            
this.hlBoot.Enabled = true;
            
this.hlNext.Enabled = true;
        }

        
this.Repeater1.DataSource = objPage;
        
this.Repeater1.DataBind();
    }

    
//删除
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    
{
        
string listID = Convert.ToString(Request.Form["chkOne"]);
        DClass_Info dci 
= new DClass_Info();
        
if (Request.Form["chkOne"== null)
        
{
            
this.lbScript.Text = "<script>alert('请先选择要删除的数据!')</script>";
        }

        
else
        
{
            
try
            
{
                
string s = dci.Delete(listID);
                
this.lbScript.Text = "<script>alert('您删除了[" + s + "]行数据');wondow.location.href=window.location.href;;</script>";

            }

            
catch (Exception ex)
            
{

                
this.lbScript.Text = "<script>alert('" + ex.Message + "')</script>";
            }

        }

        Bind(
"1=1");
    }

    
//查询
    protected void btSelect_Click(object sender, EventArgs e)
    
{
        
if (this.rbTID.Checked == true)
        
{
            
string id = this.txtID.Text.ToString();
            Bind(
"  c.id like '%" + id + "%'");
        }

        
if (rbTName.Checked == true)
        
{
            
string id = this.txtName.Text.ToString();
            Bind(
"  c.Name like '%" + id + "%'");
        }

    }

    
protected void dpPage_SelectedIndexChanged(object sender, EventArgs e)
    
{
        Server.Transfer(Request.CurrentExecutionFilePath 
+ "?Page=" + this.dpPage.SelectedValue.ToString());
    }


}

posted on 2008-06-03 17:09  code life  阅读(440)  评论(0)    收藏  举报