按钮单击行数不计算 [英] Button Click row count is not computing

查看:63
本文介绍了按钮单击行数不计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试计算此按钮有3件事,

1,总发票2,总发票已更新3,总发票未更新.

I  am trying to count  3 things out of this button,

1, total invoices 2,total invoices updated 3,total invoices not update.

根据以下代码,只有2个选项有效,而1和3你不能建议吗?

as per below code ,only 2 option is working ,whereas 1 and 3  not working could you advise?

Private inv As New List(Of Invoice)

私人子Button10_Click(ByVal发送者作为System.Object,ByVal e作为系统. EventArgs)处理Button10.Click 如果opd.ShowDialog = Windows.Forms.DialogResult.OK然后 inv.Clear() Dim str As String = System.IO.File.ReadAllText(opd.FileName) str = str.Replace(ControlChars.CrLf& ControlChars.CrLf& ControlChars.CrLf,ControlChars.CrLf) str = str.Replace(ControlChars.CrLf& ControlChars.CrLf,ControlChars.CrLf) System.IO.File.WriteAllText(opd.FileName,str) Dim fs As New System.IO.StreamReader(opd.FileName) Dim CustNum As String =" 作为新的DBTableAdapters.DOTTEDDocsTableAdapter昏暗 昏暗的dt作为DB.DOTTEDDocsDataTable Dim upCount为整数= 0 当fs.Peek> = 0时 Dim ln As String = fs.ReadLine Dim fld()为String = ln.Split(,") 如果fld.Count = 4然后 dt = ta.GetDataByInvNo(fld(0)) 如果dt.Rows.Count> 0然后 对于每个rw作为dt.Rows中的DB.DOTTEDDocsRow ta.UpdateQuery(fld(1),fld(2),rw.ID) upCount + = 1 下一个 万一 万一 结束时间 fs.Close() Dim ndt As DB.DOTTEDDocsDataTable = ta.GetBlankRecords 昏暗的nfs作为新的System.IO.StreamWriter(getAppPath()&"\ errorinvoice.txt",False) 对于每个nrw作为ndt.Rows中的DB.DOTTEDDocsRow nfs.WriteLine(nrw.InvoiceNum) 下一个 nfs.Close() Dim noupdate As Integer = ndt.Rows.Count MsgBox(文件中的总发票:"& inv.Count& ControlChars.CrLf&更新的总发票:"& upCount& ControlChars.CrLf&未更新的总发票:" & noupdate& ControlChars.CrLf&请检查"errorinvoice.txt"以获取发票清单") 万一 结束Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click If opd.ShowDialog = Windows.Forms.DialogResult.OK Then inv.Clear() Dim str As String = System.IO.File.ReadAllText(opd.FileName) str = str.Replace(ControlChars.CrLf & ControlChars.CrLf & ControlChars.CrLf, ControlChars.CrLf) str = str.Replace(ControlChars.CrLf & ControlChars.CrLf, ControlChars.CrLf) System.IO.File.WriteAllText(opd.FileName, str) Dim fs As New System.IO.StreamReader(opd.FileName) Dim CustNum As String = "" Dim ta As New DBTableAdapters.DOTTEDDocsTableAdapter Dim dt As DB.DOTTEDDocsDataTable Dim upCount As Integer = 0 While fs.Peek >= 0 Dim ln As String = fs.ReadLine Dim fld() As String = ln.Split(",") If fld.Count = 4 Then dt = ta.GetDataByInvNo(fld(0)) If dt.Rows.Count > 0 Then For Each rw As DB.DOTTEDDocsRow In dt.Rows ta.UpdateQuery(fld(1), fld(2), rw.ID) upCount += 1 Next End If End If End While fs.Close() Dim ndt As DB.DOTTEDDocsDataTable = ta.GetBlankRecords Dim nfs As New System.IO.StreamWriter(getAppPath() & "\errorinvoice.txt", False) For Each nrw As DB.DOTTEDDocsRow In ndt.Rows nfs.WriteLine(nrw.InvoiceNum) Next nfs.Close() Dim noupdate As Integer = ndt.Rows.Count MsgBox("Total invoices in file : " & inv.Count & ControlChars.CrLf & "Total invoice updated : " & upCount & ControlChars.CrLf & "Total invoices not updated:" & noupdate & ControlChars.CrLf & "Please check ""errorinvoice.txt"" for list of invoices") End If End Sub









推荐答案

你好

第一点建议是使用

The first bit of advice is to use TextFieldParser class to read your data. Next up, after reading each line via TextFieldParser place the items into a class with one typed property for each item you will work with e.g.

Public Class Sample
    Property InvoiceId As Integer
    Property SomeOtherField As Integer
    Property AnotherField As Decimal

End Class

设置列表以将数据放入

Dim SampleList As New List(Of Sample)

将数据填充到列表中后,通过设置断点进行检查.正确键入每个字段后,您可以对其进行数学运算,并根据需要更新回数据库表.

After populating the data into the list examine it by setting a break-point. Having each field typed properly you can then perform math on them and as need update back to a database table.


这篇关于按钮单击行数不计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