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

📄 invoicefrm.pas

📁 结合读卡器使用。程序中有按迟到时间长短自动开罚单功能
💻 PAS
字号:
unit Invoicefrm;

interface

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

type
  TInvoiceForm = class(TForm)
    Panel1: TPanel;
    BitBtn1: TBitBtn;
    BitBtn5: TBitBtn;
    Label6: TLabel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    ComboBox1: TComboBox;
    DateTimePicker1: TDateTimePicker;
    ComboBox2: TComboBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    procedure FormShow(Sender: TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure Edit2KeyPress(Sender: TObject; var Key: Char);
    procedure Edit3KeyPress(Sender: TObject; var Key: Char);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  InvoiceForm: TInvoiceForm;

implementation
uses DataModule1;

{$R *.dfm}

procedure TInvoiceForm.FormShow(Sender: TObject);
begin
   DateTimePicker1.Date :=Date;
   ComboBox1.Text :='';
   ComboBox2.Text :='';
   Edit1.Text :='';
   Edit2.Text :='';
   Edit3.Text :='';
   Edit4.Text :='';
   Edit5.Text :='';
   Edit6.Text :='';
   Edit7.Text :='';
   GetComboBoxItem(ComboBox2);
   ComboBox2.Text :=CurrentWorker;
end;

procedure TInvoiceForm.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
   if Key=#13 then Edit2.SetFocus;
end;

procedure TInvoiceForm.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
   if Key=#13 then Edit3.SetFocus;
end;

procedure TInvoiceForm.Edit3KeyPress(Sender: TObject; var Key: Char);
begin
     if Key=#13 then
     begin
      Edit4.Text :=FloatToStr((StrToFloat(Edit2.Text)*0.4));
      Edit5.Text :=FloatToStr(StrToFloat(Edit3.Text)-StrToFloat(Edit2.Text));
      Edit6.Text :=FloatToStr((StrToFloat(Edit5.Text)*0.4));
      Edit7.Text :=FloatToStr((StrToFloat(Edit3.Text)*0.4));
     end;
end;

procedure TInvoiceForm.BitBtn1Click(Sender: TObject);
var
   Pass:boolean;
begin
   Pass:=True;
   if not isFloat(Edit2.Text) then Pass:=False;
   if not isFloat(Edit3.Text) then Pass:=False;
   if not isFloat(Edit4.Text) then Pass:=False;
   if not isFloat(Edit5.Text) then Pass:=False;
   if not isFloat(Edit6.Text) then Pass:=False;
   if not isFloat(Edit7.Text) then Pass:=False;
   if not Pass then MessageBox(Application.Handle,pchar(Errfloat),
    '提示',MB_OK+MB_ICONERROR+MB_SYSTEMMODAL)
   else
   begin
      try
      DM.Database1.StartTransaction;
      with DM.qryInvoice do
      begin
         Close;
         SQL.Clear;
         SQL.Add('Insert into invoice(I_ProjName,I_Date,I_InvoiceName,I_InvoiceMan,I_ADMoney,I_InvoiceMoney,I_FirstTax,I_OverMoney,I_OverTax,I_ActTax)');
         SQL.Add('Values(:vProjName,:vDate,:vInvoiceName,:vInvoiceMan,:vADMoney,:vInvoiceMoney,:vFirstTax,:vOverMoney,:vOverTax,:vActTax)'); 
         ParamByName('vProjName').AsString :=ComboBox1.Text;
         ParamByName('vDate').AsDatetime :=DateTimePicker1.Date;
         ParamByName('vInvoiceName').AsString :=Edit1.Text;
         ParamByName('vInvoiceMan').AsString :=ComboBox2.Text;
         ParamByName('vADMoney').AsString :=Edit2.Text;
         ParamByName('vInvoiceMoney').AsString :=Edit3.Text;
         ParamByName('vFirstTax').AsString :=Edit4.Text;
         ParamByName('vOverMoney').AsString :=Edit5.Text;
         ParamByName('vOverTax').AsString :=Edit6.Text;
         ParamByName('vActTax').AsString :=Edit7.Text;
         ExecSQL;
         Close;
      end;
      DM.Database1.Commit;
      MessageBox(Application.Handle,'保存成功!',
       '提示',MB_OK+MB_ICONINFORMATION+MB_SYSTEMMODAL);
      
      except
      DM.Database1.Rollback;
      end;
   end;
     
end;

end.

⌨️ 快捷键说明

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