public bool actualizarPaciente(string id_paciente, string nombre, string apellidos, string direccion, string telefono, string foto, string antecedente, string email, int marketing, string id_clinica, string alias) { Seguridad s = new Seguridad(); string foto_paciente = ""; if (foto.Equals("")) { foto_paciente = foto; } else { foto_paciente = s.quitar_acentos(foto); } try { MySqlCommand cmd;; if (online) { bool internet = ti.Test(); if (!internet) { //EN CASO DE REALIZAR UNA PETICION PARA ACTUALIZAR EN SERVIDOR VERIFICAR SI HAY INTERNET, SI NO LO HAY, ENTONCES NO HACER NADA Y SEGUIR MANTENIENDO QUERIES EN EL ARCHIVO return(false); } else { //EN CASO DE REALIZAR UNA PETICION PARA INSEACTUALIZARRTAR EN SERVIDOR VERIFICAR SI HAY INTERNET, SI LO HAY, ENTONCES INSERTAR TODOS LOS QUERIES DEL ARCHIVO //query = "UPDATE usuario set alias = '" + alias + "',nombre = '" + nombre + "',apellidos = '" + apellidos + "',password = '******',id_rol = " + id_rol + " where id_usuario = '" + id_usuario + "'"; Sincronizar sincronizar = new Sincronizar(); sincronizar.insertarArchivoEnServidor(conexionBD); return(true); } } else { //string auxiliar_identificador = MostrarUsuario_Update(id_usuario); query = "UPDATE paciente set nombre = '" + nombre + "',apellidos = '" + apellidos + "',direccion = '" + direccion + "',telefono = '" + telefono + "',foto = '" + foto_paciente + "',email = '" + email + "',marketing = " + marketing + ",antecedentes='" + antecedente + "', id_clinica='" + id_clinica + "' where id_paciente ='" + id_paciente + "'"; Console.WriteLine(query); conexionBD.Open(); cmd = new MySqlCommand(query, conexionBD); cmd.ExecuteReader(); conexionBD.Close(); Escribir_Archivo ea = new Escribir_Archivo(); ea.escribir_imagen_eliminar(query + ";", @configuracion.carpetas.ruta_script_carpeta + "\\script_temporal_" + alias + ".txt"); System.Windows.Forms.MessageBox.Show("Se actualizó correctamente el Paciente: ", "Correcto", MessageBoxButtons.OK, MessageBoxIcon.Information); return(true); } } catch (MySqlException ex) { System.Windows.Forms.MessageBox.Show("Se ha producido un error al intentar actualizar ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); conexionBD.Close(); return(false); } }
public bool insertarPaciente(string nombre, string apellidos, string direccion, string telefono, string foto, string antecedente, string email, int marketing, string id_clinica, string alias) { Seguridad s = new Seguridad(); string foto_paciente = ""; string id_paciente = ""; Seguridad seguridad = new Seguridad(); if (foto.Equals("")) { foto_paciente = foto; } else { foto_paciente = s.quitar_acentos(foto); } id_paciente = seguridad.SHA1(nombre + apellidos + direccion + telefono + foto_paciente + antecedente + email + marketing + id_clinica + DateTime.Now); try { MySqlCommand cmd;; if (online) { bool internet = ti.Test(); if (!internet) { //EN CASO DE REALIZAR UNA PETICION PARA INSERTAR EN SERVIDOR VERIFICAR SI HAY INTERNET, SI NO LO HAY, ENTONCES NO HACER NADA Y SEGUIR MANTENIENDO QUERIES EN EL ARCHIVO return(false); } else { //EN CASO DE REALIZAR UNA PETICION PARA INSERTAR EN SERVIDOR VERIFICAR SI HAY INTERNET, SI LO HAY, ENTONCES INSERTAR TODOS LOS QUERIES DEL ARCHIVO //query = "INSERT INTO usuario (id_usuario,alias,nombre,apellidos,password,id_rol) VALUES('" + auxiliar_identificador + "','" + alias + "','" + nombre + "','" + apellidos + "','" + password + "'," + id_rol + ")"; Sincronizar sincronizar = new Sincronizar(); sincronizar.insertarArchivoEnServidor(conexionBD); return(true); } } else { query = "INSERT INTO paciente (id_paciente,nombre,apellidos,direccion,telefono,foto,email,marketing,id_clinica,antecedentes,factura) VALUES('" + id_paciente + "','" + nombre + "','" + apellidos + "','" + direccion + "','" + telefono + "','" + foto_paciente + "','" + email + "'," + marketing + ",'" + id_clinica + "','" + antecedente + "'," + 0 + ")"; conexionBD.Open(); cmd = new MySqlCommand(query, conexionBD); cmd.ExecuteReader(); conexionBD.Close(); Escribir_Archivo ea = new Escribir_Archivo(); ea.escribir_imagen_eliminar(query + ";", @configuracion.carpetas.ruta_script_carpeta + "\\script_temporal_" + alias + ".txt"); System.Windows.Forms.MessageBox.Show("Se insertó correctamente el Paciente: ", "Correcto", MessageBoxButtons.OK, MessageBoxIcon.Information); return(true); } } catch (MySqlException ex) { System.Windows.Forms.MessageBox.Show("Se ha producido un error al intentar insertar ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); conexionBD.Close(); return(false); } }