Friday, January 19, 2018

C# Unit 5 : User Controls , Database Programming with ADO.NET , Crystal Report , Setup Project in C# for B.C.A., B.Sc.(IT)


--------------------------------------------------------------------------------------------------------------------------
Prepared By : Uday Shah (HOD-IT)
E-Mail : rupareleducation@gmail.com
Contact No : 7600044051

User Controls , Database Programming with ADO.NET , Crystal Report , Setup Project in C# 


User Controls.

Q-1     Explain what is user control?
·        All the controls are reusable almost controls are categorized in two category.
·        That is ……
1)     Custom Control
2)     User Control
·        Custom controls are completely custom and also provide reusable functionality. It is created entirely in a code.
·        It is a light weight control because there is not anything added from visual studio.
·        It is a based on html controls.
·        While the user controls is also known as custom control and also provide the reusable functionality.
·        It is create and design in visual studio and it also contains code behind file.
·        It is much easier to deal with visual studio.
·        It is also known as heavy weight control. Because it use .ascx file.

Q-2     Explain property, methods and event of user control.
·        Microsoft .net controls are all inherited from common base class called user control.
·        This class has all the basic functionality for graphical control.
·        That will be use on windows form.
·        When you inherit from the user control class you will be automatically supplied with certain properties, events and methods.
1)     Properties :
·         There are about 30 properties that you will inherit from the user control base class.
·         This property includes all the common properties that you will see in normal controls.
o   Such as … Back color, fore color, font etc…
·         You can overwrite these properties if you need.
2)  Events:
·         A user control that you create inherits about 40 events. From the user control base class.
·         These events are also some common events like, load event, resize, layout etc…
·         Your control will also include some of the low level mouse and keyboard event.
·         You may over write these inherited events if you need.
3)  Method:
·         It is also define automatically by the user base class.
·         And you also need to create a method that can be call whenever an action is occurring.

Question : Using User Control in Windows
Answer :   
By default, a UserControl object can act as a control container only when you create the control. To make a UserControl host a constituent control after you put the UserControl on a Windows Form, you must change the default designer of the UserControl.  To implement design-time services for a component follow the following stapes.

Setp1 : Create a Windows Forms Control Library Project.
Step2 : Add  a new UserControl in this project.
Step 3 : Drag a control to the User Control. Ex. I create a login from in user control.
Step 4 : Add a new Windows Forms Application.
Step 5 : Now you can see in the toolbox that you have a login control. Drag this control onto your from.
Step 6 : Now run the Windows From Application.

Question: Project as Component
Answer: When you create an app, website, plug-in, etc. in Visual Studio, you start with a project. In a logical sense, a project contains all the source code files, icons, images, data files, etc. that are compiled into an executable, library, or website. A project also contains compiler settings and other configuration files that might be needed by various services or components that your program communicates with.


A project is contained within a solution. Despite its name, a solution is not an answer. It's simply a container for one or more related projects, along with build information, Visual Studio window settings, and any miscellaneous files that aren't associated with a particular project. A solution is described by a text file extension .sln with its own unique format. It’s not intended to be edited by hand.

Data Base Programming with ADO.NET

Q-1     What is ADO.NET?
·        Most application requires some form of data access.
·        ADO.NET is a part of Microsoft .net framework.
·        The full form of ADO.NET is active data object.
·        ADO.NET has the ability to separate data access mechanisms data manipulation and data connectivity mechanisms.
·        ADO.NET is a set of classes that allow application to read and write information in database.
·       
Following is a diagram of ADO.NET activity:-

·        According to above diagram.
·        ADO.NET can be used by any .NET languages.
·        ADO.NET is concept it’s not a programming language.
·        ADO.NET introduces the concept of disconnected architecture.
·        To use ADO.NET we need to add system. Data namespace.
·         It is next version of active data object technology which is used in V.B 6.0.
·        To work with database we need to add a namespace that is…… Using system.data.sqlclient
Q-2     What is disconnected environment? Or
            Explain connected and disconnected architecture.
·        The ADO.NET framework supports two model of data access architecture.
·        That is……
1)     Connection oriented data access architecture
2)     Disconnected data access architecture.
·        In connection oriented data access architecture application make a connection to the data source and then interact with sql request using the same connection.
·        In this case the application stay connected to throw database system even when it is not using by any database operation.
·        ADO.NET solve this problem by introduce a new concept of local buffering of, persistence data using data set.
·        The data set is central component in the ADO.NET disconnected a data access architecture.
·        A database is an in memory data store that can hold multiple tables at the same time.
·        Dataset only hold data and do not interact with data source.
·        One of the key character rustics of data set is that it has no knowledge of the underline data source.
·        That night have been used to populate it.
·        To create a dataset object use following syntax:-
Dataset ds = new dataset ( );
·        According to above syntax:-
·        Dataset represent ether an entire database or a subset of database.
·        It contains tables and relationship between those tables.

1.      Connected architecture:-
Command:-
·        It is used to fire sql commands or perform some action on the data source.
·        Such as ……Insert, update and delete.
·        Command object is depending on connection object.
·        Command object are use to execute command to a database across a data connection.
·        The command object in ADO.NET execute sql statements and store procedures that return single value one or more set of rows or No value at all.
·        The command object has a property called command text which contain a string value that represent the command that will be executed in the data source.
·        Command object require minimum two things.
·        That is ……
Connection and query.
·        There are four overloaded constructor.
Data Reader:-
·        When we execute command object using execute reader () method at that time it return data reader.
·        Which represent forward and read only rewards?
·        Data reader is use to restive read only and for word only stream of the data from the database.
·        It means we cannot perform any insert update or delete operation in data reader.
·        Data reader is opposite of dataset
·        We cannot move previous in data reader.
·        When we just want to the data use data reader fill.
·        Data reader requires open connection.
·        Data reader can hold one table at a time.
·        Data reader has item collection.
·        Data reader has read method to read next recode.
2.      Disconnected Architecture :-
Data adepter:-
·        It is associated with command and connection object.
·         The data adepter is the class at the core of ADO.NET disconnected data access.
·        It is the bridge between dataset and the database.
·        The data adepter provide a set of methods and properties to retrieve and saves data between dataset ant databases.
·        The data adepter is used fill method to fill a data table or dataset.
·        The data adepter can commit the change to database by its update method
·        Data adepter provide four properties that represent database command like,
·        Select, insert, update and delete commands etc…
·        When the data adepter fill a dataset it will create the necessary table and column for the return data.
·        It has four overloaded constructor.
Data table:-
·        Dataset contain a collection of one or more data table object.
·        Data table can be identifying in the dataset using dataset table property.
Data row:-
·        Data row represent a row of data in data table.
·        You can add data to the data table using data row object.
·        Data row collection object represent a collection of data row of a data table.
·        Data row class has its own properties and method. For access data base value.
Data column:-
·        Data column is one part of the data row.
·        Using a dataset we can access an individual column and a value of the column from data row using data column object.
Data relation:-                                                                                    
·        Using a data relation we can create parent child relationship between data tables.
·        ADO.NET data table object maintain a collection of constrain like, primary key, reference key, unique key, not null etc……
·        Using a data relation object we can element redundant data with the help of join queries. 
Data view:-
·        Data view work with data table.
·        Every table has a default data view.
·        With the help of data view you can create different views of the data store in data table.
·        Data view has a list of properties and methods.
·        Using data view you can expose the data in table with different shorted order and filter data.
·        Data view provides a dynamic view of single set of data.
·        Data view has important properties like, short and row filter.
·        Data view does not affect the actual data store in data table.

Q-2     Command objects method.
·        Command object has three important methods for execute queries.
·        To execute any method it need to open a connection.
·        That for…….
1)     Executescalar() method
2)     Executenonquery() method
3)     Executereader() method
·        Execute scalar it is used with agree get function.
·        Agreegaet functions are…….
1)     Avg
2)     Max
3)     Min
4)     Sum
5)     Count
·        It return one value at a time.
·        It fetch data from database
Executenonquery:-
·        It is use to fire insert, update and delete queries to the database.
·        It returns numbers of row affected it mean if we delete five records than it return five.
·        It is generally use in connected architecture.

Q-4 Explain Grid view.
·        It displays data in grid control.
·        It means record display in row and column tabular format.
·        Grid view display record in standard format. Even we can format the row with background color.
·        It allows displaying string, data, time, number etc…….
·        Data grid view allow you to display structure data in static format as well as data from the database
·        When we bind the control to data source we can base on the structure of data source.
·        The grid view control can display data in three distinct methods.
·        That is …….
1)     Bound
2)     Unbound
3)     Virtual

