/// <summary> /// /// </summary> /// <param name="SecurityID">int SecurityID</param> /// <param name="CollectionValue">int CollectionValue</param> /// <param name="Name">string Name</param> /// <param name="Code">string Code</param> /// <param name="NumValue">string NumValue</param> /// <param name="StringValue">string StringValue</param> /// <param name="DateValue">DateTime DateValue</param> /// <param name="BoolValue">int BoolValue</param> /// <returns></returns> internal int AddSecurityConfig(int SecurityID, int CollectionValue, string Name, string Code, string NumValue, string StringValue, DateTime DateValue,int BoolValue) { int Result = -1; System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.SecurityConfigTableAdapter adap = new DSTableAdapters.SecurityConfigTableAdapter(); try { conn.Open(); adap.Connection = conn; if (CollectionValue <= 0) { Result = int.Parse(adap.AddSecurityConfig(SecurityID, null, Name, Code, NumValue, StringValue, DateValue, BoolValue).ToString()); }else Result = int.Parse(adap.AddSecurityConfig(SecurityID, CollectionValue, Name, Code, NumValue, StringValue, DateValue, BoolValue).ToString()); } catch (Exception ex) { return -1; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="SecurityConfigID"></param> internal bool DeleteSecurityConfigBySecurityConfigID(int SecurityConfigID) { bool Result = true; System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.SecurityConfigTableAdapter adap = new DSTableAdapters.SecurityConfigTableAdapter(); try { conn.Open(); adap.Connection = conn; adap.DeleteSecurityConfigBySecurityConfigID(SecurityConfigID); } catch (Exception ex) { Result = false; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <returns></returns> internal List<Business.Security> GetAllSecurity() { List<Business.Security> Result = new List<Business.Security>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.SecurityTableAdapter adap = new DSTableAdapters.SecurityTableAdapter(); DSTableAdapters.SecurityConfigTableAdapter adapSecurityConfig = new DSTableAdapters.SecurityConfigTableAdapter(); DSTableAdapters.SymbolTableAdapter adapSymbol = new DSTableAdapters.SymbolTableAdapter(); DSTableAdapters.TradingConfigTableAdapter adapTradingConfig = new DSTableAdapters.TradingConfigTableAdapter(); DS.SymbolDataTable tbSymbol = new DS.SymbolDataTable(); DS.TradingConfigDataTable tbTradingConfig = new DS.TradingConfigDataTable(); DS.SecurityDataTable tbSecurity = new DS.SecurityDataTable(); DS.SecurityConfigDataTable tbSecurityConfig = new DS.SecurityConfigDataTable(); try { conn.Open(); adap.Connection = conn; adapSecurityConfig.Connection = conn; adapSymbol.Connection = conn; adapTradingConfig.Connection = conn; tbSecurity = adap.GetData(); if (tbSecurity != null) { int count = tbSecurity.Count; for (int i = 0; i < count; i++) { Business.Security newSecurity = new Business.Security(); newSecurity.ParameterItems = new List<Business.ParameterItem>(); newSecurity.SymbolGroup = new List<Business.Symbol>(); newSecurity.SecurityID = tbSecurity[i].SecurityID; newSecurity.Name = tbSecurity[i].Name; newSecurity.Description = tbSecurity[i].Description; newSecurity.MarketAreaID = tbSecurity[i].MarketAreaID; #region GET SECURITY CONFIG BY SECURITY ID //GET SECURITY CONFIG BY SECURITY ID tbSecurityConfig = adapSecurityConfig.GetSecurityConfigBySecurityID(newSecurity.SecurityID); if (tbSecurityConfig != null) { int countSecurityConfig = tbSecurityConfig.Count; for (int j = 0; j < countSecurityConfig; j++) { Business.ParameterItem newParameterItem = new Business.ParameterItem(); newParameterItem.ParameterItemID = tbSecurityConfig[j].SecurityConfigID; newParameterItem.SecondParameterID = tbSecurityConfig[j].SecurityID; newParameterItem.Name = tbSecurityConfig[j].Name; newParameterItem.Code = tbSecurityConfig[j].Code; newParameterItem.NumValue = tbSecurityConfig[j].NumValue; newParameterItem.StringValue = tbSecurityConfig[j].StringValue; newParameterItem.DateValue = tbSecurityConfig[j].DateValue; newParameterItem.BoolValue = tbSecurityConfig[j].BoolValue; Result[i].ParameterItems.Add(newParameterItem); } } #endregion #region GET SYMBOL BY SECURITY ID tbSymbol = adapSymbol.GetSymbolBySecurityID(newSecurity.SecurityID); if (tbSymbol != null) { int countSymbol = tbSymbol.Count; for (int j = 0; j < countSymbol; j++) { Business.Symbol newSymbol = new Business.Symbol(); newSymbol.ParameterItems = new List<Business.ParameterItem>(); if (Business.Market.MarketArea != null) { int countMarket = Business.Market.MarketArea.Count; for (int n = 0; n < countMarket; n++) { if (Business.Market.MarketArea[n].IMarketAreaID == tbSymbol[j].MarketAreaID) { newSymbol.MarketAreaRef = Business.Market.MarketArea[n]; break; } } } newSymbol.Name = tbSymbol[j].Name; newSymbol.SecurityID = tbSymbol[j].SecurityID; newSymbol.SymbolID = tbSymbol[j].SymbolID; tbTradingConfig = adapTradingConfig.GetTradingConfigBySymbolID(tbSymbol[j].SymbolID); if (tbTradingConfig != null) { int countTradingConfig = tbTradingConfig.Count; for (int n = 0; n < countTradingConfig; n++) { Business.ParameterItem newParameter = new Business.ParameterItem(); newParameter.BoolValue = tbTradingConfig[n].BoolValue; newParameter.Code = tbTradingConfig[n].Code; newParameter.DateValue = tbTradingConfig[n].DateValue; newParameter.NumValue = tbTradingConfig[n].NumValue; newParameter.ParameterItemID = tbTradingConfig[n].TradingConfigID; newParameter.SecondParameterID = tbTradingConfig[n].SymbolID; newSymbol.ParameterItems.Add(newParameter); } } newSecurity.SymbolGroup.Add(newSymbol); } } #endregion Result.Add(newSecurity); } } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); adapSecurityConfig.Connection.Close(); adapSymbol.Connection.Close(); adapTradingConfig.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="SecurityConfigID">int SecurityConfigID</param> /// <param name="SecurityID">int SecurityID</param> /// <param name="CollectionValue">int CollectionValue</param> /// <param name="Name">string Name</param> /// <param name="Code">string Code</param> /// <param name="NumValue">string NumValue</param> /// <param name="StringValue">string StringValue</param> /// <param name="DateValue">DateTime DateValue</param> /// <param name="BoolValue">int BoolValue</param> internal bool UpdateSecurityConfig(int SecurityConfigID, int SecurityID, int CollectionValue, string Name, string Code, string NumValue, string StringValue, DateTime DateValue, int BoolValue) { bool Result = true; System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.SecurityConfigTableAdapter adap = new DSTableAdapters.SecurityConfigTableAdapter(); try { conn.Open(); adap.Connection = conn; if (CollectionValue <= 0) adap.UpdateSecurityConfig(SecurityID, null, Name, Code, NumValue, StringValue, DateValue, BoolValue, SecurityConfigID); else adap.UpdateSecurityConfig(SecurityID, CollectionValue, Name, Code, NumValue, StringValue, DateValue, BoolValue, SecurityConfigID); } catch (Exception ex) { return false; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="SecurityID"></param> /// <returns></returns> internal List<Business.ParameterItem> GetSecurityConfigBySecurityID(int SecurityID) { List<Business.ParameterItem> Result = new List<Business.ParameterItem>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.SecurityConfigTableAdapter adap = new DSTableAdapters.SecurityConfigTableAdapter(); DS.SecurityConfigDataTable tbSecurityConfig = new DS.SecurityConfigDataTable(); try { conn.Open(); adap.Connection = conn; tbSecurityConfig = adap.GetSecurityConfigBySecurityID(SecurityID); if (tbSecurityConfig != null) { int count = tbSecurityConfig.Count; for (int i = 0; i < count; i++) { Business.ParameterItem newParameterItem = new Business.ParameterItem(); newParameterItem.ParameterItemID = tbSecurityConfig[i].SecurityConfigID; newParameterItem.SecondParameterID = tbSecurityConfig[i].SecurityID; newParameterItem.Name = tbSecurityConfig[i].Name; newParameterItem.Code = tbSecurityConfig[i].Code; newParameterItem.NumValue = tbSecurityConfig[i].NumValue; newParameterItem.StringValue = tbSecurityConfig[i].StringValue; newParameterItem.DateValue = tbSecurityConfig[i].DateValue; newParameterItem.BoolValue = tbSecurityConfig[i].BoolValue; //newParameterItem.CollectionValue = this.GetSecurityConfigByCollectionValue(tbSecurityConfig[i].SecurityConfigID, adap); Result.Add(newParameterItem); } } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="SecurityConfigID"></param> /// <returns></returns> internal Business.ParameterItem GetSecurityConfigBySecurityConfigID(int SecurityConfigID) { Business.ParameterItem result = new Business.ParameterItem(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.SecurityConfigTableAdapter adap = new DSTableAdapters.SecurityConfigTableAdapter(); DS.SecurityConfigDataTable tbSecurityConfig = new DS.SecurityConfigDataTable(); try { conn.Open(); adap.Connection = conn; tbSecurityConfig = adap.GetSecurityConfigBySecurityConfigID(SecurityConfigID); if (tbSecurityConfig != null) { result.ParameterItemID = tbSecurityConfig[0].SecurityConfigID; result.SecondParameterID = tbSecurityConfig[0].SecurityID; result.Name = tbSecurityConfig[0].Name; result.Code = tbSecurityConfig[0].Code; result.NumValue = tbSecurityConfig[0].NumValue; result.StringValue = tbSecurityConfig[0].StringValue; result.DateValue = tbSecurityConfig[0].DateValue; result.BoolValue = tbSecurityConfig[0].BoolValue; result.CollectionValue = this.GetSecurityConfigByCollectionValue(tbSecurityConfig[0].SecurityConfigID, adap); } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); conn.Close(); } return result; }
/// <summary> /// delete Security config by security id /// </summary> /// <param name="securityID">security id</param> /// <param name="connection">sql connection</param> /// <returns></returns> internal bool DFDeleteBySecurityID(int securityID, SqlConnection connection,SqlTransaction trans) { DSTableAdapters.SecurityConfigTableAdapter adap = new DSTableAdapters.SecurityConfigTableAdapter(); adap.Connection = connection; adap.Transaction = trans; int affectRow= adap.DeleteSecurityConfigBySecurityID(securityID); if (affectRow == 0) { return false; } else { return true; } }