Visual studio Lightswitch - database

I have a two database tables, on light switch the first one called product and the second one called invoice line items.
The Product table has one column called Bought Quantity.
The Invoice line items has one column called sold Quantity.
Now I need to have a search screen with the both tables on it, but here come my question.
When I made the relationship between the two tables, then the screen will show the grid with two columns, one called the "quantity I bought" and another column "quantity I sold".
I need to make subtraction and the result will show on another column called "available".
So I have a local property called Available. Now I need code to write to make the subtraction process and then will show on the available.
That is my question.

Lightswitch screens will only show data for an entity within your project. If you want to shape your table using joins to merge tables then you'll either need to create a view in your datasource and import it into your project or use WCF RIA to shape your data accordingly.
Michael Washington has created loads of examples on how to do this, you can find them here:
http://lightswitchhelpwebsite.com/Blog/tabid/61/tagid/21/WCF-RIA-Service.aspx
Good luck.
Paul.

Related

Form with Subform - find record by updating one of two fields

step by step i am advancing with my Gasoline inventory database and it is actually about to start becoming fun to try out different new things on the database.
However i got stuck on one little issue.
I have a form with a Subform.
May main form has two fields. One is the Gas Station and one is the date of the report that comes in.
Each report of any station contains one or more products with gallons sold, delivered and physical inventory (has to be applied manually as gas expands when warm)
I tried to add a macro to each of the two fields which requeries after update, but that didn't do anything.
Anyways, im looking for a solution that lets me look for past records by just updating one of the two fields in the main form.
I guess you have a table containing the Station details - Station ID, Station Name, etc. Something like the image below.
You'll also have a table or query that shows sales, delivery, etc for each station based on the Station ID (it'll also have a report date - forgot to add that to my example table).
When you place the subform into the main form you need to link the two forms so they stay in sync using the Master/Child fields (your StationID) which are available in the property sheet for the subform container:

MS Access Database Confused