Crystal Report.
Q-1      What is Crystal Report?
·        Crystal Report is popular windows base report writer and report generation program.
·        That allow a programmer to create report from a verity of data source with minimum of writing code.
·        Crystal report an access data from most widely used database, and an integrated data from multiple databases within one report using open database connectivity (ODBC).
·        Crystal report used an active-x control for crystal report to establish a connection with other program.
·        A programmer can set properties of the crystal report control during design time a time or at run time.
·        The programmer can use automation tools all exports, imports, linking and embedded reports.
·        Crystal report also allowed text, graphics and database field as an object.
·        That programmer can place arrange and format according to their requirement.
·        Crystal report can create a report on the fly from user define variable.
·        You can convert into an HTML and publish it to the web automatically.

Q-2     Types of crystal reports.
·        Following is some list of crystal report types :-
1)     Standard Report
2)     Sub Report
3)     Form Letter
4)     Crosstab  Report
5)     Drill Report (Column into Column)
6)     Mail later Report Etc…
Q-3     Report Section.
·        Sections are design area, which is use to build a report.
·        Crystal reports provide five different /main sections.
1)     Report Header
2)     Page Header
3)     Detail
4)     Report Footer
5)     Page Footer
·        Report header fields place in this section are printed once at the beginning of the report.
·        Page header fields place in this section are printed at the beginning of each new page.
·        Detail section fields are printed with each new reword.
·        Report footer is place in this section printed once at the end of the report.
·        Page footers place in this section are printed at the bottom of each new page.
·        More section will appear if you add group or a section in a report.
·        Just click on section expert button in the top of the menu which contains a list of all section in the report.
·        As well as you can a delete section from the report.
·        Use up down arrows they to change order of the section.

Q-4     Formula special field and summary in report
·        C# crystal report section describe how to add a formula field in the crystal report
·        If you have crystal report with Quantity and price field and you need an additional field in your report for total like.
For e. x.:    Tot = Quantity * (price)
·        In this type of situation you can use the formula field in a crystal report.
·        For each roe that means each roe in report are showing the total of Quantity and price.
·        C# crystal report also support some special field like,
·        Initial of customer name, order date, page number, etc… fields at the time of designing a report.
·        It also describes how to add summary field in a report just right click on report footer and select insert menu for summary field.
·        It will give you a combo box and select an appropriate field and location of that field in a report. 
      For e. x. :  To display grant totals in a report footer section

Setup Projects
Q-1     Explain setup projects.
·        C# support desktop application as well as web server project so it require to setup or deploy a project on server.
·        If we want to deploy application in IIS server then we need to prepare a separate publish file and folder create a virtual path.
·        Project is very useful in some situation like,
·        Suppose if we do one application for client and we need to deploy that application in the client machine at that time entire folder are cover  under a one setup file all .exe
·        C# supports 3 different types of project.
·        That is……
1)     Setup Projects
2)     Marge Module Project
3)     Cab Project

(1)   Setup Project :-
·        Create a windows installer project to which file can be added.
·        This project type is most generic out of three.

(2)   Merge Module Project :-
·        It create windows installer project to which files can be added.
·        This project type is most commonly use for third party project.

(3) Cab project:-
·        It creates cab project to which file can be added.
·        It is also provide windows installer and web project configuration.

Q-2.    File system editor.
·        It provides you to essential tool to work with the application folder user desktop and user’s program menu.
·        The first think we want to do here to include the relevant files and folder that we wish to install on the users machine.

User Interface editor:

·        It contains a single section with hierarchical list of user interface dialogue box.
·        The list is divided into two section :-
·        That is :- 
     1. Standard and administrative installation and each section contain start, progresses and end nodes.
·       2.To represent the stage of installation.
Launch Conditions editor:
·        It specifies conditions require for installation on a target computer.
·        It can be use to find a file, registry entry or a component.
·        And the search result is return as a priority.
·        That can evaluate in a condition.
·        To access the launch conditions editor on the view menu pointer to editor and then click launch conditions.

·        When a deployment project is selected from solution explorer.

Best Of Luck