OEIDUSP

IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_

CHAPTER FOUR
IMPLEMENTATION OF THE SOFTWARE
4.1 The C# language and .NET
If we were to describe the c# language and its associated environment, the .NET
framework, as the most important new technology for developers for many years, we
would not be exaggerating. .NET is designed to provide a new environment with in
which you can develop almost any application to run on windows, while C# is new
programming language that has been designed specifically to work within Dot Net. Using
C#, you can for example, write a dynamic webpage, an XML web service, a database
access component or a classic windows desktop application.
In the Dot Net label, the NET bit in the name is there to emphasize Microsoft’s
belief that distributed applications, in which the processing is distributed between client
and server are the way forward, but C# is not just a language for writing windows based
application. It provides a means for you to code up almost any type of software or
component that you might need to write for the windows platform between them. C# and
Dot Net are set both to revolutionize the way that you write programs, and to make
programming on windows much easier than it has ever been.
We’ve talked in general terms about how great .NET is, but we haven’t said much
about how it helps to make your life as a developer easier. In this section, we’ll discuss
some of the improved features of .NET in brief.
 Object-Oriented Programming—both the .NET Framework and C# are entirely
based on object-oriented principles right from the start.
 Good Design—a base class library, which is designed from the ground up in a highly
intuitive way.
 Language Independence—with .NET, all of the languages Visual Basic .NET, C#,
J#, and managed C++ compile to a common Intermediate Language. This means
that languages are interoperable in a way that has not been seen before.
_______________________________________________________________________
32
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
 Efficient Data Access—a set of .NET components, collectively known as
ADO.NET, provides efficient access to relational databases and a variety of data
sources. Components are also available to allow access to the file system, and to
directories. In particular, XML support is built into .NET, allowing you to manipulate
data, which may be imported from or exported to non-Windows platforms.
 Code Sharing—.NET has completely revamped the way that code is shared between
applications, introducing the concept of the assembly, which replaces the traditional
DLL. Assemblies have formal facilities for versioning, and different versions of
assemblies can exist side by side.
 Improved Security—each assembly can also contain built-in security information
that can indicate precisely who or what category of user or process is allowed to call
which methods on which classes. This gives you a very fine degree of control over
how the assemblies that you deploy can be used.
C# can be seen as being the same thing to programming languages as .NET is to
the Windows environment. Just as Microsoft has been adding more and more features to
Windows and the Windows API over the past decade, Visual Basic and C++ have
undergone expansion. Although Visual Basic and C++ have ended up as hugely powerful
languages as a result of this, both languages also suffer from problems due to the legacies
of how they have evolved.
In the case of Visual Basic 6 and earlier, the main strength of the language was
the fact that it was simple to understand and didn’t make many programming tasks easy,
largely hiding the details of the Windows API and the COM component infrastructure
from the developer. The downside to this was that Visual Basic was never truly objectoriented, so that large applications quickly become disorganized and hard to maintain. As
well as this, because Visual Basic’s syntax was inherited from early versions of BASIC
(which, in turn, was designed to be intuitively simple for beginning programmers to

_______________________________________________________________________
33
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
understand, rather than to write large commercial applications), it didn’t really lend itself
to well-structured or object-oriented programs.
C++ has its roots in the ANSI C++ language definition. It isn’t completely ANSI
compliant for the simple reason that Microsoft first wrote its C++ compiler before the
ANSI definition had become official, but it comes close. Unfortunately, this has led to
two problems. First, ANSI C++ has its roots in a decade-old state of technology, and this
shows up in a lack of support for modern concepts (such as Unicode strings and
generating XML documentation), and in some archaic syntax structures designed for the
compilers of yesteryear (such as the separation of declaration from definition of member
functions). Second, Microsoft has been simultaneously trying to evolve C++ into a
language that is designed for high-performance tasks on Windows, and in order to
achieve that they’ve been forced to add a huge number of Microsoft-specific keywords as
well as various libraries to the language. The result is that on Windows, the language has
become a complete mess.
Now enter .NET—a completely new environment that is going to involve new
extensions to both languages. Microsoft has gotten around this by adding yet more
Microsoft-specific keywords to C++, and by completely revamping Visual Basic into
Visual Basic .NET, a language that retains some of the basic VB syntax but that is so
different in design that we can consider it to be, for all practical purposes, a new
language.
It’s in this context that Microsoft has decided to give developers an alternative—a
language designed specifically for .NET, and designed with a clean slate. Visual C#
.NET is the result. Officially, Microsoft describes C# as a “simple, modern, objectoriented, and type-safe programming language derived from C and C++.” Most
independent observers would probably change that to “derived from C, C++, and Java.”
Such descriptions are technically accurate but do little to convey the beauty or elegance
of the language.
Syntactically, C# is very similar to both C++ and Java, to such an extent that
many keywords are the same, and C# also shares the same block structure with braces
_______________________________________________________________________
34
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ ({}) to mark blocks of code. and it has been designed to give us. low-level memory access of C++ if required.  A consistent and well-defined set of basic types. The first impression of a piece of C# code is that it looks quite like C++ or Java code. and the high performance.  Just by changing the compiler options. Some of the features of C# are:  Full support for classes and object-oriented programming.NET base class library. the ease of use of Visual Basic. which won’t be all that often). and operator overloading. _______________________________________________________________________ 35 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 .  The facility to mark classes or methods with user-defined attributes.  Automatic cleanup of dynamically allocated memory. and semicolons to separate statements.  Support for properties and events in the style of Visual Basic. Behind that initial similarity.  Full access to the . Its design is more in tune with modern developer tools than both of those other languages. marking methods to be compiled only in debug builds). however. This can be useful for documentation and can have some effects on compilation (for example.  Built-in support for automatic generation of XML documentation. simultaneously. as well as easy access to the Windows API (if you really need it.  Pointers and direct memory access are available if required. you can compile either to an executable or to a library of .NET components that can be called up by other code in the same way as ActiveX controls (COM components). C# is a lot easier to learn than C++. but the language has been designed in such a way that you can work without them in almost all cases. including interface and implementation inheritance. and of comparable difficulty to Java. virtual functions.

