You are here:   Forum
Register   |  Login

Forum Notice

For new Visual Studio LightSwitch questions,
It is recommended that you use the official Visual Studio LightSwitch Forums at:

http://social.msdn.microsoft.com/forums/en-US/lightswitch/threads


Forums

How to get the values
Last Post 23 Jul 2012 11:20 PM by hgminerva. 14 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Studio7t7User is Offline
New Member
New Member
Send Private Message
Posts:8
Avatar

--
20 Jun 2012 10:16 PM
    Hi guys,

    I have an application for selling items.Now I need to implement inventory kind of thing here.There are 3 main tables.Production,Purchase and Sales.Here is the relationship




    I have created computed field for each 3 tables and tried to get the quantity value.

    ProductQuanity,PurchaseQuantity,SalesQuanitiy

    Code is like this

    partial void ProductQuantity_Compute(ref int result)
            {
        
                result = Convert.ToInt32(this.intQuantity.ToString());
               
            }

    This returns me quantity for each item.So as I need to show this in my main Products Screen I have added these
    3 fields in to the screen using designer.I tried to run and see but it shows me empty values



    If it shows correctly I can calculate it like this

    Balance = ProductQuanity + PurchaseQuantity  - SalesQuanitiy

    Could you please let me know whats wrong here or how to implement this kind of requirement correctly

    Thanks
    hgminervaUser is Offline
    Veteran Member
    Veteran Member
    Send Private Message
    Posts:98
    Avatar

    --
    21 Jun 2012 12:37 AM
    Put the three computed fields in your tblProduct and then do a LINQ to query the Quantity of each transaction to get the result:

    dim totalQuantity as integer=0
    data= (from o in me.dataworkspace.applicationdata.trntransactionout where o.strProductNo.equals(me.strProductNo))
    if not isnothing(result)
    totalQuantity=0
    for each item in data
    totalQuantity= totalQuantity+ data.intQuantity
    next
    end if
    result=totalQuantity
    http://hgminerva.wordpress.com
    Studio7t7User is Offline
    New Member
    New Member
    Send Private Message
    Posts:8
    Avatar

    --
    21 Jun 2012 08:59 AM
    Hi,

    I tried this and i dont have strProducNo

    data= (from o in me.dataworkspace.applicationdata.trntransactionout where o.strProductNo.equals(me.strProductNo))

    Any ideas? is that something with relationships? I tried to create a relationship but it says cannot add relationship because they are in same container.

    Thanks
    hgminervaUser is Offline
    Veteran Member
    Veteran Member
    Send Private Message
    Posts:98
    Avatar

    --
    21 Jun 2012 05:08 PM
    Posted By Studio7t7 on 21 Jun 2012 09:59 AM
    Hi,

    I tried this and i dont have strProducNo

    data= (from o in me.dataworkspace.applicationdata.trntransactionout where o.strProductNo.equals(me.strProductNo))

    Any ideas? is that something with relationships? I tried to create a relationship but it says cannot add relationship because they are in same container.

    Thanks
    Base on your relationship screen shot you have a strProductNo that is related to your transaction tables.

    I assume that all the tables in the screen shot are now your Data Sources, then i expect that they are all related.  Then the linq data would not be a problem.

    If these tables are external data sources then you cannot create a relationship inside lightswitch.

    If the computed field is a problem you can also result to view and link it up to lightswitch.  Much faster this way.
    http://hgminerva.wordpress.com
    Studio7t7User is Offline
    New Member
    New Member
    Send Private Message
    Posts:8
    Avatar

    --
    21 Jun 2012 11:11 PM
    Actually I have connected LS application to SQL server which is in USA.I dont know this is the best way to do it?

    please explain what did you mean by this

    If the computed field is a problem you can also result to view and link it up to lightswitch

    I am not really an expert in LS this is my first LS project

    Thanks
    hgminervaUser is Offline
    Veteran Member
    Veteran Member
    Send Private Message
    Posts:98
    Avatar

    --
    22 Jun 2012 07:00 PM
    Sorry I'm so vague with my answers. Anyways, I don't have a document example on inventory, what I have is the a debit/credit memo adjustments on a sales invoice, plus when you debit then minus when you credit, i think it is more or less similar to inventory in and out.

    http://hgminerva.wordpress.com/2012...gthswitch/
    http://hgminerva.wordpress.com
    Studio7t7User is Offline
    New Member
    New Member
    Send Private Message
    Posts:8
    Avatar

    --
    09 Jul 2012 03:23 AM
    Posted By hgminerva on 21 Jun 2012 06:08 PM
    Posted By Studio7t7 on 21 Jun 2012 09:59 AM
    Hi,

    I tried this and i dont have strProducNo

    data= (from o in me.dataworkspace.applicationdata.trntransactionout where o.strProductNo.equals(me.strProductNo))

    Any ideas? is that something with relationships? I tried to create a relationship but it says cannot add relationship because they are in same container.

    Thanks
    Base on your relationship screen shot you have a strProductNo that is related to your transaction tables.

    I assume that all the tables in the screen shot are now your Data Sources, then i expect that they are all related.  Then the linq data would not be a problem.

    If these tables are external data sources then you cannot create a relationship inside lightswitch.

    If the computed field is a problem you can also result to view and link it up to lightswitch.  Much faster this way.
    I have added the View in my SQL database and calculation is fine there.When I try to update the datasource newly created View is no there to import

    What can be the reason and how can I import it?

    Thanks
    hgminervaUser is Offline
    Veteran Member
    Veteran Member
    Send Private Message
    Posts:98
    Avatar

    --
    10 Jul 2012 10:40 PM
    Posted By Studio7t7 on 09 Jul 2012 04:23 AM
    Posted By hgminerva on 21 Jun 2012 06:08 PM
    Posted By Studio7t7 on 21 Jun 2012 09:59 AM
    Hi,

    I tried this and i dont have strProducNo

    data= (from o in me.dataworkspace.applicationdata.trntransactionout where o.strProductNo.equals(me.strProductNo))

    Any ideas? is that something with relationships? I tried to create a relationship but it says cannot add relationship because they are in same container.

    Thanks
    Base on your relationship screen shot you have a strProductNo that is related to your transaction tables.

    I assume that all the tables in the screen shot are now your Data Sources, then i expect that they are all related.  Then the linq data would not be a problem.

    If these tables are external data sources then you cannot create a relationship inside lightswitch.

    If the computed field is a problem you can also result to view and link it up to lightswitch.  Much faster this way.
    I have added the View in my SQL database and calculation is fine there.When I try to update the datasource newly created View is no there to import

    What can be the reason and how can I import it?

    Thanks

    You cannot import it if there is no primary key.  Make sure that at least one of the field is set to Not Null so that ligthswitch will import it.
    http://hgminerva.wordpress.com
    Studio7t7User is Offline
    New Member
    New Member
    Send Private Message
    Posts:8
    Avatar

    --
    14 Jul 2012 10:32 PM
    Hi,

    This is my View

    USE [laub_Web]
    GO

    SET ANSI_NULLS ON
    GO

    SET QUOTED_IDENTIFIER OFF
    GO

    CREATE VIEW [dbo].[ss_ls_remain_Stock]
      AS SELECT DISTINCT
                          ou.strProductNo, SUM(S.intQuantity) AS stock, SUM(ou.intQuantity) AS quantityOut, SUM(I.intQuantity) AS quantityIn, SUM(ou.intQuantity) - SUM(I.intQuantity)
                          AS balance, SUM(S.intQuantity) + SUM(I.intQuantity) - SUM(ou.intQuantity) AS bal
    FROM         laubsup.SS_tblTransactionOut AS ou CROSS JOIN
                          laubsup.SS_tblTransactionIn AS I INNER JOIN
                          laubsup.SS_tblCanning AS S ON S.strProdNo = ou.strProductNo
    GROUP BY ou.strProductNo

    GO

    But still it doesn't recognized by LS?

    Any ideas
    Thanks
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:990
    Avatar

    --
    15 Jul 2012 04:21 AM
    LightSwitch needs to be able to determine a primary key to import a view as a table. A column or combination of columns that are unique for a record.
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    hgminervaUser is Offline
    Veteran Member
    Veteran Member
    Send Private Message
    Posts:98
    Avatar

    --
    15 Jul 2012 07:22 PM
    Make sure that your strProductNo is set NOT NULL it its source table.
    http://hgminerva.wordpress.com
    Studio7t7User is Offline
    New Member
    New Member
    Send Private Message
    Posts:8
    Avatar

    --
    16 Jul 2012 02:28 AM
    Hi,

    I have made strProductNo not NULL in my tables and updated the data source
    But still its not showing?
    hgminervaUser is Offline
    Veteran Member
    Veteran Member
    Send Private Message
    Posts:98
    Avatar

    --
    16 Jul 2012 05:40 PM
    Ligthswitch should be able to determine automatically a field that is not null to be a primary key. So far I don't have problem with this, I've tried it with MS SQL and Oracle for both views and tables. Anyways, please check if you have full rights to the Views using your connection strings. Worst case scenario is that you have to create a WCF RIA Service and put a flag to the strProductNo.
    http://hgminerva.wordpress.com
    Studio7t7User is Offline
    New Member
    New Member
    Send Private Message
    Posts:8
    Avatar

    --
    23 Jul 2012 10:16 PM
    Posted By hgminerva on 16 Jul 2012 06:40 PM
    Ligthswitch should be able to determine automatically a field that is not null to be a primary key. So far I don't have problem with this, I've tried it with MS SQL and Oracle for both views and tables. Anyways, please check if you have full rights to the Views using your connection strings. Worst case scenario is that you have to create a WCF RIA Service and put a flag to the strProductNo.
    Hi hgminerva,

    I have no idea about WCF RIA service.Is there any 3rd party control where I can use for this?

    Thanks
    hgminervaUser is Offline
    Veteran Member
    Veteran Member
    Send Private Message
    Posts:98
    Avatar

    --
    23 Jul 2012 11:20 PM
    Posted By Studio7t7 on 23 Jul 2012 11:16 PM
    Posted By hgminerva on 16 Jul 2012 06:40 PM
    Ligthswitch should be able to determine automatically a field that is not null to be a primary key. So far I don't have problem with this, I've tried it with MS SQL and Oracle for both views and tables. Anyways, please check if you have full rights to the Views using your connection strings. Worst case scenario is that you have to create a WCF RIA Service and put a flag to the strProductNo.
    Hi hgminerva,

    I have no idea about WCF RIA service.Is there any 3rd party control where I can use for this?

    Thanks
    You don't need any 3rd party: http://hgminerva.wordpress.com/2012/06/21/how-to-create-a-vb-wcf-ria-services-for-microsoft-lightswitch-to-aggregate-or-join-tables-at-the-same-time-pass-a-parameter/

    http://hgminerva.wordpress.com
    You are not authorized to post a reply.


    Latest Microsoft Visual Studio LightSwitch Forum Threads That Have Answers

    Thanks for help on this, Looking at moving from Access and I'm impressed with the deployment possibilities of LS along with the RAD focus (great name too - Lightswitch). Struggling with something that I'm sure is simple but I'm missing - how do I add a column/field to a query or a datagrid from a related table in LS.  I've tried adding a Data Item in a screen, bit I can't add a field to the grid, and there doesn't seem to be any options to add fields in the query builder. What am I missing folks? Brad
    Read more...

    How to set entity properties value in .beforeApplyChange event at client side. Thanks for your help. -SK SK
    Read more...

    Hi On creating a new many to many record, all it has is the 2 fields with keys to the other 2 tables. I need to add fields from the associated tables so that it has searchable fields on the screen. However I cannot seem to bind to the newly created record. This is the code I wrote to add the store name to the new record but it just picks up an existing selected record and not the new one. Please assist. Thanks, Mark. partial void GroupList_Changed(NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (GroupList Gr in e.NewItems) { Gr.StoreName = this.Stores.SelectedItem.Name; } } } Mark
    Read more...

    I got a new laptop recently, and installed both Visual Studio 2010 and 2012. I went into Visual Studio 2012 and got the latest version of a C# Lightswitch project from Team Foundation Server (which we use for source control). I then switched the solution explorer to 'File View' so that I could look at the User Code.  Any code file that I look at contains the error (listed on the title) on all of the methods contained in the code files.  I've done a lot of searching, and came across some suggestions from Yann Duran in Lightswitch thread  entitled Overwriting a Lightswitch Query produces Error "no defining declaration found for implementing declaration of partial method".  I've rebuilt the solution, Unloaded and reloaded the project, and also repaired Visual Studio.  I still have the errors in my code files. I think that this project may have been originally created in Microsoft Visual Studio Lightswitch 2011, so I installed it,
    Read more...

    I want to limit to 3 simultaneous users
    Read more...

    1234

    Microsoft Visual Studio is a registered trademark of Microsoft Corporation / LightSwitch is a registered trademark of Microsoft Corporation