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

📄 newbookunit.pas

📁 好多上载非界面和非WEB源码
💻 PAS
字号:
unit newbookUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ComCtrls,dbtables;

type
  Tnewfrm = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    typebox: TComboBox;
    nobox: TEdit;
    namebox: TEdit;
    authorbox: TEdit;
    publisherbox: TEdit;
    Label10: TLabel;
    pubtimebox: TDateTimePicker;
    pricebox: TEdit;
    intimebox: TEdit;
    outcountbox: TEdit;
    memobox: TMemo;
    procedure FormShow(Sender: TObject);
    procedure typeboxChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
  procedure autono(const stype:string);
  function nextbookno(const str:string):string;
  procedure insbook;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  newfrm: Tnewfrm;

implementation
Uses global;
{$R *.dfm}


procedure Tnewfrm.typeboxChange(Sender: TObject);
begin
autono(typebox.Text);
end;

procedure Tnewfrm.FormShow(Sender: TObject);
begin
autono(typebox.Text);
namebox.Clear;
authorbox.Clear;
publisherbox.Clear;
pricebox.Clear;
memobox.Lines.Clear;
namebox.SetFocus;
end;

procedure tnewfrm.autono(const stype:string);
var
q:tquery;
s:string;
begin
q:=tquery.Create(nil);
q.DatabaseName:=dbname;
q.SQL.Add('select 图书编号 from book_info ');
//where 类别='''+stype+''' '+' order by 图书编号 ');
q.Open;
q.Last;
s:=q.fieldbyname('图书编号').AsString;
q.Close;
q.Free;
nobox.text:=nextbookno(s);
end;

function tnewfrm.nextbookno(const str:string):string;
var
s,s1:string;
i,j,k:integer;
begin
s:=str;
s1:=copy(s,1,1);
delete(s,1,1);
i:=length(s);
j:=length(inttostr(strtoint(s)));
for k:=1 to i-j do
s1:=s1+'0';
result:=s1+inttostr(strtoint(s)+1);
end;

procedure Tnewfrm.FormCreate(Sender: TObject);
begin
intimebox.Text:=datetostr(date);
end;

procedure Tnewfrm.BitBtn2Click(Sender: TObject);
begin
if messagedlg('确定入库吗?',mtconfirmation,[mbyes,mbno],0)=mryes then
begin
insbook;
newfrm.OnShow(self);
end;
end;

procedure tnewfrm.insbook;
var
q:tquery;
begin
q:=tquery.Create(nil);
q.DatabaseName:=dbname;
q.SQL.Add('insert into book_info (图书编号,书名,作者,出版社,出版时间,书价,类别,备注,入库时间,借阅次数) values(:b_no,:b_name,:b_author,:b_publisher,:b_ptime,:b_money,:b_type,:b_memo,:b_intime,:b_outcount)');
q.ParamByName('b_no').AsString:=nobox.Text;
q.ParamByName('b_name').AsString:=namebox.Text;
q.ParamByName('b_type').AsString:=typebox.Items[typebox.itemindex];
q.ParamByName('b_author').AsString:=authorbox.Text;
q.ParamByName('b_publisher').AsString:=publisherbox.Text;
q.ParamByName('b_ptime').AsDate:=pubtimebox.Date;
q.ParamByName('b_money').asfloat:=strtofloat(pricebox.Text);
q.ParamByName('b_intime').asdate:=strtodate(intimebox.Text);
q.ParamByName('b_outcount').AsInteger:=strtoint(outcountbox.Text);
q.ParamByName('b_memo').AsString:=memobox.Lines.GetText;
q.ExecSQL;
messagedlg('新书'+namebox.Text+chr(10)+chr(13)+'已经成功入库!',mtinformation,[mbyes],0);
q.Close;
q.Free;
end;

end.

⌨️ 快捷键说明

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