/// <summary> /// /// </summary> /// <param name="InvestorGroupID"></param> /// <returns></returns> internal Business.InvestorGroup GetInvestorGroupByInvestorGroupID(int InvestorGroupID) { Business.InvestorGroup Result = new Business.InvestorGroup(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.InvestorGroupTableAdapter adap = new DSTableAdapters.InvestorGroupTableAdapter(); DS.InvestorGroupDataTable tbInvestorGroup=new DS.InvestorGroupDataTable(); try { conn.Open(); adap.Connection = conn; tbInvestorGroup = adap.GetInvestorGroupIDByInvestorGroupID(InvestorGroupID); if (tbInvestorGroup != null) { Result.DefautDeposite = tbInvestorGroup[0].DefautDeposite; Result.InvestorGroupID = tbInvestorGroup[0].InvestorGroupID; Result.Name = tbInvestorGroup[0].Name; Result.Owner = tbInvestorGroup[0].Owner; Result.ParameterItems = DBWInvestorGroup.DBWInvestorGroupConfigInstance.GetInvestorGroupConfigByInvestorGroupID(tbInvestorGroup[0].InvestorGroupID); } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <returns></returns> internal List<Business.InvestorGroup> GetAllInvestorGroup() { List<Business.InvestorGroup> Result = new List<Business.InvestorGroup>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.InvestorGroupTableAdapter adap = new DSTableAdapters.InvestorGroupTableAdapter(); DSTableAdapters.InvestorGroupConfigTableAdapter adapInvestorGroupConfig = new DSTableAdapters.InvestorGroupConfigTableAdapter(); DS.InvestorGroupDataTable tbInvestorGroup = new DS.InvestorGroupDataTable(); DS.InvestorGroupConfigDataTable tbInvestorGroupConfig = new DS.InvestorGroupConfigDataTable(); try { conn.Open(); adap.Connection = conn; adapInvestorGroupConfig.Connection = conn; tbInvestorGroup = adap.GetData(); if (tbInvestorGroup != null) { int count = tbInvestorGroup.Count; for (int i = 0; i < count; i++) { Business.InvestorGroup newInvestorGroup = new Business.InvestorGroup(); newInvestorGroup.DefautDeposite = tbInvestorGroup[i].DefautDeposite; newInvestorGroup.InvestorGroupID = tbInvestorGroup[i].InvestorGroupID; newInvestorGroup.Name = tbInvestorGroup[i].Name; newInvestorGroup.Owner = tbInvestorGroup[i].Owner; //newInvestorGroup.ParameterItems = DBWInvestorGroup.DBWInvestorGroupConfigInstance.GetInvestorGroupConfigByInvestorGroupID(tbInvestorGroup[i].InvestorGroupID); tbInvestorGroupConfig = adapInvestorGroupConfig.GetInvestorGroupConfigByInvestorGroupID(tbInvestorGroup[i].InvestorGroupID); if (tbInvestorGroupConfig != null) { int countInvestorGroupConfig = tbInvestorGroupConfig.Count; for (int j = 0; j < countInvestorGroupConfig; j++) { Business.ParameterItem newParameterItem = new Business.ParameterItem(); newParameterItem.BoolValue = tbInvestorGroupConfig[j].BoolValue; newParameterItem.Code = tbInvestorGroupConfig[j].Code; newParameterItem.DateValue = tbInvestorGroupConfig[j].DateValue; newParameterItem.NumValue = tbInvestorGroupConfig[j].NumValue; newParameterItem.ParameterItemID = tbInvestorGroupConfig[j].InvestorGroupConfigID; newParameterItem.SecondParameterID = tbInvestorGroupConfig[j].InvestorGroupID; newParameterItem.Name = tbInvestorGroupConfig[j].Name; newParameterItem.StringValue = tbInvestorGroupConfig[j].StringValue; if (tbInvestorGroupConfig[j].Code == "G01") { bool isEnable = false; if (tbInvestorGroupConfig[j].BoolValue == 1) isEnable = true; newInvestorGroup.IsEnable = isEnable; } if (tbInvestorGroupConfig[j].Code == "G26") { newInvestorGroup.FreeMargin = tbInvestorGroupConfig[j].StringValue; } if (tbInvestorGroupConfig[j].Code == "G19") { double MarginCallLevel = 0; double.TryParse(tbInvestorGroupConfig[j].NumValue, out MarginCallLevel); newInvestorGroup.MarginCall = MarginCallLevel; } if (tbInvestorGroupConfig[j].Code == "G20") { double MarginStopOutLevel = 0; double.TryParse(tbInvestorGroupConfig[j].NumValue, out MarginStopOutLevel); newInvestorGroup.MarginStopOut = MarginStopOutLevel; } if (tbInvestorGroupConfig[j].Code == "G38") { if (tbInvestorGroupConfig[j].BoolValue == 1) newInvestorGroup.IsManualStopOut = true; } if (newInvestorGroup.ParameterItems == null) newInvestorGroup.ParameterItems = new List<Business.ParameterItem>(); newInvestorGroup.ParameterItems.Add(newParameterItem); } } //if (newInvestorGroup.ParameterItems != null) //{ // int countParameter = newInvestorGroup.ParameterItems.Count; // for (int j = 0; j < countParameter; j++) // { // if (newInvestorGroup.ParameterItems[j].Code == "G26") // { // newInvestorGroup.FreeMargin = newInvestorGroup.ParameterItems[j].StringValue; // } // if (newInvestorGroup.ParameterItems[j].Code == "G19") // { // double MarginCallLevel=0; // double.TryParse(newInvestorGroup.ParameterItems[j].NumValue, out MarginCallLevel); // newInvestorGroup.MarginCall = MarginCallLevel; // } // if (newInvestorGroup.ParameterItems[j].Code == "G20") // { // double MarginStopOutLevel = 0; // double.TryParse(newInvestorGroup.ParameterItems[j].NumValue, out MarginStopOutLevel); // newInvestorGroup.MarginStopOut = MarginStopOutLevel; // } // } //} Result.Add(newInvestorGroup); } } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); adapInvestorGroupConfig.Connection.Close(); conn.Close(); } return Result; }