private void configFiles_DataGridView_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { _current = configFiles_DataGridView.Rows[e.RowIndex].DataBoundItem as PrintDriverConfig; RefreshCheckLists(); } }
private void PrintDriverCFMManagementForm_Load(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; try { _context = DbConnect.AssetInventoryContext(); LoadConfigDataFile(); LoadCheckBoxes(); if (_configData.Count > 0) { _current = configFiles_DataGridView.Rows[0].DataBoundItem as PrintDriverConfig; configFiles_DataGridView.Rows[0].Selected = true; RefreshCheckLists(); } } finally { Cursor = Cursors.Default; } }
private void AddFile(string filePath) { bool copyFileToServer = true; try { Cursor = Cursors.WaitCursor; string fileName = Path.GetFileName(filePath); string repository = GlobalSettings.Items[Setting.PrintDriverConfigFileLocation]; string destinationPath = Path.Combine(repository, fileName); if (EnvironmentFileServer.FileExists(destinationPath)) { var result = MessageBox.Show( "File [{0}] already exists on the file server.\nClick \"Yes\" to overwrite, \"No\" to keep existing, or \"Cancel\"".FormatWith(fileName), "Overwrite File", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation ); switch (result) { case DialogResult.Cancel: return; case DialogResult.No: copyFileToServer = false; break; case DialogResult.Yes: copyFileToServer = true; break; } } // Copy to file server if not already exist or user has chosen to overwrite if (copyFileToServer) { EnvironmentFileServer.CopyFile(filePath, destinationPath); } // Add entry to database if it doesn't already exist PrintDriverConfig config = _configData.FirstOrDefault(e => Path.GetFileName(e.ConfigFile).Equals(fileName, StringComparison.OrdinalIgnoreCase)); if (config == null) { config = new PrintDriverConfig { PrintDriverConfigId = SequentialGuid.NewGuid(), ConfigFile = destinationPath }; _configData.Add(config); _context.PrintDriverConfigs.Add(config); } // Set the newly uploaded item as current SelectedConfig = config; } catch (Exception ex) { MessageBox.Show ( "Error communicating with remote server.{0}{1}".FormatWith(Environment.NewLine, ex.Message), "Error Adding File", MessageBoxButtons.OK, MessageBoxIcon.Error ); } finally { Cursor = Cursors.Default; } }