Quantcast
Channel: missing row in datagrid
Viewing all articles
Browse latest Browse all 3

missing row in datagrid

$
0
0

heres the code that populates the table

PrivateSub process_gvmoi(ByVal inFile AsString, ByVal outFile AsString)

Dim ifs As FileStream

'Dim ofs As FileStream

ifs =

New FileStream(inFile, FileMode.Open, FileAccess.Read)

'ofs = New FileStream(outFile, FileMode.Create, FileAccess.Write)

Dim reader As StreamReader

'Dim writer As StreamWriter

reader =

New StreamReader(ifs)

'writer = New StreamWriter(ofs)

Dim line AsString

Dim cnt AsInteger

cnt = 0

Dim vals(15, MAXSIZE) AsString

Dim transdate AsString

Dim UniqueID AsString

Dim TaxID AsString

Dim taxIDType AsString

Dim appl AsString

Dim acctNum AsString

Dim transctl AsString

Dim transCode AsString

Dim creditcash AsString

Dim debitcash AsString

Dim creditcheck AsString

Dim debitcheck AsString

Dim transDesc AsString

Dim tellerID AsString

Dim BranchCode AsString

Dim CheckRef AsString

Dim CheckNum AsString

Dim bankNum AsString

Dim cmd AsNew ADODB.Command

cmd.ActiveConnection = conn

cmd.CommandText =

"DELETE * FROM tblGVMOI"

cmd.Execute()

cmd =

Nothing

recordCount = 0

Me.tdMessage.Text = Me.tdMessage.Text & " ("& cnt & " Records Processed) "

WhileNot reader.EndOfStream

If cnt Mod 100 = 0 Then

If recordCount = 30 Then

Me.tdMessage.Text = Replace(Me.tdMessage.Text, ".", "")

Me.tdMessage.Visible = True

Me.Refresh()

recordCount = 0

EndIf

Me.tdMessage.Text = Replace(Me.tdMessage.Text, (cnt - 100), cnt) & "."

Me.tdMessage.Visible = True

Me.Refresh()

recordCount += 1

EndIf

line = reader.ReadLine()

If line.Length > 2 Then

vals(0, cnt) = line.Substring(0, 8).Trim

'date

vals(1, cnt) = line.Substring(8, 16).Trim

vals(2, cnt) = line.Substring(24, 9).Trim

'TaxID

vals(3, cnt) = line.Substring(33, 1).Trim

'TaxID Type

vals(4, cnt) = line.Substring(34, 3).Trim

vals(5, cnt) = line.Substring(37, 18).Trim

'acct #

vals(6, cnt) = line.Substring(55, 16).Trim

'trans control

vals(7, cnt) = line.Substring(71, 16).Trim

'Trans Control Duplicate

vals(8, cnt) = line.Substring(87, 12).Trim

'trans amt

vals(9, cnt) = line.Substring(99, 3).Trim

'trans code

vals(10, cnt) = line.Substring(102, 63).Trim

'blank field (Dont know)

vals(11, cnt) = line.Substring(165, 4).Trim

'branch of transaction

vals(12, cnt) = line.Substring(169, 10).Trim

'check #

vals(13, cnt) = line.Substring(179, 5).Trim

'bank #

vals(14, cnt) = line.Substring(184, 4).Trim

'all # 1 (Dont Know)

transdate = convertDate(vals(0, cnt)).PadRight(8)

UniqueID =

""

TaxID = vals(2, cnt).PadRight(9)

taxIDType = vals(3, cnt).PadRight(1)

appl =

""

'acctNum = vals(5, cnt).PadRight(22)

acctNum =

" ".PadRight(22)

transctl = vals(6, cnt).PadRight(20)

If vals(9, cnt) = "36"Or vals(9, cnt) = "05"Then'credit

creditcash =

"000000000.00"

creditcheck = vals(8, cnt).PadLeft(12,

" ")

debitcash =

"000000000.00"

debitcheck =

"000000000.00"

ElseIf vals(9, cnt) = "55"Or vals(9, cnt) = "94"Then'debit

debitcash =

"000000000.00"

debitcheck = vals(8, cnt).PadLeft(12,

" ")

creditcash =

"000000000.00"

creditcheck =

"000000000.00"

Else

creditcash =

"000000000.00"

debitcash =

"000000000.00"

creditcheck =

"000000000.00"

debitcheck =

"000000000.00"

EndIf

'transaction Code

If vals(5, cnt) = "19000020"Then

transCode =

"CC".PadRight(5)

ElseIf vals(5, cnt) = "19000091"Then

transCode =

"MO".PadRight(5)

ElseIf vals(5, cnt) = "19000088"Then

transCode =

"TC".PadRight(5)

Else

transCode =

" ".PadRight(5)

EndIf

'trans desc

If vals(9, cnt) = "36"Then

transDesc =

"Deposit".PadRight(30)

ElseIf vals(9, cnt) = "05"Then

transDesc =

