//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 = SisRePub.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 = SisRePub.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 { } }
//Funcion que busca los datos del Mayor General Detallado y Resumido public static DataTable MayorGeneral(string sqlstring) { try { DataTable dt = new DataTable(); clsProcesos con = new clsProcesos(); string constring = con.conectar(); MySqlConnection objCon = new MySqlConnection(); objCon.ConnectionString = constring; objCon.Open(); //string consulta = sqlstring; //MySqlCommand comando = new MySqlCommand(consulta, objCon); //MySqlDataAdapter adap = new MySqlDataAdapter(comando); //adap.SelectCommand.CommandType = CommandType.StoredProcedure; //string cCadena = @"Server=localhost;Database=GsiSoft;Uid=root; Pwd=*010405;"; MySqlDataAdapter oDataAdapter = new MySqlDataAdapter(); oDataAdapter.SelectCommand = new MySqlCommand(); oDataAdapter.SelectCommand.CommandText = sqlstring; oDataAdapter.SelectCommand.Connection = objCon; DataSet dsDatos = new DataSet(); // oDataAdapter.Fill(dsDatos); //return dsDatos; oDataAdapter.Fill(dt); return(dt); } catch (MySql.Data.MySqlClient.MySqlException ex) { MessageBox.Show("Error : " + ex.Message, "Bancos", MessageBoxButtons.OK, MessageBoxIcon.Information); // ExceptionLog.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 = SisRePub.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 { } }
//AUTOCOMPLE PARA CLIENTES //metodo para cargar los datos de la bd public static DataTable DatosClientes() { DataTable dt = new DataTable(); clsProcesos con = new clsProcesos(); string constring = con.conectar(); MySqlConnection objCon = new MySqlConnection(); objCon.ConnectionString = constring; objCon.Open(); string consulta = "SELECT * FROM empresas"; //consulta a la tabla paises MySqlCommand comando = new MySqlCommand(consulta, objCon); MySqlDataAdapter adap = new MySqlDataAdapter(comando); adap.Fill(dt); return(dt); }
//Metodo que Retorna la Empresa por Default public static string DatosEmpresa() { string empresa; try { //realiza a Procesos clsProcesos conF = new clsProcesos(); string constringF = conF.conectarConta(); MySqlConnection objConF = new MySqlConnection(); objConF.ConnectionString = constringF; objConF.Open(); //Consulta datos de la empresa string sqlF; sqlF = "select nom_empre from empre_mo "; MySqlCommand mycmPR = new MySqlCommand(); mycmPR.Connection = objConF; mycmPR.CommandText = sqlF; MySqlDataReader myreaderPR = mycmPR.ExecuteReader(); myreaderPR.Read(); empresa = myreaderPR.GetString(0).ToString(); return(empresa); } 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 { } }
//metodo para cargar los datos de la bd public static DataTable DatosGeneralEscalar(string tabla, string cExpresion) { try { DataTable dt = new DataTable(); clsProcesos con = new clsProcesos(); string constring = con.conectar(); MySql.Data.MySqlClient.MySqlConnection objCon = new MySqlConnection(); objCon.ConnectionString = constring; objCon.Open(); string consulta = "SELECT " + cExpresion + " As Retorno FROM " + tabla + " "; //consulta a la tabla paises 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, "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 { } }
public static DataTable EntradaFijas() { try { DataTable dt = new DataTable(); clsProcesos con = new clsProcesos(); string constring = con.conectarConta(); MySqlConnection objCon = new MySqlConnection(); objCon.ConnectionString = constring; objCon.Open(); string consulta = "SELECT * FROM EntradaFija"; MySqlCommand comando = new MySqlCommand(consulta, objCon); MySqlDataAdapter adap = new MySqlDataAdapter(comando); 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 { } }