sklr.aspx
来自「ASP.NET开发实战详解」· ASPX 代码 · 共 635 行 · 第 1/2 页
ASPX
635 行
if themoney>0 then
str1="insert into cw_sf(cellcode,itemcode,sfterm,shouldmoney,realmoney) values('" & dycode & "'," & datar("itemcode") & "," & yfstr & "," & themoney & ",0)"
cmd1=new sqlcommand(str1,cnn1)
cmd1.executenonquery
end if
end if
end if
end if
end if
loop
cnn1.close()
datar.close()
cnn.close()
bindgrid()
End Sub
Sub ChangeYF(Sender As Object, E As EventArgs)
dim dtcmd as sqldataadapter
dim dt as new datatable
dim SumMoney as single
dim str2 as string
dim datar as sqldatareader
dim dystr as string=dyname.text
dim yfstr as string=sfyf.selecteditem.value
summoney=0
cnn=new sqlconnection(configurationsettings.appsettings("connection"))
cnn.open()
str2="select cw_sf.id,sfitem,cellcode,itemcode,ddate,cw_sf.sfterm,sffs,shouldmoney,realmoney,cw_sf.memo from cw_sf,cw_sf_other_set where itemcode=cw_sf_other_set.id and cellcode in (select code from fc_cell where name='" & Trim(dystr) & "') and cw_sf.sfterm=" & yfstr & " order by ddate"
cmd=new sqlcommand(str2,cnn)
dtable.rows.clear()
datar=cmd.executereader
while datar.read()
dim DRow as datarow=dtable.newrow()
drow(0)=datar("id")
drow(1)=datar("sfitem")
drow(2)=datar("sfterm")
drow(3)=datar("shouldmoney")
drow(4)=datar("realmoney")
if cint(datar("realmoney"))=0 then
drow(5)="未收"
summoney=summoney+datar("shouldmoney")
else
drow(5)="已收"
end if
drow(6)=datar("ddate")
drow(7)=datar("memo")
dtable.rows.add(drow)
end while
ysk.text=summoney.tostring()
datar.close()
cnn.close()
bindgrid()
End Sub
Sub OnChangedDY(Sender As Object, E As EventArgs)
dim dynamestr as string=dyname.text
dim datar as SqlDataReader
dim Str1 as string
hzname.text=""
tel.text=""
cnn=new sqlconnection(configurationsettings.appsettings("connection"))
cnn.open()
str1="select * from zh_master where cellcode in (select code from fc_cell where name='" & trim(dynamestr) & "')"
cmd=new sqlcommand(str1,cnn)
datar=cmd.executereader
if datar.read() THEN
hzname.text=datar("name")
tel.text=datar("lxdh")
end if
datar.close()
cnn.close()
End Sub
Sub Grid1_Update(Sender as object,E as DataGridCommandEventArgs)
dim RealStr as String=CType(E.Item.Cells(4).Controls(0),TextBox).Text
dim MemoStr As string=CType(E.Item.Cells(7).Controls(0),TextBox).Text
dim CodeStr as String=E.Item.Cells(0).Text
dim myDataRowCollection as datarowcollection
dim theRow as datarow
dim sum1 as single
dim zn as single
dim sql as string
mydatarowcollection=dtable.rows
sum1=0
if mydatarowcollection.Contains(codestr) then
therow=mydatarowcollection.Find(codestr)
therow(4)=realstr
therow(7)=memostr
if therow.haserrors then
dtable.RejectChanges
else
dtable.AcceptChanges
end if
end if
DataGrid1.EditItemIndex=-1
for each theRow In mydatarowcollection
if therow(5)="未收" then
if therow(4)<>0 then
sum1=sum1+therow(4)
end if
end if
next
ccsk.text=sum1.tostring()
if checkbox1.checked then
zn = Format(sum1 * (znjstr / 1000) * GetCQDay(), "0.00")
znj.text=zn.tostring()
else
zn=0
end if
hj.text=zn+sum1
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)
dim str1=e.item.cells(5).text
if str1="已收" then
page.registerstartupscript("",getalertinfo("该收费项目已收款!"))
else
DataGrid1.EditItemIndex=E.Item.ItemIndex
BindGrid()
end if
End Sub
Sub Grid1_PageIndexChanged(Sender As Object, E As DataGridPageChangedEventArgs)
datagrid1.CurrentPageIndex = e.NewPageIndex
BindGrid()
End Sub
'获取超期天数
Function GetCQDay() As Integer
Dim DayNum As Integer
Dim i As Integer
if sftime.text="" then
daynum=0
else
If Month(sftime.text) = sfyf.selecteditem.value Then
DayNum = 0
Else
If Month(sftime.text) > sfyf.selecteditem.value Then
For i = sfyf.selecteditem.value + 1 To Month(sftime.text) - 1
Select Case i
Case 1, 3, 5, 7, 8, 10, 12
DayNum = DayNum + 31
Case 2
DayNum = DayNum + 28
Case Else
DayNum = DayNum + 30
End Select
Next
DayNum = DayNum + Day(sftime.text)
Else
DayNum = 0
End If
end if
End If
return trim(DayNum)
End Function
'获取指定表的本月读数和上月读数之差,即本月的用量
Function RetNum(ByVal MMonth As Integer, ByVal theId As Integer,ByVal InitNum As Single) As Single
'MMonth表示指定的月份
'theID表示CW_Biao_User表的ID
'InitNum表示表的底数
dim str1 as string
dim datar as sqldatareader
dim num1 as single
cnn=new sqlconnection(configurationsettings.appsettings("connection"))
cnn.open()
str1="select * from cw_cb where biaocode=" & Trim(theId) & " and sf=" & MMonth
cmd=new sqlcommand(str1,cnn)
datar=cmd.executereader
if datar.read() then
num1=datar("num")
else
return 0
exit function
end if
datar.close()
str1="select * from cw_cb where biaocode=" & trim(theid) & " and sf<" & mmonth & " order by sf desc"
cmd=new sqlcommand(str1,cnn)
datar=cmd.executereader
if datar.read() then
num1=num1-datar("num")
else
num1=num1-initnum
end if
datar.close()
cnn.close()
return num1
End Function
</script>
<html>
<head>
<title>收费录入</title>
<link href="../Main.css" type="text/css" rel="stylesheet" />
</head>
<body background="../images/1.jpg">
<form runat="server">
<table id="search" cellspacing="1" cellpadding="0" width="80%" align="center" border="0">
<tbody>
<tr>
<td width="34%" height="40">
单元名称
<asp:TextBox class="input_text" id="dyname" runat="server" width="110" OnTextChanged="OnChangedDY" AutoPostBack=True></asp:TextBox>
</td>
<td width="33%">
户主姓名
<asp:TextBox class="input_text" id="hzname" runat="server" width="110" Enabled="false"></asp:TextBox>
</td>
<td width="33%">
联系电话
<asp:TextBox class="input_text" id="tel" runat="server" width="130" Enabled="false"></asp:TextBox>
</td>
</tr>
<tr class="tr4">
<td width="34%" height="40">
收费月份
<asp:DropDownList id="sfyf" runat="server" width="110" OnSelectedIndexChanged="ChangeYF" autopostback="true">
<asp:ListItem Value="1" selected="true">一月</asp:ListItem>
<asp:ListItem Value="2">二月</asp:ListItem>
<asp:ListItem Value="3">三月</asp:ListItem>
<asp:ListItem Value="4">四月</asp:ListItem>
<asp:ListItem Value="5">五月</asp:ListItem>
<asp:ListItem Value="6">六月</asp:ListItem>
<asp:ListItem Value="7">七月</asp:ListItem>
<asp:ListItem Value="8">八月</asp:ListItem>
<asp:ListItem Value="9">九月</asp:ListItem>
<asp:ListItem Value="10">十月</asp:ListItem>
<asp:ListItem Value="11">十一月</asp:ListItem>
<asp:ListItem Value="12">十二月</asp:ListItem>
</asp:DropDownList>
</td>
<td width="33%">
收费日期
<asp:TextBox class="input_text" id="sftime" runat="server" width="110"></asp:TextBox>
</td>
<td width="33%">
收费方式
<asp:DropDownList id="sffs" runat="server" width="130">
<asp:ListItem Value="现金" selected="true">现金</asp:ListItem>
<asp:ListItem Value="支票">支票</asp:ListItem>
<asp:ListItem Value="银行转账">银行转账</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td height="40">
缴 费 人
<asp:TextBox class="input_text" id="jfr" runat="server" width="110"></asp:TextBox>
</td>
<td width="33%">
经 手 人
<asp:TextBox class="input_text" id="jsr" runat="server" width="110"></asp:TextBox>
</td>
<td width="33%">
备 注
<asp:TextBox class="input_text" id="memo" runat="server" width="130"></asp:TextBox>
</td>
</tr>
<tr>
<td height="40" colspan=3>
<asp:CheckBox id="CheckBox1" runat="server" Text="计算滞纳金" ForeColor="Red"></asp:CheckBox>
应 收 款:<asp:Label id="ysk" runat="server" forecolor="red"></asp:Label>
此次收款:<asp:Label id="ccsk" runat="server" forecolor="red"></asp:Label>
滞 纳 金:<asp:Label id="znj" runat="server" forecolor="red"></asp:Label>
合 计:<asp:Label id="hj" runat="server" forecolor="red"></asp:Label>
</td>
</tr>
<tr>
<td colspan=3 height="40" align="center">
<asp:button class="input_button" id="YskBtn" onclick="YskBtn_Click" runat="server" text="生成应收款"></asp:button>
<asp:button class="input_button" id="SaveBtn" onclick="Save_Click" runat="server" text="保 存"></asp:button>
</td>
</tr>
</tbody>
</table><hr>
<table id="search" cellspacing="1" cellpadding="0" width="85%" align="center" border="0">
<tbody>
<tr>
<td style="PADDING-LEFT: 5px" height="25">
<asp:DataGrid id="DataGrid1" runat="server" width="100%" AllowSorting="True" Font-Names="verdana" bordercolor="Black" cellpadding="2" font-name="verdana" font-size="8pt" headerstyle-backcolor="#F8FAFC" OnEditCommand="Grid1_Edit" OnCancelCommand="Grid1_Cancel" OnupdateCommand="Grid1_Update" AutoGenerateColumns="False">
<HeaderStyle font-bold="True" horizontalalign="Center" verticalalign="Middle" backcolor="#F8FAFC"></HeaderStyle>
<EditItemStyle backcolor="#E9F0F8"></EditItemStyle>
<Columns>
<asp:BoundColumn DataField="id" visible="false" ReadOnly="True" HeaderText="序号"></asp:BoundColumn>
<asp:BoundColumn DataField="sfitem" ReadOnly="True" HeaderText="收费项目"></asp:BoundColumn>
<asp:BoundColumn DataField="sfterm" readonly="true" HeaderText="月份"></asp:BoundColumn>
<asp:BoundColumn DataField="shouldmoney" readonly="true" HeaderText="应收金额"></asp:BoundColumn>
<asp:BoundColumn DataField="realmoney" HeaderText="实收金额"></asp:BoundColumn>
<asp:BoundColumn DataField="sfys" readonly="true" HeaderText="是否已收"></asp:BoundColumn>
<asp:BoundColumn DataField="ddate" readonly="true" HeaderText="收费日期" DataFormatString="{0:yyyy-MM-dd}"></asp:BoundColumn>
<asp:BoundColumn DataField="memo" HeaderText="备注"></asp:BoundColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="更新" HeaderText="操作" CancelText="取消" EditText="收款"></asp:EditCommandColumn>
</Columns>
</asp:DataGrid>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?