//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
#include "Unit1.h"
USEFORM("Unit1.cpp", Form1);
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormShow(TObject *Sender)
{
int a ;
Form1->MSComm1->RThreshold = 300;
Edit8->Text = Form1->Edit1->Text;
Edit9->Text = Form1->Edit2->Text;
Sleep(160);
String s = Form1->MSComm1->Input;
String RMoney = s.SubString(3,s.Length()-3);
a = StrToInt(RMoney);
a+= 0 ;
RMoney = IntToStr(a);
Edit1->Text = RMoney;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
int a,b,k;
a = StrToInt(Edit1->Text) ; //Text与浮点型的转换
String j = Edit2->Text ;
if(j.Length()==0) ShowMessage("请输入金额!") ;
else
{
b = StrToInt(j) ;
a = a + b ;
if(a>999999) ShowMessage("数据溢出!") ;
else
{
String yu_e = IntToStr(a) ;
k = yu_e.Length();
switch(k)
{
case 6 : Form1->MSComm1->Output = StringToOleStr("!3"+yu_e+'*');break ;
case 5 : Form1->MSComm1->Output = StringToOleStr("!30"+yu_e+'*');
break ;
case 4 : Form1->MSComm1->Output = StringToOleStr("!300"+yu_e+'*');
break ;
case 3 : Form1->MSComm1->Output = StringToOleStr("!3000"+yu_e+'*');
break ;
case 2 : Form1->MSComm1->Output = StringToOleStr("!30000"+yu_e+'*');
break ;
case 1 : Form1->MSComm1->Output = StringToOleStr("!300000"+yu_e+'*');
break ;
case 0 : Form1->MSComm1->Output = StringToOleStr("!3000000"+'*');
break ;
default: break ;
}
Sleep(160);
String yuu_e = Form1->MSComm1->Input ;
yuu_e = yuu_e.SubString(3,6);
a = StrToInt(yuu_e);
a += 0 ;
yuu_e = IntToStr(a);
Edit1->Text = yuu_e;
}
}
//Edit2->Text = "" ;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button2Click(TObject *Sender)
{
int a,b,k;
a = StrToInt(Edit1->Text) ; //Text与浮点型的转换
String j = Edit3->Text ;
if(j.Length()==0) ShowMessage("请输入金额!") ;
else
{
b = StrToInt(j) ;
a = a - b ;
if(a<0) ShowMessage("数据溢出!") ;
else
{
String yu_e = IntToStr(a) ;
k = yu_e.Length();
switch(k)
{
case 6 : Form1->MSComm1->Output = StringToOleStr("!3"+yu_e+'*');break ;
case 5 : Form1->MSComm1->Output = StringToOleStr("!30"+yu_e+'*');
break ;
case 4 : Form1->MSComm1->Output = StringToOleStr("!300"+yu_e+'*');
break ;
case 3 : Form1->MSComm1->Output = StringToOleStr("!3000"+yu_e+'*');
break ;
case 2 : Form1->MSComm1->Output = StringToOleStr("!30000"+yu_e+'*');
break ;
case 1 : Form1->MSComm1->Output = StringToOleStr("!300000"+yu_e+'*');
break ;
case 0 : Form1->MSComm1->Output = StringToOleStr("!3000000"+'*');
break ;
default: break ;
}
Sleep(160);
String yuu_e = Form1->MSComm1->Input ;
yuu_e = yuu_e.SubString(3,6);
a = StrToInt(yuu_e);
a+= 0 ;
yuu_e = IntToStr(a);
Edit1->Text = yuu_e;
}
}
//Edit3->Text = "" ;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button3Click(TObject *Sender)
{
if(Edit4->Text.Length() != 6||Edit5->Text.Length() != 6||Edit6->Text.Length() != 6)
ShowMessage("请输入6位密码!") ;
else if(Edit5->Text != Edit6->Text)
ShowMessage("两次输入不同!请重新输入!") ;
else if((Edit5->Text.Length() == 0)||(Edit6->Text.Length() == 0))
ShowMessage("两次输入不同!请重新输入!") ;
else
{
String x_mima = Edit5->Text ;
Form1->MSComm1->Output = StringToOleStr("!4"+Edit4->Text+'^'+Edit6->Text+'*');
Sleep(600);
String xmm_qr = Form1->MSComm1->Input ;
if(xmm_qr == "!4R*")
{
ShowMessage("修改成功!请记住新密码!");
Edit4->Text = "" ;
Edit5->Text = "" ;
Edit6->Text = "" ;
}
else
{
ShowMessage("原密码不正确!请重试!") ;
Edit4->Text = "" ;
Edit5->Text = "" ;
Edit6->Text = "" ;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormClose(TObject *Sender, TCloseAction &Action)
{
Form1->MSComm1->Output = StringToOleStr("!$*");
//Form1->Show();
Form1->MSComm1->RThreshold = 1;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button4Click(TObject *Sender)
{
int g ;
String s ;
String ss = Edit7->Text ;
g = ss.Length();
switch(g)
{
case 0 : ShowMessage("请输入新姓名!"); break ;
case 1 : Form1->MSComm1->Output = StringToOleStr("!5#"+Edit7->Text+" *");
Sleep(160);
s = Form1->MSComm1->Input ;
s = s.SubString(3,6);
Edit8->Text = s ;
break;
case 2 : Form1->MSComm1->Output = StringToOleStr("!5#"+Edit7->Text+" *");
Sleep(160);
s = Form1->MSComm1->Input ;
s = s.SubString(3,6);
Edit8->Text = s ;
break;
case 3 : Form1->MSComm1->Output = StringToOleStr("!5#"+Edit7->Text+" *");
Sleep(160);
s = Form1->MSComm1->Input ;
s = s.SubString(3,6);
Edit8->Text = s ;
break;
case 4 : Form1->MSComm1->Output = StringToOleStr("!5#"+Edit7->Text+" *");
Sleep(160);
s = Form1->MSComm1->Input ;
s = s.SubString(3,6);
Edit8->Text = s ;
break;
case 5 : Form1->MSComm1->Output =