Below Is My Code for Window Application :
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Public Class frmTrialBalanceNew
Dim objdb As New DataSave
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim param As CreateParams = MyBase.CreateParams
param.ClassStyle = param.ClassStyle Or &H200
Return param
End Get
End Property
Private Sub frmTrialBalanceNew_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
MaximizeBox = False
Dim boundWidth As Integer = Screen.PrimaryScreen.Bounds.Width
Dim boundHeight As Integer = Screen.PrimaryScreen.Bounds.Height
Dim x As Integer = boundWidth - Me.Width
Dim y As Integer = boundHeight - Me.Height
Me.Location = New Point(x / 2, y / 2)
Dim purchase, exp As Double
Dim datefrom As Date = frmTrialBalanceDate.DateFrom.Text
lblDatefrom.Text = frmTrialBalanceDate.DateFrom.Text
Dim Dateto As Date = frmTrialBalanceDate.DateTo.Text
lblDateTo.Text = frmTrialBalanceDate.DateTo.Text
purchase = Val(objdb.GetValue("select SUM(Amount) from tbl_StockTransaction where EntryType = 'Stock Purchase' and companyid = '" & strcompanyid & "' and EntryDate Between convert(datetime,'" & datefrom & "',103) and convert(datetime,'" & Dateto & "',103)"))
exp = Val(objdb.GetValue("select SUM(Freight) + SUM(Labour) from PurchaseNew where PurchaseBillNo is not NULL and companyid = '" & strcompanyid & "' and PurchaseBillDate Between convert(datetime,'" & datefrom & "',103) and convert(datetime,'" & Dateto & "',103)"))
lblPurchase.Text = Val(purchase) + Val(exp)
lblOpeningStock.Text = Val(objdb.GetValue("select SUM(Amount) from tbl_StockTransaction where EntryType = 'Opening Stock' and companyid = '" & strcompanyid & "' and EntryDate Between convert(datetime,'" & datefrom & "',103) and convert(datetime,'" & Dateto & "',103)"))
lblPurchaseReturn.Text = Val(objdb.GetValue("select SUM(Amount) from tbl_StockTransaction where EntryType = 'Purchase Return' and companyid = '" & strcompanyid & "' and EntryDate Between convert(datetime,'" & datefrom & "',103) and convert(datetime,'" & Dateto & "',103)"))
lblTotalPurchase.Text = (Val(lblPurchase.Text) + Val(lblOpeningStock.Text)) - Val(lblPurchaseReturn.Text)
lblCrgInwards.Text = Val(objdb.GetValue("select SUM(Labour) from SalesNew where InvoiceNO is Not NULL and companyid = '" & strcompanyid & "' and InvoiceDate Between convert(datetime,'" & datefrom & "',103) and convert(datetime,'" & Dateto & "',103)"))
lblWages.Text = Val(objdb.GetValue("select SUM(Freight) from SalesNew where InvoiceNo is Not NULL and companyid = '" & strcompanyid & "' and InvoiceDate Between convert(datetime,'" & datefrom & "',103) and convert(datetime,'" & Dateto & "',103)"))
Dim ds As New DataSet
Dim closingstock As Double = "0"
ds = objdb.ReturnDS("select (SUM(B.Qty) * A.CostPrice) as [TotalAmount] from tbl_StockTransaction B,tbl_ItemMaster A where B.EntryDate Between convert(datetime,'" & datefrom & "',103) and convert(datetime,'" & Dateto & "',103) and A.ItemCode = B.ProductCode and B.companyid = '" & strcompanyid & "' group by A.CostPrice")
For count = 0 To ds.Tables(0).Rows.Count - 1
Dim totalamount As Double = ds.Tables(0).Rows(count)("TotalAmount")
closingstock = closingstock + totalamount
Next
lblClosingStockAmount.Text = closingstock
lblsales.Text = Val(objdb.GetValue("select SUM(AMount) from tbl_StockTransaction where EntryType = 'Stock Sell' and companyid = '" & strcompanyid & "' and EntryDate Between convert(datetime,'" & datefrom & "',103) and convert(datetime,'" & Dateto & "',103)"))
lblsalesreturn.Text = Val(objdb.GetValue("select SUM(AMount) from tbl_StockTransaction where companyid = '" & strcompanyid & "'and EntryType = 'Sales Return' and EntryDate Between convert(datetime,'" & datefrom & "',103) and convert(datetime,'" & Dateto & "',103)"))
lblTotalSales.Text = Val(lblsales.Text) + Val(lblsalesreturn.Text)
Dim debitsidetotal, creditsidetotal As Double
debitsidetotal = Val(lblTotalPurchase.Text) + Val(lblCrgInwards.Text) + Val(lblWages.Text)
creditsidetotal = Val(lblClosingStockAmount.Text) + Val(lblTotalSales.Text)
If debitsidetotal <= creditsidetotal Then
lblTradingProfit.Text = Val(creditsidetotal) - Val(debitsidetotal)
lblDrSideTotal.Text = Val(lblTradingProfit.Text) + Val(debitsidetotal)
lblCrSideTotal.Text = creditsidetotal
lblCRLoss.Visible = False
lblCRPL.Visible = False
lblDRPL.Visible = True
lblDRProfit.Visible = True
StrTrialBalance = lblTradingProfit.Text
Else
lblTradingLoss.Text = Val(debitsidetotal) - Val(creditsidetotal)
lblDrSideTotal.Text = debitsidetotal
lblCrSideTotal.Text = Val(lblTradingLoss.Text) + Val(creditsidetotal)
lblCRLoss.Visible = True
lblCRPL.Visible = True
lblDRPL.Visible = False
lblDRProfit.Visible = False
StrTrialBalance = -lblTradingLoss.Text
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
Try
Me.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class
form Work Completely, When I Pres Close Button Give This Error.
Collection was modified; enumeration operation may not execute.
What I have tried:
Collection was modified; enumeration operation may not execute.
I am not using eny enumeration operation.
i am only use for loop and query