//Turbi: metodo para cargar los datos de la bd sobrecargado public static DataTable DatosGeneral(string tabla, string cFiltro, string cOrderBy) { try { if (cFiltro.Trim() == "") { cFiltro = " Where 1 = 1 "; } if (cOrderBy.Trim() == "") { cOrderBy = " Order by 1 "; } DataTable dt = new DataTable(); clsProcesos con = new clsProcesos(); string constring = con.conectarConta(); if (constring == null) { constring = DispensarioMedico.clsConexion.ConectionString; } MySqlConnection objCon = new MySqlConnection(); objCon.ConnectionString = constring; objCon.Open(); string consulta = "SELECT * FROM " + tabla + " " + cFiltro + " " + cOrderBy; VFPToolkit.strings.StrToFile(consulta, "Consulta.sql", true); MySqlCommand comando = new MySqlCommand(consulta, objCon); MySqlDataAdapter adap = new MySqlDataAdapter(comando); //Turbi //dt.Locale = System.Globalization.CultureInfo.InvariantCulture; adap.Fill(dt); objCon.Close(); return(dt); } catch (MySql.Data.MySqlClient.MySqlException ex) { MessageBox.Show("Error : " + ex.Message, "Activos Fijos", MessageBoxButtons.OK, MessageBoxIcon.Information); clsExceptionLog.LogError(ex, false); return(null); } catch (Exception ex) { MessageBox.Show("Error : " + ex.Message, "frmActivosFijos", MessageBoxButtons.OK, MessageBoxIcon.Information); clsExceptionLog.LogError(ex, false); return(null); } finally { } }
public static DataTable ValidaDatos(string Tabla, string cFiltro) { try { if (cFiltro.Trim() == "") { cFiltro = " Where 1 = 1 "; } //if (cOrderBy.Trim() == "") //{ // cOrderBy = " Order by 1 "; //} DataTable dt = new DataTable(); clsProcesos con = new clsProcesos(); string constring = con.conectarConta(); if (constring == null) { constring = DispensarioMedico.clsConexion.ConectionString; } MySqlConnection objCon = new MySqlConnection(); objCon.ConnectionString = constring; objCon.Open(); string consulta = "SELECT * FROM " + Tabla + " " + cFiltro; MySqlCommand comando = new MySqlCommand(consulta, objCon); MySqlDataAdapter adap = new MySqlDataAdapter(comando); //Turbi //dt.Locale = System.Globalization.CultureInfo.InvariantCulture; adap.Fill(dt); return(dt); } catch (MySql.Data.MySqlClient.MySqlException ex) { MessageBox.Show("Error : " + ex.Message, "Bancos", MessageBoxButtons.OK, MessageBoxIcon.Information); clsExceptionLog.LogError(ex, false); return(null); } catch (Exception ex) { MessageBox.Show("Error : " + ex.Message, "Bancos", MessageBoxButtons.OK, MessageBoxIcon.Information); clsExceptionLog.LogError(ex, false); return(null); } finally { } }
//retornas los permisos del usuario public static DataTable Permisos(string cusuario, string copcion) { try { DataTable dt = new DataTable(); clsProcesos con = new clsProcesos(); string constring = con.conectarConta(); if (constring == null) { constring = DispensarioMedico.clsConexion.ConectionString; } MySqlConnection objCon = new MySqlConnection(); objCon.ConnectionString = constring; objCon.Open(); string consulta = "SELECT * FROM PermisoUsuarios where usuario=+'" + cusuario.Trim() + "' and menu='" + copcion.Trim() + "' "; MySqlCommand comando = new MySqlCommand(consulta, objCon); MySqlDataAdapter adap = new MySqlDataAdapter(comando); //Turbi //dt.Locale = System.Globalization.CultureInfo.InvariantCulture; adap.Fill(dt); return(dt); } catch (MySql.Data.MySqlClient.MySqlException ex) { MessageBox.Show("Error : " + ex.Message, "Bancos", MessageBoxButtons.OK, MessageBoxIcon.Information); clsExceptionLog.LogError(ex, false); return(null); } catch (Exception ex) { MessageBox.Show("Error : " + ex.Message, "Bancos", MessageBoxButtons.OK, MessageBoxIcon.Information); clsExceptionLog.LogError(ex, false); return(null); } finally { } }