📄 action.cpp
字号:
}
if(!readfile.eof())
{
buff=readnote(readfile);
if(buff==mtype5)
break;
}
}
while(!readfile.eof()&&!(buff=="notebegin"))
{
buff=readnote(readfile);
continue;
}
if(buff=="notebegin")
{
clean();
m_mtype1=readnote(readfile);
m_meach1=readnote(readfile);
m_mtime1=readnote(readfile);
m_mtime2=readnote(readfile);
m_mprice1=readnote(readfile);
}
buff=readnote(readfile);
while(!readfile.eof()&&!(buff=="notebegin"))
{
buff=readnote(readfile);
continue;
}
if(buff=="notebegin")
{
m_mtype2=readnote(readfile);
m_meach2=readnote(readfile);
m_mtime3=readnote(readfile);
m_mtime4=readnote(readfile);
m_mprice2=readnote(readfile);
}
buff=readnote(readfile);
while(!readfile.eof()&&!(buff=="notebegin"))
{
buff=readnote(readfile);
continue;
}
if(buff=="notebegin")
{
m_mtype3=readnote(readfile);
m_meach3=readnote(readfile);
m_mtime5=readnote(readfile);
m_mtime6=readnote(readfile);
m_mprice3=readnote(readfile);
}
buff=readnote(readfile);
while(!readfile.eof()&&!(buff=="notebegin"))
{
buff=readnote(readfile);
continue;
}
if(buff=="notebegin")
{
m_mtype4=readnote(readfile);
m_meach4=readnote(readfile);
m_mtime7=readnote(readfile);
m_mtime8=readnote(readfile);
m_mprice4=readnote(readfile);
}
buff=readnote(readfile);
while(!readfile.eof()&&!(buff=="notebegin"))
{
buff=readnote(readfile);
continue;
}
if(buff=="notebegin")
{
m_mtype5=readnote(readfile);
m_meach5=readnote(readfile);
m_mtime9=readnote(readfile);
m_mtime10=readnote(readfile);
m_mprice5=readnote(readfile);
}
if(readfile.eof())
GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);
readfile.close();
m_chk1=0;
m_chk2=0;
m_chk3=0;
m_chk4=0;
m_chk5=0;
UpdateData(FALSE);
}
void action::clean()
{
m_mtype1="";
m_meach1="";
m_mtime1="";
m_mtime2="";
m_mprice1="";
m_mtype2="";
m_meach2="";
m_mtime3="";
m_mtime4="";
m_mprice2="";
m_mtype3="";
m_meach3="";
m_mtime5="";
m_mtime6="";
m_mprice3="";
m_mtype4="";
m_meach4="";
m_mtime7="";
m_mtime8="";
m_mprice4="";
m_mtype5="";
m_meach5="";
m_mtime9="";
m_mtime10="";
m_mprice5="";
}
BOOL action::OnInitDialog()
{
CDialog::OnInitDialog();
page=0;
GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void action::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
if(m_chk1)
num+=atof(m_mprice1);
if(m_chk2)
num+=atof(m_mprice2);
if(m_chk3)
num+=atof(m_mprice3);
if(m_chk4)
num+=atof(m_mprice4);
if(m_chk5)
num+=atof(m_mprice5);
CString buff;
buff.Format("%.2f",num);
GetDlgItem(IDC_STATIC1)->SetWindowText(buff);
m_chk1=0;
m_chk2=0;
m_chk3=0;
m_chk4=0;
m_chk5=0;
num=0;
UpdateData(FALSE);
//CDialog::OnOK();
}
void action::OnCancel3()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_chk1)
num+=atof(m_mprice1);
if(m_chk2)
num+=atof(m_mprice2);
if(m_chk3)
num+=atof(m_mprice3);
if(m_chk4)
num+=atof(m_mprice4);
if(m_chk5)
num+=atof(m_mprice5);
CString buff;
buff.Format("%.2f",num);
GetDlgItem(IDC_STATIC1)->SetWindowText(buff);
m_chk1=0;
m_chk2=0;
m_chk3=0;
m_chk4=0;
m_chk5=0;
UpdateData(FALSE);
}
CString action::dateyear(CString date, int n)
{
CString buff;
CString retu;
int m=date.Find('.');
if(n==1){
retu=date.Left(m);
}
if(n==2){
n=date.Find(".",m+1);
retu=date.Left(n);
retu=retu.Right(n-m-1);
}
if(n==3){
n=date.Find(".",m+1);
m=date.GetLength();
retu=date.Right(m-n-1);
}
return retu;
}
int action::compare(CString a, CString b)
{
int montha,monthb,datea,dateb,buff,last;
int n,i;
int yeara=atoi(dateyear(a,1));
int yearb=atoi(dateyear(b,1));
datea=atoi(dateyear(a,3));
dateb=atoi(dateyear(b,3));
montha=atoi(dateyear(a,2));
monthb=atoi(dateyear(b,2));
n=yearb-yeara;
for(i=0;i<n;i++)
{
yeara+=i;
if(!(yeara%400==0)&&!(yeara%4==0))
buff+=365;
else
buff+=366;
}
for(i=1;i<monthb+1;i++)
{
if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
buff+=31;
if(i==4||i==6||i==9||i==11)
buff+=30;
if(i==2)
{
if(!(yearb%400==0)&&!(yearb%4==0))
buff+=29;
else
buff+=28;
}
}
buff+=dateb;
for(i=1;i<montha+1;i++)
{
if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
last+=31;
if(i==4||i==6||i==9||i==11)
last+=30;
if(i==2)
{
if(!(yeara%400==0)&&!(yeara%4==0))
last+=29;
else
last+=28;
}
}
last+=datea;
return buff-last+1;
}
void action::OnChangeEdit2()
{
UpdateData(TRUE);
if(m_meach1.IsEmpty())
return;
if(m_mtime1.IsEmpty())
return;
if(m_mtime2.IsEmpty())
return;
int i=compare(m_mtime1,m_mtime2);
float n=atof(m_meach1)*i;
m_mprice1.Format("%.2f",n/100);
UpdateData(FALSE); // send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void action::OnChangeEdit5()
{
UpdateData(TRUE);
if(m_meach2.IsEmpty())
return;
if(m_mtime3.IsEmpty())
return;
if(m_mtime4.IsEmpty())
return;
int i=compare(m_mtime3,m_mtime4);
float n=atof(m_meach2)*i;
m_mprice2.Format("%.2f",n/100);
UpdateData(FALSE); // send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void action::OnChangeEdit8()
{
UpdateData(TRUE);
if(m_meach3.IsEmpty())
return;
if(m_mtime5.IsEmpty())
return;
if(m_mtime6.IsEmpty())
return;
int i=compare(m_mtime5,m_mtime6);
float n=atof(m_meach3)*i;
m_mprice3.Format("%.2f",n/100);
UpdateData(FALSE); // send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void action::OnChangeEdit11()
{
UpdateData(TRUE);
if(m_meach4.IsEmpty())
return;
if(m_mtime7.IsEmpty())
return;
if(m_mtime8.IsEmpty())
return;
int i=compare(m_mtime7,m_mtime8);
float n=atof(m_meach4)*i;
m_mprice4.Format("%.2f",n/100);
UpdateData(FALSE); // send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void action::OnChangeEdit14()
{
UpdateData(TRUE);
if(m_meach5.IsEmpty())
return;
if(m_mtime9.IsEmpty())
return;
if(m_mtime10.IsEmpty())
return;
int i=compare(m_mtime9,m_mtime10);
float n=atof(m_meach5)*i;
m_mprice5.Format("%.2f",n/100);
UpdateData(FALSE); // send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -