📄 register.pas
字号:
unit register;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxLookAndFeelPainters, DBCtrls, RzDBNav, cxDropDownEdit,
cxDBEdit, cxCalendar, cxMaskEdit, cxSpinEdit, cxGroupBox, cxRadioGroup,
cxLabel, cxControls, cxContainer, cxEdit, cxTextEdit, ExtCtrls, StdCtrls,
cxButtons, cxMemo, DB, DateUtils;
type
Tfrmregister = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
cxDBTextEdit1: TcxDBTextEdit;
cxLabel1: TcxLabel;
cxLabel2: TcxLabel;
cxLabel4: TcxLabel;
cxLabel5: TcxLabel;
cxDBTextEdit2: TcxDBTextEdit;
cxDBRadioGroup1: TcxDBRadioGroup;
cxDBSpinEdit1: TcxDBSpinEdit;
edtbirth: TcxDBDateEdit;
cxLabel6: TcxLabel;
cxLabel7: TcxLabel;
cxLabel8: TcxLabel;
cxLabel9: TcxLabel;
cxLabel10: TcxLabel;
cxLabel11: TcxLabel;
cxLabel12: TcxLabel;
cmbxingzuo: TcxDBComboBox;
cmbsx: TcxDBComboBox;
cxDBTextEdit3: TcxDBTextEdit;
cxDBTextEdit4: TcxDBTextEdit;
cxDBTextEdit5: TcxDBTextEdit;
cxDBTextEdit6: TcxDBTextEdit;
cxDBTextEdit7: TcxDBTextEdit;
cxLabel3: TcxLabel;
cmbszqy: TcxDBComboBox;
cmbcity: TcxDBComboBox;
cxLabel13: TcxLabel;
Panel3: TPanel;
RzDBNavigator1: TRzDBNavigator;
Panel4: TPanel;
Label1: TLabel;
cxLabel14: TcxLabel;
cxDBMemo1: TcxDBMemo;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Label1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure edtbirthPropertiesEditValueChanged(Sender: TObject);
procedure cmbszqyPropertiesChange(Sender: TObject);
private
function getpet(birthYear: integer): string;
function getxingzuo(birth: Tdatetime): string;
public
{ Public declarations }
end;
var
frmregister: Tfrmregister;
implementation
uses md, main;
{$R *.dfm}
function Tfrmregister.getpet(birthYear: integer): string;
var
toyear, x: integer;
birthPet: string;
begin
toyear := 1997;
birthpet := 'Ox';
x := (toyear - birthyear) mod 12;
if ((x = 1) or (x = -11)) then
birthpet := '鼠'
else
if x = 0 then
birthpet := '牛'
else
if (x = 11) or (x = -1) then
birthpet := '虎'
else
if (x = 10) or (x = -2) then
birthpet := '兔'
else
if (x = 9) or (x = -3) then
birthpet := '龙'
else
if (x = 8) or (x = -4) then
birthpet := '蛇'
else
if (x = 7) or (x = -5) then
birthpet := '马'
else
if (x = 6) or (x = -6) then
birthpet := '羊'
else
if (x = 5) or (x = -7) then
birthpet := '猴'
else
if (x = 4) or (x = -8) then
birthpet := '鸡'
else
if (x = 3) or (x = -9) then
birthpet := '狗'
else
if (x = 2) or (x = -10) then
birthpet := '猪';
result := birthpet;
end;
function Tfrmregister.getxingzuo(birth: Tdatetime): string;
var
xingzuo, stryear: string;
begin
stryear := inttostr(yearof(birth));
if (birth >= strtodatetime(stryear + '-1-20')) and (birth <= strtodatetime(stryear + '-2-18')) then
xingzuo := '水瓶座'
else
if (birth >= strtodatetime(stryear + '-2-19')) and (birth <= strtodatetime(stryear + '-3-20')) then
xingzuo := '双鱼座'
else
if (birth >= strtodatetime(stryear + '-3-21')) and (birth <= strtodatetime(stryear + '-5-20')) then
xingzuo := '白羊座'
else
if (birth >= strtodatetime(stryear + '-4-21')) and (birth <= strtodatetime(stryear + '-2-18')) then
xingzuo := '金牛座'
else
if (birth >= strtodatetime(stryear + '-5-21')) and (birth <= strtodatetime(stryear + '-6-21')) then
xingzuo := '双子座'
else
if (birth >= strtodatetime(stryear + '-6-22')) and (birth <= strtodatetime(stryear + '-7-22')) then
xingzuo := '巨蟹座'
else
if (birth >= strtodatetime(stryear + '-7-23')) and (birth <= strtodatetime(stryear + '-8-22')) then
xingzuo := '狮子座'
else
if (birth >= strtodatetime(stryear + '-8-23')) and (birth <= strtodatetime(stryear + '-9-22')) then
xingzuo := '处女座'
else
if (birth >= strtodatetime(stryear + '-9-23')) and (birth <= strtodatetime(stryear + '-10-22')) then
xingzuo := '天秤座'
else
if (birth >= strtodatetime(stryear + '-10-23')) and (birth <= strtodatetime(stryear + '-11-22')) then
xingzuo := '天蝎座'
else
if (birth >= strtodatetime(stryear + '-11-23')) and (birth <= strtodatetime(stryear + '-12-21')) then
xingzuo := '射手座'
else
if (birth >= strtodatetime(stryear + '-12-22')) and (birth <= strtodatetime(stryear + '-12-31')) then
xingzuo := '魔羯座'
else
if (birth >= strtodatetime(stryear + '-1-01')) and (birth <= strtodatetime(stryear + '-1-19')) then
xingzuo := '魔羯座';
result := xingzuo;
end;
procedure Tfrmregister.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action := caFree;
frmmain.mmregister.AutoGrayScale := True;
end;
procedure Tfrmregister.Label1Click(Sender: TObject);
begin
close;
end;
procedure Tfrmregister.FormCreate(Sender: TObject);
begin
Dm1.adoqry1.Close;
Dm1.adoqry1.sql.Clear;
Dm1.adoqry1.sql.Text := 'select * from city where pbm=0';
dm1.adoqry1.Open;
Dm1.adoqry1.first;
dm1.adoqry1.next;
cmbszqy.Properties.Items.Clear;
while not dm1.adoqry1.Eof do
begin
cmbszqy.Properties.Items.Append(Dm1.adoqry1.fieldbyname('city').asstring);
Dm1.adoqry1.Next;
end;
Dm1.adoqry1.Close;
if not dm1.tblHuiyuan.Active then
dm1.tblHuiyuan.Open;
if not frmMain.mmregister.AutoGrayScale then
dm1.tblHuiyuan.Insert
else
Dm1.tblHuiyuan.Locate('bm;xm', VarArrayOf([Dm1.qryhuiyuan.FieldByName('bm').AsString, Dm1.qryhuiyuan.FieldByName('xm').AsString]), [loPartialKey]);
end;
procedure Tfrmregister.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
if dm1.tblHuiyuan.State in [dsInsert, dsEdit] then
begin
if Application.MessageBox('您还没有保存数据,是否保存?', '询问', MB_YESNO + MB_ICONQuestion) = IDYes then
dm1.tblHuiyuan.Post
else
dm1.tblHuiyuan.Cancel;
end;
end;
procedure Tfrmregister.edtbirthPropertiesEditValueChanged(Sender: TObject);
begin
if edtbirth.Text <> '' then
begin
if dm1.tblHuiyuan.State in [dsInsert, dsEdit] then
begin
dm1.tblHuiyuan.FieldByName('star').AsString := getxingzuo(edtbirth.EditValue);
dm1.tblHuiyuan.FieldByName('shuxian').AsString := getpet(yearof(edtbirth.EditValue));
end;
// cmbxingzuo.text:=getxingzuo(edtbirth.EditValue);
// cmbsx.text:=getpet(yearof(edtbirth.EditValue));
end
else
begin
cmbxingzuo.text := '';
cmbsx.text := '';
end;
end;
procedure Tfrmregister.cmbszqyPropertiesChange(Sender: TObject);
var
bm: string;
begin
Dm1.adoqry1.Close;
Dm1.adoqry1.sql.Clear;
Dm1.adoqry1.sql.Text := 'select * from city where city=''' + cmbszqy.Text + '''';
dm1.adoqry1.Open;
bm := IntToStr(dm1.adoqry1.fieldbyname('bm').asinteger);
Dm1.adoqry1.Close;
cmbcity.Text := '';
if bm = '' then
begin
cmbcity.Properties.Items.Clear;
Exit;
end;
Dm1.adoqry1.sql.Clear;
Dm1.adoqry1.sql.Text := 'select * from city where pbm=' + bm;
dm1.adoqry1.Open;
Dm1.adoqry1.first;
cmbcity.Properties.Items.Clear;
while not dm1.adoqry1.Eof do
begin
cmbcity.Properties.Items.Append(Dm1.adoqry1.fieldbyname('city').asstring);
Dm1.adoqry1.Next;
end;
Dm1.adoqry1.Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -