Пример #1
0
        public string getOneData(string toGetVar, string Table, string loginName)
        {
            string    accountNumber = "";
            DataTable temp          = myHKeInvestData.getData("SELECT accountNumber FROM Account WHERE userName = '******'");

            foreach (DataRow row in temp.Rows)
            {
                accountNumber = row["accountNumber"].ToString();
            }

            temp = myHKeInvestData.getData("SELECT " + toGetVar + " FROM " + Table +
                                           " WHERE accountNumber = '" + accountNumber + "'");

            foreach (DataRow row in temp.Rows)
            {
                return(row[toGetVar].ToString());
            }

            return(null);
        }
Пример #2
0
        public void updateTable()
        {
            Account = myHKeInvestData.getData("SELECT * FROM Account WHERE userName = '******'");
            foreach (DataRow row in Account.Rows)
            {
                accountNumber = row["accountNumber"].ToString();
                accountType   = row["accountType"].ToString();
                balance       = row["balance"].ToString();
            }

            Client = myHKeInvestData.getData("SELECT * FROM Client WHERE accountNumber = '" + accountNumber + "'");
            foreach (DataRow row in Client.Rows)
            {
                char[] delimiterChars = { ' ', '\t' };
                dateOfBirth = row["dateOfBirth"].ToString();
                string[] date = dateOfBirth.Split(delimiterChars);
                dateOfBirth            = date[0];
                firstName              = row["firstName"].ToString();
                lastName               = row["lastName"].ToString();
                email                  = row["email"].ToString();
                HKIDPassportNumber     = row["HKIDPassportNumber"].ToString();
                title                  = row["title"].ToString();
                building               = row["building"].ToString();
                street                 = row["street"].ToString();
                district               = row["district"].ToString();
                homePhone              = row["homePhone"].ToString();
                homeFax                = row["homePhone"].ToString();
                businessPhone          = row["businessPhone"].ToString();
                mobile                 = row["mobile"].ToString();
                citizenship            = row["citizenship"].ToString();
                legalResidence         = row["legalResidence"].ToString();
                passportCountryOfIssue = row["passportCountryOfIssue"].ToString();
            }
        }
Пример #3
0
 public string getUserAccountNumber(HttpSessionState session, string userName)
 {
     if (session["accountNumber"] == null)
     {
         HKeInvestData myHKeInvestData = new HKeInvestData();
         string        sql             = "SELECT accountNumber FROM dbo.Account WHERE userName='******'";
         DataTable     dtAccountNumber = myHKeInvestData.getData(sql);
         if (dtAccountNumber.Rows.Count == 1)
         {
             session["accountNumber"] = dtAccountNumber.Rows[0].Field <string>("accountNumber");
         }
         else
         {
             session["accountNumber"] = "";
         }
     }
     return((string)session["accountNumber"]);
 }
Пример #4
0
 public string getClientName(string accountNumber)
 {
     if (accountNumber == null || accountNumber.Equals(""))
     {
         return("");
     }
     else
     {
         HKeInvestData myHKeInvestData = new HKeInvestData();
         string        sql             = "SELECT lastName,firstName FROM dbo.[Client] WHERE accountNumber='" + accountNumber + "';";
         DataTable     dtName          = myHKeInvestData.getData(sql);
         if (dtName.Rows.Count == 1)
         {
             return(dtName.Rows[0].Field <string>("firstName").Trim() + " " + dtName.Rows[0].Field <string>("lastName").Trim());
         }
         else
         {
             return("");
         }
     }
 }
Пример #5
0
        //Calculate the fees for the order (will calculate for the set of transactions)
        public decimal calculateFees(string referenceNumber, string accountNumber)
        {
            decimal fee = -1m;
            //ONLY QUERYING LOCAL DATABASE
            //Query to get order type
            //Query to get order buyOrSell status
            string sql = "SELECT * FROM OrderHistory WHERE referenceNumber = '" +
                         referenceNumber + "'";
            DataTable orderH    = extData.getData(sql);
            string    type      = orderH.Rows[0]["securityType"].ToString().Trim();
            string    buyOrSell = orderH.Rows[0]["buyOrSell"].ToString().Trim();


            //Query to get completed transactions
            //TODO: throw error if query not connected to external database
            DataTable extTransaction = extFunction.getOrderTransaction(referenceNumber);

            decimal assets = accountAssets(accountNumber);

            if (type.Equals("stock"))
            {
                //Query to get the order type (from local history maybe)
                string orderType = orderH.Rows[0]["stockOrderType"].ToString().Trim();

                //variable for checking if the assessed fee is greater than the minimmum fee
                decimal minFeeCheck = 0m;

                if (assets < 1000000m)
                {
                    if (orderType.Equals("market"))
                    {
                        minFeeCheck = calculateFeesAtRate(extTransaction, .004m);
                    }
                    else if (orderType.Equals("stop") || orderType.Equals("limit"))
                    {
                        minFeeCheck = calculateFeesAtRate(extTransaction, .006m);
                    }
                    else
                    {
                        minFeeCheck = calculateFeesAtRate(extTransaction, .008m);
                    }

                    fee = minFeeCheck > 150m ? minFeeCheck : 150m;
                }
                else
                {
                    if (orderType.Equals("market"))
                    {
                        minFeeCheck = calculateFeesAtRate(extTransaction, .002m);
                    }
                    else if (orderType.Equals("stop") || orderType.Equals("limit"))
                    {
                        minFeeCheck = calculateFeesAtRate(extTransaction, .004m);
                    }
                    else
                    {
                        minFeeCheck = calculateFeesAtRate(extTransaction, .006m);
                    }
                    fee = minFeeCheck > 100m ? minFeeCheck : 100m;
                }
            }
            else
            {
                if (assets < 500000m)
                {
                    if (buyOrSell.Equals("buy"))
                    {
                        //Query execute shares and execute price from transactions
                        fee = calculateFeesAtRate(extTransaction, .05m);
                    }
                    else
                    {
                        fee = 100m;
                    }
                }
                else
                {
                    if (buyOrSell.Equals("buy"))
                    {
                        fee = calculateFeesAtRate(extTransaction, .03m);
                    }
                    else
                    {
                        fee = 50m;
                    }
                }
            }

            return(fee);
        }