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

📄 unit2.pas

📁 基于ACESS数据库的小型进销存管理软件。
💻 PAS
字号:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, DBGrids, DB, ADODB, ComCtrls, FR_DSet, FR_DBSet,
  FR_Class, DBCtrls;

type
  TForm2 = class(TForm)
    ADOTable1: TADOTable;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Label1: TLabel;
    Label2: TLabel;
    OutB: TEdit;
    Label3: TLabel;
    OutC: TEdit;
    Label4: TLabel;
    OutD: TEdit;
    Label5: TLabel;
    OutE: TEdit;
    Label6: TLabel;
    OutF: TEdit;
    Label7: TLabel;
    OutG: TEdit;
    Label8: TLabel;
    OutI: TEdit;
    Label9: TLabel;
    OutJ: TEdit;
    Label10: TLabel;
    OutK: TEdit;
    Button1: TButton;
    Button2: TButton;
    OutA: TDateTimePicker;
    Button3: TButton;
    Label11: TLabel;
    OUTL: TEdit;
    frDBDataSet1: TfrDBDataSet;
    frReport1: TfrReport;
    Button5: TButton;
    Label12: TLabel;
    outm: TEdit;
    ADOTable2: TADOTable;
    DataSource2: TDataSource;
    DBLookupComboBox1: TDBLookupComboBox;
    DBLookupComboBox2: TDBLookupComboBox;
    ADOTable3: TADOTable;
    DataSource3: TDataSource;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure DBGrid1CellClick(Column: TColumn);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormHide(Sender: TObject);
//    procedure DataSource1DataChange(Sender: TObject; Field: TField);
     private
    { Private declarations }
  public
    { Public declarations }

  end;

var
  Form2: TForm2;
  var a :integer;
  var b:string;

implementation

uses Unit4, Frm_Print, Unit5;

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
begin
with AdoTable1 do
begin
try
adotable1.Append;
AdoTable1.FieldByName('OutA').AsDateTime:=OutA.Date;
AdoTable1.FieldByName('outB').AsString:=outB.Text;
Adotable1.FieldByName('OutC').AsString:=Outc.text;
//AdoTable1.FieldByName('OutD').AsString:=OutD.text;
adotable1.FieldByName('outd').AsString:=dblookupcombobox1.Text;
adotable1.FieldByName('OutE').AsInteger:=strtoint(OutE.Text);
adotable1.FieldByName('OutF').AsFloat:=strtofloat(format('%8.6f',[strtofloat(OutF.Text)]));
adotable1.FieldByName('outG').AsFloat:=strtofloat(format('%8.6f',[strtofloat(OutG.text)]));
adotable1.FieldByName('OutH').asfloat:=strtofloat(format('%8.6f',[strtofloat(OutF.Text)*strtofloat(OutG.Text)]));
adotable1.FieldByName('outI').asString:=OutI.text;
adotable1.FieldByName('outJ').asString:=OutJ.text;
//adotable1.FieldByName('outK').asString:=OutK.text;
adotable1.FieldByName('outK').asString:=dblookupcombobox2.text;
adotable1.FieldByname('outL').asstring:=outl.text;
adotable1.fieldbyname('outm').asinteger:=strtoint(outm.text);
adotable1.Post;
showmessage('数据已经正确存盘!');
except
Cancel;
ShowMessage('数据存盘发生错误,请检查数据是否正确!');
end;
end;
end;



procedure TForm2.Button2Click(Sender: TObject);
begin
 with AdoTable1 do
begin
try
adotable1.Edit;
AdoTable1.FieldByName('OutA').asdatetime:=OutA.Date;
AdoTable1.FieldByName('outB').AsString:=outB.Text;
Adotable1.FieldByName('OutC').AsString:=Outc.text;
AdoTable1.FieldByName('OutD').AsString:=dblookupcombobox1.text;
adotable1.FieldByName('OutE').AsInteger:=strtoint(OutE.Text);
adotable1.FieldByName('OutF').AsFloat:=strtofloat(format('%8.6f',[strtofloat(OutF.Text)]));
adotable1.FieldByName('outG').AsFloat:=strtofloat(format('%8.6f',[strtofloat(OutG.text)]));
adotable1.FieldByName('OutH').asfloat:=strtofloat(format('%8.6f',[strtofloat(OutF.Text)*strtofloat(OutG.Text)]));
adotable1.FieldByName('outI').asString:=OutI.text;
adotable1.FieldByName('outJ').asString:=OutJ.text;
adotable1.FieldByName('outK').asString:=OutK.text;
adotable1.FieldByName('outl').asstring:=outl.text;
adotable1.fieldbyname('outm').Asinteger:=strtoint(outm.text);
adotable1.Post;
showmessage('数据已经正确存盘!');
except
Cancel;
ShowMessage('数据存盘发生错误,请检查数据是否正确!');
end;
end;
end;
procedure TForm2.Button3Click(Sender: TObject);
var i:integer;
begin
if MessageDlg('是否删除',mtConfirmation, [mbYes, mbNo], 0) = mrYes then
  begin
with adotable1 do
begin
adotable1.Delete;
adotable1.First;
end;
button3.Enabled:=false;
      end;
end;

procedure TForm2.DBGrid1CellClick(Column: TColumn);
begin
try
begin
button2.Enabled:=true;
button3.Enabled:=true;
outa.Date:=AdoTable1.FieldByName('OutA').asdatetime;
outB.Text:=AdoTable1.FieldByName('outB').AsString;
Outc.text:=Adotable1.FieldByName('OutC').AsString;
//OutD.text:=AdoTable1.FieldByName('OutD').AsString;
OutE.Text:=inttostr(adotable1.FieldByName('OutE').AsInteger);
OutF.Text:=floattostr(adotable1.FieldByName('OutF').AsFloat);
outG.Text:=floattostr(adotable1.FieldByName('outG').AsFloat);
OutI.text:=adotable1.FieldByName('outI').asString;
OutJ.text:=adotable1.FieldByName('outJ').asString;
OutK.text:=adotable1.FieldByName('outK').asString;
outl.text:=adotable1.fieldbyname('outl').asstring;
outm.text:=inttostr(adotable1.fieldbyname('outm').asinteger);
a:=strtoint(oute.text);
b:=outf.text;
end;
except

end;
end;

procedure TForm2.Button4Click(Sender: TObject);
begin
     form2.close;
     form2.ADOTable1.Active:=false;
     form2.ADOTable1.Active:=true;
     frReport1.LoadFromFile('print\102.frf');
     frReport1.OnObjectClick:= nil;
     frReport1.OnMouseOverObject:= nil;
     frReport1.ModifyPrepared:=false;
     frReport1.Preview:=FormPrint.frPreview1;
     if frReport1.PrepareReport then
     frReport1.ShowPreparedReport;
     FormPrint.ShowModal;
end;

procedure TForm2.Button5Click(Sender: TObject);
begin
application.CreateForm(tform5,form5);
form5.ShowModal;
form5.ADOTable1.Active:=false;
form5.ADOTable1.active:=true;
end;

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 outb.Text:='';
 outl.text:='';
 outk.text:='';
 outi.text:='';
 outd.text:='';
 outc.text:='';
 oute.text:='';
 outf.text:='';
 outg.text:='';
 outj.text:='';
end;

procedure TForm2.FormHide(Sender: TObject);
begin
 outb.Text:='';
 outl.text:='';
 outk.text:='';
 outi.text:='';
 outd.text:='';
 outc.text:='';
 oute.text:='';
 outf.text:='';
 outg.text:='';
 outj.text:='';
end;

end.

⌨️ 快捷键说明

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