private void backgroundWorkerAddContract_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { try { lblDescricaoDuplicados.Visible = !lblDescricaoDuplicados.Visible; pictureBoxLoad.Visible = !pictureBoxLoad.Visible; FileSafeOperations fileSafeOperations = new FileSafeOperations(); fileSafeOperations.RemoveDuplicateRegister(); progressBarReaderPdf.Value = 0; progressBarReaderPdf.Maximum = 0; lblLidos.Text = "0"; lblPorcentagem.Text = "0%"; lblQtd.Text = "0"; lblTempo.Text = "0"; lblTela.Text = "Tela"; pnlProgress.Visible = !pnlProgress.Visible; stopwatch.Stop(); MessageBox.Show($"Carga concluída com sucesso\n{tmp}.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception exCompleted) { throw exCompleted; } }
void AbrirContrato(string _Contract, string _tela) { fsf = new FileSafeOperations(); FileSafe _file = fsf.GetFileSafe(_Contract, _tela); _file.T16 = _Contract; frmpdf _frmPdf = new frmpdf(_file); _frmPdf.ShowDialog(); }
private void Form1_Load(object sender, EventArgs e) { Height = (Screen.PrimaryScreen.Bounds.Height - 30); fsf = new FileSafeOperations(); Users obj = fsf.CheckUser(Environment.UserName); dataGridViewContract.Enabled = (obj.IsAtivo || obj.IsGestorApp); ValidaPermissao(obj); BindGrid(); }
private void BtnOpenDirectory_Click(object sender, EventArgs e) { listContracts.Clear(); fsf = new FileSafeOperations(); listContracts = fsf.GetNumberContract(16); RadioButton radioButton = groupBox1.Controls.OfType <RadioButton>().FirstOrDefault(chk => chk.Checked); FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); folderBrowserDialog.Description = $"Selecione o diretório dos contratos {radioButton.Text}"; if (folderBrowserDialog.ShowDialog() == DialogResult.OK) { TextBoxOrigemContrato.Text = folderBrowserDialog.SelectedPath; BtnAddContrados.Enabled = true; uploadFileContracts.ForEach(f => { f.TypeContract = Convert.ToChar(radioButton.Text.Substring(0, 1)); f.Contracts = Directory.EnumerateFiles(TextBoxOrigemContrato.Text, $"*_{f.Tela}.pdf", SearchOption.AllDirectories); }); } else { TextBoxOrigemContrato.Text = string.Empty; BtnAddContrados.Enabled = false; uploadFileContracts.ForEach(f => { f.TypeContract = 'P'; f.Contracts = null; }); } }
private void DataGridViewContract_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 3) { return; } var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewImageColumn && e.RowIndex >= 0 && e.ColumnIndex == 3) { FileSafe obj = (FileSafe)dataGridViewContract.Rows[e.RowIndex].DataBoundItem; SaveFileDialog saveFile = new SaveFileDialog(); saveFile.Filter = "Contrato|*.pdf"; fsf = new FileSafeOperations(); List <FileSafe> fileSaves = fsf.DownloadFile(obj.T16); if (fileSaves.Count == 0) { return; } saveFile.FileName = obj.T16; if (saveFile.ShowDialog() == DialogResult.OK) { string _path = new FileInfo(saveFile.FileName).DirectoryName + @"\" + obj.T16; if (Directory.Exists(_path)) { Directory.Delete(_path, true); } Directory.CreateDirectory(_path); foreach (FileSafe fileSafe in fileSaves) { if (fileSafe.EncryptedFile != null) { using (BinaryWriter writer = new BinaryWriter(File.Open(_path + @"\" + obj.T16 + fileSafe.PersonName + ".pdf", FileMode.Create))) { writer.Write(fileSafe.EncryptedFile); } } } if (MessageBox.Show(string.Format("Deseja abrir o diretório onde o contrato ({0}) foi salvo?", obj.T16), "Contratos Liquidados", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { Cursor.Current = Cursors.WaitCursor; Process.Start("explorer.exe", _path); Cursor.Current = Cursors.Default; } } } // TELA 16 if (senderGrid.Columns[e.ColumnIndex] is DataGridViewImageColumn && e.RowIndex >= 0 && e.ColumnIndex == 4) { FileSafe obj = (FileSafe)dataGridViewContract.Rows[e.RowIndex].DataBoundItem; AbrirContrato(obj.T16, "16"); } // TELA 18 if (senderGrid.Columns[e.ColumnIndex] is DataGridViewImageColumn && e.RowIndex >= 0 && e.ColumnIndex == 5) { FileSafe obj = (FileSafe)dataGridViewContract.Rows[e.RowIndex].DataBoundItem; if (!string.IsNullOrWhiteSpace(obj.T18)) { AbrirContrato(obj.T16, "18"); } } // TELA 20 if (senderGrid.Columns[e.ColumnIndex] is DataGridViewImageColumn && e.RowIndex >= 0 && e.ColumnIndex == 6) { FileSafe obj = (FileSafe)dataGridViewContract.Rows[e.RowIndex].DataBoundItem; if (!string.IsNullOrWhiteSpace(obj.T20)) { AbrirContrato(obj.T16, "20"); } } // TELA 25 if (senderGrid.Columns[e.ColumnIndex] is DataGridViewImageColumn && e.RowIndex >= 0 && e.ColumnIndex == 7) { FileSafe obj = (FileSafe)dataGridViewContract.Rows[e.RowIndex].DataBoundItem; if (!string.IsNullOrWhiteSpace(obj.T25)) { AbrirContrato(obj.T16, "25"); } } }
void BindGrid() { FileSafeOperations fso = new FileSafeOperations(); DataGridViewUsuario.DataSource = fso.GetUsers(); }
public FrmAddUsuariosAD() { InitializeComponent(); fso = new FileSafeOperations(); }