Jump to content


Henrique Neto

Member Since 23/04/2009
Offline Last Active 12/06/2009, 13:02
-----

Posts I've Made

In Topic: Projeto C.

11/06/2009, 12:06

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
 
	  
 struct evento {
		  int id;
		  char nome[50];
		  char data[15];  
		  char datafim[15];
		  int qtdepart;
				
			 
		  }e;
		  
 struct participante {
		   int idparticipante;
		   char nome[50];
		   char cpf[20];
		   float rg;
	}p;

 struct palestra {
		  int idpalestra;
		  char nome[50];
		  char palestrante[50];
		  char data[15];
		  char hora[8];
		  int idevento;
		  
	}pa;
  



void menuPrincipal();
void CadastrarEvento();
void CadastrarPalestra();
void CadastrarParticipante();
void VisualizarEvento();
void VisualizarPalestra();
void VisualizarParticipante();
void deletaEvento();
void deletaParticipante();
void deletaPalestra();
void SairPrograma();

 
int main() {
	int contadorparti=0;
	
	menuPrincipal();
	getch();
	return 1;   
	system("pause");
	system("cls"); 
}






void menuPrincipal() {
	 char opcao; 
	 int saida = 1;
	 
	 
	 do {
	   printf("\n============================== MENU PRINCIPAL =============================\n");
		
		printf("\n	  1:Cadastrar Evento");
		printf("\n	  2:Cadastrar Palestra");
		printf("\n	  3:Cadastrar Participante");
		printf("\n	  4:Visualizar Evento");
		printf("\n	  5:Visualizar Palestra");
		printf("\n	  6:Visualizar Participante");
		printf("\n	  7:Deletar Evento");
		printf("\n	  8:Deletar Participante");
		printf("\n	  9:Deletar Palestra");
		printf("\n	  0:Sair do Programa\n\n");
		printf("\n	  Digite Uma Opcao: ");
	   
		opcao = getch();
		switch(opcao) {
						case '1':
						  CadastrarEvento();
						  break;
						  
						case '2':
						  CadastrarPalestra();
						  break;
						  
						 case '3':
						   CadastrarParticipante();
						   break;
							
						 case '4':
						   VisualizarEvento();
						   break;
						   
						 case '5':
						   VisualizarPalestra();
						   break;
						 
						 case '6':
						   VisualizarParticipante();
						   break;
													
						 case '7':
						   deletaEvento();
						   break;

						 case '8':
						   deletaParticipante();
						   break;
						 
						 case '9':
						   deletaPalestra();
						   break;
						   
						 
						 case '0':
						   SairPrograma();
						   break;
								
						 default: 
						   printf("\n\n\tOpcao Invalida, Tente Novamente!\n\n");
						   system("pause");
						   system("cls");
						   menuPrincipal();
						   break;   
						  }
	
	  } while (saida);
   
	  
}

