⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ustoragepart.pas

📁 天涯進銷存系統
💻 PAS
字号:
unit uStoragePart;

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
  TfrmStoragePart = 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;
    PrintInfo: TPanel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label22: TLabel;
    DBText1: TDBText;
    DBText2: TDBText;
    DBText3: TDBText;
    DBText4: TDBText;
    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;
    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;
    Label23: TLabel;
    Label24: TLabel;
    Label25: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    DBText5: TDBText;
    StoragePartDataHandTotalSum: TCurrencyField;
    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 FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure StoragePartDataHandCalcFields(DataSet: TDataSet);
  private
    procedure GetSum;
  public
    { Public declarations }
  end;

var
  frmStoragePart: TfrmStoragePart;

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, Tools;
{$R *.dfm}

procedure TfrmStoragePart.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);
  GetSum;
end;

procedure TfrmStoragePart.GetSum;
var
  Sum1, Sum2: Double;
  s: string;
begin
  dmData.ExistData.Data:=StoragePartDataHand.Data;
  with dmData.ExistData do
  begin
    while not Eof do
    begin
      Sum1:=Sum1+Fieldbyname('STOCKQUANTITY').asfloat;
      Sum2:=Sum2+(Fieldbyname('STOCKQUANTITY').asfloat*Fieldbyname('COSTPRICE').asfloat);
      Next;
    end;
    Data:=NULL;
  end;
  Label25.Caption:=FloatToStr(Sum1);
  s:=FloatToStr(Sum2);
  Label26.Caption:=Addradixpoint(S, 2);
end;

procedure TfrmStoragePart.FormShow(Sender: TObject);
begin
  OpenData(sql+' Order By Code', StoragePartDataHand);
  GetSum;
  HELPNOTENOEdit.SetFocus;
end;

procedure TfrmStoragePart.FormActivate(Sender: TObject);
begin
  GetWindowsItem(Caption, Self);
end;

procedure TfrmStoragePart.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action:=caFree;
  frmStoragePart:=Nil;
end;

procedure TfrmStoragePart.FormDestroy(Sender: TObject);
begin
  WindowItem.Delete(WindowItem.IndexOfObject(Self));
end;

procedure TfrmStoragePart.StoragePartDataHandAfterClose(DataSet: TDataSet);
begin
  StoragePartDataBody.Close
end;

procedure TfrmStoragePart.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 TfrmStoragePart.HelpnotenoEditKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key=13 then  Perform(WM_NEXTDLGCTL,0,0);
end;

procedure TfrmStoragePart.Action1Execute(Sender: TObject);
begin
  OpenData(sql+' Order By Code', StoragePartDataHand);
end;

procedure TfrmStoragePart.Action2Execute(Sender: TObject);
begin
  PrintView('RepStoragePart.frf', Report);
end;

procedure TfrmStoragePart.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 TfrmStoragePart.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 + -