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

📄 unitmengh.pas

📁 一个音像租赁店铺的管理软件,可以维护影片库信息和会员信息,及日常业务的实现(出租/归还).这是我学delphi整一个月的纪念品,有些简单,不过我还是希望和大家分享一下我的成长历程.
💻 PAS
字号:
unit UnitMenGH;

interface

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

type
  TfrmMenGH = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    DBEdit2: TDBEdit;
    Label3: TLabel;
    DBEdit3: TDBEdit;
    Label4: TLabel;
    DBEdit4: TDBEdit;
    Edit1: TEdit;
    Label5: TLabel;
    Edit2: TEdit;
    Label6: TLabel;
    ComboBox1: TComboBox;
    Label7: TLabel;
    Label8: TLabel;
    DBEdit5: TDBEdit;
    Button1: TButton;
    Button2: TButton;
    ComboBox2: TComboBox;
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ComboBox1Select(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button1Click(Sender: TObject);
    procedure ComboBox2Select(Sender: TObject);
  private
    { Private declarations }
    SerialNO:array of Integer;
  public
    { Public declarations }
  end;

var
  frmMenGH: TfrmMenGH;

implementation

uses UnitDM,UnitPub;

{$R *.dfm}

procedure TfrmMenGH.Button2Click(Sender: TObject);
begin
  frmMenGH.Close;
end;

procedure TfrmMenGH.FormCreate(Sender: TObject);
var
  index:Integer;
begin
  index:=0;

  DM.MenCZDS.Close;
  DM.MenCZDS.CommandText:='select * from 会员租赁 where 已归还 = 0';
  DM.MenCZDS.Open;
  SetLength(SerialNO,DM.MenCZDS.RecordCount);
  DM.MenCZDS.First;
  while not DM.MenCZDS.Eof do
  begin
    SerialNO[index]:=DM.MenCZDS.FieldByName('序号').AsInteger;
    ComboBox1.Items.Add(DM.MenCZDS.FieldByName('影片号').AsString);
    ComboBox2.Items.Add(DM.MenCZDS.FieldByName('会员号').AsString);
    DM.MenCZDS.Next;
    index:=index+1;
  end;
  ComboBox1.ItemIndex:=0;
  ComboBox1.OnSelect(self);
end;

procedure TfrmMenGH.ComboBox1Select(Sender: TObject);
var
  moneyreq:TDateTime;
begin
  if ComboBox1.Items.Count=0 then
    Exit;
  DM.MenCZDS.Locate('序号',SerialNO[ComboBox1.ItemIndex],[]);
  ComboBox2.ItemIndex:=ComboBox1.ItemIndex;
  Edit1.Text:=DateTimeToStr(Now());
  DM.AllFilmDS.Locate('影片号',ComboBox1.Text,[]);
  moneyreq:=GetInterval(DM.ComCZDS.FieldByName('租借日期').AsDateTime,Now())*DM.AllFilmDS.FieldByName('日消耗片次').AsFloat;
  Edit2.Text:=Format('%.0f',[int(moneyreq)]);
  DM.MenberDS.Locate('会员号',ComboBox2.Text,[]);
end;

procedure TfrmMenGH.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action:=caFree;
  frmMenGH:=nil;
end;

procedure TfrmMenGH.Button1Click(Sender: TObject);
begin
  if ComboBox1.Text='' then
  begin
    ShowMessage('请选择要归还的影片先!');
    Exit;
  end;
  ShowMessage('扣除片次:'+Edit2.Text+'   并应归还押金:'+DBEdit2.Text);
  DM.MenCZDS.Edit;
  DM.MenCZDS.FieldByName('归还日期').AsString:=Edit1.Text;
  DM.MenCZDS.FieldByName('消耗片次').AsInteger:=StrToInt(Edit2.Text);
  DM.MenCZDS.FieldByName('已归还').AsBoolean:=True;
  DM.MenCZDS.UpdateBatch();

  DM.AllFilmDS.Locate('影片号',ComboBox1.Text,[]);
  DM.AllFilmDS.Edit;
  DM.AllFilmDS.FieldByName('状态').AsString:='可借';
  DM.AllFilmDS.UpdateBatch();

  DM.MenberDS.Edit;
  DM.MenberDS.FieldByName('可用片次').AsInteger:=DM.MenberDS.FieldByName('可用片次').AsInteger-StrToInt(Edit2.Text);
  DM.MenberDS.UpdateBatch();

  DM.MenCZDS.Close;
  DM.MenCZDS.CommandText:='select * from 会员租赁';
  DM.MenCZDS.Open;

  if DM.MenberDS.FieldByName('可用片次').AsInteger<0 then
    ShowMessage('该会员的可用片次不足!');
  ShowMessage('成功归还');
  frmMenGH.Close;
end;

procedure TfrmMenGH.ComboBox2Select(Sender: TObject);
begin
  ComboBox1.ItemIndex:=ComboBox2.ItemIndex;
  ComboBox1.OnSelect(self);
end;
end.

⌨️ 快捷键说明

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