📄 unitregist.pas
字号:
//PClient_Address.Size:=50;
try
adostored.ExecProc;
finally
PClient_Name.Free ;
PClient_Sex.Free ;
PClient_Country.Free ;
PClient_Nation.free;
PClient_Birth.free;
PClient_Phone.free;
PClient_Post.Free;
PClient_Address.free;
PClient_IDNo.free;
PImage_Path.free;
PRegist_Date.free;
PLive_Day.free;
PLeave_Date.free;
PRoom_ID.free;
PBed_NO.free;
PBedsta_ID.free;
PMemo.free;
PReturn_id.free;
end;
end; }
procedure TfrmRegist.Page1Change(Sender: TObject);
begin
{case page1.ActivePageIndex of
0: showmessage('0');
1: showmessage('1');
else
end;}
end;
procedure TfrmRegist.chkIdnoClick(Sender: TObject);
begin
if chkIdno.State=cbUnchecked then
edtidno.Enabled:=false ;
if chkidno.State =cbChecked then
edtidno.Enabled :=true ;
end;
procedure TfrmRegist.chkSexClick(Sender: TObject);
begin
if chksex.State =cbUnchecked then
cboxb.Enabled :=false ;
if chksex.State =cbchecked then
cboxb.Enabled :=true ;
end;
procedure TfrmRegist.chkNameClick(Sender: TObject);
begin
if chkname.State =cbUnchecked then
edtxm.Enabled :=false;
if chkname.State =cbChecked then
edtxm.Enabled :=true;
end;
procedure TfrmRegist.chkDateClick(Sender: TObject);
begin
if chkDate.State =cbUnchecked then
begin
tpkStart.Enabled :=false;
tpkEnd.Enabled :=false;
end;
if chkDate.State =cbChecked then
begin
tpkStart.Enabled :=true;
tpkEnd.Enabled :=true ;
end;
end;
procedure TfrmRegist.btnQueryClick(Sender: TObject);
var
Smt:string;
subSmt:string;
strTitle:array[0..10] of string;
intWidth:array[0..10] of integer;
i:integer;
colu:Tcolumn;
begin
Smt:='';
subSmt:='';
if (not chkdate.Checked) and (not chkname.Checked) and (not chkSex.Checked) and (not chkidno.Checked) then
begin
showmessage('请选择查询项');
exit;
end;
//judge procedure
if chkdate.Checked then //选中日期
begin
if tpkStart.Date>tpkend.Date then
begin
showmessage('起始日期不能大于终止日期');
exit ;
end;
if datetostr(tpkStart.date) = Datetostr(tpkend.Date) then
begin
subSmt:='convert(datetime,datename(year,regist_date)+datename(month,regist_date)+datename(day,regist_date))=convert(datetime,'''+ DateToStr(tpkStart.Date)+''')'
end
else
begin
subSmt:='convert(datetime,datename(year,regist_date)+datename(month,regist_date)+datename(day,regist_date)) between convert(datetime,'''+ DateToStr(tpkStart.Date)+''')';
subSmt:=subSmt+' and convert(datetime,'''+DateToStr(tpkEnd.Date)+''')'
end;
end;
if chkname.Checked then
begin
if edtxm.Text='' then
begin
showmessage('请填写姓名');
exit;
end;
if length(subSmt)=0 then
subSmt:='custom_name like ''%'+trim(edtxm.Text)+'%'''
else
subSmt:=subSmt+' and custom_name like ''%'+trim(edtxm.Text)+'%''';
end;
if chkSex.Checked then
begin
if cboxb.Text='' then
begin
showmessage('请选择性别');
exit;
end;
if length(subSmt)=0 then
subSmt:='SexList.Sex_name='''+cboxb.Text+''''
else
subSmt:=subSmt+' and SexList.Sex_name='''+cboxb.Text+'''';
end;
if chkidno.Checked then
begin
if edtIdno.text='' then
begin
showmessage('请输入身份证号');
exit;
end;
if length(subSmt)=0 then
subSmt:='custom_idno='''+edtIdno.text+''''
else
subSmt:=subSmt+' and custom_idno='''+edtIdno.text+'''';
end;
Smt:='select convert(varchar(38),regist_id) regist_id,';
Smt:=Smt+' custom_name,CountryList.Country_name,SexList.Sex_name,custom_birth,custom_phone,custom_post,custom_address,custom_idno,regist_date,memo1 ';
Smt:=Smt+' from CustomerList left outer join CountryList';
Smt:=Smt+' on CustomerList.custom_countryid=CountryList.Country_id ' ;
Smt:=Smt+' left outer join SexList ';
Smt:=Smt+' on CustomerList.custom_sexid=SexList.Sex_id ' ;
Smt:=Smt+' where ';
Smt:=Smt+subSmt;
//edtidno.Text:=smt;
//showmessage(subsmt);
try
adoquery.Close;
adoquery.SQL.clear;
adoquery.sql.Add(Smt);
finally
adoquery.Open ;
datasource.DataSet:=adoquery;
dbgrid.Columns.Clear;
for i:=1 to 10 do
begin
colu:=dbgrid.Columns.Add;
colu.FieldName:=adoquery.Fields[i].DisplayName ;
//dbgrid.Columns.Items[i-1].FieldName:=adoquery.Fields[i].DisplayName ;
end;
dbgrid.DataSource:=datasource;
//dbgrid.Columns.Items[0].FieldName:='custom_name';
//assign values to the array which contain the title
strTitle[0]:='姓名';
strTitle[1]:='国籍';
strTitle[2]:='性别';
strTitle[3]:='出生日期';
strTitle[4]:='联系电话';
strTitle[5]:='邮编';
strTitle[6]:='住址';
strTitle[7]:='身份证号';
strTitle[8]:='登记日期';
strTitle[9]:='备注';
//assign values to the array which contain the width
for i:=0 to 9 do
intWidth[i]:=80;
for i:=0 to 9 do
begin
dbgrid.Columns.Items[i].Title.caption :=strTitle[i];
dbgrid.Columns.items[i].Width :=intWidth[i];
end;
end;
end;
procedure TfrmRegist.ToolButton4Click(Sender: TObject);
var
xx:Tdatetime;
begin
xx:=now();
showmessage(datetimetostr(xx));
end;
procedure TfrmRegist.tbnSaveClick(Sender: TObject);
var
//the value of input parameter----
strSmt:string;
//the parmaeter of the stored prccedure
InValue,OutValue:TParameter;
//below is some temporary variable
Client_Name,Client_Birth,Client_Phone,Client_Address,Client_IDNo:string;
Live_Day,Memo:string;
Client_Sex,Client_Country:string;
begin
Client_Name:=edtname.Text;
Client_Birth:=edtbirth.Text;
Client_Phone:=edtphone.Text;
Client_Address:=edtaddress.Text;
Client_IDNo:=edtno.Text;
Live_Day:=spinedit1.Text ;
Memo:=edtmemo.Text;
Client_Sex:=cbosex.Text;
Client_Country:=cbonation.Text;
strSmt:='select '''+Client_Name+''',SexList.Sex_id,CountryList.Country_id,0,''';
strSmt:=strSmt+Client_Birth+''','''+Client_Phone+''',space(0),'''+Client_Address+''','''+Client_IDNo+''',' ;
strSmt:=strSmt+'space(0),getdate(),getdate()+'+Live_Day+','+Live_Day+',0,0,';
strSmt:=strSmt+'1,'''+Memo+''' from SexList, CountryList where Sex_name='''+Client_Sex+'''' ;
strSmt:=strSmt+' and CountryList.Country_name='''+Client_Country+'''';
//showmessage(strsmt);
adostored.ProcedureName:='RegistClientAndReturnID';
adostored.ConnectionString:=strCon;
adostored.Parameters.Clear ;
//set the input parameter
InValue:=adostored.Parameters.AddParameter;
InValue.Name:='Stamt';
InValue.DataType :=ftstring;
InValue.Direction:=pdinput;
InValue.Value :=strSmt;
InValue.Size:=1000;
//set the output parameter
OutValue:=adostored.Parameters.AddParameter;
OutValue.Name:='Return_id';
OutValue.DataType :=ftlargeint;
OutValue.Direction:=pdoutput;
//InValue.Value :=strSmt;
try
adostored.ExecProc ;
ClientID:=adostored.Parameters.ParamValues['Return_id'];
//showmessage(adostored.Parameters.ParamValues['Return_id']);
finally
//------Release resource
InValue.free;
OutValue.free;
tbnSave.Enabled:=false;
end;
end;
procedure TfrmRegist.tbnSelectClick(Sender: TObject);
begin
case page1.ActivePage.TabIndex of
0: begin
if tbnsave.Enabled=false then
begin
frmMain.ClientID:=ClientID;
application.CreateForm(TfrmRoomQuery,frmRoomQuery);
frmRegist.Close;
frmRoomQuery.Show ;
end
else
begin
showmessage('请在【信息查询与修改】页选择信息');
exit;
end;
end;
1: begin
if adoquery.RecordCount=0 then
begin
showmessage('没有选取记录,请查询数据');
exit;
end
else
begin
frmMain.ClientID:=adoquery.Fields[0].AsString;
application.CreateForm(TfrmRoomQuery,frmRoomQuery);
//frmMain.ClientID:=adoquery.Fields[0].AsString;
//frmMain.clientid:='0001';
//showmessage(frmMain.clientid );
frmRegist.Close;
frmRoomQuery.Show;
end;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -