📄 deprequery.aspx
字号:
<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="system.data" %>
<%@ import Namespace="system.data.sqlclient" %>
<script runat="server">
dim Cnn as sqlconnection
dim cmd as sqlcommand
Sub Page_Load(Sender As Object, E As EventArgs)
If Not IsPostBack Then
BindGrid()
End If
End Sub
Sub Query_Click(sender As Object, e As EventArgs)
Bindgrid()
End Sub
Sub BindGrid()
dim dataR as sqldatareader
dim dtcmd as sqldataadapter
dim dt as new datatable
dim MaxPage as integer '计算最大页数
dim str2 as string
dim Str1 as string
cnn=new sqlconnection(configurationsettings.appsettings("connection"))
if query_content.text<>"" then
str1=" and " & query_tj.SelectedItem.value & " like '%" & query_content.text & "%'"
end if
str2="select count(*) as nums,sum(depreamount) as deprenums,sum(depreamount*price) as summy from depresheet a,bookinfosheet b,pressinfosheet c where a.bookcode=b.code and presscode=c.code " & str1
cmd=new sqlcommand(str2,cnn)
cnn.open()
datar=cmd.executereader()
if datar.read() then
if datar("nums").tostring()="0" then
msg.text=""
else
msg.text="合计:记录数 " & datar("nums").tostring() & " 总折损数 " & datar("deprenums").tostring & " 总码洋 " & datar("summy").tostring
end if
end if
datar.close()
str1="select a.code,ddate,event,bookcode,b.name as bookname,c.abbrname,author,price,depreamount from depresheet a,bookinfosheet b,pressinfosheet c where a.bookcode=b.code and presscode=c.code " & str1 & " order by a.code desc,bookcode"
dtcmd=new sqldataadapter(str1,cnn)
dtcmd.fill(dt)
if (dt.defaultview.count mod datagrid1.pagesize)>0 then
maxpage=dt.defaultview.count \datagrid1.pagesize+1
else
maxpage=dt.defaultview.count \datagrid1.pagesize
end if
do while datagrid1.currentpageindex>0
if maxpage<datagrid1.currentpageindex+1 then
datagrid1.currentpageindex=datagrid1.currentpageindex-1
else
exit do
end if
loop
datagrid1.datasource=dt
datagrid1.databind()
cnn.close()
End Sub
Sub Grid1_del(Sender As Object, E As DataGridCommandEventArgs)
dim codestr as string=E.Item.Cells(0).Text
dim sql as string
dim datar as sqldatareader
dim bookcodestr as string=E.Item.Cells(3).text
if CType(e.CommandSource,LinkButton).CommandName="delete" then
'删除操作
cnn=new sqlconnection(configurationsettings.appsettings("connection"))
cnn.open()
sql="delete from depresheet where code='" & trim(codestr) & "' and bookcode='" & trim(bookcodestr) & "'"
cmd=new sqlcommand(sql,cnn)
cmd.executeNonQuery
cnn.close
bindgrid()
else
if CType(e.CommandSource,LinkButton).CommandName="deleteunit" then
'删除整单操作
cnn=new sqlconnection(configurationsettings.appsettings("connection"))
cnn.open()
sql="delete from depresheet where code='" & codestr & "'"
cmd=new sqlcommand(sql,cnn)
cmd.executeNonQuery
cnn.close()
bindgrid()
end if
end if
End Sub
Sub Grid1_Update(Sender as object,E as DataGridCommandEventArgs)
dim BookCodeStr as String=E.Item.Cells(3).Text
dim NumStr As String=CType(E.Item.Cells(8).Controls(0),TextBox).Text
dim CodeStr as String=E.Item.Cells(0).Text
dim sql as string
if Isnumeric(numstr) then
cnn=new sqlconnection(configurationsettings.appsettings("connection"))
cnn.open()
sql="update depresheet set depreamount=" & cint(numstr) & " where code='" & codestr & "' and bookcode='" & bookcodestr & "'"
cmd=new sqlcommand(sql,cnn)
cmd.executeNonQuery
cnn.close()
end if
DataGrid1.EditItemIndex=-1
BindGrid()
End Sub
Sub Grid1_Cancel(Sender as object,E as DataGridCommandEventArgs)
datagrid1.EditItemIndex=-1
BindGrid()
End Sub
Sub Grid1_Edit(Sender as object,E as DataGridCommandEventArgs)
DataGrid1.EditItemIndex=E.Item.ItemIndex
BindGrid()
End Sub
Sub Grid1_PageIndexChanged(Sender As Object, E As DataGridPageChangedEventArgs)
datagrid1.CurrentPageIndex = e.NewPageIndex
BindGrid()
End Sub
Function GetAlertInfo(byval str1 as string) as String
dim Str2 as String
str2="<script language='javascript'>alert('" & str1 & "')<"
str2+="/"
str2+="script>"
return trim(str2)
End Function
</script>
<html>
<head>
<title>折损查询</title>
<link href="../Main.css" type="text/css" rel="stylesheet" />
</head>
<body>
<form runat="server">
<b>折损查询</b>
<hr size="1" />
<table id="search" cellspacing="1" cellpadding="0" width="100%" align="center" border="0">
<tbody>
<tr class="tr2">
<td style="PADDING-LEFT: 5px" height="25">
检索条件:
<asp:DropDownList class="input_text" id="query_tj" runat="server" width="97">
<asp:ListItem Value="a.code" Selected="True">折损单编码</asp:ListItem>
<asp:ListItem Value="event">折损事由</asp:ListItem>
<asp:ListItem Value="b.name">图书名称</asp:ListItem>
<asp:ListItem Value="author">作者</asp:ListItem>
</asp:DropDownList>
检索内容:
<asp:TextBox class="input_text" id="query_content" runat="server" width="120"></asp:TextBox>
<asp:button class="input_button" id="QueryBtn" onclick="Query_Click" runat="server" text="查 询" CausesValidation="False"></asp:button>
<br />
<b><asp:Label id="Msg" runat="server" forecolor="red"></asp:Label></b></td>
</tr>
<tr>
<td style="PADDING-LEFT: 5px" height="25">
<asp:DataGrid id="DataGrid1" runat="server" width="100%" OnPageIndexChanged="Grid1_PageIndexChanged" AllowSorting="True" AllowPaging="True" Font-Names="verdana" bordercolor="Black" cellpadding="2" font-name="verdana" font-size="8pt" headerstyle-backcolor="#F8FAFC" OnItemCommand="Grid1_Del" AutoGenerateColumns="False" PageSize="12" OnEditCommand="Grid1_Edit" OnCancelCommand="Grid1_Cancel" OnupdateCommand="Grid1_Update">
<HeaderStyle font-bold="True" horizontalalign="Center" verticalalign="Middle" backcolor="#F8FAFC"></HeaderStyle>
<PagerStyle nextpagetext="下一页" font-names="宋体" font-bold="True" prevpagetext="上一页" horizontalalign="Right" forecolor="Blue" mode="NumericPages"></PagerStyle>
<Columns>
<asp:BoundColumn DataField="Code" ReadOnly="True" HeaderText="折损单编码"></asp:BoundColumn>
<asp:BoundColumn DataField="ddate" ReadOnly="True" HeaderText="折损日期" DataFormatString="{0:d}"></asp:BoundColumn>
<asp:BoundColumn DataField="event" ReadOnly="True" HeaderText="折损事由"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="bookcode" ReadOnly="True" HeaderText="图书编码"></asp:BoundColumn>
<asp:BoundColumn DataField="bookname" ReadOnly="True" HeaderText="图书名称"></asp:BoundColumn>
<asp:BoundColumn DataField="abbrname" ReadOnly="True" HeaderText="版别"></asp:BoundColumn>
<asp:BoundColumn DataField="author" ReadOnly="True" HeaderText="作者"></asp:BoundColumn>
<asp:BoundColumn DataField="price" ReadOnly="True" HeaderText="定价" DataFormatString="{0:C}"></asp:BoundColumn>
<asp:BoundColumn DataField="depreamount" HeaderText="折损数"></asp:BoundColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="更新" HeaderText="编辑" CancelText="取消" EditText="编辑"></asp:EditCommandColumn>
<asp:ButtonColumn Text="删除" HeaderText="删除" CommandName="delete"></asp:ButtonColumn>
<asp:ButtonColumn Text="删除整单" HeaderText="删除整单" CommandName="deleteunit"></asp:ButtonColumn>
</Columns>
</asp:DataGrid>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -