📄 uproviderinfo.pas
字号:
unit uProviderinfo;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Grids, LBDBGrid, StdCtrls, LBCtrls, LBDBCtrls,
ActnList, DBCtrls, FR_DSet, FR_DBSet, FR_Class, LBDBScrollBar;
type
TfrmProviderinfo = class(TForm)
Panel1: TPanel;
Panel3: TPanel;
Panel4: TPanel;
DataDBGrid: TLBDBGrid;
plData: TPanel;
Panel8: TPanel;
Shape1: TShape;
Shape2: TShape;
Label1: TLabel;
Shape3: TShape;
LBDBEdit1: TLBDBEdit;
Shape4: TShape;
LBDBEdit2: TLBDBEdit;
Shape5: TShape;
LBDBEdit3: TLBDBEdit;
Shape6: TShape;
LBDBEdit4: TLBDBEdit;
Shape7: TShape;
LBDBEdit5: TLBDBEdit;
Shape8: TShape;
LBDBEdit6: TLBDBEdit;
Shape9: TShape;
LBDBEdit7: TLBDBEdit;
Shape10: TShape;
LBDBEdit8: TLBDBEdit;
Shape11: TShape;
LBDBEdit9: TLBDBEdit;
Shape12: TShape;
LBDBEdit10: TLBDBEdit;
Shape13: TShape;
LBDBEdit11: TLBDBEdit;
Shape14: TShape;
LBDBEdit12: TLBDBEdit;
Label6: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label5: TLabel;
Label15: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label16: TLabel;
Label18: TLabel;
Label19: TLabel;
Label20: TLabel;
Shape15: TShape;
Shape16: TShape;
Shape17: TShape;
Shape18: TShape;
Shape19: TShape;
Shape20: TShape;
Shape21: TShape;
Label7: TLabel;
Label17: TLabel;
LBDBEdit13: TLBDBEdit;
LBDBEdit14: TLBDBEdit;
LBDBEdit15: TLBDBEdit;
LBDBEdit16: TLBDBEdit;
LBDBNumberEdit1: TLBDBNumberEdit;
LBDBEdit18: TLBDBEdit;
LBDBComboBox1: TLBDBComboBox;
ActionList1: TActionList;
Action1: TAction;
Action2: TAction;
Action3: TAction;
Action5: TAction;
Action6: TAction;
Action4: TAction;
Action7: TAction;
Action8: TAction;
Label22: TLabel;
Label23: TLabel;
Label24: TLabel;
DBText1: TDBText;
DBText2: TDBText;
DBText3: TDBText;
Label21: TLabel;
DBText4: TDBText;
Report: TfrReport;
ReportDataSet: TfrDBDataSet;
Panel7: TPanel;
Image1: TImage;
Shape22: TShape;
Shape23: TShape;
Shape24: TShape;
Shape25: TShape;
Panel2: TPanel;
Panel5: TPanel;
Panel9: TPanel;
Panel11: TPanel;
EnterButton: TLBButton;
CancelButton: TLBButton;
LBDBScrollBar1: TLBDBScrollBar;
LBSpeecButton2: TLBSpeecButton;
LBSpeecButton1: TLBSpeecButton;
LBSpeecButton3: TLBSpeecButton;
LBSpeecButton4: TLBSpeecButton;
LBSpeecButton5: TLBSpeecButton;
LBSpeecButton6: TLBSpeecButton;
PrepayPanel: TPanel;
Label25: TLabel;
Label26: TLabel;
Label27: TLabel;
Shape26: TShape;
PrepaySumEdit: TLBDBNumberEdit;
ArrearageSumEdit: TLBDBNumberEdit;
REIMBURSESUMEdit: TLBDBNumberEdit;
procedure FormShow(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Action2Execute(Sender: TObject);
procedure Action1Execute(Sender: TObject);
procedure Action3Execute(Sender: TObject);
procedure Action5Execute(Sender: TObject);
procedure Action6Execute(Sender: TObject);
procedure Action4Execute(Sender: TObject);
procedure Action7Execute(Sender: TObject);
procedure Action8Execute(Sender: TObject);
procedure LBDBEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure DataDBGridKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormDestroy(Sender: TObject);
procedure LBDBComboBox1Enter(Sender: TObject);
procedure REIMBURSESUMEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
procedure SetView;
public
{ Public declarations }
end;
var
frmProviderinfo: TfrmProviderinfo;
isStateEdit, isEdit: Boolean;
OldCode: string;
implementation
uses uDataMo, uPublicvar, uMain, uConst;
{$R *.dfm}
procedure TfrmProviderinfo.SetView;
begin
DataDBGrid.Enabled:=not DataDBGrid.Enabled;
plData.Enabled:=not plData.Enabled;
Action1.Enabled:=not Action1.Enabled;
Action2.Enabled:=not Action2.Enabled;
Action3.Enabled:=not Action3.Enabled;
Action4.Enabled:=not Action4.Enabled;
Action5.Enabled:=not Action5.Enabled;
Action6.Enabled:=not Action6.Enabled;
Action7.Enabled:=not Action7.Enabled;
Action8.Enabled:=not Action8.Enabled;
EnterButton.Visible:=not EnterButton.Visible;
CancelButton.Visible:=not CancelButton.Visible;
end;
procedure TfrmProviderinfo.FormShow(Sender: TObject);
begin
SetView;
OpenData('select * from Providerinfo', dmData.sdsProviderinfo);
isStateEdit:=False;
end;
procedure TfrmProviderinfo.FormActivate(Sender: TObject);
begin
GetWindowsItem(Caption, Self);
end;
procedure TfrmProviderinfo.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
frmProviderinfo:=Nil;
end;
procedure TfrmProviderinfo.Action1Execute(Sender: TObject);
begin
SetView;
PrepayPanel.Visible:=True;
LBDBEdit1.SetFocus;
with dmData.sdsProviderinfo do
begin
Append;
FieldByName('Del').asstring:='0';
FieldByName('PrepaySum').asfloat:=0;
FieldByName('ArrearageSum').asfloat:=0;
FieldByName('PaymentSum').asfloat:=0;
FieldByName('REIMBURSESUM').asfloat:=0;
end;
OldCode:='';
isEdit:=False;
isStateEdit:=True;
end;
procedure TfrmProviderinfo.Action2Execute(Sender: TObject);
begin
if dmData.sdsProviderinfo.IsEmpty then
begin
Application.MessageBox(NotEditData, Hintinfo,$30);
Exit;
end;
SetView;
LBDBEdit1.SetFocus;
dmData.sdsProviderinfo.Edit;
OldCode:=dmData.sdsProviderinfo.Fieldbyname('Code').asstring ;
isEdit:=True;
isStateEdit:=True;
end;
procedure TfrmProviderinfo.Action3Execute(Sender: TObject);
begin
DeleteData(dmData.sdsProviderinfo, True);
end;
procedure TfrmProviderinfo.Action5Execute(Sender: TObject);
begin
FindData(dmData.sdsProviderinfo, '供应商资料查询', 'Providerinfo');
end;
procedure TfrmProviderinfo.Action6Execute(Sender: TObject);
begin
OpenData('select * from Providerinfo', dmData.sdsProviderinfo);
end;
procedure TfrmProviderinfo.Action4Execute(Sender: TObject);
begin
PrintView('RepProviderinfo.frf', Report);
end;
procedure TfrmProviderinfo.Action7Execute(Sender: TObject);
var
BillCode:string;
begin
if Trim(LBDBEdit1.Text)='' then
begin
Application.MessageBox('请输入供应商编号。', HintInfo,$30);
LBDBEdit1.SetFocus;
Exit;
end;
if Trim(LBDBEdit2.Text)='' then
begin
Application.MessageBox('请输入供应商名称。',HintInfo,$30);
LBDBEdit2.SetFocus;
Exit;
end;
if isExist('ProviderInfo', 'Code', Trim(LBDBEdit1.Text), OldCode, '') then
begin
Application.MessageBox('此供应商编号已存在,请重新输入。',HintInfo,$30);
LBDBEdit1.SetFocus;
Exit;
end;
//如果有期初金额
dmData.sdsProviderinfo.Post;
with dmData.sdsProviderinfo do
begin
if (isEdit=False) and
((FieldByName('PrepaySum').AsFloat>0) or
(FieldByName('ArrearageSum').AsFloat>0) or
(FieldByName('REIMBURSESUM').AsFloat>0) ) then
begin
if Application.MessageBox('你输入有期初金额,确定这些金额正确吗?',Hintinfo, $24)=idYes then
begin
Edit;
FieldByName('PaymentSum').AsFloat:=
FieldByName('ArrearageSum').AsFloat-FieldByName('PrepaySum').AsFloat-FieldByName('REIMBURSESUM').AsFloat;
FieldByName('Del').asString:='1';
if FieldByName('ArrearageSum').AsFloat>0 then
begin
BillCode:=ComDepotCode+'-'+'QF'+'-'+
GetBillID('50', DateToStr(Date));
with dmData.SQLQuery do
begin
Close;
Sql.Clear;
Sql.Text:='insert into PartsInputHand '+
'(BILLCODE, BILLDATE, PROVIDERCODE, PROVIDERNAME, TOTALSUM, AcceptSum, Agiosum, '+
'ISACCEPT, ISAUDITING, INPUTTYPE) values('+
#39+BillCode+#39+','+#39+DateToStr(Date)+#39+','+
#39+Trim(LBDBEdit1.Text)+#39+','+
#39+Trim(LBDBEdit2.Text)+#39+','+
FloatToStr(dmData.sdsProviderinfo.FieldByName('ArrearageSum').AsFloat)+',0,0,'+
#39+'0'+#39+','+#39+'1'+#39+','+#39+'5'+#39+')';
ExecSql;
end;
end;
if FieldByName('REIMBURSESUM').AsFloat>0 then
begin
BillCode:=ComDepotCode+'-'+'QT'+'-'+
GetBillID('51', DateToStr(Date));
with dmData.SQLQuery do
begin
Close;
Sql.Clear;
Sql.Text:='insert into REIMBURSEBILLHAND '+
'(BILLCODE, BILLDATE, PROVIDERCODE, PROVIDERNAME, TOTALSUM, '+
'ISACCEPT, ISAUDITING, REIMBURSETYPE) values('+
#39+BillCode+#39+','+#39+DateToStr(Date)+#39+','+
#39+Trim(LBDBEdit1.Text)+#39+','+
#39+Trim(LBDBEdit2.Text)+#39+','+
FloatToStr(dmData.sdsProviderinfo.FieldByName('REIMBURSESUM').AsFloat)+','+
#39+'0'+#39+','+#39+'1'+#39+','+#39+'3'+#39+')';
ExecSql;
end;
end;
end
else
Exit;
end;
ApplyUpdates(-1);
end;
if not isEdit then
begin
LBDBEdit1.SetFocus;
with dmData.sdsProviderinfo do
begin
Append;
FieldByName('Del').asstring:='0';
FieldByName('PrepaySum').asfloat:=0;
FieldByName('ArrearageSum').asfloat:=0;
FieldByName('PaymentSum').asfloat:=0;
FieldByName('REIMBURSESUM').asfloat:=0;
end;
end
else
begin
SetView;
isStateEdit:=False;
PrepayPanel.Visible:=False;
end;
end;
procedure TfrmProviderinfo.Action8Execute(Sender: TObject);
begin
if dmData.sdsProviderinfo.Modified then
begin
if Application.MessageBox(OnCancelEdit,HintInfo,$24)=idYes then
begin
dmData.sdsProviderinfo.CancelUpdates;
PrepayPanel.Visible:=False;
SetView;
end;
end
else
begin
dmData.sdsProviderinfo.CancelUpdates;
PrepayPanel.Visible:=False;
SetView;
end;
isStateEdit:=False;
end;
procedure TfrmProviderinfo.LBDBEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=13 then Perform(WM_NEXTDLGCTL,0,0);
end;
procedure TfrmProviderinfo.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=27 then Close;
end;
procedure TfrmProviderinfo.DataDBGridKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if (key=VK_NEXT) or (key=VK_Down) then
if dmData.sdsProviderinfo.Eof then
dmData.sdsProviderinfo.GetNextPacket;
end;
procedure TfrmProviderinfo.FormDestroy(Sender: TObject);
begin
WindowItem.Delete(WindowItem.IndexOfObject(Self));
end;
procedure TfrmProviderinfo.LBDBComboBox1Enter(Sender: TObject);
begin
SetListData('select Name from Elseinfo where Code='''+'9''', LBDBComboBox1);
end;
procedure TfrmProviderinfo.REIMBURSESUMEditKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if key=13 then Action7Execute(Sender);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -