public static void AbrirConexion() { try { conexion = new MySqlConnection(); conexion.ConnectionString = "Server=localhost;" + "Database=sis_supermercado;" + "Uid=root;" + "Pwd=;"; conexion.Open(); } catch (MySqlException ex) { MensajeDeError frmError = new MensajeDeError(); frmError.labelerrro.Text = "MYSQL ERROR"; frmError.ShowDialog(); //MessageBox.Show(ex.Message); } }
public void InicioDeSesion_db_usuarios(string condicion) { string sql; string passEncrip; passEncrip = Usuarios.Encriptar.EncryptData(txtpass.Text, txtusuario.Text); //MySqlCommand comando; sql = "select * from db_usuarios where usuario = '" + txtusuario.Text + "' and password = '******'" + condicion; MySqlCommand comando; MySqlDataAdapter consulta = new MySqlDataAdapter(); DataSet resultado = new DataSet(); try { modulo.AbrirConexion(); consulta = new MySqlDataAdapter(sql, modulo.conexion); consulta.Fill(resultado, "rsProveedor"); string TipoDeAcceso; comando = new MySqlCommand(sql, modulo.conexion); MySqlDataReader leer = comando.ExecuteReader(); if (leer.HasRows) { while (leer.Read()) { TipoDeAcceso = Convert.ToString(resultado.Tables["rsProveedor"].Rows[0]["Accesos"]); EstadoActivoVariable = Convert.ToString(resultado.Tables["rsProveedor"].Rows[0]["id"]); if (TipoDeAcceso == "ADMINISTRADOR") { FrmMenuPrincipal3 menu = new FrmMenuPrincipal3(txtusuario.Text.ToUpperInvariant()); menu.Show(); this.Hide(); } else if (TipoDeAcceso == "VENDEDOR") { FrmNuevoProductos nuevoproducto = new FrmNuevoProductos(); FrmMenuPrincipal3 menu = new FrmMenuPrincipal3(txtusuario.Text.ToUpperInvariant()); menu.Show(); menu.btnUsuarios.Enabled = false; nuevoproducto.txtCosto.Enabled = false; this.Hide(); } else if (TipoDeAcceso == "CAJERO") { FrmMenuPrincipal3 menu = new FrmMenuPrincipal3(txtusuario.Text.ToUpperInvariant()); menu.Show(); menu.btnReportes.Enabled = false; menu.btnReportes.Enabled = false; this.Hide(); } } } else { MensajeDeError show = new MensajeDeError(); show.ShowDialog(); } } catch (MySqlException ex) { MessageBox.Show(ex.Message); } }