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

📄 tsdbgrid.pas

📁 企业进销存管理系统
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    {TtsDBSmallintField}
    {Smallint field for columns in TtsCustomDBGrid. Corresponds to TSmallintField.}

    TtsDBSmallintField = class(TtsDBIntegerField)
    end;

    {TtsDBWordField}
    {Word field for columns in TtsCustomDBGrid. Corresponds to TWordField.}

    TtsDBWordField = class(TtsDBIntegerField)
    end;

    {TtsDBAutoIncField}
    {AutoInc field for columns in TtsCustomDBGrid. Corresponds to TAutoIncField.}

    TtsDBAutoIncField = class(TtsDBIntegerField)
    end;

    {TtsDBFloatField}
    {Float field for columns in TtsCustomDBGrid. Corresponds to TFloatField.}

    TtsDBFloatField = class(TtsDBNumericField)
    protected
        function  GetPrecision: Integer;
        function  GetAsFloat: Double; override;
        function  GetAsInteger: Longint; override;
        function  GetAsString: string; override;
        function  GetAsVariant: Variant; override;

        function  GetValue(var Value: Double): Boolean;
        function  GetText(DisplayText: Boolean): string; override;
        function  IsCurrency: Boolean;
        procedure SetLookupVarValue(Value: Variant); override;
        function  SetField(RecBuf: PChar; Value: string): Boolean; override;

        property  Precision: Integer read GetPrecision;
    end;

    {TtsDBCurrencyField}
    {Currency field for columns in TtsCustomDBGrid. Corresponds to TCurrencyField.}

    TtsDBCurrencyField = class(TtsDBFloatField)
    end;

    {TtsDBBCDField }
    {BCDField field for columns in TtsCustomDBGrid. Corresponds to TBCDField.}

    TtsDBBCDField = class(TtsDBNumericField)
    protected
        function  GetAsCurrency: Currency; override;
        function  GetAsFloat: Double; override;
        function  GetAsInteger: Longint; override;
        function  GetAsString: string; override;
        function  GetAsVariant: Variant; override;

        function  GetText(DisplayText: Boolean): string; override;
        function  GetValue(var Value: Currency): Boolean;
        function  IsCurrency: Boolean;
        procedure SetLookupVarValue(Value: Variant); override;
        function  SetField(RecBuf: PChar; Value: string): Boolean; override;
    end;

    {TtsDBBooleanField}
    {Boolean field for columns in TtsCustomDBGrid. Corresponds to TBooleanField.}

    TtsDBBooleanField = class(TtsDBField)
    protected
        FDisplayValues: string;
        FTextValues: array[Boolean] of string;

        procedure LoadTextValues;
        procedure GetDisplayValues;

        function  GetAsBoolean: Boolean; override;
        function  GetAsString: string; override;
        function  GetAsVariant: Variant; override;
        function  GetControlType: TtsControlType; override;
        procedure SetLookupVarValue(Value: Variant); override;
        function  SetField(RecBuf: PChar; Value: string): Boolean; override;
        function  IsBooleanField: Boolean; override;
    public
        constructor Create(Grid: TtsCustomDBGrid; Col: TtsDBCol; Field: TField); override;
    end;

    {TtsDBDateTimeField}
    {DateTime field for columns in TtsCustomDBGrid. Corresponds to TDateTimeField.}

    TtsDBDateTimeField = class(TtsDBField)
    protected
        function  GetAsDateTime: TDateTime; override;
        function  GetAsFloat: Double; override;
        function  GetAsString: string; override;
        function  GetAsVariant: Variant; override;

        function  GetValue(var Value: TDateTime): Boolean;
        function  GetText(DisplayText: Boolean): string; override;
        function  GetDisplayFormat: string; override;
        procedure SetLookupVarValue(Value: Variant); override;
        function  SetField(RecBuf: PChar; Value: string): Boolean; override;
    end;

    {TtsDBDateField}
    {Date field for columns in TtsCustomDBGrid. Corresponds to TDateField.}

    TtsDBDateField = class(TtsDBDateTimeField)
    end;

    {TtsDBTimeField}
    {Time field for columns in TtsCustomDBGrid. Corresponds to TTimeField.}

    TtsDBTimeField = class(TtsDBDateTimeField)
    end;

    {TtsDBBinaryField}
    {Binary field for columns in TtsCustomDBGrid. Corresponds to TBinaryField.}

    TtsDBBinaryField = class(TtsDBField)
    protected
        function GetAsString: string; override;
        function GetAsVariant: Variant; override;
        function GetText(DisplayText: Boolean): string; override;
    end;

    {TtsDBBytesField}
    {Bytes field for columns in TtsCustomDBGrid. Corresponds to TBytesField.}

    TtsDBBytesField = class(TtsDBBinaryField)
    end;

    {TtsDBVarBytesField}
    {VarBytes field for columns in TtsCustomDBGrid. Corresponds to TVarBytesField.}

    TtsDBVarBytesField = class(TtsDBBytesField)
    end;

    {TtsDBBlobField}
    {Blob field for columns in TtsCustomDBGrid. Corresponds to TBlobField.}

    TtsDBBlobField = class(TtsDBField)
    protected
        procedure LoadFromBlob(Blob: TtsDBBlobField);
        procedure SaveToBitmap(Bitmap: TBitmap);
        procedure SaveToStrings(Strings: TStrings);
        procedure AssignTo(Dest: TPersistent); override;
        function  GetAsString: string; override;
        function  GetAsVariant: Variant; override;

    public
        procedure Assign(Source: TPersistent); override;
        procedure SaveToFile(const FileName: string);
        procedure SaveToStream(Stream: TStream);
    end;

    {TtsDBMemoField}
    {Memo field for columns in TtsCustomDBGrid. Corresponds to TMemoField.}

    TtsDBMemoField = class(TtsDBBlobField)
    protected
        function  GetDisplayText: string; override;
        function  GetEditText: string; override;
        function  GetTransliterate: Boolean; override;
        procedure SetTransliterate(Value: Boolean); override;
    end;

    {TtsDBGraphicField}
    {Graphic field for columns in TtsCustomDBGrid. Corresponds to TGraphicField.}

    TtsDBGraphicField = class(TtsDBBlobField)
    protected
        function GetControlType: TtsControlType; override;
    end;

    {TtsDBBlobStream}
    {Blob stream for reading and writing blob fields. Corresponds to TBlobStream.}

    TtsDBBlobStream = class(TStream)
    protected
        FField: TtsDBBlobField;
        FScrollDataSet: TtsScrollDataSet;
        FBuffer: PChar;
        FOpened: Boolean;
        FPosition: Longint;
        FBlobStream: TBlobStream;

        function GetBlobSize: Longint;

    public
        constructor Create(Field: TtsDBBlobField; Mode: TBlobStreamMode);
        destructor Destroy; override;

        function  Read(var Buffer; Count: Longint): Longint; override;
        function  Write(const Buffer; Count: Longint): Longint; override;
        function  Seek(Offset: Longint; Origin: Word): Longint; override;
    end;

    {TtsFieldLayout}
    {Class for saving layout properties of TField objects}

    TtsFieldLayout = class(TObject)
    protected
        FFieldName: string;
        FDisplayLabel: string;
        FDisplayWidth: Integer;
        FReadOnly: Boolean;
        FVisible: Boolean;
        FDisplayValues: string;

        constructor Create;

        procedure AssignFieldLayout(Field: TField);
        function  FieldLayoutEqual(Field: TField): Boolean;

        property FieldName: string read FFieldName write FFieldName;
        property DisplayLabel: string read FDisplayLabel write FDisplayLabel;
        property DisplayWidth: Integer read FDisplayWidth write FDisplayWidth;
        property ReadOnly: Boolean read FReadOnly write FReadOnly;
        property Visible: Boolean read FVisible write FVisible;
        property DisplayValues: string read FDisplayValues write FDisplayValues;
    end;

    {TtsDBCol}
    {Individual column for TtsCustomDBGrid}

    TtsDBCol = class(TtsCol)
    protected
        FDBField: TtsDBField;
        FAssignedValues: TtsAssignedValues;

        procedure SetFieldName(Value: string); override;
        procedure SetDatasetField(Value: TField);
        function  GetDatasetField: TField;
        function  SetField(Value: TField): Boolean;
        procedure ResetField(ResetFieldName: Boolean);
        function  GetDBGrid: TtsCustomDBGrid;
        function  DefaultWidth: Integer;
        procedure SetDefaultWidth;
        procedure SetDefaultVisible;
        procedure SetDefaultControlType;
        procedure SetDefaultMaxLength;
        procedure SetDefaultAllowGrayed;
        procedure InitField;

        function  DefaultProps: Boolean; override;
        procedure AssignProperties(Source: TtsCol); override;
        function  GetHeading: string; override;
        function  GetAlignment: TAlignment; override;
        function  GetHorzAlignment: TtsHorzAlignment; override;
        function  GetReadOnly: Boolean; override;
        function  GetMaxTextWidth : Integer; override;
        procedure SetAlignment(Value: TAlignment); override;
        procedure SetHorzAlignment(Value: TtsHorzAlignment); override;
        procedure SetWidth(Value: Integer); override;
        procedure SetVisible(Value: Boolean); override;
        procedure SetMaxLength(Value: Integer); override;
        procedure SetControlType(Value: TtsControlType); override;
        procedure SetAllowGrayed(Value: Boolean); override;
        procedure SetDBCombo(Value: TtsDBCombo);
        function  GetDBCombo: TtsDBCombo;
        procedure SetComboDataSource(Value: TDatasource);
        function  GetComboDataSource: TDatasource;
        function  UseCheckBoxValues: Boolean; override;
        procedure WriteAssignedValues(Writer: TWriter);
        procedure ReadAssignedValues(Reader: TReader);
        procedure DefineProperties(Filer: TFiler); override;



    public
        constructor Create(Grid: TtsBaseGrid); override;
        destructor  Destroy; override;

        property Grid: TtsCustomDBGrid read GetDBGrid;
        procedure Assign(Source: TPersistent); override;
        function  Lookup: Boolean;
        procedure Reset(Properties: TtsProperties); override;
        procedure ResetAlignment;
        procedure ResetAllowGrayed;
        procedure ResetControlType;

⌨️ 快捷键说明

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