"Credit Memo".PadRight(30)

ElseIf vals(9, cnt) = "55"Then

transDesc =

"Debit Memo".PadRight(30)

ElseIf vals(9, cnt) = "94"Then

transDesc =

"Check".PadRight(30)

Else

transDesc =

" ".PadRight(30)

EndIf

tellerID =

" ".PadRight(10)

BranchCode = vals(11, cnt).PadRight(7)

CheckRef =

" ".PadRight(60)

CheckNum = vals(12, cnt).PadRight(35)

bankNum = vals(13, cnt).PadRight(5)

Dim cmd2 AsNew ADODB.Command

Dim conn2 AsNew ADODB.Connection

conn2.ConnectionString =

My.Settings.sConnString

conn2.Open()

cmd2.ActiveConnection = conn2

IfCInt(vals(9, cnt)) > 50 Then'Discard transaction codes > 50

Else

cmd2.CommandText =

"INSERT INTO tblGVMOI (TransDate, UniqueID, TaxID, TaxIDType, Application, AccountNum, TransCtl, cashcredit, cashdebit, checkcredit, checkdebit, TransCode, TransDesc, TellerID, BranchCode, CheckRef, CheckNum, BankNum) "& _

" VALUES('"& transdate & "','"& UniqueID & "','"& TaxID & "','"& taxIDType & "','"& appl & "','"& acctNum & "','"& transctl & "','"& creditcash & "','"& debitcash & "','"& creditcheck & "','"& debitcheck & "','"& transCode & "','"& transDesc & "','"& tellerID & "','"& BranchCode & "','"& CheckRef & "','"& CheckNum & "','"& bankNum & "')"

cmd2.Execute()

EndIf

cmd2 =

Nothing

conn2.Close()

EndIf

cnt += 1

EndWhile

reader.Close()

'writer.Close()

EndSub

below code is used to write to the text file(first line is missing)

PrivateSub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

Dim status AsInteger

Me.Validate()

Me.TblGVMOIBindingSource.EndEdit()

status =

Me.TblGVMOITableAdapter.Update(Me.GvMOIDataSet.tblGVMOI)

Me.TblGVMOITableAdapter.Fill(Me.GvMOIDataSet.tblGVMOI)

If MsgBox("Update Completed Successfully!", MsgBoxStyle.Information, "Update Completed!") = MsgBoxResult.Ok Then

Me.Close()

EndIf

EndSub

PrivateSub outputGVMOI()

Dim ofs As FileStream

ofs =

New FileStream(My.Settings.OutFile & "gvmoi.txt", FileMode.Create, FileAccess.Write)

Dim writer As StreamWriter

writer =

New StreamWriter(ofs)

Dim sql AsString

Dim cmd AsNew ADODB.Command

Dim rs As ADODB.Recordset

Dim conn AsNew ADODB.Connection

Dim transdate AsString

Dim uniqueid AsString

Dim taxid AsString

Dim taxidtype AsString

Dim application AsString

Dim accountnum AsString

Dim transctl AsString

Dim cashcredit AsString

Dim cashdebit AsString

Dim checkcredit AsString

Dim checkdebit AsString

Dim transcode AsString

Dim transdesc AsString

Dim tellerid AsString

Dim branchcode AsString

Dim checkref AsString

Dim checknum AsString

Dim banknum AsString

Dim purchaser AsString

Dim beneficiary AsString

Dim thirdname AsString

Dim check20 AsString

Dim check50 AsString

Dim check100 AsString

Dim check500 AsString

Dim check1000 AsString

Dim idtype AsString

Dim idnum AsString

Dim issuedby AsString

Dim other AsString

Dim address AsString

Dim city AsString

Dim state AsString

Dim zip AsString

conn.ConnectionString =

My.Settings.sConnString

conn.Open()

cmd.ActiveConnection = conn

sql =

"SELECT * FROM tblGVMOI"

cmd.CommandText = sql

rs = cmd.Execute

WhileNot rs.EOF

transdate = IIf(IsDBNull(rs(

"TransDate").Value), "", rs("TransDate").Value)

uniqueid = IIf(IsDBNull(rs(

"UniqueID").Value), "", rs("UniqueID").Value)

taxid = IIf(IsDBNull(rs(

"TaxID").Value), "", rs("TaxID").Value)

taxidtype = IIf(IsDBNull(rs(

"TaxIDType").Value), "", rs("TaxIDType").Value)

application = IIf(IsDBNull(rs(

"Application").Value), "", rs("Application").Value)

accountnum = IIf(IsDBNull(rs(

"AccountNum").Value), "", rs("AccountNum").Value)

transctl = IIf(IsDBNull(rs(

"TransCtl").Value), "", rs("TransCtl").Value)

cashcredit = IIf(IsDBNull(rs(

"cashcredit").Value), "", rs("cashcredit").Value)

cashdebit = IIf(IsDBNull(rs(

"cashdebit").Value), "", rs("cashdebit").Value)

