/************************************************************************/
/* 开发环境:vc6.0
/* 时间:2010.10.31 by zhangdongsheng                                    */
/************************************************************************/
#include <iostream>
#include <string>
#include <time.h>
#include <fstream>
#include <conio.h>
#include <windows.h>
#include <iomanip>

using namespace std;

class borrow
{
public:
 string name;
 string goods;
 string num;
};

const char *str="D:\\data.dat";

void FirstDisplay();//程序主菜单
void Input();       //输入
void Delete();      //删除记录
void Out();      //显示所有
string Int_to_string(int a);//将一个整形转化为string
tm *GetTime();       //获取当前时间
bool FindEqualData(string &today); //检查 str里面是否有字符串string
bool checkChoice(string str);//判断 str 是否为数字

int main()          //main函数
{
 ifstream fin(str);   //如果没有文件则创建
 if(fin.fail())
 { ofstream fon(str);
  fon.close();
 }
 fin.close();
 FirstDisplay();
 system("pause");
 return 0;
}

string Int_to_string(int a)  //整形转化为string
{
 char temp[10];
 
 memset(temp,0,sizeof(temp));
 itoa(a,temp,10);
 string ResultStr=temp;
 return ResultStr;
}

//程序主菜单
void FirstDisplay()
{
 ifstream fin;
 fin.open(str);
// if(fin.good()) cout<<"打开文件成功"<<endl;
 
 tm *prt=GetTime();
 
 //当前的年月日 转化为一人字符串如"2010.10.31"
 string today=Int_to_string(1900+prt->tm_year);
 today.append(".");
 today.append(Int_to_string(prt->tm_mon+1));
 today.append(".");
 today.append(Int_to_string(prt->tm_mday));

cout<<"今天是"<<today<<endl;

// 在文本中查找是否出现string"2010.10.31"
 string data;
 bool check;
 char ch;
 while(!fin.eof())
 {
  getline(fin,data);
  if(data==today) //如果出现"2010.10.31"
  {
   check=true;
   break;
  }
  else
   check=false;//
 }
 if(check)
 {
  while(!fin.eof())
  {
   ch=fin.get();
   cout<<ch;
  }
  cout<<"\n\n\n"<<endl;
 }
 else
  cout<<endl<<"今天没有记录\n\n"<<endl;
 fin.close();

//菜单
 int choice;
 string TempChoice;
 cout<<"***************欢迎使用拿包包记录系统**************\n";
 puts("*\t+--------------------------------+        *");
 puts("*\t|         1.添加记录             |        *");
 puts("*\t|         2.查看所有记录         |        *");
 puts("*\t|         3.删掉所有记录         |        *");
 puts("*\t|         4.保存退出             |        *");
 puts("*\t|                                |        *");
 puts("*\t|                                |        *");
 puts("*\t|          c++奋斗乐园           |        *");
 puts("*\t+--------------------------------+        *");
 puts("***************************************************");
    cout<<"\t请输入您的选择:";
 cin>>TempChoice;
 while(!checkChoice(TempChoice))
 {
  cout<<"输入的不是数字,重新输入"<<endl;
  cin>>TempChoice;
 }
 choice=atoi(TempChoice.c_str());
 switch(choice)
   {
   case 1:
    Input();
    break;
   case 2:
    Out();
    break;
   case 3:
    Delete();
    break;
   case 4:
    cout<<"程序即将退出"<<endl;
    exit(1);
   default:
    cout<<"输入有误,请输入1-4的数字"<<endl;
    break;
   }
 
 
}

