·      Software description:

Our Project Idea:


We want to transport petroleum derivative between three stations each station is far a way from


Other stations and by storing orders in database by date and time when the order time is detects


The hardware is response by the mean to make this order succeed and transportation complete


Without of any human factor in this system (AUTOMATIC MODE);

Also we make Manual Control (MANUAL MODE) without responsibility if what will


Happen if some one breaks some critical rules that must be satisfied for example


Valves must be open before pumps and so on;

 So we Implement SW & HW;


HW: control the physical element on the system by sending signals to open or close some thing

   Or check for some rule that must be satisfying such levels in tanks temperature etc;


SW: control the logical idea and derive the hardware to complete the task as expected

And establish a communication between these computers in different regions by LAN Networks

Between these regions;


We have here three regions CAIRO, TANTA, SINAI;


SINAI: send raw to Cairo;


CAIRO: send raw to TANTA and CAIRO LAB and send benzene, solar to TANTA


CAIRO Control every thing in station that is connected to it;and any operation that CAIRO is in it


TANTA&SINAI Are control any operations in it’s regions;

So that’s the idea of our project


Software Divided to these parts:


1-database by Active Data Object.

The Latest technology in database introduce some useful objects

For dealing with most kinds of databases and in Networks  


2-communication by Windows Sockets.


Socket is an object that by it you can make

A connection between applications.

On same PC or in LAN Networks or on Internet


3- Threads for software optimization and parallel processing.


When using Windows 95 (and other modern operating systems), you know that you can run several programs simultaneously. This ability is called multitasking. What you may not know is that many of today's operating systems also allow threads, which are separate processes that are notcomplete applications. A thread is a lot like a subprogram. An application can create several threads—several different flows of execution—and run them concurrently. Threads give you the ability to have multitasking inside multitasking. The user knows that he or she can run several applications at a time. The programmer knows that each application can run several threads at a time. In this paper, you'll understand threads in your applications.


     some companies like nokia design some libraries to make your computer communicate and full control with your mobile functionality and the important thing is that when you connect   a mobile  with your PC  your PC can send to you a message and

can receive from you a message and read it and act depend on the order you give in your message this service call

sms: short message sending.

5- Graphics by Macromedia Flash


Macromedia introduce an ActiveX to make other

Application host the flash movies more than it

It create communication rule between graphics objects and the host programming language

So you can control the objects that you create

In flash by methods in ActiveX and you can do what you want in amazing look and beautiful graphics?



     The storing of data is an essential part of most software applications. Virtually all C++ applications have the need to persist, or store, data of some kind.

Many applications also need to retrieve data efficiently. These applications typically need to search.

Through data that has been stored in order to retrieve specific information. This need to search for and.

Retrieve data means that an application must use a database.

A variety of database technologies are available to C++ programmers.


Deciding the Appropriate Database Technology forYour Visual C++ Applications


    Choosing the right database technology means finding a technology that fills the requirements of your application.

    Without knowing the capabilities of the various database technologies, you can easily choose the wrong one for your particular application. In the following sections, you will learn the capabilities of each database technology.

     When choosing a database technology, you need to carefully consider the importance of your application's data. It would be easy to think that the data needs to be used only by your application.

However, if you write your application with that thought in mind, you will end up creating an application that has a closed, proprietary database that no one else can use or make sense of.

You might think a closed, proprietary database is okay for your application because your application is the only one that needs access to the data. Don't underestimate the value of the data and the need to access the data through more than just your application. Even if you are certain that others will never want to access your data except through your application, what about future implementations of your application? What if your application is Windows executable, and you need to produce a new version of it that runs behind a Web server and provides information to users with Web browsers? Because of the nature of Web development tools, an open, nonproprietary database can enable you to perform this conversion in much less time than a closed, proprietary database.

In the end, if you do decide to write an application that has a closed database, you will ultimately shorten the life expectancy of your own application. An application that has an open, accessible database and can interoperate with other databases and applications will sooner or later replace yours.

Now you will go through the process of choosing a database technology for an imaginary application.

You will examine each database technology and see what each one has to offer. Through this process, you will learn the capabilities (and limitations) of each database technology and how to choose the most appropriate technology for your applications.


The best way to learn to choose a database is by using an example and applying it to each technology.

Let's say that your job is to write an application for a company that sells products through television advertising.

The company advertises products such as a vegetable slicing machine, a bamboo steamer, 8-track love songs of the 70s, and so on, and offers them for the low, low price of $19.95. Each time


The TV commercial airs, the company's 800 line is flooded with calls from buyers.

The salespeople who take these calls have your application running on their computers. They use your application to enter each order so that the product can be shipped and the buyer's money can be collected.

This sounds easy enough. Your application needs to present a window into which the salesperson can enter the order, and then your application must write the information for the order to a data file. This being said, you might decide it would be easier to create your own database.


ADO Object Model:


ADOX Object Model:









·       Access Authorization:

























Avaliable Quantities




System Mode:-






Fields are shown above Here we will introduce primary key, Forigen key




·      Sockets, MAPI, and the Internet:

There are a number of ways for your applications to communicate with other applications through a network like the Internet. This paper introduces you to the concepts involved with these programming techniques. Subsequent chapters will cover some of these concepts in more detail.

Before the Windows operating system even existed, the Internet existed. As it grew, it became the largest TCP/IP network in the world. The early sites were UNIX machines, and a set of conventions called Berkeley sockets became the standard for TCP/IP communication between UNIX machines on the Internet. Other operating systems implemented TCP/IP communications, too, which contributed immensely to the growth of the Internet. On those operating systems, things were starting to get messy, with a wide variety of proprietary implementations of TCP/IP, when a group of over 20 vendors banded together to create the Winsock specification.


Using Windows Sockets (Winsock):

Describes the role that Winsock.dll plays in developing communication application


Messaging API (MAPI):

The capability to send messages is a must to receive a Windows 95 stamp of approval from Microsoft. This section shows you how to use this powerful API.




New Internet Classes in Visual C++ 6:

These powerful classes make Internet development fast and easy.


Internet Server API (ISAPI) Classes:

An Application Programmer Interface is a collection of utility functions collected for a similar purpose. The Internet Server API puts your World Wide Web server under your control.



Using Windows Sockets:

The Winsock specification defines the interface to a DLL, typically called WINSOCK.DLL or WSOCK32.DLL. Vendors write the code for the functions themselves. Applications can call the functions, confident that the name, parameter meaning, and final behavior of the function is the same no matter which DLL is installed on the machine. For example, the DLLs included with Windows 95 and Windows NT is not the same at all, but a 32-bit Winsock application can run unchanged on a Windows 95 or Windows NT machine, calling the Winsock functions in the appropriate DLL.

    Winsock is not confined to TCP/IP communication. IPX/SPX support is the second protocol supported, and there will be others. For more information, check the Winsock specification itself. The Stardust Labs Winsock Resource Page at http://www.stardust.com/wsresource/ is a great starting point.

An important concept in sockets programming is a socket's port. Every site on the Internet has a numeric address called an IP address, typically written as four numbers separated by dots:, for example. Programs running on that machine are all willing to talk, using sockets, to other machines. If a request arrives at, which program should handle it?

Requests arrive at the machine carrying a port number, a number from 1,024 and up that indicates for which program the request is intended. Some port numbers are reserved for standard use; for example, port 80 is traditionally used by Web servers to listen for Web document requests from client programs like Netscape Navigator.

Most socket work is connection-based: the two programs form a connection with a socket at each end and then send and receive data along the connection. Some applications prefer to send the data without a connection, but there is no guarantee that this data arrives. The classic example is a time server that sends out the current time to every machine near it, regularly, without waiting until it is asked. The delay in establishing a connection might make the time sent through the connection outdated, so it makes sense in this case to use a connectionless approach.



Winsock in MFC:

     At first, sockets programming in Visual C++ meant making API calls into the DLL. Many developers built socket classes to encapsulate these calls. Visual C++ 2.1 introduced two new classes: CAsyncSocket and CSocket, which inherits from CAsyncSocket. These classes handle the API calls for you, including the startup and cleanup calls that would otherwise be easy to forget.

Windows programming is asynchronous: there are lots of different things going on at the same time. In older versions of Windows, if one part of an application got stuck in a loop or otherwise hung up, the entire application—and sometimes the entire operating system—would stick or hang with it. This was obviously something to be avoided at all costs. Yet a socket call, perhaps a call to read some information through a TCP/IP connection to another site on the Internet, might take a long time to complete. (A function that is waiting to send or receive information on a socket is said to be blocking.) There are three ways around this problem


    Put the function that might block in a thread of its own. The thread will block, but the rest of the application will carry on.

Have the function return immediately after making the request, and have another function check regularly (poll the socket) to see if the request has completed.

    Have the function return immediately, and send a Windows message when the request has completed.

     Option 1 was not available until recently, and Option 2 is inefficient under Windows. So most Winsock programming adopts Option 3. The class CAsyncSocket implements this approach. For example, to send a string across a connected socket to another site on the Internet, you call that socket's Send () function. Send () doesn't necessarily send any data at all; it tries to, but if the socket isn't ready and waiting, Send() just returns. When the socket is ready, a message is sent to the socket window, which catches it and sends the data across. This is called asynchronous Winsock programming.

     Winsock programming is not a simple topic; entire books have been written on it. One you might like to look at is Que's Developing Internet Applications in Visual C++ ISBN 0-7897-0213-4. If you decide that this low-level sockets programming is the way to go, building standard programs is a good way to learn the process





     The CAsyncSocket class is a wrapper class for the asynchronous Winsock calls. It has a number of useful functions, which facilitate using the Winsock API. Table lists the CAsyncSocket member functions and responsibilities.

Table—CAsyncSocket Member Functions

Method Name



Handles an incoming connection on a listening socket, filling a new socket with the address information.


Requests that a Windows message be sent when a socket is ready.


Attaches a socket handle to a CAsyncSocket instance, so that it can form a connection to another machine.


Associates an address with a socket.


Closes the socket.


Connects the socket to a remote address and port.


Completes the initialization process begun by the constructor.


Detaches a previously attached socket handle.


Returns a pointer to the CAsyncSocket attached to the handle it was passed.


Returns the error code of the socket. Call GetLastError after an operation fails, to find out why.




Finds the IP address and port number of the remote socket that the calling object socket is connected to, or fills a socket address structure with that information.


Returns the IP address and port number of this socket, or fills a socket address structure with that information.


Returns the socket options that are currently set.


Sets the mode of the socket; most commonly, to blocking or non-blocking.


Instructs a socket to watch for incoming connections.


Handles the Windows message generated when a socket has an incoming connection to accept. Often overridden by derived classes.


Handles the Windows message generated when a socket closes. Often overridden by derived classes.


Handles the Windows message generated when a socket becomes connected or a connection attempt ends in failure. Often overridden by derived classes.


Handles the Windows message generated when a socket has urgent, out-of-band data ready to read.


Handles the Windows message generated when a socket has data that could be read with Receive().Often overridden by derived classes.


Handles the Windows message generated when a socket is ready to accept data that could be sent with Send(). Often overridden by derived classes.


Reads data from the remote socket to which this socket is connected.


Reads a datagram from a connectionless remote socket.


Sends data to the remote socket to which this socket is connected.


Sends a datagram without a connection.


Sets socket options.


Keeps the socket open but prevents any further Send() or Receive() calls.

If you use the CAsyncSocket class, you will have to fill the socket address structures yourself, and many developers would rather delegate a lot of this work. In that case, CSocket is a better socket class.


  CSocket inherits from CAsyncSocket and so has all the functions listed for CAsyncSocket. Table describes the new methods added and the virtual methods that are overridden in the derived CSocket class.

Table—CSocket Methods

Method Name



Attaches a socket handle to a CAsyncSocket instance, so that it can form a connection to another machine.


Completes the initialization after the constructor constructs a blank socket.


Returns a pointer to the CSocket attached to the handle it was passed.




Returns TRUE if the socket is blocking at the moment, waiting for something to happen.


Cancels whatever request had left the socket blocking.


Handles the Windows messages generated for other parts of your application while the socket is blocking. Often overridden by derived classes.



    In many cases, socket programming is no longer necessary because the WinInet classes, ISAPI programming, and ActiveX controls for Web pages are bringing more and more power to Internet programmers. If you would like to explore a sample socket program, try Chatter and ChatSrvr, provided with Visual C++. Search on either name in the online help, or open the files, located on the CD in the \DevStudio\VC\Samples\MFC\Advanced\Chatter and \DevStudio\VC\Samples\MFC\Advanced\Chatsrvr folders.

Each session of Chatter emulates a user server. The ChatSrvr program is the server, acting as traffic manager among several clients. Each Chatter can send messages to the ChatSrvr—by typing in some text—and the ChatSrvr sends the message to everyone logged into the session. Several channels of traffic are managed at once.


     If you’ve worked with sockets before, this short overview may be all you need to get started. If not, you may not need to learn them. If you plan to write a client/server application that runs over the Internet and does not use the existing standard applications like mail or the Web, then learning sockets is probably in your future. But, if you want to use e-mail, the Web, ftp, and other popular Internet information sources, you don’t have to do it by writing socket programs at all. You may be able to use MAPI, the WinInet classes, or ISAPI to achieve the results you are looking for.






Messaging API (MAPI):

    The most popular networking feature in most offices is electronic mail. You could add code to your application to generate the right commands over a socket to transmit a mail message, but it's simpler to build on the work of others.


What Is MAPI?

    MAPI is a way of pulling together applications that need to send and receive messages (messaging applications) with applications that know how to send and receive messages (messaging services and service providers,) in order to lower the work load of all the developers involved. shows the scope of MAPI. Note that the word messaging actually covers far more than just electronic mail: a MAPI service could send a fax or voice-mail message rather than an electronic mail message. If your application uses MAPI, the messaging services such as e-mail clients that the user has installed will carry out the work of sending the messages that your application generates.


The Messaging API covers applications that need messaging and those that provide it.


      The extent to which an application uses messaging varies widely:

Some applications can send a message, but sending messages is not really what the application is about. For example, a word processor is fundamentally about entering and formatting text and then printing or saving that text. If the word processor can also send the text in a message, fine, but that's incidental. Applications like this are said to be messaging aware and typically use just the tip of the MAPI functionality.

Some applications are useful without being able to send messages, but they are far more useful in an environment where messages can be sent. For example, a personal scheduler program can manage one person's To Do list whether messaging is enabled or not, but if it is enabled, a number of workgroup and client-contact features—such as sending e-mail to confirm an appointment—become available. Applications like this are said to be messaging enabled and use some, but not all, of the MAPI features.


   Finally, some applications are all about messaging. Without messaging, these applications are useless. They are said to be messaging based, and they use all of MAPI's functionality.


Using New Internet Classes in Visual C++ 6:

MFC 4.2 introduced a number of new classes that eliminated the need to learn socket programming when your applications need to access standard Internet client services. Figure 18.4 shows the way these classes relate to each other. Collectively known as the WinInet classes, they are the following:


The WinInet classes make writing Internet client programs easier.

·        CInternetSession

·        CInternetConnection

·        CInternetFile

·        HttpConnection

·        CHttpFile

·        CGopherFile

·        CFtpConnection

·        CGopherConnection

·        CFileFind

·        CFtpFileFind

·        CGopherFileFind

·        CGopherLocator

·        CInternetException


These classes help you write Internet client applications, with which users interact directly. If you want to write server applications, which interact with client applications, you'll be interested in ISAPI, discussed in the next section.


First, your program establishes a session by creating a CInternetSession. Then, if you have a Uniform Resource Locator (URL) to a Gopher, FTP, or Web (HTTP) resource, you can call that session's OpenURL() function to retrieve the resource as a read-only CInternetFile. Your application can read the file using CStdioFile functions and manipulate that data in whatever way you need.

If you do not have a URL or do not want to retrieve a read-only file, you proceed differently after establishing the session. You make a connection with a specific protocol by calling the session's.


GetFtpConnection(), GetGopherConnection(), or GetHttpConnection() functions, which return the appropriate.


Connection object. You then call the connection's OpenFile() function. CFtpConnection::OpenFile() returns a CInternetFile; CGopherConnection::OpenFile() returns a CGopherFile; and CHttpConnection::OpenFile() returns a CHttpFile. The CFileFind class and its derived classes help you find the file you want to open.

"Internet Programming with the WinInet Classes," works through an example client program using WinInet classes to establish an Internet session and retrieve information.


Though e-mail is a standard Internet application, you'll notice that the WinInet classes do not have any e-mail functionality. That's because e-mail is handled by MAPI. There is no support for Usenet news either, in the WinInet classes or elsewhere.