checkcredit = IIf(IsDBNull(rs(

"checkcredit").Value), "", rs("checkcredit").Value)

checkdebit = IIf(IsDBNull(rs(

"checkdebit").Value), "", rs("checkdebit").Value)

transcode = IIf(IsDBNull(rs(

"TransCode").Value), "", rs("TransCode").Value)

transdesc = IIf(IsDBNull(rs(

"TransDesc").Value), "", rs("TransDesc").Value)

tellerid = IIf(IsDBNull(rs(

"TellerID").Value), "", rs("TellerID").Value)

branchcode = IIf(IsDBNull(rs(

"BranchCode").Value), "", rs("BranchCode").Value)

checkref = IIf(IsDBNull(rs(

"CheckRef").Value), "", rs("CheckRef").Value)

checknum = IIf(IsDBNull(rs(

"CheckNum").Value), "", rs("CheckNum").Value)

banknum = IIf(IsDBNull(rs(

"BankNum").Value), "", rs("BankNum").Value)

purchaser = IIf(IsDBNull(rs(

"PurchaserName").Value), "", rs("PurchaserName").Value)

beneficiary = IIf(IsDBNull(rs(

"BeneficiaryName").Value), "", rs("BeneficiaryName").Value)

thirdname = IIf(IsDBNull(rs(

"ThirdName").Value), "", rs("ThirdName").Value)

check20 = IIf(IsDBNull(rs(

"checkdenom20").Value), "", rs("checkdenom20").Value)

check50 = IIf(IsDBNull(rs(

"checkdenom50").Value), "", rs("checkdenom50").Value)

check100 = IIf(IsDBNull(rs(

"checkdenom100").Value), "", rs("checkdenom100").Value)

check500 = IIf(IsDBNull(rs(

"checkdenom500").Value), "", rs("checkdenom500").Value)

check1000 = IIf(IsDBNull(rs(

"checkdenom1000").Value), "", rs("checkdenom1000").Value)

idtype = IIf(IsDBNull(rs(

"IDType").Value), "", rs("IDType").Value)

idnum = IIf(IsDBNull(rs(

"IDNum").Value), "", rs("IDNum").Value)

issuedby = IIf(IsDBNull(rs(

"IDIssuedBy").Value), "", rs("IDIssuedBy").Value)

other = IIf(IsDBNull(rs(

"IDOthers").Value), "", rs("IDOthers").Value)

address = IIf(IsDBNull(rs(

"PurchaserAddress").Value), "", rs("PurchaserAddress").Value)

city = IIf(IsDBNull(rs(

"PurchaserCity").Value), "", rs("PurchaserCity").Value)

state = IIf(IsDBNull(rs(

"PurchaserState").Value), "", rs("PurchaserState").Value)

zip = IIf(IsDBNull(rs(

"PurchaserZip").Value), "", rs("PurchaserZip").Value)

transdate = transdate.PadRight(8)

uniqueid = uniqueid.PadRight(24)

taxid = taxid.PadRight(9)

taxidtype = taxidtype.PadRight(1)

application = application.PadRight(5)

accountnum = accountnum.PadRight(22)

transctl = transctl.PadRight(20)

cashcredit = cashcredit.PadLeft(12,

" ")

cashdebit = cashdebit.PadLeft(12,

" ")

checkcredit = checkcredit.PadLeft(12,

" ")

checkdebit = checkdebit.PadLeft(12,

" ")

transcode = transcode.PadRight(5)

transdesc = transdesc.PadRight(30)

tellerid = tellerid.PadRight(10)

branchcode = branchcode.PadRight(7)

checkref = checkref.PadRight(60)

checknum = checknum.PadRight(35)

banknum = banknum.PadRight(5)

purchaser = purchaser.PadRight(40)

beneficiary = beneficiary.PadRight(40)

thirdname = thirdname.PadRight(40)

check20 = check20.PadLeft(5,

" ")

check50 = check50.PadLeft(5,

" ")

check100 = check100.PadLeft(5,

" ")

check500 = check500.PadLeft(5,

" ")

check1000 = check1000.PadLeft(5,

" ")

idtype = idtype.PadRight(1)

idnum = idnum.PadRight(22)

issuedby = issuedby.PadRight(2)

other = other.PadRight(40)

address = address.PadRight(35)

city = city.PadRight(22)

state = state.PadRight(2)

zip = zip.PadRight(5)

writer.WriteLine(transdate + uniqueid + taxid + taxidtype + application + accountnum + transctl + cashcredit + cashdebit + checkcredit + checkdebit + transcode + transdesc + tellerid + branchcode + checkref + checknum + banknum + purchaser + beneficiary + thirdname + check20 + check50 + check100 + check500 + check1000 + idtype + idnum + issuedby + other + address + city + state + zip)

rs.MoveNext()

EndWhile

rs.Close()

cmd =

Nothing

conn.Close()

writer.Close()

EndSub

 


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>