Answered Adding the values of one fields and display in a textbox

  • Wednesday, May 02, 2012 3:51 AM
     
     
    i want to add up the total calls made my "Local" call type. So 20+1 = 21 for total calls made locally and i want to display the result in a textbox or whatever. can anybody help me how to do this as i m very begineer with the coding.

All Replies

  • Wednesday, May 02, 2012 4:25 AM
     
     Proposed
  • Wednesday, May 02, 2012 9:42 PM
     
     

    Hi glen, example is in C# but i am building my application in visual basic.  I could not understand it as it was slightly harder for me . Any other suggestions?

    Thanks

  • Wednesday, May 02, 2012 10:32 PM
     
     

    Follow this link to convert the code to vb.

    http://www.developerfusion.com/tools/convert/vb-to-csharp/

  • Wednesday, May 02, 2012 10:45 PM
     
     
    This wont help because my application is quite big, i dont know what to do now. I just need to know how i can add up the values of one field together...
  • Thursday, May 03, 2012 12:31 AM
     
     
    If you take michaels code and drop it into the app it will convert it so you can see what it looks like in VB. You do not need to drop the complete file, the app will take code snippets.
  • Thursday, May 03, 2012 1:38 AM
     
     

    I tried doing it but my count of calls are showing as 0.

    Here is my code :

    Public

    Class LocalDetails

     

     

    Private Sub LocalDetails_InitializeDataWorkspace(saveChangesTo As System.Collections.Generic.List(Of Microsoft.LightSwitch.IDataService))

    ' Write your code here.

    Dim Calls As Double = LocalDetailsAll.Count()

    CountOfCalls = Calls.ToString()

    End Sub

    End Class

  • Thursday, May 03, 2012 1:43 AM
     
     

  • Thursday, May 03, 2012 6:06 AM
     
     Answered

    I might suggest you look at using a View in SQL Server to do this as the calculation isn't complex but the selection criteria are. It looks like you're trying to calculate a phone bill by employee, call type and some time period (probably a month). You won't naturally have any database table for this combination so you'll have to invent one. A SQL Server View would be a good way to do this. You can then import that view into your LightSwitch application to show it. A straightforward view would just give you a list of employee, call type, month, total cost which is not the presentation you want. You actually want to change the call type from rows to columns. Look at the SQL Server PIVOT command to do this.


    Simon Jones
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly.

  • Thursday, May 03, 2012 9:43 PM
     
     

    You dont need to use SQL for combining tables. I was having problem with this situation before but there is a way you can combine multiple tables. There was a little error in my code but it is working now. Thanks for your help Simon...Cheers