/// <summary> /// /// </summary> /// <param name="RowNumber"></param> /// <returns></returns> internal List<Business.Investor> GetInvestorByStartEnd(int RowNumber,int Limit) { List<Business.Investor> Result = new List<Business.Investor>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.InvestorTableAdapter adap = new DSTableAdapters.InvestorTableAdapter(); DSTableAdapters.InvestorProfileTableAdapter adapInvestorProfile = new DSTableAdapters.InvestorProfileTableAdapter(); DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable(); DS.InvestorProfileDataTable tbInvestorProfile = new DS.InvestorProfileDataTable(); try { conn.Open(); adap.Connection = conn; adapInvestorProfile.Connection = conn; tbInvestor = adap.GetInvestorByStartEnd(RowNumber, Limit); if (tbInvestor != null) { int count = tbInvestor.Count; for (int i = 0; i < count; i++) { tbInvestorProfile = adapInvestorProfile.GetInvestorProfileByInvestorID(tbInvestor[i].InvestorID); Business.Investor newInvestor = new Business.Investor(); newInvestor.InvestorID = tbInvestor[i].InvestorID; newInvestor.AgentID = tbInvestor[i].AgentID; //Fill Investor Group Instance if (Business.Market.InvestorGroupList != null) { int countInvestorGroup = Business.Market.InvestorGroupList.Count; for (int j = 0; j < countInvestorGroup; j++) { if (Business.Market.InvestorGroupList[j].InvestorGroupID == tbInvestor[i].InvestorGroupID) { newInvestor.InvestorGroupInstance = Business.Market.InvestorGroupList[j]; break; } } } //newInvestor.InvestorGroupInstance = TradingServer.Facade.FacadeGetInvestorGroupByInvestorGroupID(tbInvestor[i].InvestorGroupID); newInvestor.InvestorStatusID = tbInvestor[i].InvestorStatusID; newInvestor.Balance = tbInvestor[i].Balance; newInvestor.Code = tbInvestor[i].Code; newInvestor.Credit = tbInvestor[i].Credit; newInvestor.IsDisable = tbInvestor[i].IsDisible; newInvestor.TaxRate = tbInvestor[i].TaxRate; newInvestor.Leverage = tbInvestor[i].Leverage; newInvestor.PreviousLedgerBalance = tbInvestor[i].PreviousLedgerBalance; newInvestor.UserConfig = tbInvestor[i].UserConfig; newInvestor.RefInvestorID = tbInvestor[i].RefInvestorID; //Add Data InvestorProfile To Result if (tbInvestorProfile != null && tbInvestorProfile.Count > 0) { newInvestor.InvestorProfileID = tbInvestorProfile[0].InvestorProfileID; newInvestor.Address = tbInvestorProfile[0].Address; newInvestor.City = tbInvestorProfile[0].City; newInvestor.InvestorComment = tbInvestorProfile[0].Comment; newInvestor.Country = tbInvestorProfile[0].Country; newInvestor.Email = tbInvestorProfile[0].Email; newInvestor.NickName = tbInvestorProfile[0].NickName; newInvestor.Phone = tbInvestorProfile[0].Phone; newInvestor.RegisterDay = tbInvestorProfile[0].RegisterDay; newInvestor.State = tbInvestorProfile[0].State; newInvestor.ZipCode = tbInvestorProfile[0].ZipCode; newInvestor.IDPassport = tbInvestorProfile[0].IDPassport; } Result.Add(newInvestor); } } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); adapInvestorProfile.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="InvestorID"></param> /// <returns></returns> internal string GetInvestorCodeByInvestorID(int InvestorID) { string Result = string.Empty; System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.InvestorTableAdapter adap = new DSTableAdapters.InvestorTableAdapter(); DS.InvestorDataTable tbInvestorData = new DS.InvestorDataTable(); try { conn.Open(); adap.Connection = conn; tbInvestorData = adap.GetInvestorNameByInvestorID(InvestorID); if (tbInvestorData != null) { Result = tbInvestorData[0].Code; } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="Code"></param> /// <returns></returns> internal bool GetCodeInvestor(string Code) { bool Result = false; System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.InvestorTableAdapter adap = new DSTableAdapters.InvestorTableAdapter(); DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable(); try { conn.Open(); adap.Connection = conn; tbInvestor = adap.GetCodeInvestor(Code); if (tbInvestor.Count > 0) { Result = false; } else { Result = true; } } catch (Exception ex) { return false; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// Get Investor By Investor ID /// </summary> /// <param name="InvestorID">int InvestorID</param> /// <returns>Business.Investor</returns> internal Business.Investor GetInvestorByInvestorID(int InvestorID) { Business.Investor Result = new Business.Investor(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.InvestorTableAdapter adap = new DSTableAdapters.InvestorTableAdapter(); DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable(); DSTableAdapters.InvestorProfileTableAdapter adapInvestorProfile = new DSTableAdapters.InvestorProfileTableAdapter(); DS.InvestorProfileDataTable tbInvestorProfile = new DS.InvestorProfileDataTable(); try { conn.Open(); adap.Connection = conn; adapInvestorProfile.Connection = conn; tbInvestor = adap.GetInvestorByInvestorID(InvestorID); if (tbInvestor != null) { tbInvestorProfile = adapInvestorProfile.GetInvestorProfileByInvestorID(tbInvestor[0].InvestorID); if (tbInvestorProfile != null) { //Add Data Investor To Result Result.InvestorID = tbInvestor[0].InvestorID; Result.AgentID = tbInvestor[0].AgentID; //Result.InvestorGroupInstance = TradingServer.Facade.FacadeGetInvestorGroupByInvestorGroupID(tbInvestor[0].InvestorGroupID); if (Business.Market.InvestorGroupList != null) { int countInvestorGroup = Business.Market.InvestorGroupList.Count; for (int j = 0; j < countInvestorGroup; j++) { if (Business.Market.InvestorGroupList[j].InvestorGroupID == tbInvestor[0].InvestorGroupID) { Result.InvestorGroupInstance = Business.Market.InvestorGroupList[j]; break; } } } Result.InvestorStatusID = tbInvestor[0].InvestorStatusID; Result.Balance = tbInvestor[0].Balance; Result.Code = tbInvestor[0].Code; Result.Credit = tbInvestor[0].Credit; Result.IsDisable = tbInvestor[0].IsDisible; Result.TaxRate = tbInvestor[0].TaxRate; Result.Leverage = tbInvestor[0].Leverage; Result.PreviousLedgerBalance = tbInvestor[0].PreviousLedgerBalance; Result.UserConfig = tbInvestor[0].UserConfig; Result.RefInvestorID = tbInvestor[0].RefInvestorID; //Add Data InvestorProfile To Result Result.Address = tbInvestorProfile[0].Address; Result.City = tbInvestorProfile[0].City; Result.InvestorComment = tbInvestorProfile[0].Comment; Result.Country = tbInvestorProfile[0].Country; Result.Email = tbInvestorProfile[0].Email; Result.NickName = tbInvestorProfile[0].NickName; Result.Phone = tbInvestorProfile[0].Phone; Result.RegisterDay = tbInvestorProfile[0].RegisterDay; Result.State = tbInvestorProfile[0].State; Result.ZipCode = tbInvestorProfile[0].ZipCode; Result.IDPassport = tbInvestorProfile[0].IDPassport; } } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="Code"></param> /// <returns></returns> internal Business.Investor SelectInvestorByCode(string Code) { Business.Investor newInvestor = new Business.Investor(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.InvestorTableAdapter adap = new DSTableAdapters.InvestorTableAdapter(); DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable(); DSTableAdapters.InvestorProfileTableAdapter adapProfile = new DSTableAdapters.InvestorProfileTableAdapter(); DS.InvestorProfileDataTable tbInvestorProfile = new DS.InvestorProfileDataTable(); try { conn.Open(); adap.Connection = conn; adapProfile.Connection = conn; tbInvestor = adap.SelectInvestorByCode(Code); if (tbInvestor != null) { tbInvestorProfile = adapProfile.GetInvestorProfileByInvestorID(tbInvestor[0].InvestorID); if (tbInvestorProfile != null && tbInvestorProfile.Count > 0) { newInvestor.InvestorProfileID = tbInvestorProfile[0].InvestorProfileID; newInvestor.Address = tbInvestorProfile[0].Address; newInvestor.Phone = tbInvestorProfile[0].Phone; newInvestor.City = tbInvestorProfile[0].City; newInvestor.Country = tbInvestorProfile[0].Country; newInvestor.Email = tbInvestorProfile[0].Email; newInvestor.ZipCode = tbInvestorProfile[0].ZipCode; newInvestor.RegisterDay = tbInvestorProfile[0].RegisterDay; newInvestor.InvestorComment = tbInvestorProfile[0].Comment; newInvestor.State = tbInvestorProfile[0].State; newInvestor.NickName = tbInvestorProfile[0].NickName; newInvestor.IDPassport = tbInvestorProfile[0].IDPassport; } else { newInvestor.InvestorProfileID = -1; newInvestor.Address = "NaN"; newInvestor.Phone = "NaN"; newInvestor.City = "NaN"; newInvestor.Country = "NaN"; newInvestor.Email = "NaN"; newInvestor.ZipCode = "NaN"; newInvestor.RegisterDay = DateTime.Now; newInvestor.InvestorComment = "NaN"; newInvestor.State = "NaN"; newInvestor.NickName = "NaN"; newInvestor.IDPassport = ""; } newInvestor.InvestorID = tbInvestor[0].InvestorID; newInvestor.InvestorStatusID = tbInvestor[0].InvestorStatusID; //newInvestor.InvestorGroupInstance = TradingServer.Facade.FacadeGetInvestorGroupByInvestorGroupID(tbInvestor[0].InvestorGroupID); if (Business.Market.InvestorGroupList != null) { int countInvestorGroup = Business.Market.InvestorGroupList.Count; for (int j = 0; j < countInvestorGroup; j++) { if (Business.Market.InvestorGroupList[j].InvestorGroupID == tbInvestor[0].InvestorGroupID) { newInvestor.InvestorGroupInstance = Business.Market.InvestorGroupList[j]; break; } } } newInvestor.AgentID = tbInvestor[0].AgentID; newInvestor.Balance = tbInvestor[0].Balance; newInvestor.Credit = tbInvestor[0].Credit; newInvestor.Code = tbInvestor[0].Code; newInvestor.IsDisable = tbInvestor[0].IsDisible; newInvestor.TaxRate = tbInvestor[0].TaxRate; newInvestor.Leverage = tbInvestor[0].Leverage; newInvestor.AllowChangePwd = tbInvestor[0].AllowChangePwd; newInvestor.ReadOnly = tbInvestor[0].ReadOnly; newInvestor.SendReport = tbInvestor[0].SendReport; newInvestor.PreviousLedgerBalance = tbInvestor[0].PreviousLedgerBalance; newInvestor.PhonePwd = tbInvestor[0].PhonePwd; } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); adapProfile.Connection.Close(); conn.Close(); } return newInvestor; }
/// <summary> /// /// </summary> /// <param name="listInvestorID"></param> /// <returns></returns> internal Dictionary<int, string> GetCodeByListInvestor(List<int> listInvestorID) { Dictionary<int, string> result = new Dictionary<int, string>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable(); System.Data.SqlClient.SqlDataAdapter adap = new System.Data.SqlClient.SqlDataAdapter(); try { conn.Open(); string listInvestor = string.Empty; if (listInvestorID != null) { int count = listInvestorID.Count; for (int i = 0; i < count; i++) { if (i == count - 1) { listInvestor += listInvestorID[i]; } else { listInvestor += listInvestorID[i] + ","; } } } string sql = "SELECT InvestorID,Code FROM Investor WHERE (InvestorID IN(" + listInvestor + "))"; adap.SelectCommand = new System.Data.SqlClient.SqlCommand(sql, conn); adap.Fill(tbInvestor); if (tbInvestor != null) { int count = tbInvestor.Count; for (int i = 0; i < count; i++) { result.Add(tbInvestor[i].InvestorID, tbInvestor[i].Code); } } } catch (Exception ex) { return null; } finally { conn.Close(); } return result; }
/// <summary> /// /// </summary> /// <param name="Code"></param> /// <param name="Password"></param> /// <returns></returns> internal Business.Investor LoginAgent(string Code, string Password) { Business.Investor Result = new Business.Investor(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.InvestorTableAdapter adapInvestor = new DSTableAdapters.InvestorTableAdapter(); DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable(); try { conn.Open(); adapInvestor.Connection = conn; //string hash = Model.ValidateCheck.GetEncodedString(Password); //string hash = Model.ValidateCheck.Encrypt(Password); tbInvestor = adapInvestor.LoginSystem(Code, Password); if (tbInvestor != null) { //Add Data From Table Investor To Result Result.InvestorID = tbInvestor[0].InvestorID; //Result.AgentID = tbInvestor[0].AgentID; //Result.Balance = tbInvestor[0].Balance; //Result.Code = tbInvestor[0].Code; //Result.Credit = tbInvestor[0].Credit; //if (Business.Market.InvestorGroupList != null) //{ // int count = Business.Market.InvestorGroupList.Count; // for (int i = 0; i < count; i++) // { // if (Business.Market.InvestorGroupList[i].InvestorGroupID == tbInvestor[0].InvestorGroupID) // { // Result.InvestorGroupInstance = Business.Market.InvestorGroupList[i]; // break; // } // } //} //Result.InvestorStatusID = tbInvestor[0].InvestorStatusID; //Result.IsDisable = tbInvestor[0].IsDisible; //Result.Leverage = tbInvestor[0].Leverage; } } catch (Exception ex) { return null; } finally { adapInvestor.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="code"></param> /// <param name="readPwd"></param> /// <returns></returns> internal Business.Investor LoginWithReadPwd(string code, string readPwd) { Business.Investor result = new Business.Investor(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.InvestorTableAdapter adap = new DSTableAdapters.InvestorTableAdapter(); DSTableAdapters.InvestorProfileTableAdapter adapInvestorProfile = new DSTableAdapters.InvestorProfileTableAdapter(); DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable(); DS.InvestorProfileDataTable tbInvestorProfile = new DS.InvestorProfileDataTable(); try { conn.Open(); adap.Connection = conn; adapInvestorProfile.Connection = conn; tbInvestor = adap.LoginWithReadPwd(code, readPwd); //string hash = Model.ValidateCheck.GetEncodedString(Password); if (tbInvestor != null && tbInvestor.Count > 0) { //Add Data From Table Investor To Result result.InvestorID = tbInvestor[0].InvestorID; result.AgentID = tbInvestor[0].AgentID; result.Balance = tbInvestor[0].Balance; result.Code = tbInvestor[0].Code; result.Credit = tbInvestor[0].Credit; //Result.IsOnline = true; result.IsDisable = tbInvestor[0].IsDisible; result.ReadOnly = tbInvestor[0].ReadOnly; result.IsReadOnly = true; if (Business.Market.InvestorGroupList != null) { int count = Business.Market.InvestorGroupList.Count; for (int i = 0; i < count; i++) { if (Business.Market.InvestorGroupList[i].InvestorGroupID == tbInvestor[0].InvestorGroupID) { result.InvestorGroupInstance = Business.Market.InvestorGroupList[i]; break; } } } result.InvestorStatusID = tbInvestor[0].InvestorStatusID; result.IsDisable = tbInvestor[0].IsDisible; result.Leverage = tbInvestor[0].Leverage; result.PreviousLedgerBalance = tbInvestor[0].PreviousLedgerBalance; tbInvestorProfile = adapInvestorProfile.GetInvestorProfileByInvestorID(tbInvestor[0].InvestorID); if (tbInvestorProfile != null && tbInvestorProfile.Count > 0) { //Add Data From Table InvestorProfile To Result result.Address = tbInvestorProfile[0].Address; result.City = tbInvestorProfile[0].City; result.InvestorComment = tbInvestorProfile[0].Comment; result.Country = tbInvestorProfile[0].Country; result.Email = tbInvestorProfile[0].Email; result.NickName = tbInvestorProfile[0].NickName; result.Phone = tbInvestorProfile[0].Phone; result.RegisterDay = tbInvestorProfile[0].RegisterDay; result.State = tbInvestorProfile[0].State; result.ZipCode = tbInvestorProfile[0].ZipCode; result.InvestorProfileID = tbInvestorProfile[0].InvestorProfileID; result.IDPassport = tbInvestorProfile[0].IDPassport; } } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); conn.Close(); } return result; }
/// <summary> /// /// </summary> /// <param name="investorID"></param> /// <param name="password"></param> /// <returns></returns> internal Business.Investor CheckMasterPassword(int investorID, string password) { Business.Investor result = new Business.Investor(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.InvestorTableAdapter adap = new DSTableAdapters.InvestorTableAdapter(); DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable(); try { conn.Open(); adap.Connection = conn; tbInvestor = adap.VerifyMasterPassword(investorID, password); //string hash = Model.ValidateCheck.GetEncodedString(Password); if (tbInvestor != null && tbInvestor.Count > 0) { //Add Data From Table Investor To Result result.InvestorID = tbInvestor[0].InvestorID; result.AgentID = tbInvestor[0].AgentID; result.Balance = tbInvestor[0].Balance; result.Code = tbInvestor[0].Code; result.Credit = tbInvestor[0].Credit; //Result.IsOnline = true; result.IsDisable = tbInvestor[0].IsDisible; result.ReadOnly = true; if (Business.Market.InvestorGroupList != null) { int count = Business.Market.InvestorGroupList.Count; for (int i = 0; i < count; i++) { if (Business.Market.InvestorGroupList[i].InvestorGroupID == tbInvestor[0].InvestorGroupID) { result.InvestorGroupInstance = Business.Market.InvestorGroupList[i]; break; } } } result.InvestorStatusID = tbInvestor[0].InvestorStatusID; result.IsDisable = tbInvestor[0].IsDisible; result.Leverage = tbInvestor[0].Leverage; result.PreviousLedgerBalance = tbInvestor[0].PreviousLedgerBalance; } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); conn.Close(); } return result; }
/// <summary> /// /// </summary> /// <param name="investorID"></param> /// <returns></returns> internal double GetPreviousLedgerBalance(int investorID) { double result = -1; System.Data.SqlClient.SqlConnection conn = new SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.InvestorTableAdapter adap = new DSTableAdapters.InvestorTableAdapter(); DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable(); try { if (conn.State == System.Data.ConnectionState.Closed) conn.Open(); adap.Connection = conn; tbInvestor = adap.GetPreviousLedgerBalanceByInvestorID(investorID); if (tbInvestor != null) { result = tbInvestor[0].PreviousLedgerBalance; } } catch (Exception ex) { return -1; } finally { adap.Connection.Close(); } return result; }
/// <summary> /// /// </summary> /// <param name="Code"></param> /// <returns></returns> internal int GetInvestorIDByCode(string Code) { int Result = -1; System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.InvestorTableAdapter adap = new DSTableAdapters.InvestorTableAdapter(); DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable(); try { conn.Open(); adap.Connection = conn; tbInvestor = adap.GetInvestorIDByCode(Code.Trim()); if (tbInvestor != null) Result = tbInvestor[0].InvestorID; } catch (Exception ex) { return -1; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="InvestorID"></param> /// <param name="Start"></param> /// <param name="Limit"></param> /// <returns></returns> internal List<Business.OrderData> GetOrderByInvestorID(int InvestorID, int Start, int Limit) { List<Business.OrderData> Result = new List<Business.OrderData>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.InvestorTableAdapter adapInvestor = new DSTableAdapters.InvestorTableAdapter(); DSTableAdapters.OnlineCommandTableAdapter adapOpenTrade = new DSTableAdapters.OnlineCommandTableAdapter(); DSTableAdapters.CommandHistoryTableAdapter adapHistory = new DSTableAdapters.CommandHistoryTableAdapter(); DSTableAdapters.InvestorAccountLogTableAdapter adapAccountLog = new DSTableAdapters.InvestorAccountLogTableAdapter(); DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable(); DS.OnlineCommandDataTable tbOnlineCommand = new DS.OnlineCommandDataTable(); DS.CommandHistoryDataTable tbCommandHistory = new DS.CommandHistoryDataTable(); DS.InvestorAccountLogDataTable tbInvestorAccountLog = new DS.InvestorAccountLogDataTable(); try { conn.Open(); adapInvestor.Connection = conn; adapOpenTrade.Connection = conn; adapHistory.Connection = conn; adapAccountLog.Connection = conn; tbOnlineCommand = adapOpenTrade.GetOpenTradeByInvestorID(Start, InvestorID, Limit); tbCommandHistory = adapHistory.GetHistoryByInvestorID(Start, InvestorID, Limit); tbInvestorAccountLog = adapAccountLog.GetInvestorLogByInvestorID(Start, InvestorID, Limit); if (tbOnlineCommand != null) { int count = tbOnlineCommand.Count; for (int i = 0; i < count; i++) { Business.OrderData newOrderData = new Business.OrderData(); newOrderData.OrderCode = "OPT001"; newOrderData.Code = tbOnlineCommand[i].CommandCode; newOrderData.ID = tbOnlineCommand[i].OnlineCommandID; tbInvestor = adapInvestor.GetInvestorNameByInvestorID(tbOnlineCommand[i].InvestorID); if (tbInvestor != null) newOrderData.Login = tbInvestor[0].Code; newOrderData.InvestorID = tbOnlineCommand[i].InvestorID; newOrderData.AgentCommission = 0; newOrderData.ClosePrice = tbOnlineCommand[i].ClosePrice; newOrderData.CloseTime = tbOnlineCommand[i].CloseTime; //newOrderData.Comment = tbOnlineCommand[i] newOrderData.Commission = tbOnlineCommand[i].Commission; newOrderData.ExpDate = tbOnlineCommand[i].ExpTime; newOrderData.Lots = tbOnlineCommand[i].Size; //newOrderData.MarginRate = //newOrderData.OneConvRate newOrderData.OpenPrice = tbOnlineCommand[i].OpenPrice; newOrderData.OpenTime = tbOnlineCommand[i].OpenTime; newOrderData.Profit = tbOnlineCommand[i].Profit; newOrderData.StopLoss = tbOnlineCommand[i].StopLoss; newOrderData.Swaps = tbOnlineCommand[i].Swap; newOrderData.Symbol = TradingServer.Facade.FacadeGetSymbolNameBySymbolID(tbOnlineCommand[i].SymbolID); newOrderData.TakeProfit = tbOnlineCommand[i].TakeProfit; newOrderData.Taxes = tbOnlineCommand[i].Taxes; //newOrderData.TwoConvRate newOrderData.Type = TradingServer.Facade.FacadeGetTypeNameByTypeID(tbOnlineCommand[i].CommandTypeID); //newOrderData.ValueDate Result.Add(newOrderData); } } if (tbCommandHistory != null) { int count = tbCommandHistory.Count; for (int i = 0; i < count; i++) { Business.OrderData newOrderData = new Business.OrderData(); newOrderData.OrderCode = "CMH01"; newOrderData.Code = tbCommandHistory[i].CommandCode; newOrderData.ID = tbCommandHistory[i].CommandHistoryID; tbInvestor = adapInvestor.GetInvestorNameByInvestorID(tbCommandHistory[i].InvestorID); if (tbInvestor != null) newOrderData.Login = tbInvestor[0].Code; newOrderData.InvestorID = tbCommandHistory[i].InvestorID; newOrderData.AgentCommission = 0; newOrderData.ClosePrice = tbCommandHistory[i].ClosePrice; newOrderData.CloseTime = tbCommandHistory[i].CloseTime; //newOrderData.Code = tbOnlineCommand[i].inves //newOrderData.Comment = tbOnlineCommand[i] newOrderData.Commission = tbCommandHistory[i].Commission; newOrderData.ExpDate = tbCommandHistory[i].ExpTime; newOrderData.Lots = tbCommandHistory[i].Size; //newOrderData.MarginRate = //newOrderData.OneConvRate newOrderData.OpenPrice = tbCommandHistory[i].OpenPrice; newOrderData.OpenTime = tbCommandHistory[i].OpenTime; newOrderData.Profit = tbCommandHistory[i].Profit; newOrderData.StopLoss = tbCommandHistory[i].StopLoss; newOrderData.Swaps = tbCommandHistory[i].Swap; newOrderData.Symbol = TradingServer.Facade.FacadeGetSymbolNameBySymbolID(tbCommandHistory[i].SymbolID); newOrderData.TakeProfit = tbCommandHistory[i].TakeProfit; newOrderData.Taxes = tbCommandHistory[i].Taxes; //newOrderData.TwoConvRate switch (tbCommandHistory[i].CommandTypeID) { case 13: { newOrderData.Type = "ADP01"; } break; case 14: { newOrderData.Type = "WRD01"; } break; case 15: { newOrderData.Type = "ACD01"; } break; case 16: { newOrderData.Type = "CRD01"; } break; default: { newOrderData.Type = TradingServer.Facade.FacadeGetTypeNameByTypeID(tbCommandHistory[i].CommandTypeID); } break; } //newOrderData.Type = TradingServer.Facade.FacadeGetTypeNameByTypeID(tbCommandHistory[i].CommandTypeID); //newOrderData.ValueDate Result.Add(newOrderData); } } if (tbInvestorAccountLog != null) { int count = tbInvestorAccountLog.Count; for (int i = 0; i < count; i++) { Business.OrderData newOrderData = new Business.OrderData(); newOrderData.OrderCode = "IAL01"; newOrderData.Code = tbInvestorAccountLog[i].DealID; newOrderData.ID = tbInvestorAccountLog[i].ID; tbInvestor = adapInvestor.GetInvestorNameByInvestorID(tbInvestorAccountLog[i].InvestorID); if (tbInvestor != null) newOrderData.Login = tbInvestor[0].Code; newOrderData.InvestorID = tbInvestorAccountLog[i].InvestorID; //newOrderData.AgentCommission = 0; //newOrderData.ClosePrice = tbCommandHistory[i].ClosePrice; //newOrderData.CloseTime = tbCommandHistory[i].CloseTime; //newOrderData.Code = tbOnlineCommand[i].inves //newOrderData.Comment = tbOnlineCommand[i] //newOrderData.Commission = tbCommandHistory[i].Commission; //newOrderData.ExpDate = tbCommandHistory[i].ExpTime; //newOrderData.Lots = tbCommandHistory[i].Size; //newOrderData.MarginRate = //newOrderData.OneConvRate //newOrderData.OpenPrice = tbCommandHistory[i].OpenPrice; newOrderData.OpenTime = tbInvestorAccountLog[i].Date; //newOrderData.Profit = tbCommandHistory[i].Profit; //newOrderData.StopLoss = tbCommandHistory[i].StopLoss; //newOrderData.Swaps = tbCommandHistory[i].Swap; //newOrderData.Symbol = TradingServer.Facade.FacadeGetSymbolNameBySymbolID(tbCommandHistory[i].SymbolID); //newOrderData.TakeProfit = tbCommandHistory[i].TakeProfit; //newOrderData.Taxes = tbCommandHistory[i].Taxes; //newOrderData.TwoConvRate newOrderData.Type = tbInvestorAccountLog[i].Code; newOrderData.Comment = tbInvestorAccountLog[i].Comment; newOrderData.Profit = tbInvestorAccountLog[i].Amount; //newOrderData.ValueDate Result.Add(newOrderData); } } } catch (Exception ex) { return null; } finally { adapInvestor.Connection.Close(); adapOpenTrade.Connection.Close(); adapHistory.Connection.Close(); adapAccountLog.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="Code"></param> /// <returns></returns> internal Business.OrderData GetOrderByCode(string Code) { Business.OrderData Result = new Business.OrderData(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.OnlineCommandTableAdapter adapOnlineCommand = new DSTableAdapters.OnlineCommandTableAdapter(); DSTableAdapters.CommandHistoryTableAdapter adapCommandHistory = new DSTableAdapters.CommandHistoryTableAdapter(); DSTableAdapters.InvestorAccountLogTableAdapter adapAccountLog = new DSTableAdapters.InvestorAccountLogTableAdapter(); DSTableAdapters.InvestorTableAdapter adapInvestor = new DSTableAdapters.InvestorTableAdapter(); DS.OnlineCommandDataTable tbOnlineCommand = new DS.OnlineCommandDataTable(); DS.CommandHistoryDataTable tbCommandHistory = new DS.CommandHistoryDataTable(); DS.InvestorAccountLogDataTable tbAccountLog = new DS.InvestorAccountLogDataTable(); DS.InvestorDataTable tbInvestor = new DS.InvestorDataTable(); try { bool flag = false; conn.Open(); adapAccountLog.Connection = conn; adapCommandHistory.Connection = conn; adapOnlineCommand.Connection = conn; adapInvestor.Connection = conn; tbOnlineCommand = adapOnlineCommand.GetOnlineCommandByCommandCode(Code); if (tbOnlineCommand != null && tbOnlineCommand.Count > 0) { Result.OrderCode = "OPT001"; Result.Code = tbOnlineCommand[0].CommandCode; tbInvestor = adapInvestor.GetInvestorNameByInvestorID(tbOnlineCommand[0].InvestorID); if (tbInvestor != null) Result.Login = tbInvestor[0].Code; Result.InvestorID = tbOnlineCommand[0].InvestorID; Result.AgentCommission = 0; Result.ClosePrice = tbOnlineCommand[0].ClosePrice; Result.CloseTime = tbOnlineCommand[0].CloseTime; //newOrderData.Comment = tbOnlineCommand[i] Result.Commission = tbOnlineCommand[0].Commission; Result.ExpDate = tbOnlineCommand[0].ExpTime; Result.Lots = tbOnlineCommand[0].Size; //newOrderData.MarginRate = //newOrderData.OneConvRate Result.OpenPrice = tbOnlineCommand[0].OpenPrice; Result.OpenTime = tbOnlineCommand[0].OpenTime; Result.Profit = tbOnlineCommand[0].Profit; Result.StopLoss = tbOnlineCommand[0].StopLoss; Result.Swaps = tbOnlineCommand[0].Swap; Result.Symbol = TradingServer.Facade.FacadeGetSymbolNameBySymbolID(tbOnlineCommand[0].SymbolID); Result.TakeProfit = tbOnlineCommand[0].TakeProfit; Result.Taxes = tbOnlineCommand[0].Taxes; //newOrderData.TwoConvRate Result.Type = TradingServer.Facade.FacadeGetTypeNameByTypeID(tbOnlineCommand[0].CommandTypeID); //newOrderData.ValueDate flag = true; } if (!flag) { tbCommandHistory = adapCommandHistory.GetCommandHistoryByCommandCode(Code); if (tbCommandHistory != null && tbCommandHistory.Count > 0) { Result.OrderCode = "CMH01"; Result.Code = tbCommandHistory[0].CommandCode; tbInvestor = adapInvestor.GetInvestorNameByInvestorID(tbCommandHistory[0].InvestorID); if (tbInvestor != null) Result.Login = tbInvestor[0].Code; Result.InvestorID = tbCommandHistory[0].InvestorID; Result.AgentCommission = 0; Result.ClosePrice = tbCommandHistory[0].ClosePrice; Result.CloseTime = tbCommandHistory[0].CloseTime; //newOrderData.Code = tbOnlineCommand[i].inves //newOrderData.Comment = tbOnlineCommand[i] Result.Commission = tbCommandHistory[0].Commission; Result.ExpDate = tbCommandHistory[0].ExpTime; Result.Lots = tbCommandHistory[0].Size; //newOrderData.MarginRate = //newOrderData.OneConvRate Result.OpenPrice = tbCommandHistory[0].OpenPrice; Result.OpenTime = tbCommandHistory[0].OpenTime; Result.Profit = tbCommandHistory[0].Profit; Result.StopLoss = tbCommandHistory[0].StopLoss; Result.Swaps = tbCommandHistory[0].Swap; Result.Symbol = TradingServer.Facade.FacadeGetSymbolNameBySymbolID(tbCommandHistory[0].SymbolID); Result.TakeProfit = tbCommandHistory[0].TakeProfit; Result.Taxes = tbCommandHistory[0].Taxes; //newOrderData.TwoConvRate Result.Type = TradingServer.Facade.FacadeGetTypeNameByTypeID(tbCommandHistory[0].CommandTypeID); //newOrderData.ValueDate flag = true; } } if (!flag) { tbAccountLog = adapAccountLog.GetInvestorAccountLogByCode(Code); if (tbAccountLog != null && tbAccountLog.Count > 0) { Result.OrderCode = "IAL01"; Result.Code = tbAccountLog[0].DealID; tbInvestor = adapInvestor.GetInvestorNameByInvestorID(tbAccountLog[0].InvestorID); if (tbInvestor != null) Result.Login = tbInvestor[0].Code; Result.InvestorID = tbAccountLog[0].InvestorID; //newOrderData.AgentCommission = 0; //newOrderData.ClosePrice = tbCommandHistory[i].ClosePrice; //newOrderData.CloseTime = tbCommandHistory[i].CloseTime; //newOrderData.Code = tbOnlineCommand[i].inves //newOrderData.Comment = tbOnlineCommand[i] //newOrderData.Commission = tbCommandHistory[i].Commission; //newOrderData.ExpDate = tbCommandHistory[i].ExpTime; //newOrderData.Lots = tbCommandHistory[i].Size; //newOrderData.MarginRate = //newOrderData.OneConvRate //newOrderData.OpenPrice = tbCommandHistory[i].OpenPrice; Result.OpenTime = tbAccountLog[0].Date; //newOrderData.Profit = tbCommandHistory[i].Profit; //newOrderData.StopLoss = tbCommandHistory[i].StopLoss; //newOrderData.Swaps = tbCommandHistory[i].Swap; //newOrderData.Symbol = TradingServer.Facade.FacadeGetSymbolNameBySymbolID(tbCommandHistory[i].SymbolID); //newOrderData.TakeProfit = tbCommandHistory[i].TakeProfit; //newOrderData.Taxes = tbCommandHistory[i].Taxes; //newOrderData.TwoConvRate Result.Type = tbAccountLog[0].Code; Result.Comment = tbAccountLog[0].Comment; Result.Profit = tbAccountLog[0].Amount; } } } catch (Exception ex) { return null; } finally { adapAccountLog.Connection.Close(); adapCommandHistory.Connection.Close(); adapInvestor.Connection.Close(); adapOnlineCommand.Connection.Close(); conn.Close(); } return Result; }