// ============ FUNCOES DE CADASTRO!!!!!! =======================

 void CadastrarEvento() {
	 char confirmar;
	
	 FILE *arq;
   
	 printf("\n===========================  CADASTRAR EVENTO  =================================\n");
	 
	 fflush(stdin);
	 printf("\nId do Evento: ");
	 scanf("%d",&e.id);   
		  
	 fflush(stdin);
	 printf("\nNome do Evento: ");
	 gets(e.nome);
	 
	 fflush(stdin);
	 printf("\nQuantidade maxima de Participantes: ");
	 scanf("%d",&e.qtdepart);
	 
	 fflush(stdin);
	 printf("\nData do Evento Inicial <dd/mm/aaaa>: ");
	 gets(e.data);
	 
	 fflush(stdin);
	 printf("\nData do Final do Evento <dd/mm/aaaa>: ");
	 gets(e.datafim);
	  if (strcmp(e.data, e.datafim)) 
		printf("\n*Obs: O Evento Terminara em: %s", e.datafim);
		 else 
		printf("\n*Obs: O Evento Termina no Mesmo Dia");
		  
		  
	 fflush(stdin);
	   do {
		 printf("\n\nDeseja Confirmar o cadastro do Evento[s\\n]: ");
		 confirmar = getche();		 
	 } while ((confirmar != 's') && (confirmar != 'n'));
	
	 if (confirmar == 's') {
		arq = fopen("evento.txt", "w");
		if (!arq) {
		   printf("Error 432423.");
		} else {
		   fwrite(&e, sizeof(e), 1, arq);
		   fclose(arq);  
		  
		}			 
	 }  
 }


 void CadastrarParticipante() {
	 char confirmar;
	
	 FILE *arq;
	 printf("\n\n=========================  CADASTRAR PARTICIPANTE  ==========================\n");
	 
	 fflush(stdin);
	 printf("\nId do Participante: ");
	 scanf("%d",&p.idparticipante);   
	
	 
	 fflush(stdin);
	 printf("\nNome do Participante: ");
	 gets(p.nome);
	 
	 fflush(stdin);
	 printf("\nCPF: ");
	 gets(p.cpf);
	 
	 fflush(stdin);
	 printf("\nRG: ");
	 scanf("%f",&p.rg);
	 
	 fflush(stdin);
	 do {
		 printf("\n\nDeseja Confirmar o cadastro do Participante[s\\n]: ");
		 confirmar = getche();		 
	 } while ((confirmar != 's') && (confirmar != 'n'));
	
	 if (confirmar == 's') {
		arq = fopen("part.txt", "w");
		if (!arq) {
		   printf("Error 432423.");
		} else {
		   fwrite(&p, sizeof(p), 1, arq);
		   fclose(arq);  
		  
		}			 
	 }  
	 
	 
 }
 
 
 void CadastrarPalestra() {
	 char confirmar,confipalestra;
	 FILE *arq,*ler;
	 int i;
	
	 {
	 printf("\n\n========================  CADASTRAR PALESTRA  ===============================\n");
	 
	 fflush(stdin);
	 printf("\nId do Evento: ");
	 scanf("%d",&pa.idevento); 
	 
	//ler = fopen("palestra.txt","rb"); 
	 
	//fread(&e.id, sizeof(e.id), 1, ler);
	
  if (pa.idevento == e.id) {
				   printf("Evento Existe ... \n\n!");
				  } 
	 else  { 
		   printf("Evento nao Existe");
			CadastrarPalestra();  
		   }
	 
	 fflush(stdin);
	 printf("\nId da Palestra: ");
	 scanf("%d",&pa.idpalestra);   
	
	 
	 fflush(stdin);
	 printf("\nNome do Palestra: ");
	 gets(pa.nome);
	 
	 fflush(stdin);
	 printf("\nNome do Palestrante: ");
	 gets(pa.palestrante);
	 
	 fflush(stdin);
	 printf("\nData da Palestra <dd/mm/aaaa>: ");
	 gets(pa.data);
	 
	 
	 fflush(stdin);
	 printf("\nHora da Palestra: ");
	 gets(pa.hora);
  
	
  
	 
	 fflush(stdin);
	 do {
		 printf("\n\nDeseja Confirmar o Cadastro da Palestra[s\\n]: ");
		 confirmar = getche();		 
	 } while ((confirmar != 's') && (confirmar != 'n'));
	
	 if (confirmar == 's') {
		arq = fopen("palestra.txt", "w");
		   if (!arq) {
		   printf("Error 432423.");
		} else {
		   fwrite(&pa, sizeof(pa), 1, arq);
		   fclose(arq);  
		  
		}			 
	 }  
	 
	   
	 } 
}   
	 
	 
	 
// ============ FUNCOES DE VISUALIZAR!!!!!! =======================
 
 void VisualizarEvento() {
	  
  FILE *arq;
  FILE *temp;
	 arq= fopen ("evento.txt", "r");
	
	 if (! arq )
	 printf ("\n\nErro ao abrir arquivo !");
	 
   else{

	 printf ("\n\n========================  VISUALIZAR EVENTO  ===============================\n");
	
	 do{
	 /* o dado é lido e armazenado na estrutura */
	 fread (&e , sizeof (e), 1, arq );
	 printf ("\nId: %d", e.id );
	 printf ("\nNome: %s", e.nome );
	 printf ("\nData Inicio: %s", e.data );
	 printf ("\nData Fim: %s", e.datafim );
	 printf ("\nQuantidade Participantes: %d\n\n", e.qtdepart );
	 
	 if (!feof(arq)) break;
	 }while (!feof(arq));
	 fclose (arq);
   }
}


 void VisualizarPalestra() {
	  int i;
	  FILE *arq;
	  
  
	 arq= fopen ("palestra.txt", "r");
	
	 if (! arq )
	 printf ("Erro ao abrir arquivo !");
   else{

	 printf ("\n========================VISUALIZAR PALESTRA===============================\n");
	
	
	 do{
	 /* o dado é lido e armazenado na estrutura */
	 fread (&pa , sizeof (pa), 1, arq );
	 printf ("\nId Palestra: %d", pa.idpalestra );
	 printf ("\nNome: %s", pa.nome );
	 printf ("\nData Inicio: %s", pa.palestrante );
	 printf ("\nData Fim: %s", pa.data );
	 printf ("\nHora: %d", pa.hora );
	 printf ("\nEvento: %d\n\n", pa.idevento);
	 if (!feof(arq)) break;
	 } while (!feof(arq));
	 fclose (arq);
   
 }
}

 void VisualizarParticipante() {
	 FILE *arq;
  
	 arq= fopen ("part.txt", "r");
	
	 if (! arq )
	 printf ("Erro ao abrir arquivo !");
   else{

	 printf ("\n========================VISUALIZAR PARTICIPANTE=========================\n");
	
	
	 do{
	 /* o dado é lido e armazenado na estrutura */
	 fread (&p , sizeof (p), 1, arq );
	 printf ("\nId Participante: %d", p.idparticipante );
	 printf ("\nNome: %s", p.nome );
	 printf ("\nCPF: %s", p.cpf );
	 printf ("\nRG: %f", p.rg );
	 if (!feof(arq)) break;
	 } while (!feof(arq));
	 fclose (arq);
   
 }
}

// ============ FUNCOES DE REMOVER!!!!!! =======================



  void deletaEvento() {
   
   FILE *arq, *aux; 
	 arq = fopen("evento.txt", "rb"); 
	 aux = fopen("aux.txt", "w");
		int dado, excluir;
			  printf("Dado a ser Excluido:");
			  scanf("%d",&excluir);
					fread(&e, sizeof(e), 1, arq); //ler do arquivo o primeiro dado
		   while (!feof(arq)) 
				{
					if (e.id != excluir) //if o dado a ser excluído for diferente do dado que vc leu, então...
				{
						fwrite(&e, sizeof(e), 1, aux); 
						fread(&e, sizeof(e), 1, arq); 
			   }
					fclose(arq); 
					fclose(aux);
					remove("evento.txt"); 
					rename("aux.txt", "evento.txt"); //renomeia arq para aux
			   }

   

}
	   
 

void deletaPalestra() {
   
   FILE *arq, *aux; 
	 arq = fopen("palestra.txt", "rb"); 
	 aux = fopen("aux.txt", "ab");
	 int excluir;
			  printf("Dado a ser Excluido:");
			  scanf("%d",&excluir);
					fread(&pa, sizeof(pa), 1, arq); 
		   while (!feof(arq)) 
				{
					if (pa.idpalestra != excluir) 
				{
						fwrite(&pa, sizeof(pa), 1, aux); 
						fread(&pa, sizeof(pa), 1, arq); 
				}
					fclose(arq); 
					fclose(aux);
					remove("palestra.txt"); 
					rename("aux.txt", "palestra.txt"); 
				}

}


void deletaParticipante() {
   
   FILE *arq, *aux; 
	 arq = fopen("part.txt", "rb"); 
	 aux = fopen("aux.txt", "ab");
	 int excluir;
			  printf("Dado a ser Excluido:");
			  scanf("%d",&excluir);
					fread(&p, sizeof(p), 1, arq); 
		   while (!feof(arq)) 
				{
					if (p.idparticipante != excluir) 
				{
						fwrite(&p, sizeof(p), 1, aux); 
						fread(&p, sizeof(p), 1, arq); 
			   }
					fclose(arq); 
					fclose(aux);
					remove("part.txt"); 
					rename("aux.txt", "part.txt"); 
			   }

}



// ============ SAIR DO PROGRAMA!!!!!! =======================

  void SairPrograma() {
	   
  printf("\n\n\n\n\t\tObrigado... E volte sempre!");
  getch();
  exit(0);
}



Nao to conseguindo remover o evento, digito o id selecionado para remover e nao consigo, eu so queria remover akele id e nao toda a estrutura :S

help me

In Topic: Wamp5

31/05/2009, 23:59

win vista ? se for passou pelo mesmo problema q eu desinstale o anti virus q tem e instale o wamp em seguida depois pode instalar o anti d novo
e curta o mysql.

In Topic: Where No Select

11/05/2009, 11:17

vlw brigado

In Topic: Inserindo Dados No Mysql

30/04/2009, 12:30

[codebox]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<?php
include("sessao.php");
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<style type="text/css" media="screen">
@import url("../css/Parte2.css");
</style>
<link href="../css/Parte2.css" rel="stylesheet" type="text/css" />
</head>

<body>

<form action="cadasseriado.php" method="post" enctype="multipart/form-data" id="iframecentro">
<div align="center"><a href="index.php">Pagina inicial </a> <br />


</div>
<div id="div1">
<p><br />
Nome:
<input type="text" size="40px" name="nome" />
<br />
<br />
Descri&ccedil;&atilde;o:
<input type="text" size="50px" name="descricao" />
<br />
<br />
Imagem:
<input type="file" name="imagem" />
Tamanho:
<input type="text" size="10px" name="tamanho" />
<br />
<br />
Formato:
<input type="text" size="10px" name="formato" />
Audio:
<input type="text" size="10px" name="audio" />
<br />
<br />
Legenda:
<input type="text" size="10px" name="legenda" />
<br />
<br />
<input type="submit" value="Cadastrar" name="Cadastrar" />
</p>
</div>

</form>


</body>
</html>
[/codebox]

sim rafael, pelo menos q eu saiba. tipagem?
desculpa pois sou novo.

e o banco de dados dele

create table seriado (
nome char(50) NOT NULL,
img char(128) NULL,
tamanho float NOT NULL,
formato char(10) NOT NULL,
audio char (20) NOT NULL,
legenda char(10) NOT NULL,
descricao char(50) NOT NULL );

....

In Topic: Autenticacao No Sistema.

28/04/2009, 22:04

brigado fabio_rj
resolvido
hehe

IPB Skin By Virteq