/// <summary> /// Swaps the field value of the selected excel column with the selected field /// </summary> public void SwapCell() { string field = this.SelectedField; if (this.SelectedField == "-TEXT-") { TextPromptView textWindow = new TextPromptView { DataContext = new TextPromptViewModel("", "", "string") }; textWindow.ShowDialog(); if (textWindow.DialogResult == true) { field = '"' + (textWindow.DataContext as TextPromptViewModel).Field1Value + '"'; } else { return; } } if (field != null) { this.SelectedExcelColumn.Field = field; } RenumberExcelColumns(); }
/// <summary> /// Adds the selected field to the bottom of the excel columns /// </summary> public void AddFieldToExcelColumns() { string field = this.SelectedField; if (this.SelectedField == "-TEXT-") { TextPromptView textWindow = new TextPromptView { DataContext = new TextPromptViewModel("Add Field", "Field", "string") }; textWindow.ShowDialog(); if (textWindow.DialogResult == true) { field = '"' + (textWindow.DataContext as TextPromptViewModel).Field1Value + '"'; } else { return; } } ExcelCell newCell = new ExcelCell( this.ExcelId, this.ExcelColumns.Count + 1, field, "", this.ExcelCustomer, ExcelService.ReturnColumLetter(this.ExcelColumns.Count + 1)); this.ExcelColumns.Add(newCell); }
/// <summary> /// Saves the current excel layout /// </summary> public void SaveExcelLayout() { if (ExcelColumns != new ObservableCollection <ExcelCell>()) { bool result = true; try { if (this.ExcelLayout == "-NEW-") { // int newId = RetrieveExcelLayoutNames().Count + 1; TextPromptView textWindow = new TextPromptView { DataContext = new TextPromptViewModel("Save Excel", "Excel Name", "string") }; textWindow.ShowDialog(); if (textWindow.DialogResult == true) { string name = (textWindow.DataContext as TextPromptViewModel).Field1Value; if (this.ExcelLists.Contains(name)) { MessageBox.Show(name + " is already being used by another layout. Please select another name."); result = false; } if (result) { ExcelService.InsertExcelLayout(name, this.ExcelCustomer, this.ProductType); int newId = ExcelService.RetrieveExcelLayoutId(name); foreach (ExcelCell cell in this.ExcelColumns) { cell.ExcelId = newId; } ExcelService.InsertExcelLayoutColumns(this.ExcelColumns); } } } else { int layoutId = Convert.ToInt32(ExcelColumns[0].ExcelId); ExcelService.RemoveExcelLayoutColumns(layoutId); ExcelService.InsertExcelLayoutColumns(this.ExcelColumns); } } catch (Exception ex) { ErrorLog.LogError("Odin could not insert the excel layout information.", ex.ToString()); } if (result) { MessageBox.Show("Excel Layout Saved."); } this.ExcelLists = ExcelService.RetrieveExcelLayoutNames(); } }