/// <summary> /// Retorna um objeto Preenchido, é obrigatorio a passagem de para de paramentro ID do registro /// </summary> /// <param name="_contrato">codigo do registro</param> /// <returns>retorna um objeto preenchido</returns> public FileSafe GetFileSafe(string _parametro, string _tela) { FileSafeData fs = new FileSafeData(); FileSafe obj = fs.GetFileSafe(_parametro, _tela).FirstOrDefault(); return(obj); }
public List <FileSafe> GetFileSafe(string _parametro, string _tela) { List <FileSafe> lst = new List <FileSafe>(); try { command = cnx.Parametriza(Procedures.SP_GET_FILES); command.Connection = command.Connection; command.Parameters.Add(new SqlParameter("@PARAMETRO", string.IsNullOrWhiteSpace(_parametro) ? null : _parametro)); command.Parameters.Add(new SqlParameter("@TELA", _tela)); command.Connection.Open(); SqlDataReader dr = command.ExecuteReader(); FileSafe obj = null; while (dr.Read()) { obj = new FileSafe() { EncryptedFile = (byte[])dr[0] }; lst.Add(obj); } cnx.FecharConexao(command); } catch (SqlException ex) { cnx.FecharConexao(command); throw ex; } return(lst); }
public List <FileSafe> DownloadFiles(string _contract) { List <byte[]> arquivos = new List <byte[]>(); List <FileSafe> lst = new List <FileSafe>(); try { command = cnx.Parametriza(Procedures.SP_DOWNLOAD_FILES); command.Connection = command.Connection; command.Parameters.Add(new SqlParameter("@PARAMETRO", string.IsNullOrWhiteSpace(_contract) ? null : _contract)); command.Connection.Open(); SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { FileSafe obj = null; obj = new FileSafe() { PersonName = "_16", EncryptedFile = (dr[0] == DBNull.Value) ? default(byte[]) : (byte[])dr[0] }; lst.Add(obj); obj = new FileSafe() { PersonName = "_18", EncryptedFile = (dr[1] == DBNull.Value) ? default(byte[]) : (byte[])dr[1] }; lst.Add(obj); obj = new FileSafe() { PersonName = "_20", EncryptedFile = (dr[2] == DBNull.Value) ? default(byte[]) : (byte[])dr[2] }; lst.Add(obj); obj = new FileSafe() { PersonName = "_25", EncryptedFile = (dr[3] == DBNull.Value) ? default(byte[]) : (byte[])dr[3] }; lst.Add(obj); obj = new FileSafe() { PersonName = "_34", EncryptedFile = (dr[4] == DBNull.Value) ? default(byte[]) : (byte[])dr[4] }; lst.Add(obj); } cnx.FecharConexao(command); } catch (SqlException ex) { cnx.FecharConexao(command); throw ex; } return(lst); }
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 dataGridViewContract_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { try { var senderGrid = (DataGridView)sender; foreach (DataGridViewRow item in senderGrid.Rows) { FileSafe obj = (FileSafe)item.DataBoundItem; if (string.IsNullOrEmpty(obj.T18)) { if (senderGrid.Columns[5] is DataGridViewImageColumn && item.Index >= 0) { item.Cells[5].Value = Properties.Resources.Childish_Cross_24996; } } if (string.IsNullOrEmpty(obj.T20)) { if (senderGrid.Columns[6] is DataGridViewImageColumn && item.Index >= 0) { item.Cells[6].Value = Properties.Resources.Childish_Cross_24996; } } if (string.IsNullOrEmpty(obj.T25)) { if (senderGrid.Columns[7] is DataGridViewImageColumn && item.Index >= 0) { item.Cells[7].Value = Properties.Resources.Childish_Cross_24996; } } if (string.IsNullOrEmpty(obj.T34)) { if (senderGrid.Columns[8] is DataGridViewImageColumn && item.Index >= 0) { item.Cells[8].Value = Properties.Resources.Childish_Cross_24996; } } } } catch (Exception exAddRow) { string _err = exAddRow.Message; } }
public List <FileSafe> GetFilesAll(string _parametro, char _typeContract, DateTime[] _datasParam = null) { List <FileSafe> lst = new List <FileSafe>(); try { command = cnx.Parametriza(Procedures.SP_GET_FILES_T16_T18_T20_T25_T34); command.Connection = command.Connection; command.Parameters.Add(new SqlParameter("@PARAMETRO", string.IsNullOrWhiteSpace(_parametro) ? null : _parametro)); command.Parameters.Add(new SqlParameter("@TYPECONTRACT", _typeContract)); if (_datasParam != null) { command.Parameters.Add(new SqlParameter("@DATEINI", _datasParam[0])); command.Parameters.Add(new SqlParameter("@DATEFIM", _datasParam[1])); } command.Connection.Open(); SqlDataReader dr = command.ExecuteReader(); FileSafe obj = null; while (dr.Read()) { obj = new FileSafe() { PersonName = dr[0].ToString(), PersonDocument = dr[1].ToString(), T16 = dr[2].ToString(), T18 = dr[3].ToString(), T20 = dr[4].ToString(), T25 = dr[5].ToString(), }; lst.Add(obj); } cnx.FecharConexao(command); } catch (SqlException ex) { cnx.FecharConexao(command); throw ex; } return(lst); }
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"); } } }
public frmpdf(FileSafe _fileSafe) { InitializeComponent(); _file = _fileSafe; }