Create an edm that would consist of movie entity and produce

Assignment Help Computer Engineering
Reference no: EM132991014

Lab Tutorial - 5

BusCase UI 6.1

Dafesty Video Rental Pte Ltd.is interested in creating the following Forms:
• Customer Maintenance
• Video Tape Master Maintenance

They suspect that there may be a few more Static Data Maintenance Screens that would have similar functionality and hence desire to create a template form to act as a "master" format for all such maintenance screens.

Your Task:
1. Define the Standards for a typical static data maintenance screen.
2. Identify the Template Components, i.e., those features that would be common for all the data maintenance screens.
3. Sketch a rough figure on the look and feel.
4. Identify program codes that would be common for all the screens.
5. Create a Template Form with the look and feel identified in step 3 and having program codes determined in step 4.
6. Use (Inherit) the template to create
a. Customer Maintenance Screen
b. Video Maintenance Screen

BusCase UI 6.2
Dafesty Video Co's CTO, Karen is taking efforts to convert their video rental information system not only friendly from user point of view but is bent upon making his system adopt good programming and design practices. In this light, she noticed that there is a common requirement in many of their Windows Forms.

The textbox used in many screens invariably proceeded with a label - this was not her major concern. She found that very often text boxes used in the forms required only alphanumeric entry and she felt the need to prevent the users from entering data other than alphanumeric characters. Not knowing how to approach the problem, she called Venkat of VIT who had taught her in a short course she attended. After listening to her requirement Venkat said: "I do not off- hand remember any property in Textbox control that would prevent entry of special characters." He suggested that a good way to do this would be to create a "user control" object that would comprise of a composition of two .NET visual controls, viz., Label and TextBox. Further the TextBox in the user control can have an event handler on keydown that would cancel the entry if the key that was pressed were non-alphanumeric.

Karen was thrilled by the idea, but confessed that though she understood the concept, she does not know how to proceed on actual development and requested Venkat to provide a proof of concept code sample. Venkat is currently very busy, so can you help him develop the user- control?

Description of the User Control:

The above control can be used in ay form. Let us call the user control: CodeFieldUControl. The user control would consist of a label and a textbox pair.

The user control should provide a facility for the consuming form to set the label text since each consuming form can have different captions. This is achieved fy providing a public get/ser property (accessor/mutator) to the label's text property. We would require a public property as mapping since the label control is private to the user control class. Let us call the getter/serer public property as LabelCaption.

The text box (placed in the user control) is a normal textbox, but we wish to have some additional features for this textbox. These features should be ser / programmed at the user control level for the text box. Hence the consumer of this user control would automatically be able to achieve all these features without writing codes each time in his/her form.

The following are the identified preset properties of the components within the user control.
a. Label's Text font size is 10pt
b. Textbox's Text font size is default.
c. Textbox automatically makes the text to upper case.
- To achieve this you need to sert the CharacterCasing Property appropriately.
d. Only alphanumeric characters can be entered in the text box when a person tries to enter values in the user-control's text box when this user control is used in a consuming form.*

Checking for the Alphanumeric data entry:

o Use the KeyPress event of the textbox.

o From the event argument, it would be possible for you to capture the key character that invoked the event.

o If the character pressed is not alphanumeric, then you can stop proceeding with the action by setting the Handled property of the event argument to true.

o It would be a challenge to incorporate permitting the backspace or delete keys since these are often used during data entry process - if you are not able to achieve this it is ok. If you need to achieve this also, you may need to consider additional programming and may require use of a combination of events like keydown /keyup in addition to the keypress. This may be taken up if students wish perfection.

Steps for doing this workshop:

1. Create (or use) the Windows forms project.
2. Add a couple of forms that would consume the usercontrol. Ideally these are forms that would be launched from a menu in form1, the application start up form.
3. Add a user control (name it CodeFieldUControl.cs).
4. Define the user control features:
a. Place Textbox and label with predefined properties as mentioned in the specs (including the character casing restrictions).
b. Add the getter/setter Property for label text.
c. Write event handler codes for alphanumeric check.
5. Add the user control to a consuming form:
a. Selecting the UserControl, look in the Properties Window - you should be able to see the get/set property LabelCaption in the properties window! Set the label as desired on the fly.
b. Add any other normal controls if required.
6. Run the project and test.
7. Repeat steps 5 and 6 in another form - notice how the features are well reused.

