64,282
社区成员
发帖
与我相关
我的任务
分享
//date_material.h
#pragma once
#include<string>
#include<cstring>
#include<iostream>
#include<fstream>
#include<time.h>
#include<stdio.h>
using namespace std;
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Runtime::InteropServices;
struct num_material
{
int num;
};
class date_material
{
char name[80];
Single price;
float density;
float Time;
public:
date_material()
{
price=0;
density=0;
Time=0;
}
date_material(String^ newDate_name,Single newDate_price,Single newDate_density)
{
Single year,month,day;
struct tm *ptr;
time_t t;
t=time(NULL);
ptr=localtime(&t);
year=ptr->tm_year+1900;
month=ptr->tm_mon+1;
day=ptr->tm_mday;
Time=year*10000+month*100+day;
char* stringPointer = (char*) Marshal::StringToHGlobalAnsi(newDate_name).ToPointer();
for(int i=0;i<sizeof(stringPointer);++i)
name[i]=stringPointer[i];
price=newDate_price;
density=newDate_density;
}
char *Get_name()
{
return name;
}
Single Get_time()
{
return Time;
}
Single Get_price()
{
return price;
}
Single Get_density()
{
return density;
}
friend class From_selectMaterial;
}
//Form_selectMaterial.cpp
#include "date_material.h"
//输入数据
void Form_selectMaterial::add_date(date_material *date)
{
fstream outToFile;
outToFile.open("Material_list.bin",ios::binary|ios::app);
if(!outToFile)
{
MessageBox::Show("无法成功打开材料存档,请检查!","出错了",MessageBoxButtons::OK);
}
outToFile.write((char*)&date,sizeof(date_material));
outToFile.close();
}
//读取数据
void Form_selectMaterial::Get_date()
{
date_material temp;
fstream inToFile("Material_list.bin",ios::binary|ios::in);
inToFile.read((char*)&temp,sizeof(date_material));
inToFile.close();
}
//date_material.h
#pragma once
#include<string>
#include<cstring>
#include<iostream>
#include<fstream>
#include<time.h>
#include<stdio.h>
using namespace std;
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Runtime::InteropServices;
struct num_material
{
int num;
};
class date_material
{
char name[80];
Single price;
float density;
float Time;
public:
date_material()
{
price=0;
density=0;
Time=0;
}
date_material(String^ newDate_name,Single newDate_price,Single newDate_density)
{
Single year,month,day;
struct tm *ptr;
time_t t;
t=time(NULL);
ptr=localtime(&t);
year=ptr->tm_year+1900;
month=ptr->tm_mon+1;
day=ptr->tm_mday;
Time=year*10000+month*100+day;
char* stringPointer = (char*) Marshal::StringToHGlobalAnsi(newDate_name).ToPointer();
for(int i=0;i<sizeof(stringPointer);++i)
name[i]=stringPointer[i];
price=newDate_price;
density=newDate_density;
}
char *Get_name()
{
return name;
}
Single Get_time()
{
return Time;
}
Single Get_price()
{
return price;
}
Single Get_density()
{
return density;
}
friend class From_selectMaterial;
}
//Form_selectMaterial.cpp
#include "date_material.h"
//输入数据
void Form_selectMaterial::add_date(date_material *date)
{
fstream outToFile;
outToFile.open("Material_list.bin",ios::binary|ios::app);
if(!outToFile)
{
MessageBox::Show("无法成功打开材料存档,请检查!","出错了",MessageBoxButtons::OK);
}
outToFile.write((char*)&date,sizeof(date_material));
outToFile.close();
}
//读取数据
void Form_selectMaterial::Get_date()
{
date_material temp;
fstream inToFile("Material_list.bin",ios::binary|ios::in);
inToFile.read((char*)&temp,sizeof(date_material));
inToFile.close();
}