Little help about understanding asp.net MVC - asp.net

I've recently started learning asp.net programming and am now fiddling with my small "project"
In it i have 2 models for my database : 1) Film - which consists of name,id, category(type of category model), other random properties and a DATE
2) Category - which consists just of the name of the category and id.
I want to create a form where i type a start date and an end date and choose a category. After i submit this form i want my controller to return Data from database where the data falls into range (start date - end date) and category which were chosen.
So my question is do i need another model for "data range" and the form or can i just write a javascript function or something similar and it can return data directly to my view. I'm a little lost and i have no one to ask, so maybe someone can help me.
Thanks

Related

Spring MVC - Can I Get Value Before Form Submit

I'm using Spring MVC & Thymeleaf to make a form. I'm really curious if there's any way to get a form value before submitting?
What I mean is like inputting a Country on the country dropdown field & when I'm about to fill the next field, which is the City dropdown field where the field used to be disabled before I filled the country field, the field after filling the country field will be enabled & the dropdown only shows cities correspond to the country I filled.
Btw sorry I don't share code for this question because I think it's a general question & I already use a database so I might need DISTINCT syntax since there's a lot of duplicate values on the database. And if there's no way to do all of these with Spring + Thymeleaf, I'm open to hear suggestions with other frameworks or even Javascript.

How do I create a running count of outcomes sequentially by date and unique to a specific person/ID?

I have a list of unique customers who have made transactions over a year (Jan – Dec). They have bought products using 3 different methods (card, cash, check). My goal is to build a multi-classification model to predict the method pf payment.
To do this I am engineering some Recency and Frequency features into my training data, but am having trouble with the following frequency count because the only way I know how to do it is in Excel using the Countifs and SUMIFs functions, which are inhibitingly slow. If someone can help and/or suggest another solution, it would be very much appreciated:
So I have a data set with 3 columns (Customer ID, Purchase Date, and Payment Type) that is sorted by Purchase Date then Customer ID. How do I then get a prior frequency count of payment type by date that does not include the count of the current row transaction or any future transactions that are > the Purchase Date. So basically I want to do a running count of each payment option, based on a unique Customer ID, and a date range that is < purchase date of that training row. In my head I see it as “crawling” backwards through the transactions and counting. Simplified screenshot of data frame is below with the 3 prior count columns I am looking to generate programmatically.
Screenshot
This gives you the answer as a list of CustomerID, PurchaseDate, PaymentMethod and prior counts
SELECT CustomerID, PurchaseDate, PaymentMethod,
(
select count(CustomerID) from History T
where
T.CustomerID=History.CustomerID
and T.PaymentMethod=History.PaymentMethod
and T.PurchaseDate<History.PurchaseDate
)
AS PriorCount
FROM History;
You can save this query and use it as the source for a crosstab query to get the columnar format you want
Some notes:
I assumed "History" as the source table name - you can change the query above to use the correct source
To use this as a query, open a new query in design view. Close the window that asks what tables the query is to be built on. Open the SQL view of the query design - like design view, but it shows the SQL instead of the normal design interface. Copy the above into the SQL view.
You should now be able to switch to datasheet view and see the results
When the query is working to your satisfaction, save it with any appropriate name
Open a new query in design view
When you get the list of tables to include, switch to the list of queries and include the query you just saved
Change the query type to crosstab and update the query as needed to select rows, columns and values - look up "access crosstab queries" if you need more help.
Another tip to see what is happening here:
You can take the subquery - the parts inside the () above - and make
just that statement into it's own query, excluding the opening and closing (). Then you can look at it's design view to see what it does
Save it with an appropriate name and put it into the query above in place of the statement in () - then you can look at the design view.
Sometimes it's easier to visualize and learn from 2 queries strung together this way than to work with sub queries.

parameters in subform pulled from main form

