求助:vc转tc .很难,希望有人帮助
#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM("main.cpp", fm_main);
USEFORM("data.cpp", dm_data); /* TDataModule: File Type */
USEFORM("name_gl.cpp", fm_name_gl);
USEFORM("jinhuo_gl.cpp", fm_jinhuo_gl);
USEFORM("lingshou.cpp", fm_lingshou_gl);
USEFORM("kucen.cpp", fm_kucen);
USEFORM("xiaoshou.cpp", fm_xiaoshou);
USEFORM("newname.cpp", fm_newname);
USEFORM("passwd.cpp", fm_passwd);
USEFORM("check.cpp", fm_check);
USEFORM("xiaopiao.cpp", fm_xiaopiao);
USEFORM("qingli.cpp", fm_qingli);
USEFORM("xiaoshoumx.cpp", fm_xiaoshoumx);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->CreateForm(__classid(Tfm_main), &fm_main);
Application->CreateForm(__classid(Tdm_data), &dm_data);
Application->CreateForm(__classid(Tfm_name_gl), &fm_name_gl);
Application->CreateForm(__classid(Tfm_jinhuo_gl), &fm_jinhuo_gl);
Application->CreateForm(__classid(Tfm_lingshou_gl), &fm_lingshou_gl);
Application->CreateForm(__classid(Tfm_kucen), &fm_kucen);
Application->CreateForm(__classid(Tfm_xiaoshou), &fm_xiaoshou);
Application->CreateForm(__classid(Tfm_newname), &fm_newname);
Application->CreateForm(__classid(Tfm_passwd), &fm_passwd);
Application->CreateForm(__classid(Tfm_check), &fm_check);
Application->CreateForm(__classid(Tfm_xiaopiao), &fm_xiaopiao);
Application->CreateForm(__classid(Tfm_qingli), &fm_qingli);
Application->CreateForm(__classid(Tfm_xiaoshoumx), &fm_xiaoshoumx);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
一下是各个嵌套小函数。。。
1:main.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#include"math.h"
#pragma hdrstop
#include <stdio.h>
#include "main.h"
#include "data.h"
#include "name_gl.h"
#include "jinhuo_gl.h"
#include "lingshou.h"
#include "kucen.h"
#include "xiaoshou.h"
#include "passwd.h"
#include "check.h"
#include "xiaopiao.h"
#include "qingli.h"
#include "xiaoshoumx.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfm_main *fm_main;
//-----------------------------------------------------
int danjuhao,row;;
//---------------------------------------------------------------------------
__fastcall Tfm_main::Tfm_main(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::bt_nameClick(TObject *Sender)
{
fm_name_gl->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::bt_jinhuoClick(TObject *Sender)
{
fm_jinhuo_gl->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::FormShow(TObject *Sender)
{
//计算单据号
dm_data->ds_guest->Close();
dm_data->ds_guest->CommandText="select top 1 * from xiaoshou order by danjuhao desc";
dm_data->ds_guest->Open();
if(dm_data->ds_guest->RecordCount<1 && (shuliang->Focused()==true || shoujia->Focused()==true || dazhe->Focused()==true))
danjuhao=1;
else
danjuhao=dm_data->ds_guest->FieldByName("danjuhao")->AsInteger+1;
dm_data->ds_guest->Close();
row=0;
lb->RowCount=1;
lb->ColCount=8;
lb->ColWidths[3]=30;
lb->ColWidths[7]=150;
lb->Cells[0][0]="序号";
lb->Cells[1][0]="货号";
lb->Cells[2][0]="货名";
lb->Cells[3][0]="数量";
lb->Cells[4][0]="定价";
lb->Cells[5][0]="优惠价";
lb->Cells[6][0]="金额";
lb->Cells[7][0]="时间";
danjuhaos->Text=danjuhao;
shuliang_hj->Text="0";
jine_hj->Text="0";
xianfu->Text="0";
}
//---------------------------------------------------------------------------
void __fastcall Tfm_main::codeKeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
PostMessage(Handle,WM_KEYDOWN,VK_TAB,0);
}
//---------------------------------------------------------------------------
2:data.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "data.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tdm_data *dm_data;
//---------------------------------------------------------------------------
__fastcall Tdm_data::Tdm_data(TComponent* Owner)
: TDataModule(Owner)
{
}
//---------------------------------------------------------------------------
3:name_gl.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "name_gl.h"
#include "data.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfm_name_gl *fm_name_gl;
//---------------------------------------------------------------------------
__fastcall Tfm_name_gl::Tfm_name_gl(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tfm_name_gl::addClick(TObject *Sender)
{
dm_data->ds_guest->Close();
dm_data->ds_guest->CommandText="select * from name where code='"+no->Text+"'";
dm_data->ds_guest->Open();
if(dm_data->ds_guest->RecordCount>0)
{
Application->MessageBoxA("该货物代码已经存在,请重新输入","提示",MB_OK);
no->SetFocus();
dm_data->ds_guest->Close();
return;
}
dm_data->ds_guest->Close();
if(no->Text!="" && name->Text!="")
{
dm_data->ds_name_gl->Append();
dm_data->ds_name_gl->FieldByName("code")->AsString=no->Text;
dm_data->ds_name_gl->FieldByName("name")->AsString=name->Text;
dm_data->ds_name_gl->Post();
no->Text="";
name->Text="";
no->SetFocus();
}
}
//---------------------------------------------------------------------------
void __fastcall Tfm_name_gl::noKeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
name->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_name_gl::nameKeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
add->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_name_gl::FormShow(TObject *Sender)
{
Left=170;
Top=100;
no->Text="";
name->Text="";
no->SetFocus();
dm_data->ds_name_gl->Close();
dm_data->ds_name_gl->Open();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_name_gl::xgClick(TObject *Sender)
{
DBEdit2->Enabled=true;
brow->Enabled=false;
add->Enabled=false;
save->Enabled=true;
cancel->Enabled=true;
xg->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall Tfm_name_gl::Button4Click(TObject *Sender)
{
no->Text="";
name->Text="";
no->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_name_gl::saveClick(TObject *Sender)
{
dm_data->ds_name_gl->Post();
brow->Enabled=true;
add->Enabled=true;
DBEdit2->Enabled=false;
cancel->Enabled=false;
save->Enabled=false;
xg->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall Tfm_name_gl::cancelClick(TObject *Sender)
{
dm_data->ds_name_gl->Cancel();
brow->Enabled=true;
add->Enabled=true;
DBEdit2->Enabled=false;
cancel->Enabled=false;
save->Enabled=false;
xg->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall Tfm_name_gl::Button1Click(TObject *Sender)
{
AnsiString codes;
codes=dm_data->ds_name_gl->FieldByName("code")->AsString;
dm_data->ds_guest->Close();
dm_data->ds_guest->CommandText="select * from jinhuo where code='"+codes+"'";
dm_data->ds_guest->Open();
if(dm_data->ds_guest->RecordCount>0)
{
Application->MessageBoxA((codes+"的货物有进货数据,要将其进货数据先删除才可以删除货名").c_str(),"提示",MB_OK);
dm_data->ds_guest->Close();
return;
}
if(Application->MessageBoxA((DBEdit1->Text+"的进货及销售记录将全部删除").c_str(),"警告",MB_OKCANCEL)==IDOK)
dm_data->ds_name_gl->DeleteRecords(arCurrent);
}
//---------------------------------------------------------------------------
void __fastcall Tfm_name_gl::closeClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_name_gl::FormClose(TObject *Sender,
TCloseAction &Action)
{
dm_data->ds_name_gl->Close();
}
//---------------------------------------------------------------------------
4:jinhuo_gl.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM("main.cpp", fm_main);
USEFORM("data.cpp", dm_data); /* TDataModule: File Type */
USEFORM("name_gl.cpp", fm_name_gl);
USEFORM("jinhuo_gl.cpp", fm_jinhuo_gl);
USEFORM("lingshou.cpp", fm_lingshou_gl);
USEFORM("kucen.cpp", fm_kucen);
USEFORM("xiaoshou.cpp", fm_xiaoshou);
USEFORM("newname.cpp", fm_newname);
USEFORM("passwd.cpp", fm_passwd);
USEFORM("check.cpp", fm_check);
USEFORM("xiaopiao.cpp", fm_xiaopiao);
USEFORM("qingli.cpp", fm_qingli);
USEFORM("xiaoshoumx.cpp", fm_xiaoshoumx);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->CreateForm(__classid(Tfm_main), &fm_main);
Application->CreateForm(__classid(Tdm_data), &dm_data);
Application->CreateForm(__classid(Tfm_name_gl), &fm_name_gl);
Application->CreateForm(__classid(Tfm_jinhuo_gl), &fm_jinhuo_gl);
Application->CreateForm(__classid(Tfm_lingshou_gl), &fm_lingshou_gl);
Application->CreateForm(__classid(Tfm_kucen), &fm_kucen);
Application->CreateForm(__classid(Tfm_xiaoshou), &fm_xiaoshou);
Application->CreateForm(__classid(Tfm_newname), &fm_newname);
Application->CreateForm(__classid(Tfm_passwd), &fm_passwd);
Application->CreateForm(__classid(Tfm_check), &fm_check);
Application->CreateForm(__classid(Tfm_xiaopiao), &fm_xiaopiao);
Application->CreateForm(__classid(Tfm_qingli), &fm_qingli);
Application->CreateForm(__classid(Tfm_xiaoshoumx), &fm_xiaoshoumx);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
//---------------------------------------------------------------------------
5:lingshou.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "lingshou.h"
#include "data.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfm_lingshou_gl *fm_lingshou_gl;
static int danju0,shuliang0;
static float jine0;
//---------------------------------------------------------------------------
__fastcall Tfm_lingshou_gl::Tfm_lingshou_gl(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tfm_lingshou_gl::FormShow(TObject *Sender)
{
Left=10;
Top=100;
dt->Enabled=true;
code->Enabled=false;
RadioButton1->Checked=true;
dt->DateTime=Now();
dt->SetFocus();
dtChange(Sender);
}
//---------------------------------------------------------------------------
void __fastcall Tfm_lingshou_gl::dtChange(TObject *Sender)
{
int danju1;
dm_data->ds_xiaoshou_lb->Close();
dm_data->ds_xiaoshou_lb->Parameters->ParamValues["dt"]=dt->Date.FormatString("yyyy-mm-dd")+" 0:0:0";
dm_data->ds_xiaoshou_lb->Parameters->ParamValues["dt0"]=dt->Date.FormatString("yyyy-mm-dd")+" 23:59:59";
dm_data->ds_xiaoshou_lb->Parameters->ParamValues["code"]="%";
dm_data->ds_xiaoshou_lb->Open();
danju0=0;
danju1=0;
shuliang0=0;
jine0=0;
dm_data->ds_xiaoshou_lb->First();
while(!dm_data->ds_xiaoshou_lb->Eof)
{
if(danju1!=dm_data->ds_xiaoshou_lb->FieldByName("danjuhao")->AsInteger)
{
danju1=dm_data->ds_xiaoshou_lb->FieldByName("danjuhao")->AsInteger;
danju0++;
}
shuliang0+=dm_data->ds_xiaoshou_lb->FieldByName("shuliang")->AsInteger;
jine0+=dm_data->ds_xiaoshou_lb->FieldByName("jine")->AsFloat;
dm_data->ds_xiaoshou_lb->Next();
}
danju->Text=IntToStr(danju0);
shuliang->Text=IntToStr(shuliang0);
jine->Text=FormatFloat("0.00",jine0);
}
//---------------------------------------------------------------------------
void __fastcall Tfm_lingshou_gl::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
6:kucen.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "kucen.h"
#include "data.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfm_kucen *fm_kucen;
static int shoushu,censhu,jinshu;
static float shoujine,cenjine;
//---------------------------------------------------------------------------
__fastcall Tfm_kucen::Tfm_kucen(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tfm_kucen::FormShow(TObject *Sender)
{
Left=50;
Top=50;
showjin->Checked=false;
showjinClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall Tfm_kucen::FormClose(TObject *Sender, TCloseAction &Action)
{
dm_data->ds_xiaoshou_hj->Close();
dm_data->ds_jinhuo_hj->Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_kucen::Button1Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_kucen::showjinClick(TObject *Sender)
{
int i=1;
dm_data->ds_jinhuo_hj->Close();
dm_data->ds_jinhuo_hj->Open();
dm_data->ds_xiaoshou_hj->Close();
dm_data->ds_xiaoshou_hj->Parameters->ParamValues["dt0"]="1900-01-01 0:0:0";
dm_data->ds_xiaoshou_hj->Parameters->ParamValues["dt1"]="3000-01-01 23:59:59";
dm_data->ds_xiaoshou_hj->Open();
lb->ColCount=9;
lb->RowCount=2;
lb->Cells[0][0]="序号";
lb->Cells[1][0]="货号";
lb->Cells[2][0]="货名";
lb->Cells[3][0]="销售数量";
lb->Cells[4][0]="销售金额";
lb->Cells[5][0]="进货总数";
lb->Cells[6][0]="库存数量";
lb->Cells[7][0]="进货价格";
lb->Cells[8][0]="库存金额";
TLocateOptions opts;
opts.Clear();
shoushu=censhu=jinshu=0;
shoujine=cenjine=0;
dm_data->ds_jinhuo_hj->First();
while(!dm_data->ds_jinhuo_hj->Eof)
{
if(dm_data->ds_xiaoshou_hj->Locate("code",dm_data->ds_jinhuo_hj->FieldValues["code"],opts))
{
lb->Cells[0][i]=IntToStr(i);
lb->Cells[1][i]=dm_data->ds_jinhuo_hj->FieldValues["code"];
lb->Cells[2][i]=dm_data->ds_jinhuo_hj->FieldValues["name0"];
lb->Cells[3][i]=dm_data->ds_xiaoshou_hj->FieldValues["shuliang0"];
lb->Cells[4][i]=dm_data->ds_xiaoshou_hj->FieldValues["jine0"];
lb->Cells[5][i]=dm_data->ds_jinhuo_hj->FieldValues["shuliang0"];
lb->Cells[6][i]=dm_data->ds_jinhuo_hj->FieldValues["shuliang0"]-dm_data->ds_xiaoshou_hj->FieldValues["shuliang0"];
lb->Cells[7][i]=dm_data->ds_jinhuo_hj->FieldValues["jinjia0"];
lb->Cells[8][i]=FormatFloat("0.00",StrToFloat(lb->Cells[7][i])*StrToInt(lb->Cells[6][i]));
}
else
{
lb->Cells[0][i]=IntToStr(i);
lb->Cells[1][i]=dm_data->ds_jinhuo_hj->FieldValues["code"];
lb->Cells[2][i]=dm_data->ds_jinhuo_hj->FieldValues["name0"];
lb->Cells[3][i]="0";
lb->Cells[4][i]="0";
lb->Cells[5][i]=dm_data->ds_jinhuo_hj->FieldValues["shuliang0"];
lb->Cells[6][i]=dm_data->ds_jinhuo_hj->FieldValues["shuliang0"];
lb->Cells[7][i]=dm_data->ds_jinhuo_hj->FieldValues["jinjia0"];
lb->Cells[8][i]=FormatFloat("0.00",StrToFloat(lb->Cells[7][i])*StrToInt(lb->Cells[6][i]));
}
shoushu+=StrToInt(lb->Cells[3][i]);
shoujine+=StrToFloat(lb->Cells[4][i]);
jinshu+=StrToInt(lb->Cells[5][i]);
censhu+=StrToInt(lb->Cells[6][i]);
cenjine+=StrToFloat(lb->Cells[8][i]);
dm_data->ds_jinhuo_hj->Next();
lb->RowCount++;
i++;
}
if(lb->RowCount>2)
lb->RowCount--;
else
for(int j=1;j<=6;j++)
lb->Cells[j][1]="";
shoushus->Text=shoushu;
jinshus->Text=jinshu;
censhus->Text=censhu;
shoujines->Text=FormatFloat("0.00",shoujine);
cenjines->Text=FormatFloat("0.00",cenjine);
if(showjin->Checked==false)
{
lb->ColCount=7;
cenjines->Visible=false;
}
else
{
lb->ColCount=9;
cenjines->Visible=true;
}
}
//---------------------------------------------------------------------------
7:xiaoshou.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "xiaoshou.h"
#include "data.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfm_xiaoshou *fm_xiaoshou;\
int shuliang0;
float jine0,maoli0;
//---------------------------------------------------------------------------
__fastcall Tfm_xiaoshou::Tfm_xiaoshou(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaoshou::huizongClick(TObject *Sender)
{
dm_data->ds_jinhuo_jia->Close();
dm_data->ds_jinhuo_jia->Open();
dm_data->ds_xiaoshou_hj->Close();
dm_data->ds_xiaoshou_hj->Parameters->ParamValues["dt0"]=dt0->Date.FormatString("yyyy-mm-dd")+" 0:0:0";
dm_data->ds_xiaoshou_hj->Parameters->ParamValues["dt1"]=dt1->Date.FormatString("yyyy-mm-dd")+" 23:59:59";
dm_data->ds_xiaoshou_hj->Open();
lb->ColCount=7;
lb->RowCount=2;
lb->Cells[0][0]="序号";
lb->Cells[1][0]="货号";
lb->Cells[2][0]="货名";
lb->Cells[3][0]="销售数量";
lb->Cells[4][0]="销售金额";
lb->Cells[5][0]="进货价格";
lb->Cells[6][0]="销售毛利";
shuliang0=0;
jine0=0;
maoli0=0;
int i=1;
dm_data->ds_xiaoshou_hj->First();
while(!dm_data->ds_xiaoshou_hj->Eof)
{
lb->Cells[0][i]=IntToStr(i);
lb->Cells[1][i]=dm_data->ds_xiaoshou_hj->FieldValues["code"];
lb->Cells[2][i]=dm_data->ds_xiaoshou_hj->FieldValues["name0"];
lb->Cells[3][i]=dm_data->ds_xiaoshou_hj->FieldValues["shuliang0"];
lb->Cells[4][i]=dm_data->ds_xiaoshou_hj->FieldValues["jine0"];
lb->Cells[5][i]=dm_data->ds_jinhuo_jia->FieldValues["jinjia0"];
lb->Cells[6][i]=FormatFloat("0.00",StrToFloat(lb->Cells[4][i])-StrToFloat(lb->Cells[5][i])*StrToInt(lb->Cells[3][i]));
shuliang0+=StrToInt(lb->Cells[3][i]);
jine0+=StrToFloat(lb->Cells[4][i]);
maoli0+=StrToFloat(lb->Cells[6][i]);
dm_data->ds_xiaoshou_hj->Next();
lb->RowCount++;
i++;
}
if(lb->RowCount>2)
lb->RowCount--;
else
for(int j=1;j<=6;j++)
lb->Cells[j][1]="";
shuliang->Text=shuliang0;
jine->Text=FormatFloat("0.00",jine0);
maoli->Text=FormatFloat("0.00",maoli0);
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaoshou::FormShow(TObject *Sender)
{
Left=100;
Top=80;
dt0->DateTime=Now();
dt1->DateTime=Now();
dt0->SetFocus();
huizongClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaoshou::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaoshou::FormClose(TObject *Sender,
TCloseAction &Action)
{
dm_data->ds_xiaoshou_hj->Close();
dm_data->ds_jinhuo_jia->Close();
}
//---------------------------------------------------------------------------
8:newname.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "newname.h"
#include "data.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfm_newname *fm_newname;
AnsiString newcode,newname;
//---------------------------------------------------------------------------
__fastcall Tfm_newname::Tfm_newname(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tfm_newname::Button1Click(TObject *Sender)
{
newname=name->Text;
dm_data->ds_name_gl->Close();
dm_data->ds_name_gl->Open();
dm_data->ds_name_gl->Append();
dm_data->ds_name_gl->FieldByName("code")->AsString=newcode;
dm_data->ds_name_gl->FieldByName("name")->AsString=newname;
dm_data->ds_name_gl->Post();
dm_data->ds_name_gl->Close();
Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_newname::Button2Click(TObject *Sender)
{
newname="";
Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_newname::FormShow(TObject *Sender)
{
name->SetFocus();
code->Text=newcode;
}
//---------------------------------------------------------------------------
void __fastcall Tfm_newname::nameKeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
PostMessage(Handle,WM_KEYDOWN,VK_TAB,0);
}
//---------------------------------------------------------------------------
9:passwd.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "passwd.h"
#include "data.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfm_passwd *fm_passwd;
//---------------------------------------------------------------------------
__fastcall Tfm_passwd::Tfm_passwd(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tfm_passwd::FormShow(TObject *Sender)
{
Left=200;
Top=200;
dm_data->ds_passwd->Close();
dm_data->ds_passwd->Open();
pass1->Text="";
pass2->Text="";
}
//---------------------------------------------------------------------------
void __fastcall Tfm_passwd::pass1Exit(TObject *Sender)
{
pass2->Text="";
}
//---------------------------------------------------------------------------
void __fastcall Tfm_passwd::pass2Exit(TObject *Sender)
{
if(pass1->Text!=pass2->Text)
{
Application->MessageBoxA("两次输入的密码不一致,请重新输入","提示",MB_OK);
pass1->Text="";
pass2->Text="";
pass1->SetFocus();
}
}
//---------------------------------------------------------------------------
void __fastcall Tfm_passwd::Button1Click(TObject *Sender)
{
if(pass1->Text=="" || pass2->Text=="")
{
Application->MessageBoxA("密码不能为空,请重新输入","提示",MB_OK);
pass1->Text="";
pass2->Text="";
pass1->SetFocus();
return;
}
dm_data->ds_passwd->Edit();
dm_data->ds_passwd->FieldByName("code")->AsString=pass1->Text;
dm_data->ds_passwd->Post();
dm_data->ds_passwd->Close();
Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_passwd::Button2Click(TObject *Sender)
{
dm_data->ds_passwd->Close();
Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_passwd::Button3Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_passwd::FormClose(TObject *Sender,
TCloseAction &Action)
{
dm_data->ds_passwd->Close();
}
//---------------------------------------------------------------------------
10:check.cpp"
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "check.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfm_check *fm_check;
AnsiString passwd;
//---------------------------------------------------------------------------
__fastcall Tfm_check::Tfm_check(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tfm_check::FormShow(TObject *Sender)
{
pass->Text="";
pass->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_check::Button1Click(TObject *Sender)
{
passwd=pass->Text;
Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_check::Button2Click(TObject *Sender)
{
passwd="";
Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_check::passKeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
PostMessage(Handle,WM_KEYDOWN,VK_TAB,0);
}
//---------------------------------------------------------------------------
11:xiaopiao.cpp"
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "xiaopiao.h"
#include "data.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfm_xiaopiao *fm_xiaopiao;
//---------------------------------------------------------------------------
__fastcall Tfm_xiaopiao::Tfm_xiaopiao(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaopiao::FormShow(TObject *Sender)
{
Left=100;
Top=100;
dm_data->ds_xiaopiao->Close();
dm_data->ds_xiaopiao->Open();
dm_data->ds_xiaopiao->Edit();
dm_data->ds_guest->Close();
dm_data->ds_guest->CommandText="select * from code where id=20000";
dm_data->ds_guest->Open();
piaotou->Text=dm_data->ds_guest->FieldByName("content")->AsString;
dm_data->ds_guest->Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaopiao::FormClose(TObject *Sender,
TCloseAction &Action)
{
dm_data->ds_xiaopiao->Edit();
dm_data->ds_xiaopiao->Post();
dm_data->ds_xiaopiao->Close();
dm_data->ds_guest->Close();
dm_data->ds_guest->CommandText="select * from code where id=20000";
dm_data->ds_guest->Open();
dm_data->ds_guest->Edit();
dm_data->ds_guest->FieldByName("content")->AsString=piaotou->Text;
dm_data->ds_guest->Post();
dm_data->ds_guest->Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaopiao::Button1Click(TObject *Sender)
{
int id;
dm_data->ds_xiaopiao->Last();
id=dm_data->ds_xiaopiao->FieldByName("id")->AsInteger+1;
if(id>=29999)
return;
dm_data->ds_xiaopiao->Append();
dm_data->ds_xiaopiao->FieldByName("id")->AsInteger=id;
dm_data->ds_xiaopiao->Post();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaopiao::Button2Click(TObject *Sender)
{
if(Application->MessageBoxA("真的要删除最后一行吗?","提示",MB_OKCANCEL)==IDOK)
{
if(dm_data->ds_xiaopiao->RecordCount==1) return;
dm_data->ds_xiaopiao->Last();
dm_data->ds_xiaopiao->DeleteRecords(arCurrent);
}
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaopiao::Button3Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
12:qingli.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "qingli.h"
#include "data.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfm_qingli *fm_qingli;
//---------------------------------------------------------------------------
__fastcall Tfm_qingli::Tfm_qingli(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tfm_qingli::Button1Click(TObject *Sender)
{
if(Application->MessageBoxA((lingshou->Caption+" 此删除不可恢复,请慎重!").c_str(),"警告",MB_OKCANCEL)==IDOK)
{
dm_data->cm_guest->CommandText="delete from xiaoshou";
dm_data->cm_guest->Execute();
}
}
//---------------------------------------------------------------------------
void __fastcall Tfm_qingli::Button2Click(TObject *Sender)
{
if(Application->MessageBoxA((jinhuo->Caption+" 此删除不可恢复,请慎重!").c_str(),"警告",MB_OKCANCEL)==IDOK)
{
dm_data->cm_guest->CommandText="delete from xiaoshou";
dm_data->cm_guest->Execute();
dm_data->cm_guest->CommandText="delete from jinhuo";
dm_data->cm_guest->Execute();
}
}
//---------------------------------------------------------------------------
void __fastcall Tfm_qingli::Button3Click(TObject *Sender)
{
if(Application->MessageBoxA((name->Caption+" 此删除不可恢复,请慎重!").c_str(),"警告",MB_OKCANCEL)==IDOK)
{
dm_data->cm_guest->CommandText="delete from xiaoshou";
dm_data->cm_guest->Execute();
dm_data->cm_guest->CommandText="delete from jinhuo";
dm_data->cm_guest->Execute();
dm_data->cm_guest->CommandText="delete from name";
dm_data->cm_guest->Execute();
}
}
//---------------------------------------------------------------------------
void __fastcall Tfm_qingli::Button4Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
13://---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "qr_xiaoshoumx.h"
#include "data.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfm_xiaoshoumx *fm_xiaoshoumx;
//---------------------------------------------------------------------------
__fastcall Tfm_xiaoshoumx::Tfm_xiaoshoumx(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaoshoumx::Button1Click(TObject *Sender)
{
ds_xiaoshou_lb->Close();
ds_xiaoshou_lb->Open();
rep->Preview();
}
//---------------------------------------------------------------------------
[ 本帖最后由 redicehong 于 2009-9-1 00:01 编辑 ]