void Input()      //输入
{
 ofstream fon;
 fon.open(str,ios::app);
 tm *prt=GetTime();
 
 string today=Int_to_string(1900+prt->tm_year);
 today.append(".");
 today.append(Int_to_string(prt->tm_mon+1));
 today.append(".");
 today.append(Int_to_string(prt->tm_mday));

string finish="1";
 
 borrow one;
 
 while(finish=="1")
 {
  ifstream fin(str,ios::app);
  cout<<"谁拿了"<<endl;
  cin>>one.name;
  cout<<"拿了什么"<<endl;
  cin>>one.goods;
  cout<<"几个"<<endl;
  cin>>one.num;
  if(FindEqualData(today))
  { 
   fin.close();
//   fon<<one.name<<"\t"<<one.goods<<"\t\t\t"<<one.num<<"\t\t"<<prt->tm_hour<<":"<<prt->tm_min<<":"<<prt->tm_sec<<endl;
   fon<<one.name<<setw(20)<<one.goods<<setw(10)<<one.num<<setw(10)<<prt->tm_hour<<":"<<prt->tm_min<<":"<<prt->tm_sec<<endl;
  }
  else
  { 
   
   fon<<today<<endl;
   fon<<"------------------------------------------------------------------"<<endl;
   fon<<"姓名"<<setw(20)<<"东西"<<setw(10)<<"个数"<<setw(15)<<"日期"<<endl;
   
//   fon<<one.name<<"\t"<<one.goods<<"\t\t\t"<<one.num<<"\t\t"<<prt->tm_hour<<":"<<prt->tm_min<<":"<<prt->tm_sec<<endl;
   fon<<one.name<<setw(20)<<one.goods<<setw(10)<<one.num<<setw(10)<<prt->tm_hour<<":"<<prt->tm_min<<":"<<prt->tm_sec<<endl;
   fin.close();
  }
  cout<<"再有没有要输入的,有(1),没有(0)"<<endl;
  cin>>finish;
 }
 if(finish=="0")
 cout<<"按任意键返回主菜单"<<endl;
 else cout<<"输入有误,按任意键返回主菜单"<<endl;
 getch();
 system("CLS");
 FirstDisplay();
}

void Delete()      //删除记录
{
 
 char *password;
 char *realpassword="1234";
 char *p=NULL;
 int count=0;
 int length=4;
 password = new char[length+1];
 cout<<"请输入4位密码"<<endl;
 p=password;
 while(((*p=getch()))&&(count<length))
 {
  putch('*');
  fflush(stdin);
  p++;
  count++;
 }
 password[count]='\0';
 if(strcmp(password, realpassword) == 0)
 {
  ofstream fon(str,ios::trunc);
  fon<<""<<endl;
  cout<<"成功删除"<<endl;
  fon.close();
  getch();
  system("CLS");
  FirstDisplay();
 }
 else
 {
  cout<<"密码错误"<<endl;
  FirstDisplay();
 }
/* int secret;
 cout<<"请输入密码"<<endl;
 cin>>secret;
 if(secret==3342125)
 {
  ofstream fon(str,ios::trunc);
  fon<<""<<endl;
  cout<<"成功删除"<<endl;
 }
 else
  cout<<"密码不对"<<endl;*/
}

void Out()  //输出
{
 ifstream fin(str);
 char ch;
 while(!fin.eof())
 {
  ch=fin.get();
  cout<<ch;
 }
 cout<<"\n\n按任意键进入主菜单";
 fin.close();
 getch();
 system("CLS");
 FirstDisplay();
}

tm *GetTime()//获取当前时间的一个指针
{
 tm *prt;
 time_t t;
 t=time(NULL);
 prt=localtime(&t);
 return prt;
}

bool FindEqualData(string &today)  //判断文件中是否有 today 字符串
{
 ifstream fin(str);
 string data;
 bool check;
 while(!fin.eof())
 {
  getline(fin,data);
  if(data==today) //如果出现"2010.10.31"
  {
   check=true;
   break;
  }
  else
   check=false;//
 }
 fin.close();
 return check;

}

bool checkChoice(string str)
{
 for(int i=0;i<str.length();i++)
  if(str[i]>'9'||str[i]<'0')
   return false;
 return true;
}

转载于:https://www.cnblogs.com/zhangdongsheng/archive/2010/11/02/1866773.html

商厂里调货拿包包程序相关推荐

  1. 大型跨境电商 JVM 调优经历

    大型跨境电商 JVM 调优经历 前提: 某大型跨境电商业务发展非常快,线上机器扩容也很频繁,但是对于线上机器的运行情况,特别是jvm内存的情况,一直没有一个统一的标准来给到各个应用服务的owner.经 ...

  2. (附源码)springboot球鞋调货管理系统 毕业设计 160942

    Springboot球鞋调货管理系统 摘  要 大部分的球鞋销售商和球鞋生产商他们的运营方式还停留在比较古老的时代.固然有一小部分球鞋销售商已经开始运用互联网作业,但是他们的球鞋销售管理系统并非很完美 ...

  3. 利物直播购物商城带货微信小程序源码

    源码说明 利物直播购物商城带货小程序源码,直播与购物深度结合的新体验,直播购物热度无需再多描述! 未来利物直播商城将深度的挖掘内容+电商的需求(内容:短视频带货,自媒体入驻文章带货,洋淘秀等具有强烈社 ...

  4. (附源码)Springboot球鞋调货管理系统 毕业设计160942

    Springboot球鞋调货管理系统 摘 要 大部分的球鞋销售商和球鞋生产商他们的运营方式还停留在比较古老的时代.固然有一小部分球鞋销售商已经开始运用互联网作业,但是他们的球鞋销售管理系统并非很完美, ...

  5. spring boot基于Springboot的球鞋调货管理系统设计与实现 毕业设计-附源码160942

    Springboot球鞋调货管理系统 摘  要 大部分的球鞋销售商和球鞋生产商他们的运营方式还停留在比较古老的时代.固然有一小部分球鞋销售商已经开始运用互联网作业,但是他们的球鞋销售管理系统并非很完美 ...

  6. 抖音电商的带货情况究竟如何,抖音电商带货前景如何

    继微商之后,随着抖音的火爆,现在又出现了抖商一词,甚至已经有人办抖商大会了,各种相关的培训机构也在大肆揽客,还有人准备推出抖商代运营服务了. 那么,抖音电商的带货情况究竟如何呢?刘老私花了两天时间一边 ...

  7. PHP开发B2C商城 微信小程序商城系统源码+数据库,轻量级前后端分离的电商系统,支持微信小程序 + H5+ 公众号 + APP

    项目介绍 一款轻量级.高性能.前后端分离的电商系统,支持微信小程序 + H5+ 公众号 + APP,前后端源码完全开源,看见及所得,完美支持二次开发,可学习可商用,让您快速搭建个性化独立商城. 完整代 ...

  8. 新手做电商直播带货怎么和快递合作谈价格

    新手做电商直播带货怎么和快递合作谈价格达人带货一般怎样的合作模式?#达人带货 #直播带货 #红人 #百收网 跟快递谈价其实是有方法的,快递的价格不是说不能打下来,就是需要你们多一点点的心机.这个视频我 ...

  9. 一度智信:电商店铺未发货时退款正确操作

    一度智信:电商店铺未发货时退款正确操作 店家入驻拼多多平台,在经营店铺的过程之中难免会遇到各种各样难以解决的电商问题.不少店家都想知道关于店铺退款问题.那么,接下来跟着一度智信小编一起来了解一下关于拼 ...

  10. 防窜货PDA扫描程序 APP 出入库扫描打印

    物流/防窜货PDA扫描程序,用于物流/防窜货出入库扫描管理,通过PDA扫描记录好出入库的信息如:产品,出货客户,批号等.并可以通过网络(如GPRSM.3G.WIFI)上传到后台系统,适合wince系统 ...

最新文章

  1. rsync+innotify实现实时同步
  2. danfoss 变频器的profinet通讯调试_840D sl系统PLC 开机调试
  3. OpenCV 3.x Lib 源码结构简介
  4. Confluence 6 的 Crowd 设置
  5. Paper:《Hidden Technical Debt in Machine Learning Systems—机器学习系统中隐藏的技术债》翻译与解读
  6. ckeditor java 使用_如何覆盖默认插件并使用它们拥有按钮ckeditor
  7. openstack rocky 安装_北京暖气安装费用-上海装修报价
  8. 将函数实现放在头文件中
  9. css bug 集2
  10. TPS2552DBVR配电开关
  11. 用pdf转cad转换器进行操作的简单步骤
  12. 一行 Python 能实现什么丧心病狂的功能?
  13. 细思极恐的星座分析(下)- 外太空?内子宫?人类的天赋从何而来?
  14. 28、星历处理任务实现
  15. 微信豆有什么作用?微信豆怎么用?附攻略
  16. 2021年广州市学历入户全流程(持续更新)
  17. 【5G模组】讨论RSSI,RSRP,RSRQ and SINR
  18. 我的ubuntu 8.10安装配置经验(Intrepid Ibex)(转)
  19. [python]数据整理,将取得的众多的沪深龙虎榜数据整一整
  20. 知到网课创新工程实践见面课答案

热门文章

  1. h5+js调取相机做取景框_iPhone 12 相机操作指南,用好了随手一拍就是大片!
  2. 【Python实例第32讲】一个分类分数的置换检验
  3. 【sklearn第十四讲】决策树之分类篇
  4. C++并发与多线程(一)线程传参
  5. Baxter实战 (一)ubuntu14.04安装ROS-Indigo
  6. python 爬取全本免费小说网的小说
  7. MySQL 5.7安装(多实例)最佳实践
  8. RESTful 设计工具和Web框架
  9. Python之路-(列表、元组、字典、集合、字符串)
  10. mongo .update