COM Components in PMS

Snoops

   

 
Migrating to .NET: A Pragmatic Path to Visual Basic .NET, Visual C++ .NET, and ASP.NET
By Dhananjay  Katre, Prashant  Halari, Narayana  Rao  Surapaneni, Manu  Gupta, Meghana  Deshpande

Table of Contents
Chapter 14.   Visual C++ .NET Migration Case Study


COM Components in PMS

The following COM components have been developed in Visual C++ 6.0:

  • VCLoginCom

  • VCStockServiceCom

  • VCOrdersCom

  • VCAdminCom

  • VCReportsCom

These components comprise the Data Access Layer of PMS and are designed with the classical COM approach. A brief description of each of these components is in the following subsections, which also cover development aspects of PMS in Visual Basic 6.0. These components have been developed in both Visual Basic and Visual C++ to illustrate migration concepts.

VCLoginCom

The customer uses the VCLoginCom component. This COM component is used by the CustomerServices ISAPI DLL. It provides three methods :

  • Login()

  • Logout ()

  • ChangePassword()

This COM component provide the class CLogin . It is used for the login and logout functionality for the customer. It also allows customers to change their password after logging into the system. The code for this is kept in the VCLoginCOM directory for this chapter. Let us have a closer look at these functions.

LOGIN: LOGIN(BSTR BSTRUSERID, BSTR BSTRPASSWD, VARIANT *VMESSAGE, INT *IRETVAL)

As you can see the Login function has four parameters of which two are input parameters and two are output parameters. UserID and Password are the two input parameters, and the function returns the RetVal (Status) and a related Message as the output parameters. This function checks whether the customer logging into the system is a valid customer or not by means of the UserID and password that the customer enters. When a new customer is added into the system, the system will generate the password for the customer, which will be the same as the UserID. The customer can change the password when first logging into the system. The stored procedure called in this method is sp_Validate_Login .

LOGOUT: LOGOUT(BSTR BSTRUSERID, VARIANT *VMESSAGE, INT *IRETVAL)

This function takes one input parameter UserID and returns two output parameters, which are the RetVal (Status) and the related Message. This function will log out the customer from the system. The stored procedure called by this method is sp_Logout .

CHANGEPASSWORD: CHANGEPASSWORD(BSTR BSTRUSERID, BSTR BSTROLDPASSWD, BSTR BSTRNEWPASSWD, VARIANT *VMESSAGE, INT *IRETVAL)

This function takes in the UserID, the OldPassword, and the NewPassword as the input parameters and returns the Status and related Message as the output parameters. This function changes the password of the customer only if the UserID and the OldPassword entered by the customer are correct. This method calls the stored procedure sp_Change_Password .

VCStockServiceCom

The VCStockServiceCom component is used by the CustomerServices ISAPI DLL to display the current stocks. When the TraderWorkStation application is loaded and the customer logs in, all the stocks present in the database along with their details and current prices are displayed to the customer.

The code for this is kept in the VCStockService directory for this chapter. This COM component has a class called CStockService , which in turn defines the following function for obtaining the latest prices of the stock.

GETSTOCKPRICES: GETSTOCKPRICE(VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVAL)

This function gives an output of all the stocks in the database along with their details, a Status, and the related Message. Figure 14-4 shows a screen of stock names , current price, date/time, low price, high price, opening price, closing price, and last traded quantity. The stored procedure used in this method is sp_Get_Current_Stock_Prices .

VCOrderCom

The VCOrderCom component deals with customer transactions. This component is used by the CustomerServices ISAPI DLL. It is used to place the buy and sell transactions for the various stocks. It contains the class COrder . The code for this is kept in the VCOrderCOM directory for this chapter. The class COrder uses the following function.

EXECUTEORDER: EXECUTEORDER(BSTR BSTRCUSTID, BSTR BSTRSTOCKID, FLOAT FSTOCKPRICE, INT IQUANTITY, BSTR BSTRBUYSELL, VARIANT *VMESSAGE, INT *IRETVALUE)

This function has five parameters. The input parameters are the UserID, stockID, current price, quantity, and the type of transaction (buy or sell). The output parameters are the Status and the related Message . This is shown in Figure 14-5. The Transaction section of Stock Service screen allows customers to place an order. This method calls the stored procedure sp_Order .

VCAdminCom

The AdminWorkstation module uses this COM component. It is used by the administrator ISAPI DLL in the module. The code for this is kept in the VCAdminCom directory for this chapter. This component provides all the methods needed by the administrator.

The Administrator Monitoring System will be available only to an administrator. The class associated with it is the CAdmin class. The COM component is used to log in the administrator, change the administrator password, add new users, update existing user information, and get the list of pending transactions to be approved or rejected. The functions used in this class are as follows .

LOGIN: LOGIN(BSTR BSTRUSERID, BSTR BSTRPASSWD, VARIANT *VMESSAGE, INT *IRETVAL)

This function is used to verify the user as the administrator by means of the UserID and password. This is very similar to the Login function of the VCLoginCom component. The stored procedure called in this method is sp_Validate_AdminLogin .

CHANGE PASSWORD: CHANGEPASSWORD(BSTR BSTRUSERID, BSTR BSTROLDPASSWD, BSTR BSTRNEWPASSWD, VARIANT *VMESSAGE, INT *IRETVAL)

This function is used to authenticate the administrator and then change the password of the administrator. It is very similar to the ChangePassword function of the VCLoginCom component. The stored procedure called is sp_Change_AdminPassword .

ADDCUSTOMER: ADDCUSTOMER(BSTR BSTRUSERID, BSTR BSTRPASSWD, BSTR BSTRNAME, BSTR BSTRADDRESS, DOUBLE DBLPHONE, BSTR BSTREMAIL, FLOAT FMARGIN, FLOAT FMINAMOUNT, VARIANT *VMESSAGE, INT *IRETVAL)

This function is called by the Add New User dialog to add the details of a new customer in the database. This function takes ten parameters. UserID, password, customer name , customer address, phone number, email ID, working margin for the customer, and the customer's minimum balance. All these are the input parameters. The Status code (return value) and the related Message are the output parameters. The stored procedure called in this method is sp_Customer .

This screen will have fields such as Customer ID, Customer Name, and Customer Address. Through this screen the administrator will be able to add and update Customer information.

UPDATECUSTOMER: UPDATECUSTOMER(BSTR BSTRUSERID, BSTR BSTROLDPASSWD, BSTR BSTRNEWPASSWD, BSTR BSTRNAME, BSTR BSTRADDRESS, DOUBLE DBLPHONE, BSTR BSTREMAIL, FLOAT FMARGIN, FLOAT FMINAMOUNT, VARIANT *VMESSAGE, INT *IRETVAL)

This function is used to update the details of existing users. The parameters are same as in the AddCustomer function except that we have two passwords in this method; one is the old password and the other is the new password. The stored procedure called by this method is sp_Update_Customer .

GETUNAPPROVEDORDERS: GETUNAPPROVEDORDERS(BSTR BSTRCUSTID, BSTR BSTRBUYSELL, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)

This function gets the list of pending orders for a particular customer and takes five parameters. The first two input parameters specify the UserID and the activity type (buy or sell). The vRecords parameter is populated by the list of unapproved orders. The next two parameters, giving the Status code and the related Message, are the output parameters. The stored procedure used in this method is sp_Get_Unapproved_Orders .

APPROVEORDER: APPROVEORDER(INT IORDERID, VARIANT *VMESSAGE, INT *IRETVALUE)

This function is used to approve the orders in the specified pending order list. Once the order is approved, it is moved from the pending orders list to the approved list. This method takes OrderID as the input parameter, which is generated when a user requests a transaction. The stored procedure called in this method is sp_Approve_Order .

CANCELORDER: CANCELORDER(INT IORDERID, VARIANT *VMESSAGE, INT *IRETVALUE)

This function is used to reject an order from the pending order list. The rejected order is moved from the pending order list to the rejected order list. This method takes OrderID as the input parameter, which is generated when a user requests a transaction. The stored procedure called by this method is sp_Cancel_Order .

GETCUSTOMERS: GETCUSTOMERS(VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)

This function is used to obtain a list of all the customers registered in the database. The stored procedure called by this method is sp_Get_Customer_ Name .

GETCUSTOMERDETAILS: GETCUSTOMERDETAILS(BSTR BSTRCUSTID, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)

This function is used to obtain a list of all the customers registered in the database along with their details. The stored procedure called by this method is sp_View_Customer_Details .

