📄 xssk.pas
字号:
unit Xssk;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComDj, Menus, DBCtrls, ComCtrls, ToolWin, ExtCtrls, StdCtrls, Mask,
Grids, DBGrids, Buttons, Db, CheckLst, ActnList, Variants;
type
TfrmXssk = class(TfrmComDj)
Label4: TLabel;
DBEdit2: TDBEdit;
Label9: TLabel;
Label7: TLabel;
btnKhHelp: TSpeedButton;
DBEdit7: TDBEdit;
DBEdit6: TDBEdit;
Label14: TLabel;
DBEdit12: TDBEdit;
DBLookupComboBox1: TDBLookupComboBox;
Label6: TLabel;
ToolButton1: TToolButton;
aZdfk: TAction;
aCKGJD: TAction;
N7: TMenuItem;
N8: TMenuItem;
N12: TMenuItem;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
labJEA: TLabel;
labJEB: TLabel;
labJEC: TLabel;
labJED: TLabel;
Shape1: TShape;
Shape3: TShape;
Shape4: TShape;
Shape5: TShape;
ToolButton2: TToolButton;
Label8: TLabel;
DBEdit3: TDBEdit;
DBComboBox2: TDBComboBox;
Label13: TLabel;
Label15: TLabel;
DBEdit4: TDBEdit;
Label5: TLabel;
DBLookupComboBox2: TDBLookupComboBox;
pnlHint: TPanel;
Label16: TLabel;
Label20: TLabel;
Label17: TLabel;
aZdfkB: TAction;
N13: TMenuItem;
labJYJ: TLabel;
labKYZJE: TLabel;
labSKHYE: TLabel;
DBCheckBox2: TDBCheckBox;
pnlTs: TPanel;
Panel5: TPanel;
SpeedButton1: TSpeedButton;
btnCloseTs: TButton;
Label18: TLabel;
Label19: TLabel;
aTs: TAction;
N14: TMenuItem;
N15: TMenuItem;
aKhXx: TAction;
N16: TMenuItem;
K1: TMenuItem;
procedure IniRecord;override;
procedure TotalField(Kind: char; Field: TField);override;
procedure ZbOnNewRecord(DataSet: TDataSet);override;
procedure MxBeforeInsert(DataSet: TDataSet);override;
procedure sZbDataChange(Sender: TObject; Field: TField);override;
procedure sMxDataChange(Sender: TObject; Field: TField);override;
procedure btnKhHelpClick(Sender: TObject);
procedure FormShow(Sender: TObject);override;
procedure aZdfkExecute(Sender: TObject);
procedure aCKGJDExecute(Sender: TObject);
procedure aZdfkBExecute(Sender: TObject);
procedure DBGrid1EditButtonClick(Sender: TObject);override;
procedure aSaveExecute(Sender: TObject);override;
procedure btnCloseTsClick(Sender: TObject);
procedure aTsExecute(Sender: TObject);
procedure DBComboBox2Change(Sender: TObject);
procedure DBCheckBox2Click(Sender: TObject);
procedure aKhXxExecute(Sender: TObject);
private
{ private declarations }
blnCanInsert: boolean;
procedure SetMx;
procedure SetJEABCD;
procedure SetJYJ;
procedure SetKYZJE;
procedure SetSKHYE;
public
{ Public declarations }
end;
var
frmXssk: TfrmXssk;
implementation
uses Dm, Common, Main, MyLib, KhHelp, HpHelp, ComFun, KhXx, Xskd;
{$R *.DFM}
procedure TfrmXssk.FormShow(Sender: TObject);
begin
strZbMxKey := 'ID,ZBID; RQ,RQ';
strZbKeyFields := 'DJBH; RQ; AFKLX; AKHBH; SFKFSID; ZHID';
strZbHelpFields := 'AKHBH';
strMxHh := 'HH';
blnSetZbID := True;
strAutoScale := 'DBGrid1';
inherited;
end;
procedure TfrmXssk.IniRecord;
begin
//同时更新 frmZB.dsAfterScroll
dsMx.CommandText :=
'select M.*, ' +
'D.DJBH as aDDBH, D.RQ+D.SKQX as aSKQX, D.JE as aDDJE, ' +
'D.YSJE - M.JE as aYSJE, D.JE - D.YSJE + M.JE as aMSJE ' +
'from XSSK M, XSKDZB D, M inner join D on M.DDID=D.ID ' +
'where M.ZBID = ' + Float2Str(dsZb['ID']);
inherited;
//INI LABEL
labJYJ.Caption := '0.00';
labKYZJE.Caption := '0.00';
labSKHYE.Caption := '0.00';
labJEA.Caption := '0.00';
labJEB.Caption := '0.00';
labJEC.Caption := '0.00';
labJED.Caption := '0.00';
//SetJYJ
SetJYJ;
//SetJEABCD
SetJEABCD;
//SetSKHYE
SetSKHYE;
//
DBCheckBox2.Enabled := dsZb.FieldByName('FKLX').AsInteger = 1;
end;
procedure TfrmXssk.ZbOnNewRecord(DataSet: TDataSet);
begin
inherited;
DataSet['RQ'] := Date;
DataSet['AFKLX'] := DBComboBox2.Items[0];
DataSet['CZY'] := pstrUserName;
DataSet['SFKFSID'] := Data.Sfkfs['ID'];
DataSet['SYJY'] := False;
end;
procedure TfrmXssk.btnKhHelpClick(Sender: TObject);
begin
frmKhHelp := TFrmKhHelp.Create(Application);
with frmKhHelp do
begin
strEditFieldName := 'aKHBH';
strHelpFieldName := 'BH';
dsEditing := self.dsZb;
Edit1.Text := self.DBEdit2.Text;
ShowModal;
if ModalResult = MROK then
self.Perform(WM_KEYDOWN, VK_RETURN, 0);
Free;
end;
end;
procedure TfrmXssk.sZbDataChange(Sender: TObject; Field: TField);
begin
inherited;
if (Field <> nil) and (TDataSource(Sender).State in [dsInsert, dsEdit]) then
begin
if (UpperCase(Field.FieldName) = 'RQ') then
dsZb['DJBH'] := GetDjbh('XS', Field.AsDateTime, 'XSSKZB');
if (UpperCase(Field.FieldName) = 'AKHBH') then
with CurDs do
begin
CommandText := 'select * from KH where BH = ''' + Field.AsString + '''';
Open;
if not IsEmpty then
begin
dsZb['KHID'] := FieldValues['ID'];
dsZb['aKHMC'] := FieldValues['MC'];
dsZb['JEA'] := FieldValues['YXJE'];
SetMx;
SetJYJ;
end
else
Screen.ActiveControl.Perform(WM_LBUTTONDBLCLK, 0, 0);
Close;
end;
if (UpperCase(Field.FieldName) = 'AFKLX') then
dsZb['FKLX'] := DBComboBox2.ItemIndex + 1;
if (UpperCase(Field.FieldName) = 'SFKFSID') then
begin
dsZb['aSFKFSMC'] := DBLookupComboBox1.Text;
dsZb['ZHID'] := DBLookupComboBox1.ListSource.DataSet['ZHID'];
end;
if (UpperCase(Field.FieldName) = 'ZHID') then
dsZb['aZHMC'] := DBLookupComboBox2.Text;
if (UpperCase(Field.FieldName) = 'JE') then
SetKYZJE;
end;
end;
//sZbDataChange不能即用更新,所以在这里做
procedure TfrmXssk.DBComboBox2Change(Sender: TObject);
begin
DBCheckBox2.Enabled := True;
if DBComboBox2.ItemIndex = 1 then
DBCheckBox2.Enabled := False;
if dsZb = nil then Exit;
if (DBComboBox2.ItemIndex + 1) <> dsZb.FieldByName('FKLX').AsInteger then
dsZb['FKLX'] := DBComboBox2.ItemIndex + 1;
SetMx;
end;
//sZbDataChange不能即用更新,所以在这里做
procedure TfrmXssk.DBCheckBox2Click(Sender: TObject);
begin
if dsZb = nil then Exit;
if dsZb.State in [dsInsert, dsEdit] then
dsZb.FieldByName('SYJY').AsBoolean := DBCheckBox2.Checked;
SetJYJ;
end;
procedure TfrmXssk.MxBeforeInsert(DataSet: TDataSet);
begin
if not blnCanInsert then
abort;
end;
procedure TfrmXssk.SetMx;
var
dblJE: double;
blnHaveOld: boolean;
intDDID: integer;
begin
screen.Cursor := crHourGlass;
//Del
with dsMx do
while not IsEmpty do
Delete;
//Add
if DBComboBox2.ItemIndex = 0 then
begin
blnCanInsert := True;
blnHaveOld := False;
if CheckRecord('select * from XSSKZB where ID = ' + Float2Str(dsZb['ID']) + ' and ' +
'KHID = ' + Float2Str(dsZb['KHID'])) then
with CurDs do
begin
CommandText := 'select F.DDID, F.JE as BDJE, S.DJBH, S.RQ- S.SKQX as aSKQX, S.JE, S.YSJE ' +
'from XSSK F, XSKDZB S ' +
'where F.DDID = S.ID and ZBID = ' + Float2Str(dsZb['ID']);
Open;
blnHaveOld := not IsEmpty;
while not Eof do
begin
dsMx.Append;
dsMx['DDID'] := FieldValues['DDID'];
dsMx['aDDBH'] := FieldValues['DJBH'];
dsMx['aSKQX'] := FieldValues['aSKQX'];
dsMx['aDDJE'] := FieldValues['JE'];
dsMx['aYSJE'] := FieldValues['YSJE'] - FieldValues['BDJE'];
dsMx['aMSJE'] := FieldValues['JE'] - FieldValues['YSJE'] + FieldValues['BDJE'];
dsMx['JE'] := FieldValues['BDJE'];
Next;
end;
dsMx.First;
DBGrid1.SelectedIndex := DBGrid1.FieldCount - 1;
Close;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -