public void addRowTable(Dictionary <string, double> pricePerYard, Dictionary <int, double> rslArea, AnalysisRowPanel currentRow) { double totalRowCost = 0.0; double totalRowArea = 0.0; foreach (int i in rslArea.Keys) { if (rslArea[i] > 0) { rowStyle = RowStyles[0]; Height += (int)(rowStyle.Height - 70); RowStyles.Add(new RowStyle(rowStyle.SizeType, rowStyle.Height)); Controls.Add(new TextBox() { Text = i.ToString(), ReadOnly = true }, 0, RowCount++); NumericUpDown budgetUpDown = new NumericUpDown() { Increment = 100, Minimum = 0, Maximum = (decimal)(pricePerYard[currentRow.getTreatment()] * (rslArea[i] / 9)), Value = (decimal)(pricePerYard[currentRow.getTreatment()] * (rslArea[i] / 9)), }; NumericUpDown areaUpDown = new NumericUpDown() { Increment = 100, Minimum = 0, Maximum = (decimal)(rslArea[i] / 9), Value = (decimal)(rslArea[i] / 9) }; NumericUpDown percentCoveredUpDown = new NumericUpDown() { Increment = 5, Minimum = 0, Maximum = 100, Value = 100 }; double costPerYard = (double)(budgetUpDown.Value / areaUpDown.Value); budgetUpDown.ValueChanged += new EventHandler(delegate(object sender, EventArgs e) { BudgetUpDown_ValueChanged(sender, e, costPerYard, budgetUpDown, areaUpDown, percentCoveredUpDown); }); areaUpDown.ValueChanged += new EventHandler(delegate(object sender, EventArgs e) { AreaUpDown_ValueChanged(sender, e, costPerYard, budgetUpDown, areaUpDown, percentCoveredUpDown); }); percentCoveredUpDown.ValueChanged += new EventHandler(delegate(object sender, EventArgs e) { PercentCoveredUpDown_ValueChanged(sender, e, costPerYard, budgetUpDown, areaUpDown, percentCoveredUpDown); }); costBreakdown[budgetUpDown] = budgetUpDown.Value; areaBreakdown[areaUpDown] = areaUpDown.Value; Controls.Add(budgetUpDown, 1, RowCount - 1); Controls.Add(areaUpDown, 2, RowCount - 1); Controls.Add(percentCoveredUpDown, 3, RowCount - 1); totalRowCost += (double)budgetUpDown.Value; totalRowArea += (double)areaUpDown.Value; } } formAnalysis.textBoxRowCost.Text = "$" + String.Format("{0:n0}", totalRowCost);; formAnalysis.textBoxRowArea.Text = String.Format("{0:n0}", (Math.Round(totalRowArea, 2))) + " yds\u00b2";; formAnalysis.textBoxRowPercent.Text = "100.00"; currentRow.tableCreated = true; }
public void updateRowTable(Dictionary <string, double> pricePerYard, Dictionary <int, double> rslArea, AnalysisRowPanel currentRow) { for (int i = 5; i < Controls.Count; i++) { Controls.RemoveAt(i); } foreach (int i in rslArea.Keys) { if (rslArea[i] > 0) { rowStyle = RowStyles[0]; Height += (int)(rowStyle.Height - 60); RowStyles.Add(new RowStyle(rowStyle.SizeType, rowStyle.Height)); Controls.Add(new TextBox() { Text = i.ToString(), ReadOnly = true }, 0, RowCount++); NumericUpDown budgetUpDown = new NumericUpDown() { Increment = 100, Minimum = 0, Maximum = (decimal)(pricePerYard[currentRow.getTreatment()] * (rslArea[i] / 9)), Value = (decimal)(pricePerYard[currentRow.getTreatment()] * (rslArea[i] / 9)), }; NumericUpDown areaUpDown = new NumericUpDown() { Increment = 100, Minimum = 0, Maximum = (decimal)(rslArea[i] / 9), Value = (decimal)(rslArea[i] / 9) }; NumericUpDown percentCoveredUpDown = new NumericUpDown() { Increment = 5, Minimum = 0, Maximum = 100, Value = 100 }; double costPerYard = (double)(budgetUpDown.Value / areaUpDown.Value); budgetUpDown.ValueChanged += new EventHandler(delegate(object sender, EventArgs e) { BudgetUpDown_ValueChanged(sender, e, costPerYard, budgetUpDown, areaUpDown, percentCoveredUpDown); }); areaUpDown.ValueChanged += new EventHandler(delegate(object sender, EventArgs e) { AreaUpDown_ValueChanged(sender, e, costPerYard, budgetUpDown, areaUpDown, percentCoveredUpDown); }); percentCoveredUpDown.ValueChanged += new EventHandler(delegate(object sender, EventArgs e) { PercentCoveredUpDown_ValueChanged(sender, e, costPerYard, budgetUpDown, areaUpDown, percentCoveredUpDown); }); costBreakdown[budgetUpDown] = budgetUpDown.Value; areaBreakdown[areaUpDown] = areaUpDown.Value; Controls.Add(budgetUpDown, 1, RowCount - 1); Controls.Add(areaUpDown, 2, RowCount - 1); Controls.Add(percentCoveredUpDown, 3, RowCount - 1); } } currentRow.tableValid = true; }