REPORTAPPROVEDORDERS: REPORTAPPROVEDORDERS(BSTR BSTRCUSTID, BSTR BSTRBUYSELL, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)

This function is used to obtain a list of all the orders, with details, that have been approved by the administrator for a particular customer. The first two input parameters give the UserID and the transaction type (buy or sell). The vRecords parameter is populated by the list of approved orders. The next two output parameters give the Status code and the related Message. The stored procedure called by this method is sp_Get_Approved_Orders .

REPORTCANCELLEDORDERS: REPORTCANCELLEDORDERS(BSTR BSTRCUSTID, BSTR BSTRBUYSELL, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)

This function is used to obtain a list of all the orders that have been rejected by the administrator so far for a particular customer. The first two input parameters give the UserID and the transaction type (buy or sell). The next two are the output parameters and give the Status code and the related Message. The stored procedure called by this method is sp_Get_Cancelled_Orders .

VCReportsCOM

The TraderWorkStation module creates various kinds of reports using VCReportsCOM. The code for this is kept in the VCReportsCom directory for this chapter. The class associated with this component is CPortFolio . The various methods exposed in this class are as follows.

GETPORTFOLIOINFO: GETPORTFOLIOINFO(BSTR BSTRCUSTID, VARIANT *VCUSTPORTFOLIO, VARIANT *VMESSAGE, INT *IRETVAL)

This method is used to get a customer's portfolio. The first parameter is an input parameter, which specifies the UserID. The output parameter vCustPortFolio is populated with the list of transactions. The next two are the output parameters and give the Status code and the related Message. The stored procedure called by this method is sp_Customer_Portfolio .

GETCUSTOMERDETAILS: GETCUSTOMERDETAILS(BSTR BSTRCUSTID, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVAL)

This method gives the customer details for the specified customer. It is similar to the GetCustomerDetails of the AdminCom.dll except that the administrator can get the details of any customer, and this method gives the details of the customer who is logged in. The stored procedure called in this method is sp_View_Customer_Details .

GETSTOCKPERFORMANCE:GETSTOCKPERFORMANCE(BSTR BSTRSTOCKID, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)

This method gives the weekly performance of the specified stock. The stored procedure called by this method is sp_Get_Prices_For_Week . This method is used to generate the Stock Performance report.

GETSTOCKS: GETSTOCKS(VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVAL)

This method gives stock name and corresponding stockID for all the stocks registered in the database. The stored procedure called in this method is sp_Get_All_Stocks .

GETUNAPPROVEDORDERS: GETUNAPPROVEDORDERS(BSTR BSTRCUSTID, BSTR BSTRBUYSELL, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)

This function is used to get the list of the unapproved orders for the customer who is logged into the system. This function takes five parameters. First two are input parameters specifying the UserID and activity type (buy or sell). The next two parameters are output parameters, which give the Status code and the related Message. The stored procedure used in this method is sp_Get_Unapproved_Orders .

REPORTAPPROVEDORDERS: REPORTAPPROVEDORDERS(BSTR BSTRCUSTID, BSTR BSTRBUYSELL, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)

This function is used to obtain a list, with all the details, of the orders that have been approved by the administrator so far for the customer who is logged in to the system. The first two input parameters give the UserID and the transaction type (buy or sell). The output parameter vRecords is populated with the list of approved orders. The next two output parameters give the Status code and the related Message. The stored procedure called by this method is sp_Get_Approved_Orders .

REPORTCANCELLEDORDERS: REPORTCANCELLEDORDERS(BSTR BSTRCUSTID, BSTR BSTRBUYSELL, VARIANT *VRECORDS, VARIANT *VMESSAGE, INT *IRETVALUE)

This function is used to obtain a detailed listof the orders that have been cancelled by the administrator for the customer who has logged into the system. The first two input parameters give the UserID and the transaction type (buy or sell). The output parameter vRecords is populated with the list of cancelled orders. The next two output parameters give the Status code and the related Message. The stored procedure called by this method is sp_Get_Cancelled_Orders .


Snoops

   
Top


Migrating to. NET. A Pragmatic Path to Visual Basic. NET, Visual C++. NET, and ASP. NET
Migrating to. NET. A Pragmatic Path to Visual Basic. NET, Visual C++. NET, and ASP. NET
ISBN: 131009621
EAN: N/A
Year: 2001
Pages: 149

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net