⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit37.pas

📁 一个用DELPHI编的酒店管理系统。 其中数据库:SQL Server2000, 只需恢复 My database文件夹中 My database_Data.MDF和 My database_Log.
💻 PAS
字号:
unit Unit37;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,IdGlobal;

type
  TForm37 = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    customerid: TEdit;
    Button3: TButton;
    GroupBox2: TGroupBox;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label7: TLabel;
    Label9: TLabel;
    Label6: TLabel;
    Label8: TLabel;
    Label10: TLabel;
    Label12: TLabel;
    customername: TEdit;
    gender: TComboBox;
    idcard: TEdit;
    Button1: TButton;
    Button2: TButton;
    nation: TComboBox;
    idname: TComboBox;
    customerrank: TComboBox;
    tel: TEdit;
    address: TEdit;
    mark: TEdit;
    account: TComboBox;
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
     function isInteger(s:string):boolean;
  public
    { Public declarations }
  end;

var
  Form37: TForm37;

implementation

uses Unit16;

{$R *.dfm}

procedure TForm37.FormCreate(Sender: TObject);
begin
   {没验证客户编号前不可修改}
   button1.Enabled:=false;
end;

procedure TForm37.Button2Click(Sender: TObject);
begin
form16.table1.Close;
end;

procedure TForm37.FormClose(Sender: TObject; var Action: TCloseAction);
begin
form16.table1.Close;
end;

procedure TForm37.Button3Click(Sender: TObject);
var
   flag:boolean;
   i:integer;
begin
   {验证客户编号的合法性}
   if isInteger(customerId.Text)=false then
   begin
      messageDlg('输入编号不合法',mtWarning,[mbOk],0);
      activeControl:=customerId;
      exit;
   end;
   {验证客户编号的存在性}
   flag:=false;
   with form16.table1 do
   begin
      open;
      first;
      while not eof do
      begin
         if fieldByName('客户编号').AsString=customerId.Text then
         begin
            flag:=true;
            break;
         end;
         next;
      end;
      if flag=false then//客户不存在
      begin
         messageDlg('输入编号不存在',mtWarning,[mbOk],0);
         button1.Enabled:=false;
         exit;
      end;
   end;
   button1.Enabled:=true;
   {显示此客户的信息}
   with form16.table1 do
   begin
      customerName.Text:=fieldByName('客户姓名').asString;
      i:=gender.Items.IndexOf(fieldByName('性别').asString);
      gender.ItemIndex:=i;
      i:=nation.Items.IndexOf(fieldByName('国籍').asString);
      nation.ItemIndex:=i;
      i:=idname.Items.IndexOf(fieldByName('证件名称').asString);
      idname.ItemIndex:=i;
      idcard.Text:=fieldByName('证件号码').asString;
      tel.Text:=fieldByName('联系电话').asString;
      i:=account.Items.IndexOf(fieldByName('折扣').asString);
      account.ItemIndex:=i;
      i:=customerrank.Items.IndexOf(fieldByName('客户等级').asString);
      customerrank.ItemIndex:=i;
      mark.Text:=fieldByName('消费积分').asString;
      address.Text:=fieldByName('通信地址').asString;
   end;
end;


procedure TForm37.Button1Click(Sender: TObject);
var
   i:integer;
   id:integer;
begin
   i:=messageDlg('确定要删除客户记录?',mtWarning,[mbYes,mbNo],0);
   if i=6 then
   begin
      {记录要删除记录的关键字}
      id:=strtoint(customerId.Text);
      {删除这一条记录}
      form16.table1.Delete;
      {清屏并且删除按钮不可用}
      customerId.Text:='';
      customerName.Text:='';
      gender.ItemIndex:=0;
      nation.ItemIndex:=0;
      idname.ItemIndex:=0;
      idcard.Text:='';
      tel.Text:='';
      account.ItemIndex:=0;
      customerrank.ItemIndex:=0;
      mark.Text:='';
      address.Text:='';
      activeControl:=customerId;
   end;
end;

function Tform37.isInteger(s: string): boolean;
var
   i:integer;
begin
   i:=1;
   if length(s)=0 then
   begin
      result:=false;
      exit;
   end;
   while i<=length(s) do
   begin
      if (isNumeric(s[i])=false) then
      begin
         result:=false;
         exit;
      end;
      i:=i+1;
   end;
   result:=true;
end;


end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -