elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Estamos en la red social de Mastodon


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  Duda con registros (dar de baja productos, modificar productos...)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Duda con registros (dar de baja productos, modificar productos...)  (Leído 1,487 veces)
hectorssoria

Desconectado Desconectado

Mensajes: 1


Ver Perfil
Duda con registros (dar de baja productos, modificar productos...)
« en: 26 Mayo 2015, 00:48 am »

Hola! Buen día!
Tengo una mega dudota, necesito en el registro de inventario poner las opciones de dar de baja, modificar y dar un reporte de productos que existen ingresados en el programa, podrían ayudarme?
Les dejo el código que llevo:

Código
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<conio.h>
  4.  
  5. void menu();
  6. void invtrain();
  7. void invtranw();
  8. void invtranl();
  9. int opcion;
  10.  
  11. struct datosInven{
  12. int codigo;
  13. char descripcion[15];
  14. char fechault[6];
  15. char unidad[10];
  16. int existencia;
  17. float precio;
  18. char estatus;
  19. };
  20.  
  21. struct datosTran{
  22. int ntran;
  23. int codigo;
  24. char fechamovto[6];
  25. int tipomovto; //1=entrada, 2=venta o salida, 3=devolucion
  26. int cantidad;
  27. char estatus;
  28. };
  29.  
  30. int main()
  31. {
  32. while(opcion<3)
  33. {
  34. menu();
  35. printf("\n\t\t Selecciona una opcion:");
  36. scanf("%d",&opcion);
  37. switch(opcion)
  38. {
  39. case 1: system("cls");
  40. invtrain();
  41. break;
  42. case 2: system("cls");
  43. invtranw();
  44. break;
  45. case 3: system("cls");
  46. invtranl();
  47. break;
  48. }
  49. }
  50. }
  51.  
  52. void menu()
  53. {
  54. system("cls");
  55. printf("\n\t\tMenu de inventarios");
  56. printf("\n1.-Inicializar el archivo.");
  57. printf("\n2.-Captura de inventario.");
  58. printf("\n3.-Existencias de inventarios.");
  59. printf("\n4.-Modificar inventario.");
  60. }
  61.  
  62. void invtrain()
  63. {
  64. int i;
  65. struct datosInven productos={0,"","","",0,0.0,'n'};
  66. struct datosTran movtos={0,0,"",0,0,'n'};
  67. FILE*fptrl,*fptrM;
  68.  
  69. if((fptrl=fopen("inv.dat","wb"))==NULL)
  70. printf("\n\aNo se pudo abrir el archivo.");
  71. else
  72. {
  73. for(i=1;i<=100;i++)
  74. {
  75. fwrite(&productos, sizeof(struct datosInven),1,fptrl);
  76. }
  77. printf("\n\aINICIALIZACION SATISFACTORIA PARA EL INVENTARIO");
  78. fclose(fptrl);
  79. }
  80. if ((fptrM=fopen("mov.dat","wb"))==NULL)
  81. printf("\n\aNo se pudo abrir el archivo.");
  82. else
  83. {
  84. for(i=1;i<=100;i++)
  85. {
  86. fwrite(&movtos,sizeof(struct datosTran),1,fptrM);
  87. }
  88. printf("\n\aINICIALIZACION SATISFACTORIA PARA TRANSACCIONES");
  89. fclose(fptrM);
  90. }
  91. }
  92.  
  93. void invtranw()
  94. {
  95. struct datosInven Inventario={0,"","","",0,0.0,'n'};
  96. FILE*fptrC;
  97.  
  98. if((fptrC=fopen("inv.dat","rb+"))==NULL)
  99. printf("\n\aNo se pudo abrir el archivo");
  100. else
  101. {
  102. printf("\nIntroduzca el CODIGO CONSECUTIVO entre [1,100],0 para terminar:>");
  103. scanf("%d",&Inventario.codigo);
  104. while(Inventario.codigo!=0)
  105. {
  106. printf("\nIntroduce Codigo de producto:>");
  107. fscanf(stdin,"%d",&Inventario.codigo);
  108. printf("\nIntroduce descripcion:>");
  109. fscanf(stdin,"%s",Inventario.descripcion);
  110. printf("\nIntroduce Unidad:>");
  111. fscanf(stdin,"%s",Inventario.unidad);
  112. printf("\nIntroduce fecha ultima:>");
  113. fscanf(stdin,"%s",Inventario.fechault);
  114. printf("\nIntroduce existencia:>");
  115. fscanf(stdin,"%d",&Inventario.existencia);
  116. printf("\nIntroduce precio:>");
  117. fscanf(stdin,"%f",&Inventario.precio);
  118. Inventario.estatus='a';
  119. fseek(fptrC,(Inventario.codigo-1)*sizeof(struct datosInven),SEEK_SET);
  120. fwrite(&Inventario,sizeof(struct datosInven),1,fptrC);
  121.  
  122. printf("\nIntroduzca el numero CONSECUTIVO:>");
  123. scanf("%d",&Inventario.codigo);
  124. }
  125. printf("\n\t\t\a*******FIN DE CAPTURA******");
  126. fclose(fptrC);
  127. }
  128. }
  129.  
  130. void invtranl()
  131. {
  132. struct datosInven Inv={0,"","","",0,0.0,'n'};
  133. FILE*fptrC;
  134.  
  135. if((fptrC=fopen("inv.dat","rb"))==NULL)
  136. printf("\n\aNo se pudo abrir el archivo.");
  137. else
  138. {
  139. printf("\n\t\t\tEXISTENCIAS EN INVENTARIOS");
  140. printf("\n\t\t**********************************\n");
  141.  
  142. printf("\nCOD DESCRIPCION UNIDAD FECHA EXIST PRECIO ESTATUS");
  143.  
  144. while(!feof(fptrC))
  145. {
  146. fread(&Inv, sizeof(struct datosInven),1,fptrC);
  147. /*despliega el registro*/
  148.  
  149. if(Inv.codigo!=0)
  150. {
  151. printf("\n%-5d%-15s%-10s%-5s%-3d%5.2f%c",Inv.codigo,Inv.descripcion,Inv.unidad,Inv.fechault,Inv.existencia,Inv.precio,Inv.estatus);
  152. }
  153. }/*fin del while*/
  154. printf("\n\t\t******FIN DE EJECUCION*******");
  155. fclose(fptrC);
  156. }
  157. }

Mod: Al publicar código, deben usarse etiquetas GeSHi


« Última modificación: 26 Mayo 2015, 00:51 am por engel lex » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Productos de Singapur
Juegos y Consolas
ZeloX 1 1,589 Último mensaje 1 Septiembre 2005, 15:22 pm
por DJ46
Catalogo de Productos
Desarrollo Web
Clavo Oxidado 4 3,564 Último mensaje 10 Septiembre 2010, 16:42 pm
por Bender-Deicide
consulta de productos!
Bases de Datos
Rk_PetIT 3 2,883 Último mensaje 1 Agosto 2013, 18:55 pm
por 1mpuls0
Duda vender PRODUCTOS digitales[Solucionado]
Foro Libre
Senior++ 2 1,945 Último mensaje 27 Julio 2014, 22:13 pm
por Senior++
Duda diseño para servicios/productos.
Bases de Datos
1304654 0 2,173 Último mensaje 26 Agosto 2015, 17:32 pm
por 1304654
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines