前台:
<table class="li1" cellspacing="1" cellpadding="2" border="0" style=" 100%;" id="sort" oncontextmenu="return false; " onpaste=" return false;">
<thead>
<tr>
<td style=" 3%; padding-left: 0px;" align="left"><input id="selectall" onclick="SelectAll(selectall)" type="checkbox" name="selectall" /></td>
<td align="left" style=" 15%;"><asp:LinkButton ID="LinkButton1" runat="server" CommandName="username" OnClick="field_sort_Click">用户名</asp:LinkButton></td>
<td style=" 10%;"><asp:LinkButton ID="LinkButton2" runat="server" CommandName="logTime" OnClick="field_sort_Click">登录时间</asp:LinkButton></td>
<td style=" 10%;"><asp:LinkButton ID="LinkButton3" runat="server" CommandName="exitTime" OnClick="field_sort_Click">退出时间</asp:LinkButton></td>
<td style=" 9%;"><asp:LinkButton ID="LinkButton4" runat="server" CommandName="useredTime" OnClick="field_sort_Click">使用时间</asp:LinkButton></td>
<td style=" 15%;"><asp:LinkButton ID="LinkButton5" runat="server" CommandName="opename" OnClick="field_sort_Click">操作日志</asp:LinkButton></td>
<td style=" 9%;" align="center">操作</td>
</tr>
</thead>
<tbody>
<asp:Repeater ID="rpt_loginLog" runat="server"
onitemcommand="rpt_loginLog_ItemCommand" EnableViewState="False" onitemdatabound="rpt_loginLog_ItemDataBound"
>
<ItemTemplate>
<tr onmouseover=" this.className='on' " onmouseout="this.className='off'" style="cursor: hand">
<td style="padding-left: 0px;" align="left"><input onclick="SelectOne(this)" type="checkbox" name="sel_one" value='<%#DataBinder.Eval(Container.DataItem,"id")%>'></td>
<td align="left" title='<%#Eval("username")%>'> <%#Eval("username").ToString().Length > 8 ? Eval("username").ToString().Substring(0, 8) + "..." : Eval("username").ToString()%></td>
<td><%#Eval("logTime")%></td>
<td><%#Eval("exitTime").ToString() == "" ? "正在使用系统" : Eval("exitTime").ToString()%></td>
<td><%#Eval("useredTime")%>分钟</td>
<td>
<asp:Repeater runat="server" ID="rtp_operdetail">
<HeaderTemplate>
<table>
<tr>
<td>
操作模块
</td>
<td>
操作类别
</td>
<td>
次数
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Eval("plateid")%></td>
<td><%#Eval("operateType")%></td>
<td><%#Eval("time")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</td>
<td>
<a href="javascript:deleteOne('<%#Eval("id") %>')" ><font color="blue">删除 </font></a>
<%--<asp:LinkButton ID="btn_del" CommandName="del" runat="server" CommandArgument='<%#Eval("id") %>' OnClientClick="return confirm('确定要删除此客户吗?')"><font color="blue">删除<%#Eval("id") %></font></asp:LinkButto--%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
后台:
protected void field_sort_Click(object sender, EventArgs e)
{
LinkButton lbt = sender as LinkButton;
if (hdSort.Value.Trim() == "0")
{
hdSort.Value = "1";
BindData("", lbt.CommandName.ToString()+" DESC");
}
else
{
BindData("", lbt.CommandName.ToString() + " ASC");
hdSort.Value = "0";
}
}
protected void AspNetPager2_PageChanged(object sender, EventArgs e)
{
BindData("","logTime desc");
}
protected void rpt_loginLog_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "del")
{
string id = e.CommandArgument.ToString();
erp_crm.BLL.crm_loginLog loginLog = new crm_loginLog();
loginLog.Delete(id);
BindData("", "logTime desc");
}
}
protected void rpt_loginLog_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
string id=DataBinder.Eval(e.Item.DataItem,"id").ToString();
string sql=string.Format("select plateid,operateType,sum(1) 'time' from dbo.crm_OperationLog where loginid='{0}' group by plateid,operateType",id);
Repeater rpt = (Repeater)e.Item.FindControl("rtp_operdetail");
rpt.DataSource=DbHelperSQL.Query(sql).Tables[0];
rpt.DataBind();
}