Está en la página 1de 27

//El pasword para las opciones de la 1 a la 5 es: "sistemas" o "SISTEMAS"

#include<conio.h>
#include<stdio.h>
#include<ctype.h>
#include<iostream.h>
#include<stdlib.h>
struct alumnos
{
int clave;
char nombre[25];
int cvemaes;
int semestre;
int graduado;
char pasa;
int nummat;
}dat_alu;
struct profesores
{
int clave;
char nombre[25];
int cvemat;
}dat_maes;
struct materias
{
int clave;
char nombre[15];
int creditos;
int semestre;
int cvemaes;
}dat_mat;
struct mat_asig
{
int cvealu;
int cvemat;
}dat_asig;
void
void
void
void
void
void

altas_alu();
reportes_alu();
consultas_alu();
cambios_alu();
titulos_alu();
bajas_alu();

void
void
void
void
void
void

altas_maes();
reportes_maes();
consultas_maes();
cambios_maes();
titulos_maes();
bajas_maes();

void
void
void
void
void

altas_mat();
reportes_mat();
consultas_mat();
cambios_mat();
titulos_mat();

void bajas_mat();
void pasaalu_cs3();
void pasaalu_cs4();
void inscrip();
//void reportes_matasig();
int password();
void
void
void
void

menualu();
menumaes();
menumat();
menupri();

void main()
{
textcolor(10);
menupri();
}
void menupri()
{
clrscr();
char i,d,opc;
do
{
clrscr();
gotoxy(17,3); cout<<"M E N U P R I N C I P A L
";
gotoxy(20,5);cout<<"1. Alumnos";
gotoxy(20,6);cout<<"2. Profesores";
gotoxy(20,7);cout<<"3. Materias";
gotoxy(20,8);cout<<"4. lista CS3";
gotoxy(20,9);cout<<"5. Lista CS4";
gotoxy(20,10);cout<<"6. Inscripcion";
gotoxy(20,11);cout<<"7. Salir";
gotoxy(22,13);cout<<"Opcion: ";
opc=toupper(getche());
switch(opc)
{
case '1':if(password()=
=1)
menualu();break;
case '2':if(password()=
=1)
menumaes();break;
case '3':if(password()=
=1)
menumat();break;
case '4':if(password()=
=1)
pasaalu_cs3();break;
case '5':if(password()=
=1)
pasaalu_cs4();break;
case '6':inscrip(); bre

ak;
}
}while (opc!='7');
}
void menualu()
{
clrscr();
char i,d,opc;
do
{
clrscr();
gotoxy(17,3); cout<<"M E N U A L U M N O S";
gotoxy(20,5);cout<<"1. Altas";
gotoxy(20,6);cout<<"2. Bajas";
gotoxy(20,7);cout<<"3. Cambios";
gotoxy(20,8);cout<<"4. Consultas";
gotoxy(20,9);cout<<"5. Reportes";
gotoxy(20,10);cout<<"6. Salir";
gotoxy(22,12);cout<<"Opcion: ";
opc=toupper(getche());
switch(opc)
{
case '1':altas_alu();br
eak;
case '2':bajas_alu();br
eak;
case '3':cambios_alu();
break;
case '4':consultas_alu(
);break;
case '5':reportes_alu()
;break;
}
}while (opc!='6');
}
void titulos()
{
gotoxy(15,5);cout<<"1. Clave...............:";
gotoxy(15,7);cout<<"2. Nombre..............:";
gotoxy(15,9);cout<<"3. Semestre............:";
gotoxy(15,11);cout<<"4. Profesor Adjunto....:";
}
void altas_alu()
{
FILE *arch, *busca;
clrscr();
char opc;
int encontrado,m_num;
arch=fopen("dat_alu.dat","ab");
busca=fopen("dat_alu.dat","rb");
gotoxy(15,2);cout<<" A L T A S ";
titulos();
gotoxy(40,5); cin>>m_num;

encontrado=0;
rewind(busca);
fread(&dat_alu,sizeof(struct alumnos),1,busca);
while (!feof(busca))
{
if (m_num==dat_alu.clave)
{
encontrado = 1;
titulos();
gotoxy(40,5);cout<<dat_alu.clave;
gotoxy(40,7);cout<<dat_alu.nombre;
gotoxy(40,9);cout<<dat_alu.semestre;
gotoxy(40,11);cout<<dat_alu.cvemaes;
gotoxy(20,20);clreol;
gotoxy(20,20);cout<<"La clave ya esta dada de Al
ta";
getche();
}
fread(&dat_alu,sizeof(struct alumnos),1,busca);
}
if (encontrado==0)
{
dat_alu.clave=m_num;
gotoxy(40,7);gets(dat_alu.nombre);
if (dat_alu.nombre == " ")
{
gotoxy(40,7);gets(dat_alu.nombre);
}
gotoxy(40,9);cin>>dat_alu.semestre;
gotoxy(40,11);cin>>dat_alu.cvemaes;
fwrite(&dat_alu,sizeof(dat_alu),1,arch);
}
fclose(arch);
fclose(busca);
}
void consultas_alu()
{
int m_num,encontrado;
char ok;
FILE *arch;
arch=fopen("dat_alu.dat","rb");
do
{
clrscr();
encontrado=0;
rewind(arch);
gotoxy(20,2);cout<<" C O N S U L T A S ";
gotoxy(15,5);cout<<"clave: ";
cin>>m_num;
fread(&dat_alu,sizeof(struct alumnos),1,arch);
while (!feof(arch))
{
if (m_num==dat_alu.clav
e)
{
encontrado = 1;

titulos();
gotoxy(40,5);cout<<dat_alu.clave;
gotoxy(40,7);cout<<dat_alu.nombre;
gotoxy(40,9);cout<<dat_alu.semestre;
gotoxy(40,11);cout<<dat_alu.cvemaes;
}
fread(&dat_alu,sizeof(s
truct alumnos),1,arch);
}
if (encontrado==0)
{
gotoxy(20,20);clreol;
gotoxy(20,20);cout<<"La
clave no esta dada de Alta";
getche();
}
gotoxy(20,20);clreol;
gotoxy(20,20);cout<<"Deseas consultar otro regi
stro [S/N]";
ok=toupper(getche());
}while (ok!='N');
fclose(arch);
}
void cambios_alu()
{
int m_num,modi,n_mod;
long int pos;
char ok;
FILE *arch;
arch=fopen("dat_alu.dat","rb+");
do
{
clrscr();
rewind(arch);
gotoxy(20,2);cout<<"C A M B I O S";
gotoxy(15,5);cout<<"clave: ";
cin>>m_num;
fread(&dat_alu,sizeof(struct alumnos),1,arch);
modi=0;
while (!feof(arch))
{
if (m_num==dat_alu.clav
e)
{
titulos();
gotoxy(40,5);cout<<dat_alu.clave;
gotoxy(40,7);cout<<dat_alu.nombre;
gotoxy(40,9);cout<<dat_alu.semestre;
gotoxy(40,11);cout<<dat_alu.cvemaes;

do
{
gotoxy(15,20);clreol();
gotoxy(15,20);cout<<"teclea numero para cambiar [0 para terminar]: ";
cin>>n_mod;
gotoxy(15,20);clreol();
switch (n_mod)
{
case 2:gotoxy(40,7);gets(dat_alu.nombre);break;
case 3:gotoxy(40,9);cin>>dat_alu.semestre;break;
case 4:gotoxy(40,11);cin>>dat_alu.cvemaes;break;
}
}while (n_mod != 0);
pos=ftell(arch);
fseek(arch,pos-(sizeof(struct alumnos)),SEEK_SET);
fwrite(&dat_alu,sizeof(struct alumnos),1,arch);
if (modi != 0)
{
gotoxy(20,20);clreol();
gotoxy(20,20);cout<<"Se han guardado los Cambios";
getche();
}
}
fread(&dat_alu,sizeof(s
truct alumnos),1,arch);
}
gotoxy(20,20);clreol;
gotoxy(20,20);cout<<"Deseas cambiar otro regist
ro [S/N]";
ok=toupper(getche());
} while(ok!='N');
fclose(arch);
}
void bajas_alu()
{
int m_num,n_mod;
char modi;
long int pos;

char ok;
FILE *arch;
arch=fopen("dat_alu.dat","rb+");
do
{
clrscr();
rewind(arch);
gotoxy(20,2);cout<<" B A J A S";
gotoxy(15,5);cout<<"clave: ";
cin>>m_num;
fread(&dat_alu,sizeof(struct alumnos),1,arch);
modi=' ';
while (!feof(arch))
{
if (m_num==dat_alu.clav
e)
{
titulos();
gotoxy(40,5);cout<<dat_alu.clave;
gotoxy(40,7);cout<<dat_alu.nombre;
gotoxy(40,9);cout<<dat_alu.semestre;
gotoxy(40,11);cout<<dat_alu.cvemaes;
gotoxy(20,20);cout<<"ESTA SEGURO QUE DESEA ELIMINAR EL REGISTRO[S/N] ";
modi = toupper(getch());
if (modi == 'S')
{
dat_alu.clave = -99;
pos=ftell(arch);
fseek(arch,pos-(sizeof(struct alumnos)),SEEK_SET);
fwrite(&dat_alu,sizeof(struct alumnos),1,arch);
gotoxy(20,20);clreol();
gotoxy(20,20);cout<<"Registro Eliminado";
getche();
}
}
fread(&dat_alu,sizeof(s
truct alumnos),1,arch);
}
gotoxy(20,20);clreol;
gotoxy(20,20);cout<<"Deseas eliminar otro regis
tro[S/N]";
ok=toupper(getche());
} while(ok!='N');

fclose(arch);
}
void reportes_alu()
{
clrscr();
int r;
FILE *arch;
arch=fopen("dat_alu.dat","rb");
if (arch==NULL)
{
gotoxy(20,20);cout<<"El archivo esta Vacio";
getche();
}
else
{
r=6;
gotoxy(20,2);cout<<" R E P O R T E S ";
gotoxy(3,4);cout<<"CLAVE NOMBRE
SEMESTRE CVE. MAESTRO
pasa";
while (!feof(arch))
{
fread(&dat_alu,sizeof(s
truct alumnos),1,arch);
if (!feof(arch))
{
if (dat_alu.clave!= -99)
{
gotoxy(3,r);cout<<dat_alu.clave;
gotoxy(9,r);cout<<dat_alu.nombre;
gotoxy(35,r);cout<<dat_alu.semestre;
gotoxy(47,r);cout<<dat_alu.cvemaes;
gotoxy(60,r);cout<<dat_alu.pasa;
r++;
}
}
}
gotoxy(20,20);cout<<"Presiona una tecla para co
ntinuar";
getch();
}
}

