C2676 and C2228 errors

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jul 2008
Posts: 60
Reputation: gispe is an unknown quantity at this point 
Solved Threads: 0
gispe gispe is online now Online
Junior Poster in Training

C2676 and C2228 errors

 
0
  #1
Jul 15th, 2009
hi all,
i've written a program, n almost works, it just gives me this errors and dont know how to solve them
thanks for the help in advanced




  1.  
  2. 1>Compiling...
  3. 1>VersionFinalTpProg1.cpp
  4. 1>e:\esba\2cuat\programacion1\tpfinalaentregar\versionfinaltpprog1\versionfinaltpprog1\versionfinaltpprog1.cpp(199) : error C2676: binary '[' : 'art' does not define this operator or a conversion to a type acceptable to the predefined operator
  5. 1>e:\esba\2cuat\programacion1\tpfinalaentregar\versionfinaltpprog1\versionfinaltpprog1\versionfinaltpprog1.cpp(199) : error C2228: left of '.name' must have class/struct/union
  6. 1>e:\esba\2cuat\programacion1\tpfinalaentregar\versionfinaltpprog1\versionfinaltpprog1\versionfinaltpprog1.cpp(199) : fatal error C1903: unable to recover from previous error(s); stopping compilation
  7. 1>Build log was saved at "file://e:\ESBA\2Cuat\PROGRAMACION1\TPFinalAEntregar\VersionFinalTpProg1\VersionFinalTpProg1\Debug\BuildLog.htm"
  8. 1>VersionFinalTpProg1 - 3 error(s), 0 warning(s)
  9. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  10.  
  11.  
  12.  
  13.  
  14. // VersionFinalTpProg1.cpp : Defines the entry point for the console application.
  15. //
  16.  
  17. #include "stdafx.h"
  18. #include <cstdlib>
  19. #include <iostream>
  20.  
  21. using namespace std;
  22.  
  23.  
  24. struct art
  25. {
  26. char name [50];
  27. char branch [50];
  28. float PrecioVenta;
  29. float PrecioCosto;
  30. int stock;
  31.  
  32. void load_art(float &price, char name[], char branch[], float &PrecioVenta, float &PrecioCosto, int &stock);
  33. void CambiarStock(int &stock);
  34. void ConsultarPrecioCosto(char name[], float PrecioCosto);
  35. void ConsultarPrecioVenta(char name[], float PrecioVenta);
  36. void mostrar(char name[], float price, char branch[], float PrecioVenta, float PrecioCosto, int stock);
  37. };
  38.  
  39.  
  40. struct StockGeneral
  41. {
  42. art datos[100];
  43.  
  44. char encontrado;
  45. int pos;
  46. char NombreBuscado[100];
  47.  
  48. StockGeneral();
  49. void BuscarStock(char NombreBuscado[], int &pos, char &encontrado);
  50. void CargarStockGeneral(float &price, char name[], char branch[], float &PrecioVenta, float &PrecioCosto, int &stock);
  51. void CompraArticulos();
  52. void MostrarStock();
  53. };
  54.  
  55.  
  56. struct client
  57. {
  58. char name[50];
  59. int id;
  60. char domicilio [100];
  61. float precio_acumulado;
  62.  
  63. void CargarDatos(int &id, char nombre[], char domicilio[], float &precio_acumulado);
  64. void MostrarDatos(int id, char nombre[], char domicilio[], float precio_acumulado);
  65. void ConsultarSaldo();
  66. void ActualizarSaldo(int id, float &precio_acumulado);
  67. };
  68.  
  69.  
  70. struct total_clients
  71. {
  72. client datos[100];
  73. int tope;
  74.  
  75. void CargarTotalClientes();
  76. void MostrarTotalClientes();
  77. void BuscarTotalClientes(char NombreBuscado[], int &pos, bool &encontrado);
  78. };
  79.  
  80.  
  81.  
  82. struct venta
  83. {
  84. void CargarFactura(char name[], char branch[], int &stock, float &totalfactura);
  85. void MostrarFactura (char name[], char branch[], int &stock, float totalfactura);
  86. };
  87.  
  88.  
  89.  
  90.  
  91. //----------------------------------
  92. //
  93. // ART - FUNCIONES
  94. //
  95. //----------------------------------
  96.  
  97. void art::load_art(float &price, char name[], char branch[], float &PrecioVenta, float &PrecioCosto, int &stock)
  98. {
  99.  
  100. cout << " ------------------------------------- \n\n";
  101. cout << " CARGA DATOS DEL ARTICULO: \n";
  102. cout << " ------------------------------------- \n\n";
  103.  
  104. cout<< " Nombre: ";
  105. cin.getline(name, 50);
  106.  
  107. cout << " Marca: ";
  108. cin.getline(branch, 50);
  109.  
  110. cout << " Precio Venta: ";
  111. cin >> PrecioVenta;
  112.  
  113. cout << " Precio Costo: ";
  114. cin >> PrecioCosto;
  115.  
  116. cout << " Stock: ";
  117. cin >> stock;
  118. }
  119.  
  120.  
  121. void art::CambiarStock (int &stock)
  122. {
  123. cout << " Ingrese el nombre del articulo: ";
  124. cin.getline(name, 50);
  125.  
  126. cout << " Ingresar nuevo stock: ";
  127. cin >> stock;
  128. }
  129.  
  130.  
  131. void art::ConsultarPrecioCosto (char name[], float PrecioCosto)
  132. {
  133. art article;
  134.  
  135. cout << " Ingrese el nombre del articulo: ";
  136. cin.getline(article.name, 50);
  137.  
  138. cout << " El precio es: " << article.PrecioCosto;
  139. }
  140.  
  141.  
  142. void art::ConsultarPrecioVenta (char name[], float PrecioVenta)
  143. {
  144. cout << " Ingrese el nombre del articulo: ";
  145. cin.getline(name, 50);
  146.  
  147. cout << " El precio es: " << PrecioVenta;
  148. }
  149.  
  150.  
  151. void art::mostrar(char name[], float price, char branch[], float PrecioVenta, float PrecioCosto, int stock)
  152. {
  153. art article;
  154.  
  155. cout << " -------------------------------------------------------------- \n";
  156. cout << " -------------------------- ARTICULO --------------------------";
  157. cout << " -- Nombre: " << article.name << "\n";
  158. cout << " -- Marca: " << article.branch << "\n";
  159. cout << " -- Precio de Venta: " << article.PrecioVenta << "\n";
  160. cout << " -- Precio de Costo: " << article.PrecioCosto << "\n";
  161. cout << " -- Stock: " << article.stock << "\n";
  162. cout << " -------------------------------------------------------------- \n";
  163. }
  164.  
  165.  
  166.  
  167. //----------------------------------
  168. //
  169. // STOCK - FUNCIONES
  170. //
  171. //----------------------------------
  172.  
  173. StockGeneral::StockGeneral()
  174. {
  175. int tope[100];
  176.  
  177.  
  178. for (int i =0; i <100; i++)
  179. tope[i]=0;
  180. }
  181.  
  182.  
  183.  
  184. void StockGeneral::CargarStockGeneral(float &price, char name[], char branch[], float &PrecioVenta, float &PrecioCosto, int &stock)
  185. {
  186. char rta;
  187. int tope;
  188.  
  189. while (tope<100)
  190. {
  191. do {
  192. datos[pos].load_art(price, name, branch, PrecioVenta, PrecioCosto, stock);
  193. tope++;
  194. cout << " Cargar otro? S/N?";
  195. cin >> rta;
  196. cin.ignore();
  197. } while(rta != 'n' && rta!='N');
  198.  
  199. system("CLS");
  200. }
  201. }
  202.  
  203.  
  204. void StockGeneral::BuscarStock(char NombreBuscado[],int &pos, char &encontrado)
  205. {
  206. encontrado=0;
  207. pos=0;
  208. int tope=100;
  209. int i=0;
  210. art article;
  211.  
  212. while ((pos < tope) && (strcmp(NombreBuscado, article[pos].name)!=0))
  213. {
  214. pos++;
  215.  
  216. if (pos<tope)
  217. encontrado=1;
  218. else
  219. pos=1;
  220. }
  221. }
  222.  
  223.  
  224. float StockGeneral::CambiarPrecioVenta (float PrecioVenta)
  225. {
  226. char encontrado;
  227.  
  228. cout << " Ingrese el nombre del articulo: ";
  229. cin.getline(art.name, 50);
  230.  
  231. StockGeneral.BuscarStock(NombreBuscado[], pos, encontrado);
  232.  
  233. if (encontrado==0)
  234. {
  235. cout << " Ingresar precio de costo del articulo: ";
  236. cin >> PrecioVenta;
  237. }
  238. else if (encontrado == 1)
  239. cout << " No se puede cambiar el precio. \n El articulo ingresado no existe. \n\n";
  240.  
  241. return PrecioVenta;
  242. }
  243.  
  244.  
  245. void StockGeneral::CompraArticulos()
  246. {
  247. char NombreBuscado[100], encontrado;
  248. int stockaux, pos;
  249.  
  250. cout << " Escribir nombre de articulo a cambiar stock: ";
  251. cin.getline(NombreBuscado, 100);
  252.  
  253. StockGeneral.BuscarStock(NombreBuscado[], pos, encontrado);
  254.  
  255. if (encontrado==0)
  256. {
  257. cout << " Ingresar stock del articulo a comprar: ";
  258. cin >> stockaux;
  259.  
  260. datos[pos].stock += stockaux;
  261.  
  262. cout << " Se actualizo el stock.-";
  263. }
  264. else if (encontrado == 1)
  265. cout << " No se puede cambiar el precio. \n El articulo ingresado no existe. \n\n";
  266.  
  267. }
  268.  
  269.  
  270. void StockGeneral::MostrarStock()
  271. {
  272. art articulo;
  273.  
  274. cout << " ------------------------------------------------------------------- \n";
  275. cout << " -------------------------- STOCK GENERAL -------------------------- \n";
  276. cout << " ------------------------------------------------------------------- \n";
  277.  
  278. for (int i=0; i <100; i++)
  279. articulo.mostrar(name[], branch[], PrecioVenta, PrecioCosto, stock);
  280.  
  281. cout << " ------------------------------------------------------------------- \n";
  282. cout << " ------------------------------------------------------------------- \n";
  283. cout << " ------------------------------------------------------------------- \n";
  284. }
  285.  
  286.  
  287.  
  288.  
  289. //----------------------------------
  290. //
  291. // CLIENTE - FUNCIONES
  292. //
  293. //----------------------------------
  294.  
  295.  
  296. void client::CargarDatos(int &id, char nombre[], char domicilio[], float &precio_acumulado)
  297. {
  298. client cliente;
  299.  
  300. cout << " INGRESO DE DATOS DEL CLIENTE: \n";
  301. cout << " ------------------------------------- \n\n";
  302.  
  303. cout << " Codigo: ";
  304. cin >> cliente.id;
  305.  
  306. cout << " Nombre: ";
  307. cin.getline (cliente.name,50);
  308.  
  309. cout << " Domicilio: ";
  310. cin.getline (cliente.domicilio,100);
  311.  
  312. cout << " Saldo Acumulado: ";
  313. cin >> cliente.precio_acumulado;
  314. }
  315.  
  316.  
  317. void client::MostrarDatos(int id, char nombre[], char domicilio[], float precio_acumulado)
  318. {
  319. client cliente;
  320.  
  321. cout << " -+-+-+- DATOS DEL CLIENTE -+-+-+- \n";
  322. cout << " ---------------------------------------------------- \n\n\n";
  323. cout << " --- ID:" << cliente.id << " \n";
  324. cout << " --- Nombre: " << cliente.name << " \n";
  325. cout << " --- Domicilio: " << cliente.domicilio << "\n";
  326. cout << " --- Saldo: " << cliente.precio_acumulado << "\n";
  327. cout << " ---------------------------------------------------- \n\n\n";
  328. }
  329.  
  330.  
  331. void client::ConsultarSaldo()
  332. {
  333. client cliente;
  334.  
  335. cout << " Ingrese ID del cliente: ";
  336. cin >> cliente.id;
  337.  
  338. cout << " El saldo es " << cliente.precio_acumulado << " \n";
  339. }
  340.  
  341.  
  342.  
  343. void client::ActualizarSaldo(int id, float &precio_acumulado)
  344. {
  345. client cliente;
  346. float nuevosaldo;
  347.  
  348. cout << " Ingresar ID del cliente: ";
  349. cin >> cliente.id;
  350.  
  351. cout << " Ingrese nuevo Saldo: ";
  352. cin >> nuevosaldo;
  353.  
  354. cliente.precio_acumulado = nuevosaldo;
  355. }
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367. //----------------------------------
  368. // TOTAL DE CLIENTES
  369. //
  370. // FUNCIONES
  371. //----------------------------------
  372.  
  373.  
  374. void total_clients::CargarTotalClientes()
  375. {
  376. char rta;
  377.  
  378. while (tope<100)
  379. {
  380. do {
  381. datos[tope].CargarDatos();
  382. tope++;
  383. cout << " Cargar otro? S/N?";
  384. cin >> rta;
  385. cin.ignore();
  386. } while(rta != 'n' && rta!='N');
  387.  
  388. system("CLS");
  389. }
  390. }
  391.  
  392.  
  393. void total_clients::MostrarTotalClientes()
  394. {
  395. client cliente;
  396. int id;
  397. char name [50], domicilio [100];
  398. float precio_acumulado;
  399.  
  400. cout << " DETALLE DE TODOS LOS CLIENTES: \n";
  401. cout << " ------------------------------------------------- \n\n";
  402. cliente.MostrarDatos(id, name, domicilio, precio_acumulado);
  403. cout << " ------------------------------------------------- \n\n";
  404. }
  405.  
  406.  
  407. void total_clients::BuscarTotalClientes(char NombreBuscado[],int &pos, char &encontrado)
  408. {
  409. encontrado=0;
  410. pos=0;
  411. int tope=100;
  412.  
  413. while ((pos <tope) && (strcmp(NombreBuscado, article[pos].name)!=0))
  414. {
  415. pos++;
  416.  
  417. if (pos<tope)
  418. encontrado=true;
  419. else
  420. pos=1;
  421. }
  422. }
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430. //----------------------------------
  431. // FACTURAS
  432. //
  433. // FUNCIONES
  434. //----------------------------------
  435.  
  436.  
  437. void venta::CargarFactura(char name[], char branch[], int &stock, float totalfactura)
  438. {
  439. art articulo;
  440. int stockfactura;
  441. float totalfactura;
  442.  
  443. cout << " Ingresar nombre de articulo a vender: ";
  444. cin.getline(articulo.name, 50);
  445.  
  446. StockGeneral.BuscarStock(NombreBuscado, pos, encontrado);
  447.  
  448. if (encontrado == 1)
  449. {
  450. cout << " Ingresar marca: ";
  451. cin.getline(articulo.branch,50);
  452.  
  453. cout << " Ingresar stock: ";
  454. cin >> stockfactura;
  455.  
  456. while (stockfactura > articulo.stock)
  457. {
  458. cout << " No se puede vender esa cantidad. \n Ingresar stock correcto: ";
  459. cin >> stockfactura;
  460. }
  461. }
  462. articulo.stock = articulo.stock - stockfactura;
  463.  
  464. totalfactura= stockfactura*articulo.PrecioVenta;
  465.  
  466. cout << " Ingresar nombre de cliente: ";
  467. cin.getline (client.name, 50);
  468.  
  469. total_clients.BuscarCliente(NombreBuscado, pos, encontrado);
  470.  
  471. if (encontrado == 1)
  472. {
  473. client.precio_acumulado = client.precio_acumulado - totalfactura;
  474.  
  475. if (client.precio_acumulado < 0)
  476. cout << " No se puede realizar esta venta.";
  477. }
  478. else if (encontrado ==0)
  479. cout << " El cliente ingresado no existe. \n";
  480.  
  481. }
  482.  
  483.  
  484.  
  485. void venta::MostrarFactura(char name[], char branch[], int &stock, float totalfactura)
  486. {
  487. cout << " ---------------------------------------------------- ";
  488. cout << " -- Articulo: " << art.name << "\n";
  489. cout << " -- Marca: " << art.branch << "\n";
  490. cout << " -- Stock vendido: " << art.stock << "\n\n";
  491. cout << " -- Cliente: " << client.name << "\n";
  492. cout << " -- Saldo actual del cliente: " << client.precio_acumulado << "\n\n\n";
  493. cout << " ---------- TOTAL FACTURA: -- $" << totalfactura << "\n";
  494. }
  495.  
  496.  
  497.  
  498.  
  499.  
  500. //----------------------------------
  501. //
  502. // MAIN
  503. //
  504. //----------------------------------
  505.  
  506.  
  507. int _tmain(int argc, _TCHAR* argv[])
  508. {
  509. art articulos;
  510. StockGeneral StockTotal;
  511. client clientes;
  512. total_clients todoslosclientes;
  513. venta factura;
  514.  
  515. char choice;
  516.  
  517. cout << " ------------------------------------------- \n";
  518. cout << " -------------- ELEGIR ACCION -------------- \n";
  519. cout << " ------------------------------------------- \n\n";
  520.  
  521. cout << " -1- Cargar articulos. \n";
  522. cout << " -2- Consultar Precio de Costo. \n";
  523. cout << " -3- Consultar Precio de Venta. \n";
  524. cout << " -4- Cambiar Stock. \n";
  525. cout << " -5- Mostrar articulos. \n\n";
  526. cout << " -6- Buscar un articulo. \n";
  527. cout << " -7- Comprar articulos. \n";
  528. cout << " -8- Mostrar StockGeneral. \n\n";
  529. cout << " -9- Cargar datos del cliente. \n";
  530. cout << " -a- Consultar Saldo. \n";
  531. cout << " -b- Actualizar saldo. \n";
  532. cout << " -c- Buscar Cliente. \n";
  533. cout << " -d- Mostrar clientes. \n\n";
  534. cout << " -h- Cargar datos para factura. \n";
  535. cout << " -i- Mostrar factura. \n\n";
  536. cout << " -0- Salir. \n\n";
  537. cout << " Elegiste: ";
  538. cin >> choice;
  539.  
  540. cout << " ------------------------------------------- \n\n";
  541. cout << " ------------------------------------------- \n\n";
  542. cout << " ------------------------------------------- \n\n";
  543.  
  544. switch (choice)
  545. {
  546. case '1':
  547. StockTotal.CargarStockGeneral();
  548. break;
  549.  
  550. case '2':
  551. articulo.consultarprecosto();
  552. break;
  553.  
  554. case '3':
  555. articulo.consultarprevta();
  556. break;
  557.  
  558. case '4':
  559. articulo.cambiarcosto();
  560. break;
  561.  
  562. case '5':
  563. StockTotal.MostrarStock();
  564. break;
  565.  
  566. case '6':
  567. StockTotal.BuscarStock(NombreBuscado[], pos, encontrado);
  568. break;
  569.  
  570. case '7':
  571. StockTotal.CompraArticulos();
  572. break;
  573.  
  574. case '8':
  575. StockTotal.MostrarStock();
  576. break;
  577.  
  578. case '9':
  579. todoslosclientes.CargarTotalClientes();
  580. break;
  581.  
  582. case 'a': case 'A':
  583. clientes.ConsultarSaldo();
  584. break;
  585.  
  586. case 'b':case 'B':
  587. clientes.ActualizarSaldo();
  588. break;
  589.  
  590. case 'c': case 'C':
  591. todoslosclientes.BuscarTotalClientes();
  592. break;
  593.  
  594. case 'd': case 'D':
  595. todoslosclientes.MostrarTotalClientes();
  596. break;
  597.  
  598. case 'h': case 'H':
  599. factura.CargarFactura();
  600. break;
  601.  
  602. case 'i': case 'I':
  603. factura.MostrarFactura();
  604. break;
  605.  
  606. case'0':
  607. cout << " ---Fin del programa--- \n";
  608. }
  609.  
  610. system("PAUSE");
  611. return 0;
  612. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,387
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1466
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: C2676 and C2228 errors

 
0
  #2
Jul 15th, 2009
>> while ((pos < tope) && (strcmp(NombreBuscado, article[pos].name)!=0))

variable article is not an array. Change article[pos].name)!=0 to article.name)!=0
Last edited by Ancient Dragon; Jul 15th, 2009 at 7:26 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 60
Reputation: gispe is an unknown quantity at this point 
Solved Threads: 0
gispe gispe is online now Online
Junior Poster in Training

Re: C2676 and C2228 errors

 
0
  #3
Jul 20th, 2009
Im back, with same code. But this time I tested the code with dev c++, and now its givin me a lot more errors than with microsoft c++. Cant paste the errors.

Thanks in advanced

  1.  
  2. #include <cstdlib>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. struct art
  8. {
  9. char name [50];
  10. char branch [50];
  11. float PrecioVenta;
  12. float PrecioCosto;
  13. int stock;
  14.  
  15. void load_art(float &price, char name, char branch, float &PrecioVenta, float &PrecioCosto, int &stock);
  16. void CambiarStock(int &stock);
  17. void ConsultarPrecioCosto(char name[], float PrecioCosto);
  18. void ConsultarPrecioVenta(char name[], float PrecioVenta);
  19. void mostrar(char name[], float price, char branch[], float PrecioVenta, float PrecioCosto, int stock);
  20. };
  21.  
  22.  
  23. struct StockGeneral
  24. {
  25. art datos[100];
  26.  
  27. char encontrado;
  28. int pos;
  29. char NombreBuscado[100];
  30.  
  31. StockGeneral();
  32. void BuscarStock(char NombreBuscado[], int &pos, char &encontrado);
  33. void CargarStockGeneral();
  34. void CompraArticulos();
  35. void MostrarStock();
  36. };
  37.  
  38.  
  39. struct client
  40. {
  41. char name[50];
  42. int id;
  43. char domicilio [100];
  44. float precio_acumulado;
  45.  
  46. void CargarDatos(int &id, char nombre[], char domicilio[], float &precio_acumulado);
  47. void MostrarDatos(int id, char nombre[], char domicilio[], float precio_acumulado);
  48. void ConsultarSaldo();
  49. void ActualizarSaldo(int id, float &precio_acumulado);
  50. };
  51.  
  52.  
  53. struct total_clients
  54. {
  55. client datos[100];
  56. int tope;
  57.  
  58. void CargarTotalClientes();
  59. void MostrarTotalClientes();
  60. void BuscarTotalClientes(char NombreBuscado[],int &pos, char &encontrado);
  61. };
  62.  
  63.  
  64.  
  65. struct venta
  66. {
  67. void CargarFactura(char name[], char branch[], int &stock, float &totalfactura);
  68. void MostrarFactura (char name[], char branch[], int &stock, float totalfactura);
  69. }
  70.  
  71.  
  72.  
  73.  
  74. //----------------------------------
  75. //
  76. // ART - FUNCIONES
  77. //
  78. //----------------------------------
  79.  
  80. void art::load_art(float &price, char name, char branch, float &PrecioVenta, float &PrecioCosto, int &stock)
  81. {
  82. art article;
  83.  
  84. cout << " ------------------------------------- \n\n";
  85. cout << " CARGA DATOS DEL ARTICULO: \n";
  86. cout << " ------------------------------------- \n\n";
  87.  
  88. cout<< " Nombre: ";
  89. cin.getline(article.name, 50);
  90.  
  91. cout << " Marca: ";
  92. cin.getline(article.branch, 50);
  93.  
  94. cout << " Precio Venta: ";
  95. cin >> article.PrecioVenta;
  96.  
  97. cout << " Precio Costo: ";
  98. cin >> article.PrecioCosto;
  99.  
  100. cout << " Stock: ";
  101. cin >> article.stock;
  102. }
  103.  
  104.  
  105. void art::CambiarStock (int &stock)
  106. {
  107. cout << " Ingrese el nombre del articulo: ";
  108. cin.getline(article.name, 50);
  109.  
  110. cout << " Ingresar nuevo stock: ";
  111. cin >> article.stock;
  112. }
  113.  
  114.  
  115. void art::ConsultarPrecioCosto (char name[], float PrecioCosto)
  116. {
  117. art article;
  118.  
  119. cout << " Ingrese el nombre del articulo: ";
  120. cin.getline(article.name, 50);
  121.  
  122. cout << " El precio es: " << article.PrecioCosto;
  123. }
  124.  
  125.  
  126. void art::ConsultarPrecioVenta (char name[], float PrecioVenta)
  127. {
  128. art article;
  129.  
  130. cout << " Ingrese el nombre del articulo: ";
  131. cin.getline(article.name, 50);
  132.  
  133. cout << " El precio es: " << article.PrecioVenta;
  134. }
  135.  
  136.  
  137. void art::mostrar(char name[], float price, char branch[], float PrecioVenta, float PrecioCosto, int stock)
  138. {
  139. art article;
  140.  
  141. cout << " -------------------------------------------------------------- \n";
  142. cout << " -------------------------- ARTICULO --------------------------";
  143. cout << " -- Nombre: " << article.name << "\n";
  144. cout << " -- Marca: " << article.branch << "\n";
  145. cout << " -- Precio de Venta: " << article.PrecioVenta << "\n"; //EXPECTED ; BEFORE "ARTICLE"
  146. cout << " -- Precio de Costo: " << article.PrecioCosto << "\n";
  147. cout << " -- Stock: " << article.stock << "\n"; // EPECTED ; BEFORE "ARTICLE"
  148. cout << " -------------------------------------------------------------- \n";
  149. }
  150.  
  151.  
  152.  
  153. //----------------------------------
  154. //
  155. // STOCK - FUNCIONES
  156. //
  157. //----------------------------------
  158.  
  159. StockGeneral::StockGeneral()
  160. {
  161. int tope[100];
  162.  
  163.  
  164. for (int i =0; i <100; i++)
  165. tope[i]=0;
  166. }
  167.  
  168.  
  169.  
  170. void StockGeneral::CargarStockGeneral()
  171. {
  172. char rta;
  173. int tope;
  174.  
  175. while (tope<100)
  176. {
  177. do {
  178. datos[pos].load_art(id, nombre[], domicilio[], precio_acumulado);
  179. tope++;
  180. cout << " Cargar otro? S/N?";
  181. cin >> rta;
  182. cin.ignore();
  183. } while(rta != 'n' && rta!='N');
  184.  
  185. system("CLS");
  186. }
  187. }
  188.  
  189.  
  190. void StockGeneral::BuscarStock(char NombreBuscado[],int &pos, char &encontrado)
  191. {
  192. encontrado=0;
  193. pos=0;
  194. int tope=100;
  195. int i=0;
  196.  
  197. while ((pos < tope) && (strcmp(NombreBuscado, article.name)!=0))
  198. {
  199. pos++;
  200.  
  201. if (pos<tope)
  202. encontrado=1;
  203. else
  204. pos=1;
  205. }
  206. }
  207.  
  208.  
  209. float StockGeneral::CambiarPrecioVenta (float PrecioVenta)
  210. {
  211. char encontrado;
  212.  
  213. cout << " Ingrese el nombre del articulo: ";
  214. cin.getline(art.name, 50);
  215.  
  216. StockGeneral.BuscarStock(NombreBuscado[], pos, encontrado);
  217.  
  218. if (encontrado==0)
  219. {
  220. cout << " Ingresar precio de costo del articulo: ";
  221. cin >> PrecioVenta;
  222. }
  223. else if (encontrado == 1)
  224. cout << " No se puede cambiar el precio. \n El articulo ingresado no existe. \n\n";
  225.  
  226. return PrecioVenta;
  227. }
  228.  
  229.  
  230. void StockGeneral::CompraArticulos()
  231. {
  232. char NombreBuscado[100], encontrado;
  233. int stockaux, pos;
  234.  
  235. cout << " Escribir nombre de articulo a cambiar stock: ";
  236. cin.getline(NombreBuscado, 100);
  237.  
  238. StockGeneral.BuscarStock(NombreBuscado[], pos, encontrado);
  239.  
  240. if (encontrado==0)
  241. {
  242. cout << " Ingresar stock del articulo a comprar: ";
  243. cin >> stockaux;
  244.  
  245. datos[pos].stock += stockaux;
  246.  
  247. cout << " Se actualizo el stock.-";
  248. }
  249. else if (encontrado == 1)
  250. cout << " No se puede cambiar el precio. \n El articulo ingresado no existe. \n\n";
  251.  
  252. }
  253.  
  254.  
  255. void StockGeneral::MostrarStock()
  256. {
  257. art articulo;
  258.  
  259. cout << " ------------------------------------------------------------------- \n";
  260. cout << " -------------------------- STOCK GENERAL -------------------------- \n";
  261. cout << " ------------------------------------------------------------------- \n";
  262.  
  263. for (int i=0; i <100; i++)
  264. articulo.mostrar(name[], branch[], PrecioVenta, PrecioCosto, stock);
  265.  
  266. cout << " ------------------------------------------------------------------- \n";
  267. cout << " ------------------------------------------------------------------- \n";
  268. cout << " ------------------------------------------------------------------- \n";
  269. }
  270.  
  271.  
  272.  
  273.  
  274. //----------------------------------
  275. //
  276. // CLIENTE - FUNCIONES
  277. //
  278. //----------------------------------
  279.  
  280.  
  281. void client::CargarDatos(int &id, char nombre[], char domicilio[], float &precio_acumulado)
  282. {
  283. client cliente;
  284.  
  285. cout << " INGRESO DE DATOS DEL CLIENTE: \n";
  286. cout << " ------------------------------------- \n\n";
  287.  
  288. cout << " Codigo: ";
  289. cin >> cliente.id;
  290.  
  291. cout << " Nombre: ";
  292. cin.getline (cliente.name,50);
  293.  
  294. cout << " Domicilio: ";
  295. cin.getline (cliente.domicilio,100);
  296.  
  297. cout << " Saldo Acumulado: ";
  298. cin >> cliente.precio_acumulado;
  299. }
  300.  
  301.  
  302. void client::MostrarDatos(int id, char nombre[], char domicilio[], float precio_acumulado)
  303. {
  304. client cliente;
  305.  
  306. cout << " -+-+-+- DATOS DEL CLIENTE -+-+-+- \n";
  307. cout << " ---------------------------------------------------- \n\n\n";
  308. cout << " --- ID:" << cliente.id << " \n";
  309. cout << " --- Nombre: " << cliente.name << " \n";
  310. cout << " --- Domicilio: " << cliente.domicilio << "\n";
  311. cout << " --- Saldo: " << cliente.precio_acumulado << "\n";
  312. cout << " ---------------------------------------------------- \n\n\n";
  313. }
  314.  
  315.  
  316. void client::ConsultarSaldo()
  317. {
  318. client cliente;
  319.  
  320. cout << " Ingrese ID del cliente: ";
  321. cin >> cliente.id;
  322.  
  323. cout << " El saldo es " << cliente.precio_acumulado << " \n";
  324. }
  325.  
  326.  
  327.  
  328. void client::ActualizarSaldo(int id, float &precio_acumulado)
  329. {
  330. client cliente;
  331. float nuevosaldo;
  332.  
  333. cout << " Ingresar ID del cliente: ";
  334. cin >> cliente.id;
  335.  
  336. cout << " Ingrese nuevo Saldo: ";
  337. cin >> nuevosaldo;
  338.  
  339. cliente.precio_acumulado = nuevosaldo;
  340. }
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352. //----------------------------------
  353. // TOTAL DE CLIENTES
  354. //
  355. // FUNCIONES
  356. //----------------------------------
  357.  
  358.  
  359. void total_clients::CargarTotalClientes()
  360. {
  361. char rta;
  362.  
  363. while (tope<100)
  364. {
  365. do {
  366. datos[tope].CargarDatos();
  367. tope++;
  368. cout << " Cargar otro? S/N?";
  369. cin >> rta;
  370. cin.ignore();
  371. } while(rta != 'n' && rta!='N');
  372.  
  373. system("CLS");
  374. }
  375. }
  376.  
  377.  
  378. void total_clients::MostrarTotalClientes()
  379. {
  380. client cliente;
  381. int id;
  382. char name [50], domicilio [100];
  383. float precio_acumulado;
  384.  
  385. cout << " DETALLE DE TODOS LOS CLIENTES: \n";
  386. cout << " ------------------------------------------------- \n\n";
  387. cliente.MostrarDatos(id, name, domicilio, precio_acumulado);
  388. cout << " ------------------------------------------------- \n\n";
  389. }
  390.  
  391.  
  392. void total_clients::BuscarTotalClientes(char NombreBuscado[],int &pos, char &encontrado)
  393. {
  394. art article;
  395. encontrado=0;
  396. pos=0;
  397. int tope=100;
  398.  
  399. while ((pos <tope) && (strcmp(NombreBuscado, article[pos].name)!=0))
  400. {
  401. pos++;
  402.  
  403. if (pos<tope)
  404. encontrado=true;
  405. else
  406. pos=1;
  407. }
  408. }
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416. //----------------------------------
  417. // FACTURAS
  418. //
  419. // FUNCIONES
  420. //----------------------------------
  421.  
  422.  
  423. void venta::CargarFactura(char name[], char branch[], int &stock, float totalfactura)
  424. {
  425. art articulo;
  426. int stockfactura;
  427. float totalfactura;
  428.  
  429. cout << " Ingresar nombre de articulo a vender: ";
  430. cin.getline(articulo.name, 50);
  431.  
  432. StockGeneral.BuscarStock(NombreBuscado, pos, encontrado);
  433.  
  434. if (encontrado == 1)
  435. {
  436. cout << " Ingresar marca: ";
  437. cin.getline(articulo.branch,50);
  438.  
  439. cout << " Ingresar stock: ";
  440. cin >> stockfactura;
  441.  
  442. while (stockfactura > articulo.stock)
  443. {
  444. cout << " No se puede vender esa cantidad. \n Ingresar stock correcto: ";
  445. cin >> stockfactura;
  446. }
  447. }
  448. articulo.stock = articulo.stock - stockfactura;
  449.  
  450. totalfactura= stockfactura*articulo.PrecioVenta;
  451.  
  452. cout << " Ingresar nombre de cliente: ";
  453. cin.getline (client.name, 50);
  454.  
  455. total_clients.BuscarCliente(NombreBuscado, pos, encontrado);
  456.  
  457. if (encontrado == 1)
  458. {
  459. client.precio_acumulado = client.precio_acumulado - totalfactura;
  460.  
  461. if (client.precio_acumulado < 0)
  462. cout << " No se puede realizar esta venta.";
  463. }
  464. else if (encontrado ==0)
  465. cout << " El cliente ingresado no existe. \n";
  466.  
  467. }
  468.  
  469.  
  470.  
  471. void venta::MostrarFactura(char name[], char branch[], int &stock, float totalfactura)
  472. {
  473. cout << " ---------------------------------------------------- ";
  474. cout << " -- Articulo: " << art.name << "\n";
  475. cout << " -- Marca: " << art.branch << "\n";
  476. cout << " -- Stock vendido: " << art.stock << "\n\n";
  477. cout << " -- Cliente: " << client.name << "\n";
  478. cout << " -- Saldo actual del cliente: " << client.precio_acumulado << "\n\n\n";
  479. cout << " ---------- TOTAL FACTURA: -- $" << totalfactura << "\n";
  480. }
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505. //----------------------------------
  506. //
  507. // MAIN
  508. //
  509. //----------------------------------
  510.  
  511. int main()
  512. {
  513. art articulos;
  514. StockGeneral StockTotal;
  515. client clientes;
  516. total_clients todoslosclientes;
  517. venta factura;
  518.  
  519. char choice;
  520.  
  521. cout << " ------------------------------------------- \n";
  522. cout << " -------------- ELEGIR ACCION -------------- \n";
  523. cout << " ------------------------------------------- \n\n";
  524.  
  525. cout << " -1- Cargar articulos. \n"; // LLAMA A CARGAR DEL STOCKGENERAL
  526. cout << " -2- Consultar Precio de Costo. \n";
  527. cout << " -3- Consultar Precio de Venta. \n";
  528. cout << " -4- Cambiar Stock. \n";
  529. cout << " -5- Mostrar articulos. \n\n"; // MOSTRAR DEL STOCKGENERAL
  530. cout << " -6- Buscar un articulo. \n";
  531. cout << " -7- Comprar articulos. \n";
  532. cout << " -8- Mostrar StockGeneral. \n\n";
  533. cout << " -9- Cargar datos del cliente. \n";
  534. cout << " -a- Consultar Saldo. \n";
  535. cout << " -b- Actualizar saldo. \n";
  536. cout << " -c- Buscar Cliente. \n";
  537. cout << " -d- Mostrar clientes. \n\n";
  538. cout << " -h- Cargar datos para factura. \n";
  539. cout << " -i- Mostrar factura. \n\n";
  540. cout << " -0- Salir. \n\n";
  541. cout << " Elegiste: ";
  542. cin >> choice;
  543.  
  544. cout << " ------------------------------------------- \n\n";
  545. cout << " ------------------------------------------- \n\n";
  546. cout << " ------------------------------------------- \n\n";
  547.  
  548. switch (choice)
  549. {
  550. case '1':
  551. StockTotal.CargarStockGeneral();
  552. break;
  553.  
  554. case '2':
  555. articulo.consultarprecosto();
  556. break;
  557.  
  558. case '3':
  559. articulo.consultarprevta();
  560. break;
  561.  
  562. case '4':
  563. articulo.cambiarcosto();
  564. break;
  565.  
  566. case '5':
  567. StockTotal.MostrarStock();
  568. break;
  569.  
  570. case '6':
  571. StockTotal.BuscarStock(NombreBuscado[], pos, encontrado);
  572. break;
  573.  
  574. case '7':
  575. StockTotal.CompraArticulos();
  576. break;
  577.  
  578. case '8':
  579. StockTotal.MostrarStock();
  580. break;
  581.  
  582. case '9':
  583. todoslosclientes.CargarTotalClientes();
  584. break;
  585.  
  586. case 'a': case 'A':
  587. clientes.ConsultarSaldo();
  588. break;
  589.  
  590. case 'b':case 'B':
  591. clientes.ActualizarSaldo();
  592. break;
  593.  
  594. case 'c': case 'C':
  595. todoslosclientes.BuscarTotalClientes();
  596. break;
  597.  
  598. case 'd': case 'D':
  599. todoslosclientes.MostrarTotalClientes();
  600. break;
  601.  
  602. case 'h': case 'H':
  603. factura.CargarFactura(name[], branch[], stock, totalfactura);
  604. break;
  605.  
  606. case 'i': case 'I':
  607. factura.MostrarFactura();
  608. break;
  609.  
  610. case'0':
  611. cout << " ---Fin del programa--- \n";
  612. }
  613.  
  614. system("PAUSE");
  615. return EXIT_SUCCESS;
  616. }
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC