📄 ustorageredressal.pas
字号:
unit uStorageRedressal;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ActnList, LBCtrls, ExtCtrls, StdCtrls, Grids, FR_DSet, FR_DBSet,
FR_Class, DB, DBClient, SimpleDS, LBDBScrollBar, LBDBGrid, DBCtrls;
type
TfrmStorageRedressal = class(TForm)
Panel7: TPanel;
Image2: TImage;
Shape22: TShape;
Shape23: TShape;
Shape24: TShape;
Shape25: TShape;
LBSpeecButton2: TLBSpeecButton;
LBSpeecButton1: TLBSpeecButton;
ActionList1: TActionList;
Action1: TAction;
Action2: TAction;
Panel1: TPanel;
Label2: TLabel;
Label3: TLabel;
Label5: TLabel;
Label10: TLabel;
HelpnotenoEdit: TLBEdit;
PartCodeEdit: TLBEdit;
PartNameEdit: TLBEdit;
ProducingEdit: TLBEdit;
Panel2: TPanel;
Panel4: TPanel;
Panel10: TPanel;
Panel5: TPanel;
Panel11: TPanel;
LBDBGrid1: TLBDBGrid;
Panel3: TPanel;
Label4: TLabel;
Label6: TLabel;
Label8: TLabel;
Label19: TLabel;
Label20: TLabel;
Label21: TLabel;
Label1: TLabel;
Label9: TLabel;
Label11: TLabel;
Label14: TLabel;
Label12: TLabel;
LBDBGrid2: TLBDBGrid;
Panel6: TPanel;
LBDBScrollBar1: TLBDBScrollBar;
StoragePartDataHand: TSimpleDataSet;
dsStoragePartDataHand: TDataSource;
StoragePartDataBody: TSimpleDataSet;
dsStoragePartDataBody: TDataSource;
Report: TfrReport;
ReportDataSet: TfrDBDataSet;
Label15: TLabel;
Panel8: TPanel;
LBSpeecButton3: TLBSpeecButton;
Action3: TAction;
Action4: TAction;
LBSpeecButton4: TLBSpeecButton;
OpenView: TPanel;
Image1: TImage;
PrintInfo: TPanel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label22: TLabel;
DBText1: TDBText;
DBText2: TDBText;
DBText3: TDBText;
DBText4: TDBText;
StoragePartDataHandCODE: TStringField;
StoragePartDataHandNAME: TStringField;
StoragePartDataHandPRODUCING: TStringField;
StoragePartDataHandCARMODEL: TStringField;
StoragePartDataHandUNITS: TStringField;
StoragePartDataHandINPUTPRICE: TBCDField;
StoragePartDataHandDEPOTPLACE: TStringField;
StoragePartDataHandBILLQUANTITY: TBCDField;
StoragePartDataHandSTOCKQUANTITY: TBCDField;
StoragePartDataHandSTOCKPRICE: TBCDField;
StoragePartDataHandSALEPRICE: TBCDField;
StoragePartDataHandCOSTPRICE: TBCDField;
StoragePartDataHandMAXSTOCK: TBCDField;
StoragePartDataHandMINSTOCK: TBCDField;
StoragePartDataHandOUTPOUTPRICE: TBCDField;
StoragePartDataHandTotalSum: TCurrencyField;
Label27: TLabel;
DBText5: TDBText;
procedure FormShow(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure StoragePartDataHandAfterClose(DataSet: TDataSet);
procedure StoragePartDataHandAfterScroll(DataSet: TDataSet);
procedure HelpnotenoEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Action1Execute(Sender: TObject);
procedure Action2Execute(Sender: TObject);
procedure SelectData(Sender: TObject);
procedure Action3Execute(Sender: TObject);
procedure Action4Execute(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure StoragePartDataHandCalcFields(DataSet: TDataSet);
private
public
{ Public declarations }
end;
var
frmStorageRedressal: TfrmStorageRedressal;
const
sql='select Code, name, Producing, Carmodel, Units, InPutPrice, '+
'DepotPlace, BillQuantity, StockQuantity, StockPrice, SalePrice, '+
'CostPrice, MAXSTOCK, MINStock, OUTPOUTPRICE '+
' From PartInfo where not Code is Null';
implementation
uses uMain, uDataMo, uPublicvar, uPartDepotPlace, uStoragePartsRes, uConst;
{$R *.dfm}
procedure TfrmStorageRedressal.SelectData(Sender: TObject);
var
Sqltext : string;
begin
Sqltext:=Sql;
if Trim(ProducingEdit.Text)<>'' then
Sqltext:=Sqltext+' and Producing Like '+#39+'%'+Trim(ProducingEdit.Text)+'%'+#39;
if Trim(PartCodeEdit.Text)<>'' then
Sqltext:=Sqltext+' and Code Like '+#39+'%'+Trim(PartCodeEdit.Text)+'%'+#39;
if Trim(PartNameEdit.Text)<>'' then
Sqltext:=Sqltext+' and Name Like '+#39+'%'+Trim(PartNameEdit.Text)+'%'+#39;
if Trim(HELPNOTENOEdit.Text)<>'' then
Sqltext:=Sqltext+' and HELPNOTENO Like '+#39+'%'+Trim(HELPNOTENOEdit.Text)+'%'+#39;
OpenData(Sqltext+' Order By Code', StoragePartDataHand);
end;
procedure TfrmStorageRedressal.FormShow(Sender: TObject);
begin
OpenData(sql+' Order By Code', StoragePartDataHand);
HELPNOTENOEdit.SetFocus;
end;
procedure TfrmStorageRedressal.FormActivate(Sender: TObject);
begin
GetWindowsItem(Caption, Self);
end;
procedure TfrmStorageRedressal.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
frmStorageRedressal:=Nil;
end;
procedure TfrmStorageRedressal.FormDestroy(Sender: TObject);
begin
WindowItem.Delete(WindowItem.IndexOfObject(Self));
end;
procedure TfrmStorageRedressal.StoragePartDataHandAfterClose(DataSet: TDataSet);
begin
StoragePartDataBody.Close
end;
procedure TfrmStorageRedressal.StoragePartDataHandAfterScroll(DataSet: TDataSet);
begin
OpenData('select * from StockPart where PartCode='+
#39+StoragePartDataHand.Fieldbyname('Code').asstring+#39,
StoragePartDataBody);
if StoragePartDataHand.FieldByName('STOCKQUANTITY').asfloat>
StoragePartDataHand.FieldByName('MAXSTOCK').asfloat then
Label15.Caption:='库存数量大于最大库存数!'
else
if StoragePartDataHand.FieldByName('STOCKQUANTITY').asfloat<
StoragePartDataHand.FieldByName('MINSTOCK').asfloat then
Label15.Caption:='库存数据小于最底库存数!'
else
Label15.Caption:='';
end;
procedure TfrmStorageRedressal.HelpnotenoEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=13 then Perform(WM_NEXTDLGCTL,0,0);
end;
procedure TfrmStorageRedressal.Action1Execute(Sender: TObject);
begin
OpenData(sql+' Order By Code', StoragePartDataHand);
end;
procedure TfrmStorageRedressal.Action2Execute(Sender: TObject);
begin
PrintView('RepStorageRedressal.frf', Report);
end;
procedure TfrmStorageRedressal.Action3Execute(Sender: TObject);
var
ESql: string;
begin
if StoragePartDataHand.IsEmpty then
begin
Application.MessageBox('没有可调价商品。',Hintinfo, $30);
Exit;
end;
ResPrice3:=StoragePartDataHand.Fieldbyname('StockPrice').asfloat;
ResPrice4:=StoragePartDataHand.Fieldbyname('SalePrice').asfloat;
frmStoragePartsRes:=TfrmStoragePartsRes.Create(Application);
frmStoragePartsRes.ShowModal;
frmStoragePartsRes.Free;
if not isRedressal then Exit;
OpenView.Visible:=True;
Update;
if RedressalType=1 then
begin
dmData.ExistData.Data:=StoragePartDataHand.Data;
while not dmData.ExistData.Eof do
begin
ESql:='Update Partinfo set ';
if isCost then
ESql:=ESql+' StockPrice=StockPrice*'+FloatToStr(ResPrice1)+',';
if isSell then
ESql:=ESql+' SalePrice=SalePrice*'+FloatToStr(ResPrice2)+',';
Delete(ESql, Length(ESql), 1);
ESql:=ESql+' where Code='+#39+dmData.ExistData.Fieldbyname('Code').asstring+#39;
with dmData.SQLQuery do
begin
Close;
SQL.Clear;
Sql.text:=ESql;
ExecSQL;
end;
dmData.ExistData.Next;
end;
end
else
if RedressalType=2 then
begin
ESql:='Update Partinfo set '+
' StockPrice='+FloatToStr(ResPrice3)+','+
' SalePrice='+FloatToStr(ResPrice4)+
' where Code='+#39+StoragePartDataHand.Fieldbyname('Code').asstring+#39;
with dmData.SQLQuery do
begin
Close;
SQL.Clear;
Sql.text:=ESql;
ExecSQL;
end;
end;
StoragePartDataHand.Refresh;
OpenView.Visible:=False;
Update;
end;
procedure TfrmStorageRedressal.Action4Execute(Sender: TObject);
begin
if StoragePartDataHand.IsEmpty then
begin
Application.MessageBox('没有可移仓商品。',Hintinfo, $30);
Exit;
end;
FrmPartDepotPlace:=TFrmPartDepotPlace.Create(Application);
FrmPartDepotPlace.ShowModal;
FrmPartDepotPlace.Free;
end;
procedure TfrmStorageRedressal.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=27 then Close;
if key=VK_F5 then PrintInfo.Visible:=not PrintInfo.Visible;
end;
procedure TfrmStorageRedressal.StoragePartDataHandCalcFields(
DataSet: TDataSet);
begin
with StoragePartDataHand do
begin
Fieldbyname('TotalSum').asfloat:=
Fieldbyname('COSTPRICE').asfloat*
Fieldbyname('STOCKQUANTITY').asfloat;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -