public bool loginSystem(String user, String password) { try { //Comprobamos si el usuario y el password en MD5 son correctos conn.querySQL("SELECT username FROM tbl_users WHERE tbl_users.username = '******' AND tbl_users.password ='******'"); conn.fillDataset("tbl_users", ""); //Si obtenemos al menos una fila nos logueamos en el sistema devolviendo verdadero if (conn.getDataSet().Tables[0].Rows.Count == 1) { return(true); } else { return(false); } } catch (Exception ex) { mssg.showMessage(ex.Message, "error", ""); return(false); } }
private void btn_aceptar_Click(object sender, EventArgs e) { try { //Comprobamos los campos de usuario y password, ademas removemos los caracteres de espacios //para evitar inserción de datos o código malicioso if (sesion.loginSystem(txt_usuario.Text.Replace(" ", ""), txt_password.Text.Replace(" ", ""))) { //Inicializamos e invocamos el llamado de un nuevo formulario MessageBox.Show("Bienvenido Usuario", "Bienvenida", MessageBoxButtons.OK, MessageBoxIcon.Information); Principal formMain = new Principal(); this.Visible = false; //Pasamos por parámetro público la variable session, la cual contiene la conexión actual formMain.session = this.sesion; formMain.Show(); } else { mssg.showMessage("", "warning", "fail_auth"); } } catch (Exception ex) { mssg.showMessage(ex.Message, "error", ""); } }
private void txb_search_TextChanged(object sender, EventArgs e) { try { if (txb_search.Text != "") { //Se evalua la propiedad Tag del forulario Origen para saber que datos buscar switch (this.Tag.ToString()) { case "buscar_paciente": paciente.searchPacientes(session, ltv_data, txb_search.Text); break; case "buscar_expediente": expediente.searchExpediente(session, ltv_data, txb_search.Text); break; case "buscar_tratamiento": tratamiento.searchTratamiento(session, ltv_data, txb_search.Text); break; } } else { ltv_data.Clear(); } } catch (Exception ex) { mssg.showMessage(ex.Message, "error", ""); } }
//Función para abrir la conexión ODBC public bool openConexion(string stringConnection) { try { connection = new OdbcConnection(stringConnection); connection.Open(); return(true); } catch (Exception ex) { mssg.showMessage(ex.Message, "error", ""); return(false); } }
public void searchOdontograma(Conexion conn, System.Windows.Forms.ListView listView, String textdata) { try { string stringSQL = "SELECT cedula_paciente AS Cedula, categoria_odontograma AS Categoria, imagen_odontograma AS Imagen" + "FROM tbl_odontograma" + " WHERE (UPPER(cedula_paciente) LIKE UPPER('" + textdata + "%')"; func.fillListView(conn, listView, stringSQL); } catch (Exception ex) { mssg.showMessage(ex.Message, "error", ""); } }
public void searchImagenes(Conexion conn, System.Windows.Forms.ListView listView, String textdata) { try { string stringSQL = "SELECT nombre_imagen AS Nombre" + " FROM tbl_imagen " + " WHERE (UPPER(nombre_imagen) LIKE UPPER('" + textdata + "%'))"; func.fillImagenSystem(conn, listView, stringSQL); } catch (Exception ex) { mssg.showMessage(ex.Message, "error", ""); } }
public DataSet getReportSQL(Conexion conn, List <string> listvalues, string numrpt) { try { string stringSQL = ""; switch (numrpt) { case "0": conn.getDataSet().Clear(); stringSQL = "SELECT cedula_paciente, nombre_paciente, apellido_paciente, telefono_paciente, direccion_paciente," + "edad_paciente, sexo_paciente, lugar_nacimiento, enfermedad_padecimiento, problema_presion, fiebre_reumatica" + "FROM tbl_paciente ORDER BY nombre_paciente ASC"; conn.querySQL(stringSQL); conn.fillDataset("tbl_paciente", conn.getDataSet().DataSetName); break; case "1": conn.getDataSet().Clear(); stringSQL = "SELECT cedula_paciente, nombre_paciente, apellido_paciente, telefono_paciente, direccion_paciente," + " edad_paciente, sexo_paciente, lugar_nacimiento, enfermedad_padecimiento, problema_presion, fiebre_reumatica," + " medico_cabecera, tipo_sangre, telefono_emergencia, parentesco, historia_queja_medica " + " FROM tbl_paciente " + " WHERE cedula_paciente = '" + listvalues[0] + "'"; conn.querySQL(stringSQL); conn.fillDataset("tbl_paciente", conn.getDataSet().DataSetName); break; } }catch (Exception ex) { mssg.showMessage("Seleccione 'Aceptar' para mostrar el reporte", "", ""); return(null); } return(conn.getDataSet()); }
/* Se encarga de forma general de tomar los datos por medio de consultas SQL y mostrar los resultados en * el componente listview. * LLena el ListView en forma de Matriz, con columnas en Y y filas en X con el recorrido del ciclo FOR. */ public void fillListView(CapaDatos.Clases.Conexion conn, System.Windows.Forms.ListView listView, String query) { try { int x = 0; int y = 0; conn.querySQL(query); conn.fillDataset("", ""); listView.Clear(); if (conn.getDataSet().Tables.Count != 0) { while (y < conn.getDataSet().Tables[0].Rows.Count) { x = 0; while (x < conn.getDataSet().Tables[0].Columns.Count) { if (y == 0) { listView.Columns.Add(conn.getDataSet().Tables[0].Columns[x].ColumnName, 150, HorizontalAlignment.Left); } if (x == 0) { listView.Items.Add(conn.getDataSet().Tables[0].Rows[y].ItemArray[x].ToString()); } else { listView.Items[y].SubItems.Add(conn.getDataSet().Tables[0].Rows[y].ItemArray[x].ToString()); } x += 1; } if (y % 2 == 0) { // Damos color gris a las filas pares para dar un efecto de resaltado intercalado listView.Items[y].BackColor = Color.WhiteSmoke; } y += 1; } } } catch (Exception ex) { mssg.showMessage(ex.Message, "error", ""); } }
public void searchAnamnesis(Conexion conn, System.Windows.Forms.ListView listView, String textdata) { try { string stringSQL = "SELECT cedula_paciente AS Cedula, medico_cabecera AS Medico, tipo_sangre AS Tipo, persona_avisar AS Persona, telefono_emergencia AS Telefono," + " direccion AS Direccion, parentesco AS Parentesco, queja_principal AS Queja, historia_queja_historia AS Queja_Historiar" + " FROM tbl_anamnesis " + " WHERE (UPPER(cedula_paciente) LIKE UPPER('" + textdata + "%')" + " OR UPPER(nombre_paciente) LIKE UPPER('" + textdata + "%'))"; func.fillListView(conn, listView, stringSQL); } catch (Exception ex) { mssg.showMessage(ex.Message, "error", ""); } }
public void searchExpediente(Conexion conn, System.Windows.Forms.ListView listView, String textdata) { try { string stringSQL = "SELECT cedula_paciente AS Cedula, nombre_paciente AS Nombre,apellido_paciente AS Apellido, telefono_paciente AS Telefono," + " sexo_paciente AS Sexo, lugar_nacimiento AS Lugar, enfermedad_padecimiento AS Enfermedad," + " problema_presion AS Presion, fiebre_reumatica AS Fiebre," + " medico_cabecera AS Medico, tipo_sangre AS Tipo, telefono_emergencia AS Telefono, parentesco AS Parentesco, historia_queja_medica AS Historia" + " FROM tbl_paciente " + " WHERE (UPPER(cedula_paciente) LIKE UPPER('" + textdata + "%')" + " OR UPPER(nombre_paciente) LIKE UPPER('" + textdata + "%'))"; func.fillListView(conn, listView, stringSQL); } catch (Exception ex) { mssg.showMessage(ex.Message, "error", ""); } }
/* Función para búsqueda de datos de Películas mediante un sólo parámetro (nombre o código) * y llenado de resultado de datos (se invoca el llenado del ListView) * */ public bool editTratamiento(Conexion conn, List <string> listData) { bool edit = false; try { //conn.getDataSet().Clear(); string stringSQL = "SELECT * FROM tbl_tratamiento WHERE nombre_tratamiento = '" + listData[0] + "'"; conn.querySQL(stringSQL); conn.fillDataset("", ""); if (conn.getDataSet().Tables[0].Rows.Count == 0) { conn.getDataSet().Clear(); stringSQL = " INSERT INTO tbl_tratamiento (nombre_tratamiento, precio)" + " VALUES ('" + listData[0] + "'," + listData[1] + ");"; conn.querySQL(stringSQL); conn.fillDataset("", ""); edit = false; } else { conn.getDataSet().Clear(); stringSQL = "UPDATE tbl_tratamiento SET nombre_tratamiento = '" + listData[0] + "', precio = " + listData[1] + " WHERE nombre_tratamiento='" + listData[0] + "';"; conn.querySQL(stringSQL); conn.fillDataset("", ""); edit = true; } } catch (Exception ex) { mssg.showMessage(ex.Message, "error", ""); } return(edit); }
private void btn_generar_Click(object sender, EventArgs e) { try { ReportesViewer reportes = new ReportesViewer(); reportes.Tag = cmb_reporte.SelectedIndex; reportes.session = this.session; reportes.ShowDialog(); } catch (Exception ex) { mssg.showMessage(ex.Message, "error", ""); } }
private void btn_buscar_Click(object sender, EventArgs e) { try { Buscar buscar = new Buscar(); buscar.Tag = "buscar_expediente"; buscar.session = this.sesion; buscar.ShowDialog(); if (buscar.resultData.Count != 0) { fillForm(buscar.resultData); } } catch (Exception ex) { mssg.showMessage(ex.Message, "error", ""); } }
private void ReportesViewer_Load(object sender, EventArgs e) { try { ReportDocument myreport = new ReportDocument(); //Para poder usar las propiedades de Crystal Reports List <string> listvalues = new List <string>(); // Guardará los datos que alimentará la consulta del reporte switch (this.Tag.ToString()) { case "0": //Cargamos el reporte de Todas la Películas desde la respectiva carpeta myreport.Load(@"..\..\Reportes\Todos_pacientes.rpt"); //Indicamos el reporte (índice del combo) myreport.SetDataSource(rpt.getReportesSQL(session, listvalues, this.Tag.ToString())); myreport.SetParameterValue("prm_dato", "Reportes de todos los pacientes"); //LLenamos el parámetro creado en el reporte crv_viewer.ReportSource = myreport; break; case "1": //Cargamos el reporte por Película individual listvalues.Add(getData()); //Usando el formulario buscar definimos cual dato solicitar myreport.Load(@"..\..\Reportes\Reporte_paciente.rpt"); //Indicamos el reporte (índice del combo) myreport.SetDataSource(rpt.getReportesSQL(session, listvalues, this.Tag.ToString())); //LLenamos los parámetros creados en el reporte myreport.SetParameterValue("prm_dato", "Reportes del expediente"); crv_viewer.ReportSource = myreport; break; } } catch (Exception ex) { mssg.showMessage(ex.Message, "error", ""); } }
private void panel2_MouseClick(object sender, MouseEventArgs e) { try { switch (tipo) { case 1: x = e.X; y = e.Y; panel2.Invalidate(); opcion = 1; break; case 2: x = e.X; y = e.Y; panel2.Invalidate(); opcion = 2; break; case 3: x = e.X; y = e.Y; panel2.Invalidate(); opcion = 3; break; case 4: x = e.X; y = e.Y; panel2.Invalidate(); opcion = 4; break; case 5: x = e.X; y = e.Y; panel2.Invalidate(); opcion = 5; break; case 6: x = e.X; y = e.Y; panel2.Invalidate(); opcion = 6; break; case 7: x = e.X; y = e.Y; panel2.Invalidate(); opcion = 7; break; case 8: x = e.X; y = e.Y; panel2.Invalidate(); opcion = 8; break; case 9: x = e.X; y = e.Y; panel2.Invalidate(); opcion = 9; break; case 10: x = e.X; y = e.Y; panel2.Invalidate(); opcion = 10; break; case 11: x = e.X; y = e.Y; panel2.Invalidate(); opcion = 11; break; case 12: x = e.X; y = e.Y; panel2.Invalidate(); opcion = 12; break; case 13: x = e.X; y = e.Y; panel2.Invalidate(); opcion = 13; break; case 14: x = e.X; y = e.Y; panel2.Invalidate(); opcion = 14; break; case 15: x = e.X; y = e.Y; panel2.Invalidate(); opcion = 15; break; } } catch (Exception ex) { mssg.showMessage(ex.Message, "error", ""); } }