/************************************************************************
************************ M A E S T R O S ********************************
*************************************************************************/
void titumaes()
{
gotoxy(15,5);cout<<"1. Clave...............:";

gotoxy(15,7);cout<<"2. Nombre..............:";
}
void menumaes()
{
clrscr();
char i,d,opc;
do
{
clrscr();
gotoxy(17,3); cout<<"M E N U M A E S T R O S";
gotoxy(20,5);cout<<"1. Altas";
gotoxy(20,6);cout<<"2. Bajas";
gotoxy(20,7);cout<<"3. Cambios";
gotoxy(20,8);cout<<"4. Consultas";
gotoxy(20,9);cout<<"5. Reportes";
gotoxy(20,10);cout<<"6. Salir";
gotoxy(22,12);cout<<"Opcion: ";
opc=toupper(getche());
switch(opc)
{
case '1':altas_maes();b
reak;
case '2':bajas_maes();b
reak;
case '3':cambios_maes()
;break;
case '4':consultas_maes
();break;
case '5':reportes_maes(
);break;
}
}while (opc!='6');
}
void altas_maes()
{
FILE *arch, *busca;
clrscr();
char opc;
int encontrado,m_num;
arch=fopen("dat_maes.dat","ab");
busca=fopen("dat_maes.dat","rb");
gotoxy(15,2);cout<<" A L T A S ";
titumaes();
gotoxy(40,5); cin>>m_num;
encontrado=0;
rewind(busca);
while (!feof(busca))
{
if (m_num==dat_maes.clave)
{
encontrado = 1;
titumaes();
gotoxy(40,5);cout<<dat_maes.clave;
gotoxy(40,7);cout<<dat_maes.nombre;
gotoxy(20,20);clreol;
gotoxy(20,20);cout<<"La clave ya esta dada de Al
ta";

getche();
}
fread(&dat_maes,sizeof(struct profesores),1,busca);
}
if (encontrado==0)
{
dat_maes.clave=m_num;
gotoxy(40,7);gets(dat_maes.nombre);
if (dat_maes.nombre == " ")
{
gotoxy(40,7);gets(dat_maes.nombre);
}
fwrite(&dat_maes,sizeof(dat_maes),1,arch);
}
fclose(arch);
fclose(busca);
}
void consultas_maes()
{
int m_num,encontrado;
char ok;
FILE *arch;
arch=fopen("dat_maes.dat","rb");
do
{
clrscr();
encontrado=0;
rewind(arch);
gotoxy(20,2);cout<<" C O N S U L T A S ";
gotoxy(15,5);cout<<"clave: ";
cin>>m_num;
fread(&dat_maes,sizeof(struct profesores),1,arc
h);
while (!feof(arch))
{
if (m_num==dat_maes.cla
ve)
{
encontrado = 1;
titumaes();
gotoxy(40,5);cout<<dat_maes.clave;
gotoxy(40,7);cout<<dat_maes.nombre;
}
fread(&dat_maes,sizeof(
struct profesores),1,arch);
}
if (encontrado==0)
{
gotoxy(20,20);clreol;
gotoxy(20,20);cout<<"La
clave no esta dada de Alta";
getche();
}
gotoxy(20,20);clreol;

gotoxy(20,20);cout<<"Deseas consultar otro regi


stro [S/N]";
ok=toupper(getche());
}while (ok!='N');
fclose(arch);
}
void cambios_maes()
{
int m_num,modi,n_mod;
long int pos;
char ok;
FILE *arch;
arch=fopen("dat_maes.dat","rb+");
do
{
clrscr();
rewind(arch);
gotoxy(20,2);cout<<"C A M B I O S";
gotoxy(15,5);cout<<"clave: ";
cin>>m_num;
fread(&dat_maes,sizeof(struct profesores),1,arc
h);
modi=0;
while (!feof(arch))
{
if (m_num==dat_maes.cla
ve)
{
titumaes();
gotoxy(40,5);cout<<dat_maes.clave;
gotoxy(40,7);cout<<dat_maes.nombre;
do
{
gotoxy(15,20);clreol();
gotoxy(15,20);cout<<"teclea numero para cambiar [0 para terminar]: ";
cin>>n_mod;
gotoxy(15,20);clreol();
switch (n_mod)
{
case 2:gotoxy(40,7);gets(dat_maes.nombre);
gets(dat_maes.nombre);modi= 1; break;
}
}while (n_mod != 0);

pos=ftell(arch);
fseek(arch,pos-(sizeof(struct profesores)),SEEK_SET);
fwrite(&dat_maes,sizeof(struct profesores),1,arch);
if (modi != 0)
{
gotoxy(20,20);clreol();
gotoxy(20,20);cout<<"Se han guardado los Cambios";
getche();
}
}
fread(&dat_maes,sizeof(
struct profesores),1,arch);
}
gotoxy(20,20);clreol;
gotoxy(20,20);cout<<"Deseas cambiar otro regist
ro [S/N]";
ok=toupper(getche());
} while(ok!='N');
fclose(arch);
}
void bajas_maes()
{
int m_num,n_mod;
char modi;
long int pos;
char ok;
FILE *arch;
arch=fopen("dat_maes.dat","rb+");
do
{
clrscr();
rewind(arch);
gotoxy(20,2);cout<<" B A J A S";
gotoxy(15,5);cout<<"clave: ";
cin>>m_num;
fread(&dat_maes,sizeof(struct profesores),1,arc
h);
modi=' ';
while (!feof(arch))
{
if (m_num==dat_maes.cla
ve)
{
titumaes();
gotoxy(40,5);cout<<dat_maes.clave;
gotoxy(40,7);cout<<dat_maes.nombre;
gotoxy(20,20);cout<<"ESTA SEGURO QUE DESEA ELIMINAR EL REGISTRO[S/N] ";

modi = toupper(getch());
if (modi == 'S')
{
dat_maes.clave = -99;
pos=ftell(arch);
fseek(arch,pos-(sizeof(struct profesores)),SEEK_SET);
fwrite(&dat_maes,sizeof(struct profesores),1,arch);
gotoxy(20,20);clreol();
gotoxy(20,20);cout<<"Registro Eliminado";
getche();
}
}
fread(&dat_maes,sizeof(
struct profesores),1,arch);
}
gotoxy(20,20);clreol;
gotoxy(20,20);cout<<"Deseas eliminar otro regis
tro[S/N]";
ok=toupper(getche());
} while(ok!='N');
fclose(arch);
}
void reportes_maes()
{
clrscr();
int r;
FILE *arch;
arch=fopen("dat_maes.dat","rb");
if (arch==NULL)
{
gotoxy(20,20);cout<<"El archivo esta Vacio";
getche();
}
else
{
r=6;
gotoxy(20,2);cout<<" R E P O R T E S ";
gotoxy(3,4);cout<<"CLAVE
NOMBRE";
while (!feof(arch))
{
fread(&dat_maes,sizeof(
struct profesores),1,arch);
if (!feof(arch))
{
if (dat_maes.clave!= -99)
{

gotoxy(3,r);cout<<dat_maes.clave;
gotoxy(9,r);cout<<dat_maes.nombre;
r++;
}
}
}
gotoxy(20,20);cout<<"Presiona una tecla para co
ntinuar";
getch();
}
}
/************************************************************************
*************** G E N E R A D O R D E L I S T A S *******************
*************************************************************************/
void pasaalu_cs3()
{
int cvm,encontrado;
long int pos;
char ok;
FILE *alum, *maes, *buscalu;
alum=fopen("dat_alu.dat","rb+");
maes=fopen("dat_maes.dat","rb");
rewind(maes);
clrscr();
gotoxy(15,5);cout<<"Clave del profesor: ";cin>>cvm;
encontrado=0;
fread(&dat_maes,sizeof(struct profesores),1,maes);
while (!feof(maes))
{
if(dat_maes.clave==cvm)
{
encontrado=1;
clrscr();
gotoxy(5,2);cout<<"Clave del profesor: ";cout<<c
vm; cout<<"
Nombre: ";cout<<dat_maes.nombre;
gotoxy(1,3);cout<<"-----------------------------------------------------------------";
rewind(alum);
fread(&dat_alu,sizeof(struct alumnos),1,alum);
while (!feof(alum))
{
if ((dat_alu.cvemaes==cvm)/*&&(d
at_alu.clave!=-99)*/)
{
titulos();
gotoxy(40,5);clreol();co
ut<<dat_alu.clave;
gotoxy(40,7);clreol();co
ut<<dat_alu.nombre;
gotoxy(40,9);clreol();co
ut<<dat_alu.semestre;
gotoxy(40,11);clreol();c
out<<dat_alu.cvemaes;

gotoxy(30,15);clreol();
gotoxy(20,20);clreol();
do
{
gotoxy(30,13);cl
reol();cout<<"Este alumno pasa de semestre?[s/n]";
ok=toupper(getch
e());
}
while ((ok!='S') && (ok!
='N'));
if (ok=='S')
{
dat_alu.semestre
= dat_alu.semestre + 1;
dat_alu.pasa = '
S';
gotoxy(30,15);co
ut<<"Ahora este alumno esta en ";cout<<dat_alu.semestre;cout<<" semestre";
gotoxy(20,20);co
ut<<"Presione enter para continuar con el siguiente estudiante";
getch();
}
pos=ftell(alum);
fseek(alum,pos-(sizeof(s
truct alumnos)),SEEK_SET);
fwrite(&dat_alu,sizeof(s
truct alumnos),1,alum);
}
fseek(alum,pos,0);
fread(&dat_alu,sizeof(struct alu
mnos),1,alum);
}
fclose(alum);
}
fread(&dat_maes,sizeof(struct profesores),1,maes);
}
fclose(maes);
if (encontrado==0)
{
gotoxy(20,20);cout<<"El profesor no esta dado de alta";
getch();
}
}
void pasaalu_cs4()
{
int cvm,encontrado;
long int pos;
char ok;
FILE *alum, *maes;
alum=fopen("dat_alu.dat","rb+");
maes=fopen("dat_maes.dat","rb");
rewind(maes);
clrscr();
gotoxy(15,5);cout<<"Clave del profesor: ";cin>>cvm;
encontrado=0;

fread(&dat_maes,sizeof(struct profesores),1,maes);
while (!feof(maes))
{
if(dat_maes.clave==cvm)
{
encontrado=1;
clrscr();
gotoxy(5,2);cout<<"Clave del profesor: ";cout<<c
vm; cout<<"
Nombre: ";cout<<dat_maes.nombre;
gotoxy(1,3);cout<<"-----------------------------------------------------------------";
rewind(alum);
fread(&dat_alu,sizeof(struct alumnos),1,alum);
pos=1;
while (!feof(alum))
{
if ((dat_alu.cvemaes==cvm)&&(dat
_alu.pasa=='S'))
{
titulos();
gotoxy(40,5);clreol();co
ut<<dat_alu.clave;
gotoxy(40,7);clreol();co
ut<<dat_alu.nombre;
gotoxy(40,9);clreol();co
ut<<dat_alu.semestre;
gotoxy(40,11);clreol();c
out<<dat_alu.cvemaes;
gotoxy(30,15);clreol();
gotoxy(20,20);clreol();
do
{
gotoxy(30,13);cl
reol();cout<<"Este alumno se queda en este semestre?[s/n]";
ok=toupper(getch
e());
}
while ((ok!='S') && (ok!
='N'));
if (ok=='N')
{
dat_alu.semestre
= dat_alu.semestre - 1;
dat_alu.pasa = '
N';
gotoxy(30,15);co
ut<<"Ahora este alumno esta en ";cout<<dat_alu.semestre;cout<<" semestre";
gotoxy(20,20);co
ut<<"Presione enter para continuar con el siguiente estudiante";
getch();
}
pos=ftell(alum);
fseek(alum,pos-(sizeof(s
truct alumnos)),SEEK_SET);
fwrite(&dat_alu,sizeof(s
truct alumnos),1,alum);
}
else

pos++;
fseek(alum,pos,0);
fread(&dat_alu,sizeof(struct alu
mnos),1,alum);
}
fclose(alum);
}
fread(&dat_maes,sizeof(struct profesores),1,maes);
}
fclose(maes);
if (encontrado==0)
{
gotoxy(20,20);cout<<"El profesor no esta dado de alta";
getch();
}
}

