unit khjbgl; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, Buttons, DB, Grids, DBGrids; type TForm25 = class(TForm) BitBtn1: TBitBtn; BitBtn3: TBitBtn; BitBtn5: TBitBtn; BitBtn4: TBitBtn; BitBtn2: TBitBtn; DBGrid1: TDBGrid; DataSource1: TDataSource; Label1: TLabel; Label2: TLabel; Label10: TLabel; Edit2: TEdit; Edit1: TEdit; Label7: TLabel; Label4: TLabel; Label3: TLabel; Label5: TLabel; Label6: TLabel; procedure FormShow(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure BitBtn5Click(Sender: TObject); procedure BitBtn3Click(Sender: TObject); procedure Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure Edit2KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure BitBtn4Click(Sender: TObject); procedure BitBtn1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure BitBtn1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); private { Private declarations } public { Public declarations } end; var Form25: TForm25; implementation uses wlzgl,data2; {$R *.dfm} procedure TForm25.FormShow(Sender: TObject); begin Label5.Caption := ForMatDateTime(‘yyyy-mm-dd‘,Now); Label6.Caption := czymc; with datam.ADOQuery1 do begin Close; SQL.Clear; SQL.Add(‘select * from 客户级别表‘); Open; end; if datam.ADOQuery1.RecordCount>0 then DataSource1.DataSet := datam.ADOQuery1; end; procedure TForm25.BitBtn1Click(Sender: TObject); var s,m: String; i: integer; begin s:= ‘C‘+ FormatDateTime(‘yyyymmdd‘,Now()); With datam.ADOQuery2 do begin Close; SQL.Clear; SQL.Add(‘select max(级别编号) as ss From 客户级别表 ‘); Open; end; If datam.ADOQuery2.FieldByName(‘ss‘).Value = null then s := s + ‘001‘ else begin m:= Trim(datam.ADOQuery2.FieldByName(‘ss‘).Value) ; i:= StrToInt(Trim(Copy(m,10,5))) ; if i<9 then s:= s + ‘00‘+ InttoStr(i +1) else if i<99 then s:= s + ‘0‘+ InttoStr(i +1) else s:= s +InttoStr(i +1); end; Label7.Caption := s; Label6.Caption := czymc; Label5.Caption := FormatDateTime(‘yyyy-mm-dd‘,Now); Edit1.SetFocus; BitBtn3.Enabled := True; end; procedure TForm25.BitBtn5Click(Sender: TObject); begin Edit1.Clear; Edit2.Clear; Label7.Caption := ‘‘; Label6.Caption := ‘‘; Label5.Caption := ‘‘; end; procedure TForm25.BitBtn3Click(Sender: TObject); begin if (Trim(Edit1.Text)<>‘‘)and(Trim(Edit2.Text)<>‘‘)and(Trim(Label5.Caption)<>‘‘)and (Trim(Label6.Caption)<>‘‘)and(Trim(Label7.Caption)<>‘‘)then begin Try with datam.ADOQuery2 do begin Close; SQL.Clear; SQL.Add(‘Insert 客户级别表 values (:a ,:b,Default ,:d,:e)‘); Parameters.ParamByName(‘a‘).Value := Trim(Label7.Caption); Parameters.ParamByName(‘b‘).Value := Trim(Edit1.Text); Parameters.ParamByName(‘d‘).Value := Trim(Label6.Caption); Parameters.ParamByName(‘e‘).Value := Trim(Edit2.Text); ExecSQL; end; Application.MessageBox(‘添加成功。‘,‘提示‘,64); BitBtn5.OnClick(Sender); with datam.ADOQuery1 do begin Close; SQL.Clear; SQL.Add(‘select * from 客户级别表‘); Open; end; if datam.ADOQuery1.RecordCount>0 then DataSource1.DataSet := datam.ADOQuery1; BitBtn3.Enabled := False; BitBtn1.SetFocus; Except Application.MessageBox(‘系统出错。‘,‘提示‘,64); Close; end; end; end; procedure TForm25.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = Vk_ReTurn then if Trim(Edit1.Text)<>‘‘ then Edit2.SetFocus; end; procedure TForm25.Edit2KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = VK_ReTurn then if (Trim(Edit2.Text)<>‘‘)and(BitBtn3.Enabled = True) then BitBtn3.SetFocus; end; procedure TForm25.BitBtn4Click(Sender: TObject); begin if datam.ADOQuery1.RecordCount>0 then if Application.MessageBox(Pchar(‘确实要删除级别编号为‘+ Trim(datam.ADOQuery1.FieldByName(‘级别编号‘).Value) +‘的级别信息吗?‘),‘提示‘,MB_YesNo)= ID_Yes then datam.ADOQuery1.Delete; end; procedure TForm25.BitBtn1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin TBitBtn(Sender).Font.Color := clRed ; end; procedure TForm25.BitBtn1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin TBitBtn(Sender).Font.Color := clBlue; end; end.
时间: 2024-10-04 11:30:43