I am setting up a database for our hunting club, plus learning access along the way...ouch
I want the database to contain all of the deer observed along with their locations, when the user enters the data it will go as buck/doe/fawn/unknown and they will also enter the location where the deer was observed. The location could be a stand located at various different places on the property or a stand could be located on a food plot.
Here is where I am confused, I got to this point and really just don't know the best path to follow. I have followed much of the normalization techniques and set up relationships. I am working with a form (frmEnterNewStand) to add the stands to the database, what I need is a single combo box with choices that come from two tables (tblProperty Sections for stands not located on food plots) and (tblFoodplots for stands located on food plots). But couldn't figure that one out. So I attempted to add food plots as another entry but things started getting messy.
Since I am new to this I don't even know the right questions to ask, but I just cannot figure out the best way to organize this to be able to enter data easily then access the data easily.
I know we will want to perform queries to get statistics on, i.e. how many deer were observed blah blah blah, we will also want to query the food plots as well, how many deer were seen on food plot 1 for example, and what time of day. We will also keep up with other food plot parameters.
I have been taking the Udemy course and have several books, but my mind is blown, any help would be appreciated.
I am going to include an example map of our property, the blue numbers are different sections for the property (tblPropertySections), the yellow S numbers are Stand 1, 2 etc, the orange F numbers are Food Plot 1, 2 etc.
Also included are my current screenshots of what I have so far. I was going to try to post images but I need at least 10 reputation points i guess.
NOt sure what else I need to provide but I will say thank you in advance
tim
thank you
tim
I think you should start simple on this and add complexity as needed.
From my reading of the problem the main outcome is a database that records deer sightings. The easiest possible "database" is just a table that lists the sighting, and associated info.
For example:
ID, Date, Time, DeerType, Location, SeenBy, Comments
1, 1/1/2015, 11:45pm, "Doe", "Behind the shed", "Garry Abblet", "After a few beers Garry went for a slash and saw a deer"
Start with that and then worry about what needs to be added. I know a single table isn't the most exciting database to learn about, but you should follow a philosophy of the simplest solution usually being the best.
Access forms are essentially the visual representation of tables. In fact, if users were just computers you would not need a user interface but can manage processing (edit, add, save, delete) through code. The combo box form control is the tool needed to select corresponding data from other tables, specifically foreign keys.
As you point out, a Stand can either be on a Property Section or Food Plot. So in the tblStands table you can carry two foreign keys: Property Section ID and Food Plot ID.
Then, on their corresponding forms of tblStands the IDs wold be stored/bounded in combo boxes whose RowSources are a queries of the underlying tables:
SELECT id, PropertySectionName FROM tblPropertySections
SELECT id, FoodPlotName FROM tblFoodPlots
Now, computers would know which ID to pick but not humans who would need names/titles to help identify which item to select. Fortunately, combo boxes come with a special hidden column feature where the IDs can be hidden from view but its related name is presented on the form. However, the ID is stored in table. You set this up with the wizard when you select and position combo boxes.
Manually, or no-wizard approach, you do the following in Property Sheet of selected combo box:
Format tab
Column Count: 2 (or any greater than 2 depending on RowSource query)
Column Width: 0"; 1" (or any non-zero that fits into combo box's width)
Data tab
Control Source: PropertySheetID (or FoodPlotID)
Row Source: (see above queries)
Row Source type: table/query
Bound column: 1
Altogether, users will navigate to frmEnterNewStand and choose if the Stand is on Property Section or Food Plot by entering one combo box and not the other (leave label instructions as needed, since users are human).

How to make title sortable with two different tables whose data coming from same model in cakephp?

I have a view showing two tables which data is coming from same model but based on different column status I divided in 2 tables. Problem is, when I click on top table's column name heading for sorting, it also sort the bottom tables. I'm wanting the bottom table data won't sort when I click on top table column heading title. If any one have a good solution, would highly appreciated.
This highly depends on your setup, but you're going to have to do some custom code.
For example, don't allow Cake to sort for you. See what the links look like when created by Cake, then write your own, and include an additional variable &table=1 or something.
Based on the sort variable and the table variable, build your pagination options for each including the correct sort you want for each group separately.
Another option (depending on how large your data sets are) is to use javascript datatables.

Database hierarchy, aggregation, relations in LibreOffice Base

I am working on a homework project where we design a website for a store, and I have been assigned the database. This is my first database attempt. I am using LibreOffice Base for the design, and cannot find any guides on how to make subtypes. For example, for every shirt in the inventory, there'd be a different group of colors it comes in and for every different color a list of individual sizes and how many of each size is in stock. However, I can't find aggregation anywhere in "Table Relations."
So I make a table for shirts with the base information (brand, price, etc), and then a separate table with just 2 columns (size and number of units in stock --- we're letting the possibility of multiple colors wait for now). I then make a form for the shirt with the base information and a subform with 2 columns: size and number available. Both of the forms are tables rather than labeled text boxes. However, the subform for shirt size does not maintain separate information for each row in the main form (ie the one with the base information for the shirts). How the heck do I do this?
Lastly, since this is my first crack at databases, I would not be at all surprised if I'm going at it all wrong, and if so would gladly appreciate a push in the right direction or a webpage explaining how to do this that I didn't find due to not entering the correct search terms.
You need to create linked fields in the master table. The shirt table has a primary key; refer to that in the subordinate table. Alternatively, create a primary key in the subordinate table and refer to it in the master table. Then in the subform --> properties, designate the appropriate link between the master and slave fields. The functionality is described in the LibreOffice Base handbook (p.105)

Troubleshooting a many-to-many relationship in Microsoft Access?

I created a database that holds a STUDENT table, a COURSE table, and an intersection table named STUDENT_COURSE. However, I have problems with duplicated rows and I don't know how to solve them.
Here are pictures of the tables in design view and many-to-many relationship I have created.
http://imgur.com/P7DI1l&THH7A (Be sure to click the "Second Image" link to view the relationships picture.)
In an attempt to simplify data entry, I used the form wizard to set up a SCHEDULE form (and subform).
http://imgur.com/isf4Y&ARYu3
As you can see, one enters the student data in the form and the course data associated with that specific student in the subform. However, when one enters course subform data, it creates a new courseID (autoNumber). This new courseID results in duplicate courseNames (See "Linear Algebra" entries in above imgur link via "Second Image") so that associated students aren't grouped together when one queries by class.
Is there a flaw in my design? Am I not using the form correctly to enter data? Please help me troubleshoot this.
Thank you very much!
Your subform should be based on STUDENT_COURSE table and not on COURSE one. You can still add columns from COURSE table to the subform to display course related data.
Here are some links:
http://www.techrepublic.com/article/accommodating-a-many-to-many-relationship-in-access/5285168
http://www.dhdurso.org/articles/ms-access-forms-pg4.html
http://en.allexperts.com/q/Using-MS-Access-1440/Help-form.htm

Resources