void cpasaalu_cs4()
{
int cvm,encontrado;
long int pos;
char ok;
FILE *alum, *maes;
alum=fopen("dat_alu.dat","rb+");
maes=fopen("dat_maes.dat","rb");
rewind(maes);
clrscr();
gotoxy(15,5);cout<<"Clave del profesor: ";cin>>cvm;
encontrado=0;
fread(&dat_maes,sizeof(struct profesores),1,maes);
while (!feof(maes))
{
if(dat_maes.clave==cvm)
{
encontrado=1;
clrscr();
gotoxy(5,2);cout<<"Clave del profesor: ";cout<<c
vm; cout<<"
Nombre: ";cout<<dat_maes.nombre;
gotoxy(1,3);cout<<"-----------------------------------------------------------------";
rewind(alum);
fread(&dat_alu,sizeof(struct alumnos),1,alum);
pos=1;
while (!feof(alum))
{
if ((dat_alu.cvemaes==cvm)&&(dat
_alu.pasa=='S'))
{
titulos();
gotoxy(40,5);clreol();co
ut<<dat_alu.clave;
gotoxy(40,7);clreol();co
ut<<dat_alu.nombre;
gotoxy(40,9);clreol();co
ut<<dat_alu.semestre;
gotoxy(40,11);clreol();c
out<<dat_alu.cvemaes;

gotoxy(30,15);clreol();
gotoxy(20,20);clreol();
do
{
gotoxy(30,13);cl
reol();cout<<"Este alumno se queda en este semestre?[s/n]";
ok=toupper(getch
e());
}
while ((ok!='S') && (ok!
='N'));
if (ok=='N')
{
dat_alu.semestre
= dat_alu.semestre - 1;
dat_alu.pasa = '
N';
gotoxy(30,15);co
ut<<"Ahora este alumno esta en ";cout<<dat_alu.semestre;cout<<" semestre";
gotoxy(20,20);co
ut<<"Presione enter para continuar con el siguiente estudiante";
getch();
}
pos=ftell(alum);
fseek(alum,pos-(sizeof(s
truct alumnos)),SEEK_SET);
fwrite(&dat_alu,sizeof(s
truct alumnos),1,alum);
}
fread(&dat_alu,sizeof(struct alu
mnos),1,alum);
}
fclose(alum);
}
fread(&dat_maes,sizeof(struct profesores),1,maes);
}
fclose(maes);
if (encontrado==0)
{
gotoxy(20,20);cout<<"El profesor no esta dado de alta";
getch();
}
}
/************************************************************************
************************ I N S C R I P I O N E S ************************
*************************************************************************/
void inscrip()
{
int m_num,encontrado,nummat,cvm,ban;
char ok;
FILE *arch, *mater, *asig, *busca;
arch=fopen("dat_alu.dat","rb");
mater=fopen("dat_mat.dat","rb");
asig=fopen("dat_asig.dat","ab+");

busca=fopen("dat_asig.dat","rb");
clrscr();
encontrado=0;
rewind(arch);
gotoxy(15,5);cout<<"clave: ";
cin>>m_num;
nummat=0;ban=0;
fread(&dat_alu,sizeof(struct alumnos),1,arch);
while (!feof(arch))
{
if (m_num==dat_alu.clave)
{
if (dat_alu.pasa=='S')
{
encontrado = 1;
titulos();
gotoxy(40,5);cout<<dat_alu.clave
;
gotoxy(40,7);cout<<dat_alu.nombr
e;
gotoxy(40,9);cout<<dat_alu.semes
tre;
gotoxy(40,11);cout<<dat_alu.cvem
aes;
nummat=dat_alu.nummat;
do
{
gotoxy(30,13);clreol();c
out<<"Teclea la clave de la materia: ";cin>>cvm;
ban=0;
gotoxy(15,15);clreol();
gotoxy(20,23);clreol();
rewind(mater);
fread(&dat_mat,sizeof(st
ruct materias),1,mater);
while (!feof(mater))
{
if (cvm==dat_mat
.clave)
{
rewind(b
usca);
fread(&d
at_asig,sizeof(struct mat_asig),1,busca);
while(!f
eof(busca))
{
if ((dat_asig.cvealu==dat_alu.clave)&&(dat_asig.cvemat==dat_mat.clave))
{
ban=1;
gotoxy(15,15);cout<<"Esta materia ya esta asignada para el alumno";
getch();
}

fread(&dat_asig,sizeof(struct mat_asig),1,busca);
}
if (ban
== 0)
{
dat_asig.cvealu=m_num;
dat_asig.cvemat=cvm;
fwrite(&dat_asig,sizeof(dat_asig),1,asig);
nummat++;
}
}
fread(&dat_mat,s
izeof(struct materias),1,mater);
}
gotoxy(20,23);cout<<"Des
eas agregar otra materia?[s/n] ";ok=toupper(getche());
}while((ok!='N')&&(numma
t<9));
}
else
{
cout<<"Este alumno no puede insc
ribirse por que no paso de semestre";
getch();
}
}
fread(&dat_alu,sizeof(struct alumnos),1,arch);
}
if (encontrado==0)
{
gotoxy(20,20);clreol;
gotoxy(20,20);cout<<"La clave no esta dada de Al
ta";
getche();
}
fclose(arch);
fclose(mater);
fclose(asig);
}
/************************************************************************
************************ M A T E R I A S ********************************
*************************************************************************/
void titumat()
{
gotoxy(15,5);cout<<"1. Clave...............:";
gotoxy(15,7);cout<<"2. Nombre..............:";
gotoxy(15,9);cout<<"3. Creditos............:";
gotoxy(15,11);cout<<"4. Semestre............:";
gotoxy(15,13);cout<<"5. Clave de Profesor...:";
}

void menumat()
{
clrscr();
char i,d,opc;
do
{
clrscr();
gotoxy(17,3); cout<<"M E N U M A T E R I A S";
gotoxy(20,5);cout<<"1. Altas";
gotoxy(20,6);cout<<"2. Bajas";
gotoxy(20,7);cout<<"3. Cambios";
gotoxy(20,8);cout<<"4. Consultas";
gotoxy(20,9);cout<<"5. Reportes";
gotoxy(20,10);cout<<"6. Salir";
gotoxy(22,12);cout<<"Opcion: ";
opc=toupper(getche());
switch(opc)
{
case '1':altas_mat();br
eak;
case '2':bajas_mat();br
eak;
case '3':cambios_mat();
break;
case '4':consultas_mat(
);break;
case '5':reportes_mat()
;break;
}
}while (opc!='6');
}
void altas_mat()
{
FILE *arch, *busca;
clrscr();
char opc;
int encontrado,m_num;
arch=fopen("dat_mat.dat","ab");
busca=fopen("dat_mat.dat","rb");
gotoxy(15,2);cout<<" A L T A S ";
titumat();
gotoxy(40,5); cin>>m_num;
encontrado=0;
rewind(busca);
while (!feof(busca))
{
if (m_num==dat_mat.clave)
{
encontrado = 1;
titulos();
gotoxy(40,5);cout<<dat_mat.clave;
gotoxy(40,7);cout<<dat_mat.nombre;
gotoxy(40,9);cout<<dat_mat.creditos;
gotoxy(40,11);cout<<dat_mat.semestre;
gotoxy(40,13);cout<<dat_mat.cvemaes;
gotoxy(20,20);clreol;
gotoxy(20,20);cout<<"La clave ya esta dada de Al

ta";
getche();
}
fread(&dat_mat,sizeof(struct materias),1,busca);
}
if (encontrado==0)
{
dat_mat.clave=m_num;
gotoxy(40,7);gets(dat_mat.nombre);
gotoxy(40,9);cin>>dat_mat.creditos;
gotoxy(40,11);cin>>dat_mat.semestre;
gotoxy(40,13);cin>>dat_mat.cvemaes;
fwrite(&dat_mat,sizeof(dat_mat),1,arch);
}
fclose(arch);
fclose(busca);
}
void consultas_mat()
{
int m_num,encontrado;
char ok;
FILE *arch;
arch=fopen("dat_mat.dat","rb");
do
{
clrscr();
encontrado=0;
rewind(arch);
gotoxy(20,2);cout<<" C O N S U L T A S ";
gotoxy(15,5);cout<<"clave: ";
cin>>m_num;
fread(&dat_mat,sizeof(struct materias),1,arch);
while (!feof(arch))
{
if (m_num==dat_mat.clav
e)
{
encontrado = 1;
titumat();
gotoxy(40,5);cout<<dat_mat.clave;
gotoxy(40,7);cout<<dat_mat.nombre;
gotoxy(40,9);cout<<dat_mat.creditos;
gotoxy(40,11);cout<<dat_mat.semestre;
gotoxy(40,13);cout<<dat_mat.cvemaes;
}
fread(&dat_mat,sizeof(s
truct materias),1,arch);
}
if (encontrado==0)
{
gotoxy(20,20);clreol;

gotoxy(20,20);cout<<"La
clave no esta dada de Alta";
getche();
}
gotoxy(20,20);clreol;
gotoxy(20,20);cout<<"Deseas consultar otro regi
stro [S/N]";
ok=toupper(getche());
}while (ok!='N');
fclose(arch);
}
void cambios_mat()
{
int m_num,modi,n_mod;
long int pos;
char ok;
FILE *arch;
arch=fopen("dat_mat.dat","rb+");
do
{
clrscr();
rewind(arch);
gotoxy(20,2);cout<<"C A M B I O S";
gotoxy(15,5);cout<<"clave: ";
cin>>m_num;
fread(&dat_mat,sizeof(struct materias),1,arch);
modi=0;
while (!feof(arch))
{
if (m_num==dat_mat.clav
e)
{
titumat();
gotoxy(40,5);cout<<dat_mat.clave;
gotoxy(40,7);cout<<dat_mat.nombre;
gotoxy(40,9);cout<<dat_mat.creditos;
gotoxy(40,11);cout<<dat_mat.semestre;
gotoxy(40,13);cout<<dat_mat.cvemaes;
do
{
gotoxy(15,20);clreol();
gotoxy(15,20);cout<<"teclea numero para cambiar [0 para terminar]: ";
cin>>n_mod;
gotoxy(15,20);clreol();
switch (n_mod)

{
case 2:gotoxy(40,7);gets(dat_mat.nombre);break;
case 3:gotoxy(40,9);cout<<dat_mat.creditos;break;
case 4:gotoxy(40,11);cout<<dat_mat.semestre;break;
case 5:gotoxy(40,13);cout<<dat_mat.cvemaes;break;
}
}while (n_mod != 0);
pos=ftell(arch);
fseek(arch,pos-(sizeof(struct materias)),SEEK_SET);
fwrite(&dat_mat,sizeof(struct materias),1,arch);
if (modi != 0)
{
gotoxy(20,20);clreol();
gotoxy(20,20);cout<<"Se han guardado los Cambios";
getche();
}
}
fread(&dat_mat,sizeof(s
truct materias),1,arch);
}
gotoxy(20,20);clreol;
gotoxy(20,20);cout<<"Deseas cambiar otro regist
ro [S/N]";
ok=toupper(getche());
} while(ok!='N');
fclose(arch);
}
void bajas_mat()
{
int m_num,n_mod;
char modi;
long int pos;
char ok;
FILE *arch;
arch=fopen("dat_mat.dat","rb+");
do
{
clrscr();
rewind(arch);
gotoxy(20,2);cout<<" B A J A S";
gotoxy(15,5);cout<<"clave: ";
cin>>m_num;
fread(&dat_mat,sizeof(struct materias),1,arch);
modi=' ';

while (!feof(arch))
{
if (m_num==dat_mat.clav
e)
{
titumat();
gotoxy(40,5);cout<<dat_mat.clave;
gotoxy(40,7);cout<<dat_mat.nombre;
gotoxy(40,9);cout<<dat_mat.creditos;
gotoxy(40,11);cout<<dat_mat.semestre;
gotoxy(40,13);cout<<dat_mat.cvemaes;
gotoxy(20,20);cout<<"ESTA SEGURO QUE DESEA ELIMINAR EL REGISTRO[S/N] ";
modi = toupper(getch());
if (modi == 'S')
{
dat_mat.clave = -99;
pos=ftell(arch);
fseek(arch,pos-(sizeof(struct materias)),SEEK_SET);
fwrite(&dat_mat,sizeof(struct materias),1,arch);
gotoxy(20,20);clreol();
gotoxy(20,20);cout<<"Registro Eliminado";
getche();
}
}
fread(&dat_mat,sizeof(s
truct materias),1,arch);
}
gotoxy(20,20);clreol;
gotoxy(20,20);cout<<"Deseas eliminar otro regis
tro[S/N]";
ok=toupper(getche());
} while(ok!='N');
fclose(arch);
}
void reportes_mat()
{
clrscr();
int r;
FILE *arch;
arch=fopen("dat_mat.dat","rb");
if (arch==NULL)

{
gotoxy(20,20);cout<<"El archivo esta Vacio";
getche();
}
else
{

CREDITOS

r=6;
gotoxy(20,2);cout<<" R E P O R T E S ";
gotoxy(3,4);cout<<"CLAVE
NOMBRE
CLAVE DE MAESTRO";
while (!feof(arch))
{
fread(&dat_mat,sizeof(s

SEMESTRE

truct materias),1,arch);
if (!feof(arch))
{
if (dat_mat.clave!= -99)
{
gotoxy(3,r);cout<<dat_mat.clave;
gotoxy(9,r);cout<<dat_mat.nombre;
gotoxy(35,r);cout<<dat_mat.creditos;
gotoxy(50,r);cout<<dat_mat.semestre;
gotoxy(60,r);cout<<dat_mat.cvemaes;
r++;
}
}
}
gotoxy(20,20);cout<<"Presiona una tecla para co
ntinuar";
getch();
}
}
int password()
{
char pass[10];
char keypress;
int x=0, c=42;
clrscr();
gotoxy(15,15);cout<<"Teclea la clave de acceso: ";
do
{
keypress=getch();
if (keypress!=13)
{
if (keypress==8)
{
x=x-1;
c=c-1;
gotoxy(c,15); clreol();

}
else
{
pass[x]=toupper(keypress);
gotoxy(c,15);clreol();cout<<"*";
c++;
x++;
}
}
}while (keypress!=13);
if (pass[0]=='S'&&pass[1]=='I'&&pass[2]=='S'&&pass[3]=='T'&&pass[4]=='E'&&pass[5
]=='M'&&pass[6]=='A'&&pass[7]=='S')
{
return(1);
}
else
{
clrscr();
gotoxy(15,15);
cout<<"password invalido";
getch();
return(0);
}
}

También podría gustarte