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

📄 unttcomputer.pas

📁 销售软件
💻 PAS
字号:
(*===========================================================*)
(*                                                           *)
(*              Jerk Computer Assembly Manager               *)
(*                                                           *)
(*                    程序作者:杨芹勍                       *)
(*          武汉科技大学 理学院 信息与计算科学031班          *)
(*                  武汉科技大学 莘特工作室                  *)
(*                                                           *)
(*              IDE:Borland Delphi 2006 Update 2            *)
(*                 第三方控件:Raize 4.03                    *)
(*             数据库:Microsoft SQL Server 2000             *)
(*            数据库访问引擎:原生ADO(ADODB_TLB)           *)
(*           数据库管理引擎:JERK DBMANAGER ALPHA            *)
(*                                                           *)
(*           此软件及源代码归 JERK SYSTEM 版权所有           *)
(*            (C)Copyright 2002-2006 Jerk System.            *)
(*                                                           *)
(*===========================================================*)

unit untTComputer;

interface

uses
  SysUtils,
  Variants,
  ADODB_TLB,
  JCAMTableView,
  JCAMConsts,
  JCAMUtils;

const
  TN_COMPUTER: string = 't_Computer';
  VN_COMPUTER: string = 'v_Computer';
  KFN_COMPUTER: string = 'Computer_ID';
  FN_COMPUTERID: string = 'Computer_ID';
  FN_COMPUTERNAME: string = 'Computer_Name';
  FN_CLIENTNAME: string = 'ClientName';
  FN_MAKEDATE: string = 'MakeDate';
  FN_TOTALINPRICES: string = 'TotalInPrices';
  FN_TOTALOUTPRICES: string = 'TotalOutPrices';
  FN_TOTALPROFIT: string = 'TotalProfit';
  PN_SAVECOMPUTERINFO: string = 'sp_SaveComputerInfo';
  PN_DELETECOMPUTERINFO: string = 'sp_DeleteComputerInfo';

type
  TTableComputer = class( TCustomTableView )
  private
    m_rsComputer: _Recordset;
    m_nComputerID: Integer;
    m_sComputerName: string;
    procedure SetComputerID( const Value: Integer );
    procedure SetComputerName( const Value: string );
    function GetStrComputerName: string;
  protected
    procedure GetAllFieldsValue; override;
  public
    constructor Create; override;
    destructor Destroy; override;
    property ComputerID: Integer
      read m_nComputerID
      write SetComputerID
      default -1;
    property ComputerName: string
      read m_sComputerName
      write SetComputerName;
    property StrComputerName: string
      read GetStrComputerName;
    property Connection;
    function TotalInPricesByCondition( sCondition: string ): Integer;
    function TotalOutPricesByCondition( sCondition: string ): Integer;
    function TotalProfitByCondition( sCondition: string ): Integer;
  end;

implementation

{ TTableComputer }

constructor TTableComputer.Create;
begin
  inherited;

  m_rsComputer := CoRecordset.Create;
  m_nComputerID := -1;
end;

destructor TTableComputer.Destroy;
begin
  m_rsComputer := nil;

  inherited;
end;

procedure TTableComputer.GetAllFieldsValue;
begin
  inherited;

  try
    if m_rsComputer.EOF then
    begin
      m_nComputerID := -1;
      m_sComputerName := EmptyStr;
    end
    else
    begin
      m_nComputerID := Integer( m_rsComputer.Fields[ FN_COMPUTERID ].Value );
      m_sComputerName := VarToStr( m_rsComputer.Fields[ FN_COMPUTERNAME ].Value
        );
    end;
  except

  end;
end;

function TTableComputer.GetStrComputerName: string;
begin
  Result := FN_COMPUTERNAME;
end;

procedure TTableComputer.SetComputerID( const Value: Integer );
begin
  if m_rsComputer.State <> adStateClosed then
    m_rsComputer.Close;
  m_rsComputer.Open( 'SELECT * FROM [' + TN_COMPUTER + '] WHERE [' +
    FN_COMPUTERID + ']=' + IntToStr( Value ),
    Connection, adOpenForwardOnly, adLockReadOnly, adCmdText );
  GetAllFieldsValue;
end;

procedure TTableComputer.SetComputerName( const Value: string );
begin
  if m_rsComputer.State <> adStateClosed then
    m_rsComputer.Close;
  m_rsComputer.Open( 'SELECT * FROM [' + TN_COMPUTER +
    '] WHERE [' + FN_COMPUTERNAME + ']=''' + Value + '''',
    Connection, adOpenForwardOnly, adLockReadOnly, adCmdText );
  GetAllFieldsValue;
end;

function TTableComputer.TotalInPricesByCondition( sCondition: string ): Integer;
begin
  Result := GetFieldSumByCondition( FN_TOTALINPRICES, VN_COMPUTER, sCondition );
end;

function TTableComputer.TotalOutPricesByCondition( sCondition: string ):
  Integer;
begin
  Result := GetFieldSumByCondition( FN_TOTALOUTPRICES, VN_COMPUTER, sCondition
    );
end;

function TTableComputer.TotalProfitByCondition( sCondition: string ): Integer;
begin
  Result := TotalOutPricesByCondition( sCondition ) - TotalInPricesByCondition(
    sCondition );
end;

end.

⌨️ 快捷键说明

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