I have done this a couple years ago but can't seem to remember how; I am working with access 2010 and the macro builder as opposed to VBA ( I don't do this enough for the coding).
Anyways what I have is a main form that has a subform that displays as a datasheet. This subform data source is a query that asks for three values which are applied as filters using just a where statement.
The query SQL is a select statement, followed by from and then a where statement and no parameter statement.
What I am trying to do is get the subform when it opens to pull the parameters from the main form record it is under.
I know this is possible because I have done this a couple years ago but don't have that database anymore. I have gone through all the books I have and still can't seem to find a combination that works.
Any suggestions or help with what I am missing?
****Update******
The set value isn't working... What I have is a form SQ_Ticket that has fields Site Number, Date Submitted, and End Date. I then I have a sub form that is based on a parameter query, it has a different number of fields then then the ticket query so a Union is too much of a hassle. But the fields in the sub form that would relate to the main form are Site Number and create date.
What I am trying to do is I have the main form (SQ_Ticket) with a sub form (SQ_Alarm_Parameter subform) and the form is a datasheet. When I click to expand the subdatasheet I want the Parameter query to pull the Site Number from the main form and use it to match to the site number in the subform and the pull the Date Submitted and End Date and use it as the start and end in a between statement for the create date in the sub form.
Basically I want to use find all records in the sub form (SQ_ALarm_Parameter subform) that have the same Site Number as the record in SQ_Ticket and that are Created between the Date Submitted and End Date of the Record in SQ_Ticket.
I seem to recall needing to pull the specific data from the main form and then using it as a temp value in the subform, but again can't remember how do to do that.
I know I am missing something obvious since I know I have done this before, but I didn't think to keep a copy of that work and it was quite a while ago. So I really appreciate the help
Firstly, I think taking a few minutes to do the VBA would be valuable and easier to work with. However with the macro method you can just use the Set Value submacro. This won't show up by default so you will need to select "Show All Actions" on your ribbon at the top of Access.
The Macro:
This will allow you to set the RecordSource for one form based off of value of a textbox on another form. You just need to adjust now work with your fields and parameters.

Asp.net create function Student of the day

Im working on a ASP.net web application about my class.
All students have their own webform site with an own link refering to thier page.
But I´m trying to do a function for the homepage "student of the day".
I know that i have to put all student links in an array and randomize them.
My problem is that i want the studentlink to change every 24 hours.
How can I make a timer to pick a new object from the array.
Cheers
I'd agree with the comment that has been posted, however I am going to assume that you dont have a database at the moment, or you would alreday be using that rather than an array...
I minght have missed something in your question but I think we can use the pseudo random number generator with a seed based on today to get the "Random Number"
//I am assumung that you already have an array of students created at this point.
Random rnd = new Random(DateTime.Now.Day);
int selectedStudent = Console.WriteLine(rnd.Next(1, 6));
object student = studentArray[selectedStudent];
Because the seed is the same every time you should get the same result every time until the seed changes and that happens when the day changes.
Of course this will not work unless you create a new instance of rnd each time that you need to generate the number.
Hope this helps, if not let me know.

pro asp.net 4.5 in c# book by adam freeman sportstore

just wondering did anybody complete the sport store application in this book, i am having a problem with the data binding in the orders page for the admin, i want to pull in the product id from the order lines table but i keep getting errors, it working correctly for the quantity but i can seem to get the product id to bind. i have tried the following code but this is not working for me at the moment
**<td><%# Item.OrderLines.Product_ProductID %></td>**
it says i am missing a definition in the orderline
First of all, OrderLines is of type List most likely. So the list doesn't have a definition of Product_ProductID. You should rather make a loop for Item.OrderLines and then you can access each order line of the order with its product. At second, take a look at your OrderLine model. Does it contain Product_ProductID? Most likely it has Product property
references to Product model which contains ProductID. So after all, your code would look like:
**<td><%# Item.OrderLines[i].Product.ProductID %></td>**

Resources