Click here to Skip to main content
15,904,287 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi experts, can anyone help me with this:

this is my formula field named totalcashpaid and code:
SQL
if {actualguesting.paymentmode}='CASH' then
sum({actualguesting.totalamount})

this is my code in my form:
VB
If ComboBox1.Text = "Shift 1" Then
    Dim dt As Date = DateTimePicker1.Text
    Dim rpt As New endofshift() 'The report you created.
    Dim MyCommand As New SqlCommand()
    Dim myDS2 As New loghistory() 'The DataSet you created.
    Dim myDA2 As New SqlDataAdapter()
    Dim myDS As New DSactualguesting() 'The DataSet you created.
    Dim myDA As New SqlDataAdapter()
    Dim cn As New SqlConnection(ConnectString())

    Try

        MyCommand.Connection = cn
        MyCommand.CommandText = "Select * from actualguesting where shift = 1 and datecheckin='" + dt + "'"
        MyCommand.CommandType = CommandType.Text
        myDA.SelectCommand = MyCommand
        myDA.Fill(myDS, "actualguesting")

        myDA.SelectCommand.CommandText = "Select * from loghistory where username='" + Login.txtuser.Text + "'"
        myDA.Fill(myDS, "loghistory")

        myDS.EnforceConstraints = False
        rpt.SetDataSource(myDS)
        CrystalReportViewer1.ReportSource = rpt
    Catch Excep As Exception
        MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try
endif


everytime i checked the report,the totalcashpaid amount doubles up eventhough i did not make a transaction. for example i made a transaction that cost 5000, the totalcashpaid is 5000 when i check the report.but when i logout and login with the same account and check the report, it became 10000.what should i do?

this is an end of shift report which is the time varies on my server:
6:00 AM - 2:00 PM = shift 1
2:00 PM - 10:00 PM = shift 2
10:00 PM -6:00 AM = shift 3


that means,i'm on the time of shift 1
Posted
Updated 16-Jun-13 18:37pm
v2
Comments
Kschuler 20-Jun-13 15:03pm    
In your crystal report are you joining the loghistory table to the actualguesting file? If so, perhaps your join or link isn't correct. Or perhaps you are not supposed to join them at all. - If you log in a third time, does the amount increase again?
Chester Costa 20-Jun-13 20:18pm    
if my join or link isn't correct,then what is the right way for joining the two tables in single datasets?yes everytime i login the amount increase.

i manage to do this report not using the loghistory and it works,now i'm wondering,how can i get the username/fullname in my table if i'm not going to use the loghistory
Kschuler 24-Jun-13 8:47am    
You must have a table that just maintains the user id and password and other user information. You wouldn't want to do that in a log file. What if the user changed his/her user name or password? Now you wouldn't be able to track them properly in the log file because past entries would have one username/password and new entries would have another. It's best to have a separate ID for each user that gets used in log file, etc. That ID would also be in a table that tracks users and passwords. That way if they change a username/password the ID will still be the same and they can be linked to other tables and still found.
Chester Costa 25-Jun-13 20:49pm    
thank you sir..that was a great idea.it really helps me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900