Wow what a reuse!

To distribute your user controls to other projects you may try this: (this is an optional exercise)
1. Start a fresh project called UCLib - the project should be a user control project not a windows forms project.
2. You need to do the user control as before - rather than repeating all the steps, you may simply copy the CodeFieldUControl.cs into the new project directory and include it from the solution explorer.
3. Compile the project into a dll library.
4. Start a new windows forms project call it TestUCApp.
- Add a couple of forms in this where the UC would be consumed.
5. Right click on the Toolbox and add components. Choose the UCLib.dll
a. You would notice that the user control that you had created now appears in the Toolbox.
b. You would also notice that references are added in the solution explorer.
6. Now you can use the user control the same way you had done earlier.
a. Test it and enjoy.
b. Why not, perhaps you can build a lot of useful templates and controls in this separate library project for use at a later point.
7. Caution: After adding a user control to an application project, if you make modifications to the original control, the changes are not automatic since the old version of the dll has been localised in the windows forms library - hence you may need to repeat step 5, every time you make a change in the library. There are of course other productive ways of tackling it; these are not discussed here since it does not relate to UI specific learning.

Lab Tutorial - 6

Design Windows Applications with Visual Studio
Design following Marks Calculator on Visual Studio. Use C#.Net to design and develop the functionality. Upload the project on Moodle via the link provided

Lab Tutorial - 7

ACTIVITY:
- Use the Dafesty Video database
- Create a class for Movie Object

- Create a class for Movie Broker that would perform the CRUD functions on the Movies Table
- Create a form that would contain text boxes for the four fields
- Implement button click events to test the CRUD function using the Data Broker that you had just created

Lab Tutorial - 8

Object Persistence & Windows Forms Application Development using Entity Framework

The goal of this tutorial is to train you on how to work with ORM and carry out Object Persistence using the Microsoft Entity Framework when building a Windows Application. This tutorial assumes that you are familiar with the basics of EF through earlier tutorial and have practiced EDM creation and retrieving data using LINQ and Lambda. This tutorial and builds on the persistence operations which would help you to modify, add and delete records through working at Entity level.

The Microsoft Entity Framework is an Object Relational Mapping (O/RM) tool that enables you to generate a data access layer from a database automatically. The Entity Framework enables you to avoid the tedious work of building your data access classes by hand.

We shall continue working with the Dafesty database to illustrate the Entity Framework.

EDM Creation:

Create an Entity Data Model consisting of Customer and Country Entities to arrive at the following Model.

Note:
a. The following are the naming and choices that we have made:

i. Model Name: DafestyModel
ii. Context: DafestyEntities
iii. Include Foreign Key field is unchecked - so that country code does not appear as an attribute to the Customers entity.
b. Further Modelling: As a proof of concept to mapping variations, the MemberCategory column generated as an attribute has been renamed to MemberRating with appropriate mapping.
Driver Form:

Create a form as below to test the various operations.

Retrieving a single customer

Using the EDM, we would retrieve a single customer with id 1818 and display his Customer Name and Member Category in the Label.

private void QueryButton_Click(object sender, EventArgs e)
{
DafestyEntities ctx = new DafestyEntities();
Customer c = ctx.Customers.Where(x => x.CustomerID == "1818").First(); label1.Text = c.CustomerName + " " + c.MemberRating;
}

Note:
• We use MemberRating for the field when working with the object (not the column name MemberCategory).
• The .First method throws exception if there are no retrievals. If you want to avoid exception and assign null to c, then you would use .FirstOrDefault method.

Updating customer data

We would now modify the member category of customer 1818 from A to B. Note:
• To modify an existing customer, you should first retrieve the customer data from the database,
make the desired changes to the customer object and persist back to the database.
• Often, beginners make the mistake of trying to re-create a customer, which is wrong as you may be trying to create a duplicate row for the same customer and a exception would result. Hence first retrieve the object and then persist it.

private void QueryButton_Click(object sender, EventArgs e)
{
DafestyEntities ctx = new DafestyEntities();
Customer c = ctx.Customers.Where(x => x.CustomerID == "1818").First();

ctx.SaveChanges()
;
}

• The save changes method performs the necessary updates of all changes that has been done on the data held by the EDM context.
• This could include several changes to several entities and entity collections.
• Changes can be inserts, deletes, modification of values or even object association changes.
• Upon performing the updates review the database to ensure that the new value of MemberCategory (i.e., Customer 1818 is now B).

Creating a new customer
We would now create a new customer with id 1007 with CustomerName Venkat and MemberCategory as B.
This would eventually mean that a customer record gets inserted when the persistence operation is carried out.

private void QueryButton_Click(object sender, EventArgs e) {
DafestyEntities ctx = new DafestyEntities();

Customer c = new Customer(); c.CustomerID = "1007";
c.CustomerName = "Venkat"; c.MemberRating = "B";
ctx.Customers.Add(c);

ctx.SaveChanges();
} Note:
• Since the customer is a new customer, create a new object.
• Set all values and importantly the Customer ID, which should be assigned a value that no other current customer uses (else a primary key violation would occur).

• Add the customer object to the Customers collection of the context. Creation of new Customer object does not link it to the context automatically.
• The SaveChanges would determine that this is a new object added to the Customer Collection and hence would issue an Insert command to the database.

Deleting an existing customer
We would now demonstrate how to delete an existing customer. i.e, Customer with id 1007.

private void QueryButton_Click(object sender, EventArgs e)
{
DafestyEntities ctx = new DafestyEntities();

Customer c = ctx.Customers.Where(x => x.CustomerID == "1007").First(); ctx.Customers.Remove(c);

ctx.SaveChanges();
}


Note:
• Since the customer is existing customer, we would retrieve the customer object and delete.
• The operation requires to remove the object from the collection and save.
• The SaveChanges would issue the necessary delete statement to the database.
• It is important that you should delete a Customer who has no other related records in other tables.
Otherwise a foreign key violation may happen due to referential integrity check at the database.

EXERCISES

1. Create an EDM that would consist of Movie entity and Producer Entity.

2. Make sure your entity is called Movie and not Movy!

3. In the object model, MovieType should be called Genre and RentalPrice as RentalCost. Make the appropriate changes in one instance from the designer and in other instance in the XML code that defines the EDM.

4. Perform the following CRUD operations
a. Retrieve the movie with code 5 (Nemesis)
b. Update the rental cost of this movie to $1.80
c. Create a new Movie with id 400, name of the movie is Sully, genere is Drama, Producer is Warner Brothers, rental price is $2.50, Rating is U, number of copies (total stock) is 4.
d. Modify the Producer of Demolition Man (code 4) from Universal to Pixar. Alter the association from Movie object (1-side).
e. Modify the Producer of Die Hard 2 (code 11) from Pixar to Warner. Alter the association from the Producer side (n-side).
f. Delete the movie with code 400.

5. Create a Movie Data Maintenance Screen as below. Provide Navigation Buttons, and buttons for various CRUD operation and Find operation. Try to make the screen as functional and user friendly as possible.

Attachment:- Developing Windows Applications.rar

Reference no: EM132991014

Questions Cloud

Define the standards for a typical static data maintenance : Define the Standards for a typical static data maintenance screen and Identify the Template Components, i.e., those features that would be common
Define operations management for the car manufacturing : You are an operations manager at a large car manufacturing plant in the United States. Your Chief Operating Office (COO) has sent a request that you write a mem
Primary purposes of organizational communication : -Why is it important to make a distinction between "group" and "team"? What kinds of behaviors might be different in these assemblages?
What is walt disneys current culture and structure : What is Walt Disneys current Culture and Structure?
Create an edm that would consist of movie entity and produce : ITAP3011 Developing Windows Applications - Create an EDM that would consist of Movie entity and Producer Entity.
Perform a strategy for conquering the career fair : An open answer question:How would you perform a strategy for conquering the career fair?
Advantages and disadvantages of the maturing approach : In the article "Increasing the relevance of enterprise architecture through "crisitunities" in US State Governments", the authors discuss several EA approaches.
What actions should linda take to control costs : Your best friend, Linda, just sold her apartment and purchased another one. Linda is planning her move. Linda asked you to advise her on the cost of her move.
Think about an idea of a fictitious company : Think about an idea of a fictitious company offering products or services to University Students and imagine what the company would like to know from their pote

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd