Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<conio2.h>
- #include<stdlib.h>
- #include<stdio.h> //bibliotecas
- #include<string.h>
- #include<ctype.h>
- #define TF 10
- //declaração de funções ou prototipos
- char menu(void);
- void Executa(void);
- void Vendas(TpProd Produtos[TF], int tam);
- int Busca(TpProd Tabela[TF], int TL, char Prod[20]);
- //void cadastro(TpProd TabProd[TF], int &tam);
- //void Relatorio(TpProd Tabela[TF], int qtde);
- struct TpProd //cosntantes
- {
- int cod, qtde;
- char Descr[10]; //structs
- float valor;
- };
- void Vendas(TpProd Produtos[TF], int tam)
- {
- int p, qt;
- char AuxDescr[20];
- printf("\nDescricao do Produto:");
- gets(AuxDescr);
- while(strcmp(AuxDescr,"\0")!=0)
- {
- p=Busca(Produtos, tam, AuxDescr);
- if(p==-1)
- printf("\nNao encontrado\n");
- else
- {
- printf("\nProduto Encontrado\n");
- printf("Codigo:%d\n", Produtos[p].cod);
- printf("Descrição:%s\n", Produtos[p].Descr);
- printf("Estoque:%d\n", Produtos[p].Qtd);
- printf("Valor Un R$:%.2f\n", Produtos[p].valor);
- printf("Quantidade:");
- scanf("%d", &qt);
- if(qt>Produtos[p].Qtde)
- printf("\n Quantidade Insuficiente\n");
- else
- {
- printf("\nValor total R$ %.2f\n", qt*Produto[p].valor);
- Produtos[p].Qtde=Produtos[p].Qtde-qt;
- printf("\nVenda Realizada!\n");
- }
- }
- getch();
- printf("\nDescricao do Produto:");
- gets(AuxDescr);
- }
- };
- char menu(void)
- {
- clrscr();
- printf("\n##Menu de Opcao##\n");
- printf("\n[C]adastro");
- printf("\n[E]xibe");
- printf("\n[V]enda");
- printf("\n[A]d. Estoque\n");
- printf("\nopcao");
- return toupper (getch());
- };
- void cadastro(TpProd TabProd[TF], int &tam)
- {
- int auxProd;
- printf("Codigo do Produto:\n");
- scanf("%d", &auxProd);
- while(tam<TF &&auxProd!=0)
- {
- TabProd[tam].cod=auxProd;
- printf("Descricao:\n");fflush(stdin);
- gets(TabProd[tam].Descr);
- printf("QTDE. Inicial:\n");
- scanf("%d", &TabProd[tam].qtde);
- printf("Valor:\n");
- scanf("%d", &TabProd[tam].valor);
- tam++;
- printf("Codido do Pruduto\n");
- scanf("%d", &auxProd);
- }
- };
- void Executa (void)
- {
- TpProd Tab[TF];
- int TL=0;
- char op;
- do
- {
- op=menu();clrscr();
- switch(op)
- {
- case 'C': printf("\nCadastra Produto\n");
- cadastro(Tab, TL);break;
- case 'E':printf("\nRelatorio de Produtos\n");
- //relatorio (Tab, TL);break;
- case 'V':printf("\nVendas de Produtos\n");
- printf("\nVendas");
- vendas(Tab, TL);
- break;
- case 'A':printf("\nAdiciona Estoque\n");
- break;
- }
- }while(op!=27);
- };
- int main()
- { Executa();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement