private void BtnGuardarHC_Click(Object sender, System.EventArgs e) { if (txtHHCC.Text.Length > 0) { if (File.Exists(Configuracion.getDirectorioHC() + "\\" + documento + "_HC.dat")) { DialogResult r = MessageBox.Show("¿Desea reemplazarlo?", documento + "_HC.dat ya existe!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (r == DialogResult.Yes) { List <string> data = new List <string>(); foreach (string s in txtHHCC.Lines) { data.Add(s); } data.Add("-------------------------------------------------"); data.Add("Ultima entrada de datos: " + DateTime.Now); data.Add("-------------------------------------------------" + Environment.NewLine); File.WriteAllLines(Configuracion.getDirectorioHC() + "\\" + documento + "_HC.dat", data.ToArray()); } } else { List <string> data = new List <string>(); foreach (string s in txtHHCC.Lines) { data.Add(s); } data.Add("--------------------------------------------------------------------" + Environment.NewLine); data.Add("Ultima entrada de datos: " + DateTime.Now + Environment.NewLine); data.Add("--------------------------------------------------------------------" + Environment.NewLine); File.WriteAllLines(Configuracion.getDirectorioHC() + "\\" + documento + "_HC.dat", data.ToArray()); } } this.Close(); }
public static void doBackup() { try { List <string> bkpfiles = new List <string>(); DateTime fecha = DateTime.Now; string format = "yyyyMMdd"; // Use this format String[] pacientes = Directory.GetFiles(Configuracion.getDirectorioPacientes(), "*.dat"); String[] hhcc = Directory.GetFiles(Configuracion.getDirectorioHC(), "*.dat"); String[] imagenes = Directory.GetFiles(Configuracion.getDirectorioImagenes()); foreach (string s in pacientes) { bkpfiles.Add(s); } foreach (string s in hhcc) { bkpfiles.Add(s); } foreach (string s in imagenes) { bkpfiles.Add(s); } String backupfile = Configuracion.getDirectorioBackup() + "\\" + "Backup_" + fecha.ToString(format) + ".zip"; ZipFile zip = new ZipFile(); zip.AddFiles(bkpfiles.ToArray()); zip.Save(backupfile); MessageBox.Show("Backup realizado correctamente.\n" + backupfile); } catch (Exception e) { MessageBox.Show("Error en el proceso de backup!\n" + e.Message); } }
public Reporte(string apellido, string nombre, string tipodoc, string documento, string telefono, string sexo, string email) { this.documento = documento; html = "<html>"; html += "<head><title>Reporte pacientes</title></head>"; html += "<body>"; html += "<h1 align=\"center\">Reporte pacientes</h1>"; html += "<table border=\"1\">"; html += "<tr>"; html += "<td> Paciente: </td><td>" + apellido + ", " + nombre + " (" + sexo + ")</td></tr>"; html += "<td>" + tipodoc + ":</td><td>" + documento + "</td></tr>"; html += "<td> Teléfono: </td><td>" + telefono + "</td></tr>"; html += "<td> Email: </td><td>" + email + "</td></tr>"; html += "</tr>"; html += "</table>"; html += "<h2>Historia clínica</h2>"; html += "<textarea rows=\"14\" cols=\"65\">"; if (File.Exists(Configuracion.getDirectorioHC() + "\\" + documento + "_HC.dat")) { hc = File.ReadAllLines(Configuracion.getDirectorioHC() + "\\" + documento + "_HC.dat"); foreach (string s in hc) { html += s + Environment.NewLine; } } html += "</textarea>"; html += "</body>"; html += "</html>"; this.Width = 600; this.Height = 550; //MessageBox.Show(html); wb = new WebBrowser(); wb.Width = 600; wb.Height = 480; wb.DocumentText = html; btnSalir = new Button(); btnImprimir = new Button(); btnSalir.Text = "Salir"; btnImprimir.Text = "Imprimir"; btnImprimir.Location = new System.Drawing.Point(10, 484); btnSalir.Location = new System.Drawing.Point(100, 484); btnSalir.Click += new System.EventHandler(btnSalir_Click); btnImprimir.Click += new System.EventHandler(btnImprimir_Click); this.Controls.Add(wb); this.Controls.Add(btnImprimir); this.Controls.Add(btnSalir); this.ShowDialog(); }
public HC(string apellido, string nombre, string tipodoc, string documento, string telefono, string sexo, string email) { this.apellido = apellido; this.nombre = nombre; this.tipodoc = tipodoc; this.documento = documento; this.telefono = telefono; this.sexo = sexo; this.email = email; lblPacienteHC = new Label(); txtHHCC = new RichTextBox(); btnGuardarHC = new Button(); btnSalirHC = new Button(); this.Width = 500; this.Height = 500; this.Text = "Historia Clínica " + apellido + ", " + nombre; lblPacienteHC.Text = "Historia Clínica " + apellido + ", " + nombre; lblPacienteHC.Location = new Point(10, 10); txtHHCC.Multiline = true; txtHHCC.Location = new Point(10, 25); txtHHCC.Width = 450; txtHHCC.Height = 395; txtHHCC.Font = new Font("Tahoma", 10, FontStyle.Bold); btnGuardarHC.Text = "Guardar"; btnGuardarHC.Location = new Point(10, 426); btnSalirHC.Text = "Salir"; btnSalirHC.Location = new Point(100, 426); btnSalirHC.Click += new System.EventHandler(BtnSalirHC_Click); btnGuardarHC.Click += new System.EventHandler(BtnGuardarHC_Click); this.Controls.Add(txtHHCC); this.Controls.Add(btnGuardarHC); this.Controls.Add(btnSalirHC); this.Controls.Add(lblPacienteHC); if (File.Exists(Configuracion.getDirectorioHC() + "\\" + documento + "_HC.dat")) { txtHHCC.Lines = File.ReadAllLines(Configuracion.getDirectorioHC() + "\\" + documento + "_HC.dat"); } txtHHCC.Focus(); txtHHCC.SelectionStart = txtHHCC.Text.Length + 2; this.ShowDialog(); }