private void SaveExcel_Click(object sender, RoutedEventArgs e) { try { ExtraMethods.ExportGridToExcel(this.ProgramsDataChart); } catch (Exception error) { MessageBox.Show(error.ToString()); } }
/* --------------------- Method For Adding Data Of The Programs To The Program Window --------------------- */ public static void DisplayProgramData(Dictionary <String, Box> boxes, StackPanel departmentsWrapper, ProgramsSubWindow subWindow) { // Index Of The Row For each new Program int rowIndex = 1; for (int i = 0; i < departmentsWrapper.Children.Count; i++) { Expander department = departmentsWrapper.Children[i] as Expander; Grid programs = LogicalTreeHelper.FindLogicalNode(departmentsWrapper, department.Name + "Programs") as Grid; // Add A New Row For The Headers RowDefinition gridRow = new RowDefinition(); subWindow.ProgramsDataChart.RowDefinitions.Add(gridRow); foreach (DockPanel element in programs.Children) { if (Grid.GetColumn(element) == 0) { // Add Row For Each Program gridRow = new RowDefinition(); gridRow.Height = new GridLength(1, GridUnitType.Star); subWindow.ProgramsDataChart.RowDefinitions.Add(gridRow); // The Label Of The Program From The Controller Window Label original = element.Children[0] as Label; // Name Of The ProgramBox string boxName = original.Name.Replace("Label", "ProgramBox"); // Generate And Display Label Of Each Program Label programLabel = new Label(); programLabel.Content = original.Content; programLabel.Height = 30; programLabel.FontSize = 14; programLabel.FontWeight = FontWeights.DemiBold; programLabel.Foreground = original.Foreground; programLabel.Background = original.Background; programLabel.HorizontalContentAlignment = HorizontalAlignment.Center; programLabel.VerticalContentAlignment = VerticalAlignment.Center; programLabel.HorizontalAlignment = HorizontalAlignment.Stretch; programLabel.VerticalAlignment = VerticalAlignment.Center; Grid.SetColumn(programLabel, 0); Grid.SetRow(programLabel, rowIndex); subWindow.ProgramsDataChart.Children.Add(programLabel); // Generate And Display Department Of Each Program Label programDepartment = new Label(); programDepartment.Content = boxes[boxName].departmentName; programDepartment.Height = 30; programDepartment.FontSize = 14; programDepartment.FontWeight = FontWeights.DemiBold; programDepartment.Foreground = original.Foreground; programDepartment.Background = original.Background; programDepartment.HorizontalContentAlignment = HorizontalAlignment.Center; programDepartment.VerticalContentAlignment = VerticalAlignment.Center; programDepartment.HorizontalAlignment = HorizontalAlignment.Stretch; programDepartment.VerticalAlignment = VerticalAlignment.Center; Grid.SetColumn(programDepartment, 1); Grid.SetRow(programDepartment, rowIndex); subWindow.ProgramsDataChart.Children.Add(programDepartment); // Generate And Display Function Of Each Program Label programFunction = new Label(); programFunction.Content = boxes[boxName].function; programFunction.Height = 30; programFunction.FontSize = 14; programFunction.FontWeight = FontWeights.DemiBold; programFunction.Foreground = original.Foreground; programFunction.Background = original.Background; programFunction.HorizontalContentAlignment = HorizontalAlignment.Center; programFunction.VerticalContentAlignment = VerticalAlignment.Center; programFunction.HorizontalAlignment = HorizontalAlignment.Stretch; programFunction.VerticalAlignment = VerticalAlignment.Center; Grid.SetColumn(programFunction, 2); Grid.SetRow(programFunction, rowIndex); subWindow.ProgramsDataChart.Children.Add(programFunction); // Generate And Display Floor Of Each Program Label programFloor = new Label(); programFloor.Content = boxes[boxName].floor; programFloor.Height = 30; programFloor.FontSize = 14; programFloor.FontWeight = FontWeights.DemiBold; programFloor.Foreground = original.Foreground; programFloor.Background = original.Background; programFloor.HorizontalContentAlignment = HorizontalAlignment.Center; programFloor.VerticalContentAlignment = VerticalAlignment.Center; programFloor.HorizontalAlignment = HorizontalAlignment.Stretch; programFloor.VerticalAlignment = VerticalAlignment.Center; Grid.SetColumn(programFloor, 3); Grid.SetRow(programFloor, rowIndex); subWindow.ProgramsDataChart.Children.Add(programFloor); // Generate And Display Total Program GSF Of Each Program Label programTotalGSF = new Label(); programTotalGSF.Content = boxes[boxName].boxTotalGSFValue.ToString("C0", System.Globalization.CultureInfo.CurrentCulture).Remove(0, 1); programTotalGSF.Height = 30; programTotalGSF.FontSize = 14; programTotalGSF.FontWeight = FontWeights.DemiBold; programTotalGSF.Foreground = original.Foreground; programTotalGSF.Background = original.Background; programTotalGSF.HorizontalContentAlignment = HorizontalAlignment.Center; programTotalGSF.VerticalContentAlignment = VerticalAlignment.Center; programTotalGSF.HorizontalAlignment = HorizontalAlignment.Stretch; programTotalGSF.VerticalAlignment = VerticalAlignment.Center; Grid.SetColumn(programTotalGSF, 4); Grid.SetRow(programTotalGSF, rowIndex); subWindow.ProgramsDataChart.Children.Add(programTotalGSF); // Generate And Display Cost Per GSF Of Each Program Label costPerGSF = new Label(); costPerGSF.Content = ExtraMethods.CastDollar(boxes[boxName].cost); costPerGSF.Height = 30; costPerGSF.FontSize = 14; costPerGSF.FontWeight = FontWeights.DemiBold; costPerGSF.Foreground = original.Foreground; costPerGSF.Background = original.Background; costPerGSF.HorizontalContentAlignment = HorizontalAlignment.Center; costPerGSF.VerticalContentAlignment = VerticalAlignment.Center; costPerGSF.HorizontalAlignment = HorizontalAlignment.Stretch; costPerGSF.VerticalAlignment = VerticalAlignment.Center; Grid.SetColumn(costPerGSF, 5); Grid.SetRow(costPerGSF, rowIndex); subWindow.ProgramsDataChart.Children.Add(costPerGSF); // Generate And Display Total Raw Cost Program Label programRawCost = new Label(); programRawCost.Content = ExtraMethods.CastDollar(boxes[boxName].totalRawCostValue); programRawCost.Height = 30; programRawCost.FontSize = 14; programRawCost.FontWeight = FontWeights.DemiBold; programRawCost.Foreground = original.Foreground; programRawCost.Background = original.Background; programRawCost.HorizontalContentAlignment = HorizontalAlignment.Center; programRawCost.VerticalContentAlignment = VerticalAlignment.Center; programRawCost.HorizontalAlignment = HorizontalAlignment.Stretch; programRawCost.VerticalAlignment = VerticalAlignment.Center; Grid.SetColumn(programRawCost, 6); Grid.SetRow(programRawCost, rowIndex); subWindow.ProgramsDataChart.Children.Add(programRawCost); rowIndex += 1; } } } }
public ModifyProgramDataWindow() { InitializeComponent(); foreach (string key in MainWindow.functions.Keys) { // Initialize And Illustrate MEP if (key == "MEP") { this.MEPCost.Text = ExtraMethods.CastDollar(MainWindow.functions["MEP"]["cost"]); } // Initialize And Illustrate Circulatio else if (key == "Circulation") { this.CirculationCost.Text = ExtraMethods.CastDollar(MainWindow.functions["Circulation"]["cost"]); } // Initialize And Illustrate BES else if (key == "BES") { this.BESCost.Text = ExtraMethods.CastDollar(MainWindow.functions["BES"]["cost"]); } // Other Inputs else { string addedProgramDataIndex = (this.ProgramsDataChart.RowDefinitions.Count - 1).ToString(); RowDefinition gridRow = new RowDefinition(); this.ProgramsDataChart.RowDefinitions.Add(gridRow); TextBox programName = new TextBox(); programName.Name = "ProgramName" + addedProgramDataIndex; programName.Text = key; // Store Function Names In The Sequence Of Rows this.listOfKeys.Add(programName.Text); programName.Margin = new Thickness(0, 0, 2.5, 10); programName.Padding = new Thickness(2); programName.VerticalAlignment = VerticalAlignment.Center; this.ProgramsDataChart.Children.Add(programName); Grid.SetColumn(programName, 0); Grid.SetRow(programName, this.ProgramsDataChart.RowDefinitions.Count - 1); TextBox programCost = new TextBox(); programCost.Name = "ProgramCost" + addedProgramDataIndex; programCost.Text = ExtraMethods.CastDollar(MainWindow.functions[key]["cost"]); programCost.Margin = new Thickness(2.5, 0, 2.5, 10); programCost.Padding = new Thickness(2); programCost.VerticalAlignment = VerticalAlignment.Center; this.ProgramsDataChart.Children.Add(programCost); Grid.SetColumn(programCost, 1); Grid.SetRow(programCost, this.ProgramsDataChart.RowDefinitions.Count - 1); TextBox initialCount = new TextBox(); initialCount.Name = "ProgramInitialCount" + addedProgramDataIndex; initialCount.Text = MainWindow.functions[key]["keyVal"].ToString(); initialCount.Margin = new Thickness(2.5, 0, 2.5, 10); initialCount.Padding = new Thickness(2); initialCount.VerticalAlignment = VerticalAlignment.Center; this.ProgramsDataChart.Children.Add(initialCount); Grid.SetColumn(initialCount, 2); Grid.SetRow(initialCount, this.ProgramsDataChart.RowDefinitions.Count - 1); TextBox countRange = new TextBox(); countRange.Name = "ProgramCountRange" + addedProgramDataIndex; countRange.Text = ((MainWindow.functions[key]["keyMax"] - MainWindow.functions[key]["keyVal"]) * 2).ToString(); countRange.Margin = new Thickness(2.5, 0, 2.5, 10); countRange.Padding = new Thickness(2); countRange.VerticalAlignment = VerticalAlignment.Center; this.ProgramsDataChart.Children.Add(countRange); Grid.SetColumn(countRange, 3); Grid.SetRow(countRange, this.ProgramsDataChart.RowDefinitions.Count - 1); TextBox initialGross = new TextBox(); initialGross.Name = "ProgramInitialGross" + addedProgramDataIndex; initialGross.Text = MainWindow.functions[key]["DGSFVal"].ToString(); initialGross.Margin = new Thickness(2.5, 0, 2.5, 10); initialGross.Padding = new Thickness(2); initialGross.VerticalAlignment = VerticalAlignment.Center; this.ProgramsDataChart.Children.Add(initialGross); Grid.SetColumn(initialGross, 4); Grid.SetRow(initialGross, this.ProgramsDataChart.RowDefinitions.Count - 1); TextBox grossRange = new TextBox(); grossRange.Name = "ProgramGrossRange" + addedProgramDataIndex; grossRange.Text = ((MainWindow.functions[key]["DGSFMax"] - MainWindow.functions[key]["DGSFVal"]) * 2).ToString(); grossRange.Margin = new Thickness(2.5, 0, 0, 10); grossRange.Padding = new Thickness(2); grossRange.VerticalAlignment = VerticalAlignment.Center; this.ProgramsDataChart.Children.Add(grossRange); Grid.SetColumn(grossRange, 5); Grid.SetRow(grossRange, this.ProgramsDataChart.RowDefinitions.Count - 1); } } }