members. private float length. The classes that we defined are listed below with their respective generalized sample code structure. constructors and has their own specified purposes to manipulate some actions.2 Classes in OEIDUSP When we design our project. Some of the specifications are room length. 1) Room 2) Project 3) Luminaries 4) Data access 5) ID base 6) Form ( ) Room Class This class holds the required specifications that are crucial for the room object. It also calculated the intensity of the room that is entered from the room form. using System. public float RoomWidth _______________________________________________________________________ 36 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 .OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ 4. namespace InstallationDesign { public class Room : IDBase { private float width. private float height. public float requiredIllLevel. we have defined different classes. This class also holds the method draw to draw the room by taking the length and width of the room that is entered from the room form.Drawing.Collections. room height and required illumination level. using System. using System.Text. room width.Generic. Each class has its own parameters. methods. using System.

OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ { /// <summary> /// get and set the room width /// </summary> /// } public float RoomLength { /// <summary> /// get and set the room length /// </summary> /// } public float RoomHeight { /// <summary> /// fget and set the room height /// </summary> /// } public float RequiredIllLevel { /// <summary> /// get and set the required illumination level /// </summary> /// } public Room() { /// <summary> /// constructor /// </summary> /// } public void Draw() { /// <summary> /// It will draw on the panel when it is called /// </summary> /// } public double intencity_n() { /// <summary> _______________________________________________________________________ 37 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 .

using System. /// </summary> /// } } } Project Class In this class.Text. we defined some object like the room. using System. luminary that has to be on the current project and its own member variables such as project ID. namespace InstallationDesign { public class Project : IDBase { #region mem vars #endregion /// <summary> /// Declaration of Member variables /// </summary> /// #region properties /// <summary> /// gets or sets the Member variables /// </summary> /// #region ctor and dpose public Project() { /// <summary> /// region of Constructor /// </summary> _______________________________________________________________________ 38 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 . using System.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ /// it will calculate the intensity of the room.Drawing. Each method is partially described in their region briefly below using System. Generally this class will hold and organize the materials that are used for creating the current or new project.Data.

/// </summary> /// } public int get_Vstarting_point() { /// <summary> /// it will get the vertical starting point of /// the luminaire that will be drawn on the form.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ /// } #endregion #region methods public void Draw() { /// <summary> /// it will call the draw method defined in the class room /// </summary> /// } public int get_Hstarting_point() { /// <summary> /// it will get the horizontal starting point of /// the luminaire that will be drawn on the form. /// </summary> /// } public void DrawLuminaries() { /// <summary> /// it will draw the lamps when it is called /// </summary> /// } public int SaveLuminaire() { /// <summary> /// it will save luminaires that are entered on the data entry /// form /// </summary> /// } _______________________________________________________________________ 39 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 .

using System. namespace InstallationDesign { public class Luminaire { #region mem vars /// <summary> /// Declaration of Member variables /// </summary> /// #endregion #region properties /// <summary> /// gets or sets the Member variables /// </summary> /// #endregion public Luminaire() { /// <summary> /// region of Constructor /// </summary> /// } #region methods _______________________________________________________________________ 40 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 .Generic.Text. using System.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ #endregion } } Luminary Class This class organizes the luminaries’ specifications like name. power.Collections. distributor name. these properties will be considered and the luminary will be drawn. family name. using System. When we draw and calculate the number of luminaries’ needed. the housing type they used. flux and color. using System.Drawing.

insert and update return a specific value and also returning the whole data table to the user. namespace InstallationDesign { public class DataAcess { #region Global Variables /// <summary> /// it will assign variables /// </summary> /// #endregion #region ctor public DataAcess() _______________________________________________________________________ 41 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 .Data. using System.SqlClient.Data.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ public Double intencity_of_lamp() { /// <summary> /// it will calculate the lamps intensity /// </summary> /// } public Double get_total_power() { /// <summary> /// it will calculate the total power of the lamps /// </summary> /// } #endregion } } Data Access Class In this class all the actions that are related to the database are manipulated some of the actions. using System. using System.Collections. using System. These actions are performed by using the methods that are listed below.

/// </summary> /// public static DataTable ExecuteDataTable(string Sql) { /// region of accessing the database to return a table.Generic. using System. } public static int ExecuteNonQuery(string Sql) { /// region of accessing the database to insert.Text.Drawing. namespace InstallationDesign _______________________________________________________________________ 42 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 . using System. using System.update and delete a /// database. } public static object ExecuteScalar(string Sql) { /// region of accessing the database to return a single value. using System. } #endregion } } ID Base Class This is a base class for project and room classes and it contains the graphics materials that are crucial for drawing the room and the luminary on the panel.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ { /// <summary> /// region of Constructor /// </summary> /// } #endregion #region Methods /// <summary> /// region of database access.Collections.

OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ { public abstract class IDBase { #region mem vars /// <summary> /// declaration of member variables for the graphics object and /// pen with which the graphics on the project is to be drawn /// </summary> /// #endregion #region properties /// <summary> /// gets or sets the IDGraphics values /// </summary> #endregion #region ctor public IDBase() { /// <summary> /// region of constructor /// </summary> /// } #endregion } } 4. we tried to show the general steps that we go through in executing the developed system from the beginning of the software until the end of the process. This can be easily shown using flow chart diagram.3 General Steps In this section. _______________________________________________________________________ 43 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 .

General Steps _______________________________________________________________________ 44 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 .1.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ Start Enter luminary data to the Database Enter room parameters & Draw room Select luminary from Database & Calculate number of lamps Draw Luminary on the room Fig 4.

OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ Enter supply voltage & Cable length Calculate cable size & Breaker rating Close application End _______________________________________________________________________ 45 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 .

OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ 4. Flow Chart of OEIDUSP _______________________________________________________________________ 46 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 .4.

Flow Chart _______________________________________________________________________ 47 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 . If room is selected A Fill room fields. J E D If room! =null Wait until user inputs the fields Draw room. B Fig 4. Click on data.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ Start Create a new project. Click on data & select project luminary. Give the room to the room class.2.

Wait till it is selected F If lamp is selected Do nothing _______________________________________________________________________ 48 C _ G Department Electrical Engineering Arba Minch University Faculty of Engineering June 2007 .OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ B If family selected Wait till it is selected Populate housing D If housing selected E D Populate Distributors Wait till it is selected If distributors selected Populate Lamps.

D If selected family changed If selected Housing changed E D F If selected Distributor changed If selected Lamp changed G _______________________________________________________________________ 49 _ H Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 . color.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ C Display flux. calculate number of lamps & display number.

Select the breaker rating current. cable length.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ H Click on ok. Calculate voltage drop. Draw the luminary. If Voltage drop > 4% of supply voltage Select the next larger cable size. Select the cable size. temperature & check for fuse. Enter the supply voltage. Calculate the design current. Display cable size & breaker rating _______________________________________________________________________ 50End _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 .

OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ A Enter the luminary database. Add the luminary to the database J _______________________________________________________________________ 51 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 . Click on ok.

Our developed system comprises four different user interfaces. n ne ope Fig 4.3. we will describe each and every user interfaces that are developed in our system sequentially when the program is running. These are: 1) Main Form 2) Project Luminary Form 3) Room Form 4) Data Entry Form it to n o m lick w for C 1.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ 4. User Interfaces In this section.5. Main Form _______________________________________________________________________ 52 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 .

This is new form Fig 4.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ 3. Click here to enter room parameters 2. New Main Form _______________________________________________________________________ 53 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 .4.

This is room form 5.5.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ 4. Click here to draw the room after filling the parameters Fig 4. Top view of the room _______________________________________________________________________ 54 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 . Room Form 6.

OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ Fig 4.6. Room selecting luminary _______________________________________________________________________ 55 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 . Click here to select luminary types Fig 4. Top view of the room 7.7.

This shows the calculated number _______________________________________________________________________ 56 of liminaries _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 . Project luminary form 10. Click here to select family types 11.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ 8. Select maint. Click here to see the luminaries inside the room 13. factors 12. This displays lamp specifications 14. and util. Click here to select luminaries’ preference from a list 9.

Displayed output Fig 4. Luminary selection 16.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ Fig 4. cable length and temp 17. Displays cable size and breaker rating 15.8. Displayed luminaries and calculation of cable size _______________________________________________________________________ 57 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 . Enter the supply voltage.9. Click here to calculate cable size and breaker rating 18.

Selecting data entry form _______________________________________________________________________ 58 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 . Click here to add luminary to the data base Fig 4.10.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ 19.

are persistent. Microsoft SQL server 2000 is widely available and many trained manpower can be found easily. In addition we have noted that the nature of the system is highly queried intensive. Fig 4.6. Lamp family. Microsoft SQL server 2000 provides connectivity standards such as ODBC that can provide data abstraction enabling us to encapsulate data into subsystems and define high level interface that is vendor independent. Housing Lamps. data such as Luminary type. _______________________________________________________________________ 59 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 .11. In addition to the above services. Database Selection In this OEIDUSP system.OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ 20. Click here to save the specification to the data base. Data Entry form 21. Add the specifications of the luminary 20. relational database is found to be the right choice.Data entry form 4. In light of the above reasons. We have also selected Microsoft SQL server 2000 as our database management system.

the id of the housing table).OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ In our designed system we use the following data table diagram to manipulate the data execution of the system. amount of flux & distributor they use (i. _______________________________________________________________________ 60 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 . Each table contains its own data type for its own column. & the foreign key from the housing table (i. family id) & its own id. vii. vi. Voltage_drop table: In this table the data for voltage drop of some specific cable is stored. Housing: In this table the lamp’s housing type is stored with its foreign key from the family table (i. power. name. Cable_size: In this table the current carrying conductors cross sectional area is determined from its current carrying capacity (amount of current). Distributor: In this table the name of lamp distributor is stored with its own row id. ii. v. Breaker table: in this table the breaker rating current with the design current is stored. The cable is determined by its size & the voltage drop is in mm volts. These are color. viii. iv. The tables that are used are: i. Family: In this table the name of the lamp family is stored with its own id.e.e. foreign key from the distributor table).e. iii. Temperature table: In this table the temperature effect of the grouped cables is determined according to the temperature of the cables inside the conduit. Lamp: In this table each & every property of the lamp are stored.

12. Database diagram of OEIDUSP. _______________________________________________________________________ 61 _ Electrical Engineering Department Arba Minch University Faculty of Engineering June 2007 .OEIDUSP IMPLEMENTATION OF THE SOFTWARE _______________________________________________________________________ _ Fig 4.