📄 ustoragecheck.pas
字号:
unit uStorageCheck;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, LBCtrls, FR_DSet, FR_DBSet, FR_Class, DB, DBClient,
SimpleDS, ActnList, DBCtrls, StdCtrls, LBDBCtrls, LBDBScrollBar, Mask,
dbcgrids;
type
TfrmStorageCheck = class(TForm)
BillHandData: TSimpleDataSet;
BillHandDs: TDataSource;
BillBodyData: TSimpleDataSet;
BillBodyDs: TDataSource;
Report: TfrReport;
ReportDataSet: TfrDBDataSet;
Label1: TLabel;
Label2: TLabel;
Shape1: TShape;
DBText2: TDBText;
BillPanel: TPanel;
BillNextButton: TLBLabel;
BillPriorButton: TLBLabel;
Label16: TLabel;
Label14: TLabel;
LBEditButton2: TLBEditButton;
ORDERMANDBEdit: TLBDBComboBox;
BillDateDBEdit: TLBDBEdit;
Label3: TLabel;
DBText7: TDBText;
Shape4: TShape;
Shape3: TShape;
Shape2: TShape;
Label11: TLabel;
Label17: TLabel;
DBText1: TDBText;
DBText3: TDBText;
Label12: TLabel;
Label13: TLabel;
DBText4: TDBText;
Label15: TLabel;
DBText5: TDBText;
Label23: TLabel;
DBText6: TDBText;
Auditing: TImage;
Shape6: TShape;
DBCtrlGrid: TDBCtrlGrid;
Panel5: TPanel;
Shape9: TShape;
Shape10: TShape;
Shape12: TShape;
Shape14: TShape;
Shape15: TShape;
Shape16: TShape;
Shape17: TShape;
Shape18: TShape;
Shape19: TShape;
Panel6: TPanel;
PartCodeDBEdit: TDBEdit;
PartNameDBEdit: TDBEdit;
DepotPlaceDBEdit: TDBEdit;
UnitDBEdit: TDBEdit;
QuantityDBEdit: TDBEdit;
PriceDBEdit: TDBEdit;
SumDBEdit: TDBEdit;
Panel4: TPanel;
Label4: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label19: TLabel;
Label20: TLabel;
Label24: TLabel;
MemoDBEdit: TLBDBEdit;
LBDBScrollBar1: TLBDBScrollBar;
SaveButton: TLBButton;
CancelButton: TLBButton;
OpenView: TPanel;
Image1: TImage;
Label5: TLabel;
DBEdit1: TDBEdit;
Label6: TLabel;
CheckMemoDBEdit: TDBEdit;
Label10: TLabel;
InPubImg: TImage;
ActionList1: TActionList;
Action1: TAction;
Action2: TAction;
Action3: TAction;
Action4: TAction;
Action5: TAction;
Action6: TAction;
Action7: TAction;
Action8: TAction;
Action9: TAction;
plToolbar: TPanel;
LBSpeecButton2: TLBSpeecButton;
LBSpeecButton1: TLBSpeecButton;
LBSpeecButton3: TLBSpeecButton;
LBSpeecButton4: TLBSpeecButton;
LBSpeecButton5: TLBSpeecButton;
LBSpeecButton6: TLBSpeecButton;
Image2: TImage;
Shape22: TShape;
Shape23: TShape;
Shape24: TShape;
Shape25: TShape;
LBSpeecButton9: TLBSpeecButton;
DBCheckBox1: TDBCheckBox;
BillInfoLabel: TLabel;
BillHandDataBILLCODE: TStringField;
BillHandDataBILLDATE: TSQLTimeStampField;
BillHandDataCHECKDEPOTNAME: TStringField;
BillHandDataCHECKDEPOTCODE: TStringField;
BillHandDataTOTALSUM: TBCDField;
BillHandDataBIGSUM: TStringField;
BillHandDataOPERATIONMAN: TStringField;
BillHandDataOPERATOR: TStringField;
BillHandDataISAUDITING: TStringField;
BillHandDataAUDITINGMAN: TStringField;
BillHandDataAUDITINGDATE: TSQLTimeStampField;
BillHandDataMEMO: TStringField;
BillBodyDataBILLCODE: TStringField;
BillBodyDataID: TIntegerField;
BillBodyDataPARTCODE: TStringField;
BillBodyDataPARTNAME: TStringField;
BillBodyDataBORNCODE: TStringField;
BillBodyDataCARMODEL: TStringField;
BillBodyDataPRODUCING: TStringField;
BillBodyDataUNITS: TStringField;
BillBodyDataDEPOTPLACE: TStringField;
BillBodyDataQUANTITY: TBCDField;
BillBodyDataPRICE: TBCDField;
BillBodyDataTOTALSUM: TBCDField;
BillBodyDataCHECKQRY: TBCDField;
BillBodyDataMEMO: TStringField;
BillBodyDataISCHECK: TStringField;
procedure FormShow(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
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 ORDERMANDBEditDropDown(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 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 DBEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure PriceDBEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure SumDBEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure CheckMemoDBEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure QuantityDBEditEnter(Sender: TObject);
procedure QuantityDBEditExit(Sender: TObject);
procedure BillHandDataAfterScroll(DataSet: TDataSet);
procedure DBCtrlGridKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure BillNextButtonClick(Sender: TObject);
procedure BillPriorButtonClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
procedure SetView;
procedure GetSum; //合计金额
procedure SetAuditing; //审核
public
{ Public declarations }
end;
var
frmStorageCheck: TfrmStorageCheck;
isStateEdit, isEdit: Boolean;
Sum, OldSum, OldSaleQty: Double;
BillID: string;
const
sqltext=' select A.*, B.Code, B.Name, B.Units, B.DepotPlace, '+
'B.CostPrice From StockPart a, Partinfo b where a.PartCode=B.Code ';
implementation
uses uPublicvar, uDataMo, uMain, Tools, uSelectStorage,
uSelectStorageCheck, uConst;
{$R *.dfm}
procedure TfrmStorageCheck.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;
SaveButton.Visible:=not SaveButton.Visible;
CancelButton.Visible:=not CancelButton.Visible;
end;
procedure TfrmStorageCheck.GetSum;
var
Agiosum: Extended;
begin
if isStateEdit then
begin
OldSum:=BillBodyData.FieldByName('TotalSum').asfloat;
BillBodyData.Edit;
if BillBodyData.FieldByName('CheckQry').asstring='' then
BillBodyData.FieldByName('CheckQry').asfloat:=0;
if BillBodyData.FieldByName('Price').asstring='' then
BillBodyData.FieldByName('Price').asfloat:=0;
Agiosum:=BillBodyData.FieldByName('Price').asfloat*
BillBodyData.FieldByName('CheckQry').asfloat;
BillBodyData.FieldByName('TotalSum').asfloat:=Agiosum;
BillHandData.Edit;
Sum:=Sum+BillBodyData.FieldByName('TotalSum').asfloat-OldSum;
BillHandData.FieldByName('TotalSum').Asfloat:=Sum;
BillHandData.FieldByName('BigSum').asstring:=
SumSmallTOBig(BillHandData.FieldByName('TotalSum').Asfloat);
DBCtrlGrid.SetFocus;
BillBodyData.Post;
end;
end;
//审核
procedure TfrmStorageCheck.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;
while not SavePartData.Eof do
begin
with dmData.SQLQuery do
begin
//更新仓库数量
Close;
SQL.Clear;
Sql.Text:='Update StockPart '+
'set StockQuantity=StockQuantity+'+
SavePartData.Fieldbyname('CHECKQRY').asstring+
' where PartCode='+#39+
SavePartData.Fieldbyname('PartCode').asstring+#39+
' and DepotCode='+#39+
BillHandData.FieldByName('CheckDepotCode').asstring+#39;
ExecSQL;
//更新商品数量
Close;
SQL.Clear;
Sql.Text:='Update Partinfo '+
'set StockQuantity=StockQuantity+'+
SavePartData.Fieldbyname('CHECKQRY').asstring+
' where Code='+#39+SavePartData.Fieldbyname('PartCode').asstring+#39;
ExecSQL;
end;
SetDataDelInfo('PartInfo','Code',SavePartData.Fieldbyname('PartCode').asstring);
SavePartData.Next;
end;
BillHandData.ApplyUpdates(-1);
Auditing.Visible:=True;
BillHandData.ReadOnly:=True;
Application.MessageBox('审核提交数据成功。', Hintinfo,$30);
SetDataDelInfo('Depot','DepotCode',BillHandData.Fieldbyname('CheckDepotCode').asstring);
except
Application.MessageBox('审核单据不成功。',Errorinfo,$10);
end;
end;
procedure TfrmStorageCheck.FormShow(Sender: TObject);
begin
SetView;
OpenData('Select * from DepotCheckHand Order by BillCode DESC',BillHandData);
isStateEdit:=False;
end;
procedure TfrmStorageCheck.FormActivate(Sender: TObject);
begin
GetWindowsItem(Caption, Self);
end;
procedure TfrmStorageCheck.FormDestroy(Sender: TObject);
begin
WindowItem.Delete(WindowItem.IndexOfObject(Self));
BillHandData.Close;
BillBodyData.Close;
end;
procedure TfrmStorageCheck.Action1Execute(Sender: TObject);
var
i: integer;
begin
frmSelectStorage:=TfrmSelectStorage.Create(Application);
frmSelectStorage.ShowModal;
frmSelectStorage.Free;
if not isNewCheckBill then Exit;
OpenData(sqltext+' and A.DepotCode='+#39+CheckDepotCode+#39, dmData.sdsPublic);
if dmData.sdsPublic.IsEmpty then
begin
Application.MessageBox(Pchar(CheckDepotName+'没有需盘点的商品。'),Hintinfo,$30);
Exit;
end;
i:=0;
SetView;
OpenView.Caption:='正在打开数据,请稍后...';
OpenView.Visible:=True;
Update;
BillBodyData.ReadOnly:=False;
BillHandData.ReadOnly:=False;
BillHandData.Append;
BillHandData.Fieldbyname('BillCode').asstring:='新单据';
BillHandData.FieldByName('Operator').asstring:=UserName;
BillHandData.FieldByName('CheckDepotCode').asstring:=CheckDepotCode;
BillHandData.FieldByName('CheckDepotName').asstring:=CheckDepotName;
BillHandData.FieldByName('Operator').asstring:=UserName;
BillHandData.Fieldbyname('BILLDATE').asDateTime:=Date;
BillID:=FormatDateTime('yyyymmdd',Now);
with dmData.sdsPublic do
begin
while not Eof do
begin
BillBodyData.Append;
BillBodyData.FieldByName('BillCode').AsString:=BillID;
BillBodyData.FieldByName('ID').Asinteger:=i+1;
BillBodyData.FieldByName('PartCode').AsString:=Fieldbyname('PartCode').asstring;
BillBodyData.FieldByName('PartName').AsString:=Fieldbyname('Name').asstring;
BillBodyData.FieldByName('Units').AsString:=Fieldbyname('Units').asstring;
BillBodyData.FieldByName('DepotPlace').AsString:=Fieldbyname('DepotPlace').asstring;
BillBodyData.FieldByName('Price').Asfloat:=Fieldbyname('CostPrice').asfloat;
BillBodyData.FieldByName('TotalSum').Asfloat:=0;
BillBodyData.FieldByName('CheckQry').Asfloat:=0;
BillBodyData.FieldByName('isCheck').asstring:='False';
BillBodyData.Post;
Next;
end;
end;
BillBodyData.First;
OldSum:=0;
Sum:=0;
isEdit:=False;
isStateEdit:=True;
OpenView.Visible:=False;
Update;
SetListData('select Name From Employee', ORDERMANDBEdit);
BillInfoLabel.Caption:=''
end;
procedure TfrmStorageCheck.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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -