goodsinoutfm.pas

来自「群星医药系统源码」· PAS 代码 · 共 647 行 · 第 1/2 页

PAS
647
字号
unit GoodsInOutFm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGridEh, DbUtilsEh, EhLibCDS, xEhLibCtl, RzButton, ComCtrls, RzRadChk,
  StdCtrls, Mask, RzEdit, RzBtnEdt, ExtCtrls, RzDTP, DB, DBClient, MConnect,
  xBaseFrm,iMainFrm, ActnList, ModuleAction,ShowProGress, ckDBClient,
  uDataTypes, RzDBEdit, RzDBBnEd, Menus, TFlatSpeedButtonUnit, RzStatus,
  TFlatPanelUnit,DbFuncs, RzTabs, RzPanel,SelectDepotFrm;
type
    TFmGoodsInOut=class(TxBaseForm)
    Panel1: TRzPanel;
    edGoodsID: TRzButtonEdit;
    edGoodsName: TRzEdit;
    cbName: TRzCheckBox;
    PageCtrl1: TRzPageControl;
    Page_GoodsIn: TRzTabSheet;
    dbgGoodsIn: TxDBGridEh;
    Page_GoodsOut: TRzTabSheet;
    Panel4: TPanel;
    Label10: TLabel;
    Panel5: TPanel;
    Label11: TLabel;
    Label12: TLabel;
    edNum2: TRzEdit;
    edSum2: TRzEdit;
    edBerth2: TRzButtonEdit;
    RzBitBtn3: TRzBitBtn;
    BtnFindOut: TRzBitBtn;
    dbgGoodsOut: TxDBGridEh;
    cbCode: TRzCheckBox;
    cbDate: TRzCheckBox;
    dtpBeginDate: TRzDateTimePicker;
    dtpEndDate: TRzDateTimePicker;
    Label1: TLabel;
    DsGoodsIn: TDataSource;
    CdsGoodsIn: TckClientDataSet;
    DComConn: TDCOMConnection;
    CdsGoodsOut: TckClientDataSet;
    DsGoodsOut: TDataSource;
    Page_DetailStock: TRzTabSheet;
    Panel6: TPanel;
    Label2: TLabel;
    Label3: TLabel;
    Label13: TLabel;
    Panel7: TPanel;
    Label4: TLabel;
    Label14: TLabel;
    edNum3: TRzEdit;
    edSum3: TRzEdit;
    edBerth3: TRzButtonEdit;
    edBatch3: TRzEdit;
    RzMenuButton3: TRzBitBtn;
    edFind3: TRzBitBtn;
    dbgDetailStock: TxDBGridEh;
    Page_RankStock: TRzTabSheet;
    Panel8: TPanel;
    Label16: TLabel;
    Panel9: TPanel;
    Label17: TLabel;
    Label18: TLabel;
    edNum4: TRzEdit;
    edSum4: TRzEdit;
    edBerth4: TRzButtonEdit;
    RzBitBtn1: TRzBitBtn;
    edFind4: TRzBitBtn;
    dbgRankStock: TxDBGridEh;
    Page_TotalStock: TRzTabSheet;
    Panel10: TPanel;
    edFind5: TRzBitBtn;
    Panel11: TPanel;
    Label19: TLabel;
    Label20: TLabel;
    edNum5: TRzEdit;
    edSum5: TRzEdit;
    RzBitBtn6: TRzBitBtn;
    dbgTotalStock: TxDBGridEh;
    CdsTotalStock: TckClientDataSet;
    DsTotalStock: TDataSource;
    DsRankStock: TDataSource;
    CdsRankStock: TckClientDataSet;
    CdsDetailStock: TckClientDataSet;
    DsDetailStock: TDataSource;
    ActionList1: TActionList;
    ActFind1: TModlAction;
    ActFind2: TModlAction;
    ActFind3: TModlAction;
    ActFind4: TModlAction;
    ActFind5: TModlAction;
    Panel2: TPanel;
    Label7: TLabel;
    Label8: TLabel;
    Panel3: TPanel;
    Label5: TLabel;
    Label6: TLabel;
    edNum1: TRzEdit;
    edSum1: TRzEdit;
    BtnFindIn: TRzBitBtn;
    RzBitBtn4: TRzBitBtn;
    edDepotName1: TRzButtonEdit;
    edDepot1: TRzEdit;
    edBerth1: TRzButtonEdit;
    Label9: TLabel;
    edDepotName2: TRzButtonEdit;
    edDepot2: TRzEdit;
    Label15: TLabel;
    edDepotName4: TRzButtonEdit;
    edDepot4: TRzEdit;
    edDepotName3: TRzButtonEdit;
    edDepot3: TRzEdit;
    TopPopMenu: TPopupMenu;
    SetFields1: TMenuItem;
    refresh1: TMenuItem;
    ActFieldsLayout: TModlAction;
    ActDataExport: TModlAction;
    CdsDetailStockDepotID: TIntegerField;
    CdsDetailStockDepotNo: TStringField;
    CdsDetailStockDepotName: TStringField;
    CdsDetailStockBerthNo: TStringField;
    CdsDetailStockGoodsID: TStringField;
    CdsDetailStockName: TStringField;
    CdsDetailStockSpecs: TStringField;
    CdsDetailStockFDate: TDateTimeField;
    CdsDetailStockProvNo: TStringField;
    CdsDetailStockProvName: TStringField;
    CdsDetailStockQty: TBCDField;
    CdsDetailStockQty1: TBCDField;
    CdsDetailStockQty2: TBCDField;
    CdsDetailStockPrice1: TBCDField;
    CdsDetailStockPrice2: TBCDField;
    CdsDetailStockAmount: TBCDField;
    CdsDetailStockGroupNo: TIntegerField;
    CdsDetailStockBatchNo: TStringField;
    CdsDetailStockValidDate: TDateTimeField;
    CdsDetailStockInOutKind: TSmallintField;
    CdsDetailStockPBillNo: TStringField;
    CdsDetailStockPItemNo: TIntegerField;
    CdsDetailStockInQty: TBCDField;
    CdsDetailStockUnit: TStringField;
    CdsDetailStockRecNO: TAutoIncField;
    CdsRankStockDepotID: TIntegerField;
    CdsRankStockDepotNo: TStringField;
    CdsRankStockDepotName: TStringField;
    CdsRankStockBerthNo: TStringField;
    CdsRankStockGoodsID: TStringField;
    CdsRankStockName: TStringField;
    CdsRankStockSpecs: TStringField;
    CdsRankStockBatchNo: TStringField;
    CdsRankStockQty: TBCDField;
    CdsRankStockQty1: TBCDField;
    CdsRankStockQty2: TBCDField;
    CdsRankStockPrice1: TBCDField;
    CdsRankStockPrice2: TBCDField;
    CdsRankStockAmount: TBCDField;
    CdsRankStockValidDate: TDateTimeField;
    CdsTotalStockGoodsID: TStringField;
    CdsTotalStockName: TStringField;
    CdsTotalStockSpecs: TStringField;
    CdsTotalStockQty: TBCDField;
    CdsTotalStockQty1: TBCDField;
    CdsTotalStockQty2: TBCDField;
    CdsTotalStockPrice1: TBCDField;
    CdsTotalStockPrice2: TBCDField;
    CdsTotalStockAmount: TBCDField;
    ActPrint1: TModlAction;
    ActPrint2: TModlAction;
    ActDesignReport: TModlAction;
    ActPrint3: TModlAction;
    ActPrint4: TModlAction;
    ActPrint5: TModlAction;
    ptBkPanel: TFlatPanel;
    FlatPanel2: TPanel;
    BtnWhatIs: TFlatSpeedButton;
    BtnHelp: TFlatSpeedButton;
    FlatPanel3: TPanel;
    BtnPopMenu: TFlatSpeedButton;
    Label21: TLabel;
    CdsGoodsInRecNo: TAutoIncField;
    CdsGoodsInGoodsID: TStringField;
    CdsGoodsInName: TStringField;
    CdsGoodsInSpecs: TStringField;
    CdsGoodsInUnit: TStringField;
    CdsGoodsInDepotID: TIntegerField;
    CdsGoodsInDepotNo: TStringField;
    CdsGoodsInDepotName: TStringField;
    CdsGoodsInFDate: TDateTimeField;
    CdsGoodsInStockRecNo: TIntegerField;
    CdsGoodsInInOutKind: TSmallintField;
    CdsGoodsInQty: TBCDField;
    CdsGoodsInAmount: TBCDField;
    CdsGoodsInPBillNo: TStringField;
    CdsGoodsInPItemNo: TIntegerField;
    CdsGoodsInGroupNo: TIntegerField;
    CdsGoodsInBatchNo: TStringField;
    CdsGoodsInFlag: TIntegerField;
    CdsGoodsOutRecNo: TAutoIncField;
    CdsGoodsOutGoodsID: TStringField;
    CdsGoodsOutName: TStringField;
    CdsGoodsOutSpecs: TStringField;
    CdsGoodsOutUnit: TStringField;
    CdsGoodsOutDepotID: TIntegerField;
    CdsGoodsOutDepotNo: TStringField;
    CdsGoodsOutDepotName: TStringField;
    CdsGoodsOutFDate: TDateTimeField;
    CdsGoodsOutStockRecNo: TIntegerField;
    CdsGoodsOutInOutKind: TSmallintField;
    CdsGoodsOutQty: TBCDField;
    CdsGoodsOutAmount: TBCDField;
    CdsGoodsOutPBillNo: TStringField;
    CdsGoodsOutPItemNo: TIntegerField;
    CdsGoodsOutGroupNo: TIntegerField;
    CdsGoodsOutBatchNo: TStringField;
    CdsGoodsOutFlag: TIntegerField;
    CdsDetailStockProdDate: TDateTimeField;
    Function FilterGoods:String;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure ActFind1Execute(Sender: TObject);
    procedure ActFind2Execute(Sender: TObject);
    procedure ActFind3Execute(Sender: TObject);
    procedure ActFind4Execute(Sender: TObject);
    procedure ActFind5Execute(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure ActFieldsLayoutExecute(Sender: TObject);
    procedure ActDataExportExecute(Sender: TObject);
    procedure BtnPopMenuClick(Sender: TObject);
    procedure ActPrint1Execute(Sender: TObject);
    procedure ActPrint2Execute(Sender: TObject);
    procedure ActPrint5Execute(Sender: TObject);
    procedure ActPrint4Execute(Sender: TObject);
    procedure ActPrint3Execute(Sender: TObject);
    procedure edGoodsIDButtonClick(Sender: TObject);
    procedure edDepotName4ButtonClick(Sender: TObject);
    procedure edDepotName1ButtonClick(Sender: TObject);
    procedure edDepotName2ButtonClick(Sender: TObject);
    procedure edDepotName3ButtonClick(Sender: TObject);
    procedure edBerth2ButtonClick(Sender: TObject);
    procedure edBerth1ButtonClick(Sender: TObject);
    procedure edBerth3ButtonClick(Sender: TObject);
    procedure edBerth4ButtonClick(Sender: TObject);
  private
    CdsFieldProperty : TCkClientDataSet;
    IFmMain : IMainForm;
    LocSetting: PLocSetting;
    SvrStock,SvrCommon:TDispatchConnection;
    Function SumValue(DataSet:TDataSet):Variant;
    Function FilterStock:String;
    function SelectBerths(DepotID: string): string;
    { Private declarations }
  public
    { Public declarations }
  end;

Const
  sFieldProPerty='Select * From SysFieldProperty '+
        ' Where TableName In(''GoodsInOut'',''DetailStock'',''BatchPartStock'',''Depots'')';

var
  FmGoodsInOut: TFmGoodsInOut;
  SqlInText:String;

implementation

uses RepSelectFrm,DBPopupForm, DataExportFrm, FieldsLayoutFrm, ceGlobal,SelectGoodsFrm,
  SelectBerthFrm;

{$R *.dfm}

function TFmGoodsInOut.FilterGoods: String;
Var
  SqlText:String;
begin
  SqlText:='';
  If cbCode.Checked Then
    If edGoodsId.Text<>'' Then
      SqlText:=' GoodsId='+edGoodsId.Text;
  If cbName.Checked Then
    If edGoodsName.Text<>'' Then
      If SqlText<>'' Then
        SqlText:=SqlText+' And Name Like '+''''+edGoodsName.Text+'%'+''''
      Else
        SqlText:=' Name Like '+''''+edGoodsName.Text+'%'+'''';
  If cbDate.Checked Then
    If SqlText<>'' Then
      SqlText:=SqlText+' And Fdate<= '+DateToStr(dtpEndDate.Date)+' And FDate>= '+DateToStr(dtpBeginDate.Date)
    Else
      SqlText:=' Fdate<= '+DateToStr(dtpEndDate.Date)+' And FDate>= '+DateToStr(dtpBeginDate.Date);
  Result:=SqlText;
end;

function TFmGoodsInOut.SumValue(DataSet: TDataSet): Variant;
Var
  A:Variant;
begin
  A:=VarArrayCreate([0,1],varDouble);
  A[0]:=0;
  A[1]:=0;
  With DataSet Do
  begin
    DisableControls;
    First;
    While Not Eof Do
    Begin
      A[0]:=A[0]+Fieldbyname('Qty').AsFloat;
      A[1]:=A[1]+FieldbyName('Amount').AsFloat;
      Next;
    End;
    EnableControls;
  End;
  Result:=A;
end;

procedure TFmGoodsInOut.FormCreate(Sender: TObject);
begin
  CdsFieldProperty:=TCkClientDataSet.Create(Self);
  IFmMain := Application.MainForm as IMainForm;
  LocSetting := IFmMain.IFmMainEx.GetLocSetting;
  SetGressHint('正在连接药品出入库明细服务器...');
  SvrStock := IFmMain.GetConnection(Handle,'','CkStockSvr.Stock');
  CdsGoodsIn.RemoteServer:=SvrStock;
  CdsGoodsOut.RemoteServer:=SvrStock;
  CdsDetailStock.RemoteServer:=SvrStock;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?