📄 upartsmove.pas
字号:
unit uPartsMove;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, LBCtrls, ExtCtrls, ActnList, StdCtrls, LBDBScrollBar, dbcgrids,
LBDBCtrls, FR_DSet, FR_DBSet, FR_Class, DB, DBClient, SimpleDS, DBCtrls,
Mask, ToolWin, ActnMan, ActnCtrls, ActnMenus, XPStyleActnCtrls,
ActnColorMaps, jpeg;
type
TfrmPartsMove = class(TForm)
ActionList1: TActionList;
Action1: TAction;
Action2: TAction;
Action3: TAction;
Action4: TAction;
Action7: TAction;
Action8: TAction;
Action9: TAction;
Action10: TAction;
Label1: TLabel;
Label2: TLabel;
BillPanel: TPanel;
Shape1: TShape;
BillHandData: TSimpleDataSet;
BillHandDs: TDataSource;
BillBodyData: TSimpleDataSet;
BillBodyDs: TDataSource;
Report: TfrReport;
ReportDataSet: TfrDBDataSet;
Label3: TLabel;
Label14: TLabel;
BillDateDBEdit: TLBDBEdit;
InPutDepotDBEdit: TLBDBComboBox;
plToolbar: TPanel;
LBSpeecButton2: TLBSpeecButton;
LBSpeecButton1: TLBSpeecButton;
LBSpeecButton3: TLBSpeecButton;
LBSpeecButton4: TLBSpeecButton;
LBSpeecButton5: TLBSpeecButton;
LBSpeecButton6: TLBSpeecButton;
Image2: TImage;
Shape22: TShape;
Shape23: TShape;
Shape24: TShape;
Shape25: TShape;
LBEditButton2: TLBEditButton;
LBSpeecButton9: TLBSpeecButton;
Action5: TAction;
DBText2: TDBText;
Action6: TAction;
LBSpeecButton7: TLBSpeecButton;
BillNextButton: TLBLabel;
BillPriorButton: TLBLabel;
Shape4: TShape;
Shape2: TShape;
Label12: TLabel;
Label13: TLabel;
DBText4: TDBText;
Label15: TLabel;
DBText5: TDBText;
Label23: TLabel;
DBText6: TDBText;
Auditing: TImage;
Shape6: TShape;
BillInfoLabel: TLabel;
DBCtrlGrid: TDBCtrlGrid;
Panel5: TPanel;
Shape9: TShape;
Shape11: TShape;
Shape12: TShape;
Shape14: TShape;
Shape15: TShape;
Panel6: TPanel;
PartCodeDBEdit: TDBEdit;
PartNameDBEdit: TDBEdit;
ProducingDBEdit: TDBEdit;
DepotPlaceDBEdit: TDBEdit;
UnitDBEdit: TDBEdit;
QuantityDBEdit: TDBEdit;
Panel4: TPanel;
Label4: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label20: TLabel;
Label24: TLabel;
MemoDBEdit: TLBDBEdit;
LBDBScrollBar1: TLBDBScrollBar;
SaveButton: TLBButton;
CancelButton: TLBButton;
Label22: TLabel;
EXECUTEMANDBEdit: TLBDBComboBox;
Label10: TLabel;
OutPutDepotDBEdit: TLBDBComboBox;
HintPanel: TPanel;
Label26: TLabel;
Image1: TImage;
Shape3: TShape;
Shape5: TShape;
Label9: TLabel;
InPubImg: TImage;
BillHandDataBILLCODE: TStringField;
BillHandDataBILLDATE: TSQLTimeStampField;
BillHandDataOUTPUTDEPOTNAME: TStringField;
BillHandDataOUTPUTDEPOTCODE: TStringField;
BillHandDataINPUTDEPOTNAME: TStringField;
BillHandDataINPUTDEPOTCODE: TStringField;
BillHandDataISAUDITING: TStringField;
BillHandDataAUDITINGMAN: TStringField;
BillHandDataAUDITINGDATE: TSQLTimeStampField;
BillHandDataISEXECUTE: TStringField;
BillHandDataEXECUTEMAN: TStringField;
BillHandDataEXECUTEDATE: TSQLTimeStampField;
BillHandDataOPERATIONMAN: TStringField;
BillHandDataOPERATOR: TStringField;
BillHandDataMEMO: TStringField;
BillBodyDataBILLCODE: TStringField;
BillBodyDataID: TIntegerField;
BillBodyDataPARTCODE: TStringField;
BillBodyDataPARTNAME: TStringField;
BillBodyDataBORNCODE: TStringField;
BillBodyDataCARMODEL: TStringField;
BillBodyDataPRODUCING: TStringField;
BillBodyDataDEPOTPLACE: TStringField;
BillBodyDataUNITS: TStringField;
BillBodyDataQUANTITY: TBCDField;
BillBodyDataOUTPUTQRY: TBCDField;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormActivate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure BillHandDataAfterScroll(DataSet: TDataSet);
procedure Action1Execute(Sender: TObject);
procedure Action2Execute(Sender: TObject);
procedure Action3Execute(Sender: TObject);
procedure Action4Execute(Sender: TObject);
procedure Action5Execute(Sender: TObject);
procedure Action6Execute(Sender: TObject);
procedure Action7Execute(Sender: TObject);
procedure Action8Execute(Sender: TObject);
procedure Action9Execute(Sender: TObject);
procedure Action10Execute(Sender: TObject);
procedure InPutDepotDBEditEnter(Sender: TObject);
procedure DBCtrlGridKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure LBSpeecButton3Click(Sender: TObject);
procedure LBEditButton2Click(Sender: TObject);
procedure PartCodeDBEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure PartNameDBEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ProducingDBEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure UnitDBEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure DepotPlaceDBEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure QuantityDBEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure QuantityDBEditExit(Sender: TObject);
procedure BillNextButtonClick(Sender: TObject);
procedure BillPriorButtonClick(Sender: TObject);
procedure BillDateDBEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure InPutDepotDBEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure InPutDepotDBEditExit(Sender: TObject);
procedure EXECUTEMANDBEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure QuantityDBEditEnter(Sender: TObject);
procedure EXECUTEMANDBEditEnter(Sender: TObject);
procedure OutPutDepotDBEditEnter(Sender: TObject);
procedure OutPutDepotDBEditExit(Sender: TObject);
procedure OutPutDepotDBEditChange(Sender: TObject);
procedure InPutDepotDBEditChange(Sender: TObject);
procedure PartCodeDBEditDblClick(Sender: TObject);
private
procedure SetView;
procedure SetAuditing;
public
{ Public declarations }
end;
var
frmPartsMove: TfrmPartsMove;
isStateEdit, isEdit, isGetList: Boolean;
OldSum, Sum, OldSaleQty: Double;
OldCode, OldDepotCode, OldProviderCode, OldInPutBillCode: string;
implementation
uses uMain, uPublicvar, uConst, uDataMo, Tools, uReimbureseParts,
uPartOutPutStock, uSelectDepotPartMove;
{$R *.dfm}
procedure TfrmPartsMove.SetView;
begin
BillPanel.Enabled:=not BillPanel.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;
Action9.Enabled:=not Action9.Enabled;
Action10.Enabled:=not Action10.Enabled;
SaveButton.Visible:=not SaveButton.Visible;
CancelButton.Visible:=not CancelButton.Visible;
HintPanel.Visible:=not HintPanel.Visible;
end;
procedure TfrmPartsMove.SetAuditing;
begin
try
BillHandData.ReadOnly:=False;
BillHandData.Edit;
BillHandData.FieldByName('isAuditing').AsString:='1';
BillHandData.FieldByName('AuditingMan').AsString:=UserName;
BillHandData.FieldByName('AuditingDate').asDateTime:=Now;
SavePartData:=TClientDataSet.Create(Nil);
SavePartData.Data:=BillBodyData.Data;
PartOutPutDataSave(BillHandData.FieldByName('OutPutDepotCode').asstring,
BillHandData.FieldByName('OutPutDepotName').asstring,
BillHandData.FieldByName('BillDate').asDateTime,
0);
PartInPutDataSave(BillHandData.FieldByName('InPutDepotCode').asstring,
BillHandData.FieldByName('InPutDepotName').asstring,
BillHandData.FieldByName('BillDate').asDateTime,
3);
BillHandData.ApplyUpdates(-1);
Auditing.Visible:=True;
BillHandData.ReadOnly:=True;
Application.MessageBox('审核提交数据成功。',Hintinfo,$30);
SetDataDelInfo('Depot','DepotCode',BillHandData.Fieldbyname('InPutDepotCode').asstring);
SetDataDelInfo('Depot','DepotCode',BillHandData.Fieldbyname('OutPutDepotCode').asstring);
BillBodyData.First;
while not BillBodyData.Eof do
begin
SetDataDelInfo('PartInfo','Code',BillBodyData.Fieldbyname('PartCode').asstring);
BillBodyData.Next;
end;
except
Application.MessageBox('审核单据不成功。',Errorinfo,$10);
end;
end;
procedure TfrmPartsMove.FormShow(Sender: TObject);
begin
SetView;
OpenData('Select * from DepotPartsMoveHand Order by BillCode DESC',BillHandData);
isStateEdit:=False;
end;
procedure TfrmPartsMove.FormActivate(Sender: TObject);
begin
GetWindowsItem(Caption, Self);
end;
procedure TfrmPartsMove.FormDestroy(Sender: TObject);
begin
WindowItem.Delete(WindowItem.IndexOfObject(Self));
BillHandData.Close;
BillBodyData.Close;
end;
procedure TfrmPartsMove.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
frmPartsMove:=Nil;
end;
procedure TfrmPartsMove.BillHandDataAfterScroll(DataSet: TDataSet);
begin
OpenData('Select * from DepotPartsMoveBody where BillCode='+
#39+BillHandData.Fieldbyname('BillCode').asstring+#39,
BillBodyData);
if BillHandData.FieldByName('isAuditing').AsString='1' then
Auditing.Visible:=True
else
Auditing.Visible:=False;
if BillHandData.FieldByName('isExecute').AsString='1' then
InPubImg.Visible:=True
else
InPubImg.Visible:=False;
end;
procedure TfrmPartsMove.Action1Execute(Sender: TObject);
begin
SetView;
OutPutDepotDBEdit.SetFocus;
BillBodyData.ReadOnly:=False;
BillHandData.ReadOnly:=False;
BillHandData.Append;
BillBodyData.Append;
BillHandData.Fieldbyname('BillCode').asstring:='新单据';
BillHandData.FieldByName('Operator').asstring:=UserName;
BillHandData.Fieldbyname('BILLDATE').asDateTime:=Date;
BillBodyData.Fieldbyname('BillCode').asstring:='新单据';
BillBodyData.Fieldbyname('ID').asInteger:=1;
BillBodyData.Post;
isEdit:=False;
isStateEdit:=True;
BillInfoLabel.Caption:=''
end;
procedure TfrmPartsMove.Action2Execute(Sender: TObject);
begin
if BillHandData.IsEmpty then
begin
Application.MessageBox('没有可修改的移仓单。',Hintinfo,$30);
Exit;
end;
if BillHandData.FieldByName('isAuditing').asstring='1' then
begin
Application.MessageBox('此移仓单已审核,不可修改。',Hintinfo,$30);
Exit;
end;
SetView;
try
BillHandData.ReadOnly:=False;
BillBodyData.ReadOnly:=False;
BillHandData.Edit;
BillBodyData.Edit;
except
SetView;
Application.MessageBox('修改数据错误。',Hintinfo,$10);
Exit;
end;
isEdit:=True;
isStateEdit:=True;
end;
procedure TfrmPartsMove.Action3Execute(Sender: TObject);
var
BillCode: string;
begin
if BillHandData.IsEmpty then
begin
Application.MessageBox('没有可删除的移仓单。',Hintinfo,$30);
Exit;
end;
if BillHandData.FieldByName('isAuditing').asstring='1' then
begin
Application.MessageBox('此移仓单已审核,不可删除。',Hintinfo,$30);
Exit;
end;
if Application.MessageBox('确定在要删除当前移仓单吗?',Hintinfo,$24)=idYes then
begin
BillHandData.ReadOnly:=False;
BillCode:=BillHandData.Fieldbyname('BillCode').asstring;
try
BillHandData.Delete;
BillHandData.ApplyUpdates(-1);
DeleteBillBody('Delete From DepotPartsMoveBody where BillCode='+#39+BillCode+#39);
OpenData('select * from DepotPartsMoveHand Order by BillCode DESC',
BillHandData);
except
Application.MessageBox('删除数据不成功。',Errorinfo,$10);
end;
BillHandData.ReadOnly:=True;
end;
end;
procedure TfrmPartsMove.Action4Execute(Sender: TObject);
begin
PrintView('RepPartDepotMove.frf', Report);
end;
procedure TfrmPartsMove.Action5Execute(Sender: TObject);
begin
if BillHandData.IsEmpty then
begin
Application.MessageBox('没有可审核的单据。',Hintinfo,$30);
Exit;
end;
if BillHandData.FieldByName('isAuditing').AsString='1' then
begin
Application.MessageBox('此单据已审核。',Hintinfo,$30);
Exit;
end;
if Application.MessageBox('确定要审核此移仓单吗?',Hintinfo,$24)=idYes then
SetAuditing;
end;
procedure TfrmPartsMove.Action6Execute(Sender: TObject);
begin
if BillHandData.IsEmpty then
begin
Application.MessageBox('没有可出库的单据。',Hintinfo,$30);
Exit;
end;
if BillHandData.FieldByName('isExecute').AsString='1' then
begin
Application.MessageBox('此单据已出库。',Hintinfo,$30);
Exit;
end;
if BillHandData.FieldByName('isAuditing').AsString<>'1' then
begin
Application.MessageBox('请先审核单据后再出库。',Hintinfo,$30);
Exit;
end;
PickUpType:=2;
PickUpGoodsNo:=BillHandData.Fieldbyname('BillCode').asstring;
PickUpGoodsUnitCode:=BillHandData.Fieldbyname('InPutDepotCode').asstring;
PickUpGoodsUnit:=BillHandData.Fieldbyname('InPutDepotName').asstring;
PickUpDepotCode:=BillHandData.Fieldbyname('OutPutDepotCode').asstring;
PickUpDepotName:=BillHandData.Fieldbyname('OutPutDepotName').asstring;
PickHandTableName:='DepotPartsMoveHand';
PickBodyTableName:='DepotPartsMoveBody';
FrmPartOutPutStock:=TFrmPartOutPutStock.Create(Application);
FrmPartOutPutStock.ShowModal;
FrmPartOutPutStock.Free;
OpenData('Select * from DepotPartsMoveHand where BillCode='+#39+PickUpGoodsNo+#39+
' Order by BillCode DESC',BillHandData);
end;
procedure TfrmPartsMove.Action7Execute(Sender: TObject);
var
sql: string;
begin
SelectBillCode:='';
frmSelectDepotPartMove:=TfrmSelectDepotPartMove.Create(Application);
frmSelectDepotPartMove.ShowModal;
frmSelectDepotPartMove.Free;
if SelectBillCode<>'' then
begin
sql:='Select * from DepotPartsMoveHand where '+
'BillCode='+#39+SelectBillCode+#39+
'Order by BillCode DESC';
OpenData(sql,BillHandData);
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -