protected void Page_Load(object sender, EventArgs e) { lblStart.Text = DateTime.Now.ToString(); if (!IsPostBack) { FillExpiryDates(ddlExpiryDates); FilterConditions filterConditions = new FilterConditions(); //filterConditions.SPLowerRange = MySession.Current.RecordsObject.strikePrices.Min(); //filterConditions.SPHigherRange = MySession.Current.RecordsObject.strikePrices.Max(); //filterConditions.SPExpiry = Convert.ToInt32(ddlSPExpiry.SelectedValue); filterConditions.ContractType = ddlContractType.SelectedValue; filterConditions.OcType = rblOCType.SelectedValue; filterConditions.StrategyType = enumStrategyType.BUTTERFLY.ToString(); filterConditions.TimeGap = timeAddGap; filterConditions.ExpiryDate = ddlExpiryDates.SelectedValue; filterConditions.PercentageRange = iPercentageRage; filterConditions.SPDifference = 100; DataSet dataSetResult = Butterfly.GetButterflySpreadStrategies(filterConditions); PopulateDataSet(dataSetResult); PopulateFilterFields(filterConditions); Page.LoadComplete += new EventHandler(Page_LoadComplete); } }
protected void btnFilterResults_Click(object sender, EventArgs e) { FilterConditions filterConditions = new FilterConditions(); filterConditions.SPLowerRange = Convert.ToInt32(ddlSPLowerRange.SelectedValue); filterConditions.SPHigherRange = Convert.ToInt32(ddlSPHigherRange.SelectedValue); if (ddlSPExpiry.SelectedValue.Equals("NONE")) { filterConditions.SPExpiry = 0; } else { filterConditions.SPExpiry = Convert.ToInt32(ddlSPExpiry.SelectedValue); } filterConditions.ContractType = ddlContractType.SelectedValue; filterConditions.OcType = rblOCType.SelectedValue; filterConditions.StrategyType = enumStrategyType.BUTTERFLY.ToString(); filterConditions.TimeGap = timeAddGap; filterConditions.ExpiryDate = ddlExpiryDates.SelectedValue; filterConditions.PercentageRange = 0; filterConditions.SPDifference = 100; DataSet dataSetResult = Butterfly.GetButterflySpreadStrategies(filterConditions); PopulateDataSet(dataSetResult); PopulateFilterFields(filterConditions); //DataSet filteredDataSet = new DataSet(); //foreach (DataTable dataTable in dataSetResult.Tables) //{ // //List<string> sp = dataTable.AsEnumerable().Select(x => x["Strike Price"].ToString()).ToList(); // //Find Lowest and Highest value in the given table column // int iLowestSP = int.MaxValue; // int iHighestSP = int.MinValue; // int iMiddleSP = 0; // foreach (DataRow dr in dataTable.Rows) // { // int currentSP = Convert.ToInt32(dr.Field<string>("StrikePrice")); // iLowestSP = Math.Min(iLowestSP, currentSP); // iMiddleSP = Math.Max(iLowestSP, currentSP); // iMiddleSP = Math.Min(iHighestSP, currentSP); // iHighestSP = Math.Max(iHighestSP, currentSP); // } // if (filterConditions.SPLowerRange == iLowestSP && // filterConditions.SPHigherRange == iHighestSP && // filterConditions.SPExpiry == iMiddleSP) // { // filteredDataSet.Tables.Add(dataTable.Copy()); // } //} ////dataSetResult = Butterfly.GetButterflySpreadStrategies(filterConditions); //PopulateDataSet(filteredDataSet); }