Using Internet Server API (ISAPI) Classes:

ISAPI is used to enhance and extend the capabilities of your HTTP (World Wide Web) server. ISAPI developers produce extensions and filters. Extensions are DLLs that are invoked by a user from a Web page in much the same way as CGI applications are invoked from a Web page. Filters are DLLs that run with the server and look at or change the data going to and from the server. For example, a filter might redirect requests for one file to a new location.


n order for the ISAPI extensions and filters that you write to be useful, your Web pages must be kept on a server that is running as ISAPI-compliant server like the Microsoft IIS Server. You must have permission to install DLLs onto the server, and for an ISAPI filter, you must be able to change the Registry on the server. If your Web pages are kept on a machine administered by your Internet Service Provider (ISP), you will probably not be able to use ISAPI to bring more power to your Web pages. You may choose to move your pages to a dedicated server (a powerful Intel machine running Windows NT Server 4.0 and Microsoft IIS is a good combination) so that you can use ISAPI, but this will involve considerable expense. Make sure that you understand the constraints of your


The five MFC ISAPI classes form a wrapper for the API to make it easier to use. They are:

·        CHttpServer

·        CHttpFilter

·        CHttpServerContext

·        CHttpFilterContext

·        CHtmlStream


Your application will have a server or a filter class (or both) that inherit from CHttpServer or CHttpFilter. These are rather like the classes in a normal application that inherit from CWinApp. There is only one instance of the class in each DLL, and each interaction of the server with a client is done through its own instance of the appropriate context class. (A DLL may contain both a server and a filter, but at most one of each.) CHtmlStream is a helper class that describes a stream of HTML to be sent by a server to a client.




·      Multitasking with Windows Threads:


When using Windows 95 (and other modern operating systems), you know that you can run several programs simultaneously. This ability is called multitasking. What you may not know is that many of today's operating systems also allow threads, which are separate processes that are not complete applications. A thread is a lot like a subprogram. An application can create several threads—several different flows of execution—and run them concurrently. Threads give you the ability to have multitasking inside multitasking. The user knows that he or she can run several applications at a time. The programmer knows that each application can run several threads at a time. In this paper, you'll understand threads in your applications.


How to Create and Run Threads:

Writing a thread and getting it started is easy under MFC. In fact, one function call is all it takes to get your thread running.


About Inter-Thread Communication:

Although threads are like self-contained subprograms, they still need to communicate with other threads, including the main program. There are several ways of doing this, the best of which is Windows messages and event objects.


About Synchronizing Threads with Critical Sections:

You often have to ensure that data can be accessed by only one thread at a time. Critical sections help you accomplish this type of data protection.



How to Use Mutexes to Synchronize Threads:

Mutexes are a lot like critical sections in that they enable you to guard data against thread corruption.



About Using Semaphores to Manage Multiple Resource Accesses:


Semaphores count the number of threads that access a resource and limit those accesses to a given maximum number of threads.


Understanding Simple Threads

A thread is a path of execution through a program. In a multi-threaded program, each thread has its own stack, and operates independently of any other threads that may be running within the same program. MFC distinguishes between UI threads, which have a message pump and typically perform user interface tasks, and worker threads, which do not.


Any application always has at least one thread, which is the program's primary or main thread. You can start and stop as many additional threads as you need, but the main thread keeps running as long as the application is active.


To create a thread using MFC, all you have to do is write a function that you wish to run parallel with the rest of your application then call AfxBeginThread() to start a thread that will execute your function. The thread remains active as long as the thread's function is executing: When the thread function exits, the thread is destroyed. A simple call to AfxBeginThread() looks like this:


AfxBeginThread(ProcName, param, priority);

In the previous line, ProcName is the name of the thread's function, param is any 32-bit value you want to pass to the thread, and priority is the thread's priority, which is represented by a number of predefined constants. Those constants and their descriptions are shown in Table

Table—Thread Priority Constants





Sets a priority one point higher than normal.


Sets a priority one point lower than normal.


Sets a priority two points above normal.


Sets a base priority of 1. For a REALTIME_PRIORITY_CLASS process, sets a priority of 16.


Sets a priority two points below normal.


Sets normal priority.


Sets a base priority of 15. For a REALTIME_PRIORITY_CLASS process, sets a priority of 30.



A thread's priority determines how often the thread takes control of the system relative to the other running threads. Generally, the higher the priority, the more running time the thread gets, which is why the value of THREAD_PRIORITY_TIME_CRITICAL is so high.








·        Scripting with Flash Player and ActiveX:


The documentation below describes the scripting interface for the Flash Player ActiveX control. This control handles playback of Flash content on Windows machines which support ActiveX (all 32-bit versions of Windows, beginning with Windows 95.) These methods may also be available to PocketPC Devices using the Flash Player for PocketPC




Action; allows the Flash movie to communicate with either the Flash Player, or the program hosting the Flash Player, such as a Web browser. You can also use the
fscommand action to pass messages to Macromedia Director, or to Visual Basic, Visual C++, and other programs that can host ActiveX controls.



 fscommand( " command " ,  " parameters " )


command A string passed to the host application for any use or a command passed to the stand-    alone Flash Player.

 parameters A string passed to the host application for any use or a value passed to the Flash   Player.



Usage 1: In Visual Basic, Visual C++, and other programs that can host ActiveX controls, fscommand sends a VB event with two strings that can be handled in the environment's programming language. For more information, use the keywords Flash method to search the Flash Support Center.

Usage 2: To use the fscommand action to send a message to a scripting language such as JavaScript in a Web browser, you can pass any two parameters in the command and parameters parameters. These parameters can be strings or expressions and are used in a JavaScript function that "catches," or handles, the fscommand action.


Use the following table to determine the integer that should be used for the corresponding property in your scripting environment.






You will create a button like that draw any shape then select it then choose from menu

Insert->Convert to symbol and this window will appear then choose button or movie clip



Then try to give it a name if you choose movie clip.

The difference that button always send action that is pressed .

Movie clip is more general and properties above applied to it.

Then to make an action macromedia introduce ActiveX that communicate with movie clip.

Through the properties above recived by flash and the fscommand received by the host (programming language)

Then try to add action to the command that you have created like that

Right click on the button or movie clip as shown in the photo

Choose Action then choose like in the photo










After that export your movie clip to *.swf format

Then open visual basic (for example)

Choose from menu

Project -> component then choose











After that from properties of the the component specify the movie to the location of you *.swf













And your movie will appear try to double click your flash component and in the event

Choose fscommand and write the following code



Run your project and press the command in the movie



Software Tutorial: -


When you first lunch the software this window will appear.






It is a Presentation window you can access others window from the graphic  Or you can choose from menu


ADNISSION ->login/logout

And above window will appear to choose your name and password

Only Employee that have privilege can access our system


After that you will be informed that your access is successful

And you will enter to the system and you can explore it






You can choose from menu security and control->access authorization And this window will appear if you have a privilege (Activity like Administrator) by which you can add new employee

and give him

His ability or you can remove or modify privilege or data of the employee  




You can choose from menu Data and Information ->Orders of Stations

station And this window will appear if you have a privilege then you can store

Orders in given date and time to be start and the direction so if you are trusted user you will be allowed to add orders without option check conflict

By mean the system trust you and you will store orders without restrict










You can choose from menu Data and information->Today Orders

And this window will appear if you have a privilege

Our system is clock base systems that mean all share on database so all will detect what should do today so if there is orders that will

Transport today it will be display in this table as you see

So when the time and date of this order detect it our program will

Direct this order to be complete




You can choose from menu Data and information->Reports

And this window will appear if you have a privilege

Then you can choose some data to be printed as a report

As shown in the next picture



And from this window you can either print this report directly  to the printer or you can export this to word document or excel  and then  you Can print  them from these applications





As you add employee so each employee belong to you and all employee

Belong in final to the parent (ADMINISTRATOR)

So here will display employee belong to the current user





This window handle all communication between the three station so It consider the second important window after the main window

It adjust time of other station synchronize them and do much than

You think.





This window is simple chat between users in other stations



This  window is initialization window you can adjust the tanks and what  In main pipes








    In the final you will set and relax to see and monitor the Automation and what it can introduce to you.

    if something happen, our system will inform you on the screen if you are at the station or he will send you a message on your mobile if you are out So trust us;