protected void bttnSubmitFilter_Click(object sender, EventArgs e) { if (Session["currentTransaction"] != null) { currentTransaction = (TranSaction)Session["currentTransaction"]; if (lblTransactionDescription.Text.IndexOf(txtFilter.Text) != -1) { //look at our updated MyFilterXML to see if there an existing filter if (!CategoryMe(currentTransaction)) { MyFilterXML.Add(new KeyValuePair <string, string>(RadioButtonList1.SelectedItem.Text, txtFilter.Text.Trim())); Session["XMLFilter"] = MyFilterXML; currentTransaction.myCategory = RadioButtonList1.SelectedValue.ToString(); currentTransaction.myFilter = txtFilter.Text.Trim(); if (modifiedTransactions != null) { modifiedTransactions.Add(currentTransaction); } else { modifiedTransactions = new TranSactionS(); modifiedTransactions.Add(currentTransaction); } myTransactions.Remove(currentTransaction); if (myTransactions.Count > 0) { Session["modifiedTransactions"] = modifiedTransactions; Server.Transfer("CategorizeMe.aspx"); } } } else { lblFilterError.Text = "Please choose your filter words part of the description."; } } else { lblFilterError.Text = "Something has horrible gone wrong."; } }
private bool DrawMyBarChart(TranSactionS TransactionS) { bool bReturn = false; if (TransactionS != null) { TranSactionS deposit = new TranSactionS(); TranSactionS withraw = new TranSactionS(); Legend leg = new Legend(); Chart3.Legends.Add(leg); Chart3.Series.Add("Spending"); Chart3.Series.Add("Deposit"); //Chart3.Series["Spending"].PostBackValue = "#INDEX"; //Chart3.Series["Spending"].LegendPostBackValue = "#INDEX"; //Chart3.Series["Deposit"].PostBackValue = "#INDEX"; //Chart3.Series["Deposit"].LegendPostBackValue = "#INDEX"; withraw.AddRange(TransactionS); foreach (TranSaction s in withraw.ToList()) { if (s.myCategory == "Bank") { deposit.Add(s); withraw.Remove(s); } } barGraphLookUp = (Lookup <string, decimal>)withraw.ToLookup(p => p.myDate.ToString("y"), p => p.Amt); foreach (IGrouping <string, decimal> TransactionsGroup in barGraphLookUp) { decimal amount = 0.00m; foreach (decimal s in TransactionsGroup) { amount += Math.Abs(s); } Chart3.Series["Spending"].Points.AddXY(TransactionsGroup.Key, amount); } barGraphLookUp = (Lookup <string, decimal>)deposit.ToLookup(p => p.myDate.ToString("y"), p => p.Amt); foreach (IGrouping <string, decimal> TransactionsGroup in barGraphLookUp) { decimal amount = 0.00m; foreach (decimal s in TransactionsGroup) { amount += Math.Abs(s); } Chart3.Series["Deposit"].Points.AddXY(TransactionsGroup.Key, amount); } // Set series visual attributes Chart3.Series["Spending"].ChartType = SeriesChartType.Column; Chart3.Series["Spending"].ShadowOffset = 2; Chart3.Series["Spending"].Color = Color.Red; Chart3.Series["Deposit"].ChartType = SeriesChartType.Column; Chart3.Series["Deposit"].ShadowOffset = 2; Chart3.Series["Deposit"].Color = Color.Green; Chart3.ChartAreas[0].AxisY.Title = "Value in $$"; Chart3.Titles[0].Text = "Overall Spendings"; bReturn = true; } return(bReturn); }