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

📄 indepotquery.pas

📁 1、系统环境要求:WindowsXP/2000 2、DELPHI7.0企业版 3、如果数据库为SQL Server数据库
💻 PAS
字号:
unit indepotquery;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, basequery, DB, StdCtrls, ComCtrls, Grids, DBGrids, ExtCtrls;

type
  Tf_indepotquery = class(Tf_basequery)
    procedure QueryClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  f_indepotquery: Tf_indepotquery;

implementation
  uses Data;
{$R *.dfm}

procedure Tf_indepotquery.QueryClick(Sender: TObject);
begin
  inherited;
  if(Not Condition.Checked )and(Not Timedate.Checked) then
  begin
    Application.MessageBox('请设置查询条件.','提示',64);
  end
  else
  begin
    if (Trim(Value.Text)='')and(Condition.Checked) then
    begin
      Application.MessageBox('查询信息不完整.','提示',64);
      exit;
    end;
    With t_data.Query1 do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select * from v_indepotquery where ');
      if Timedate.Checked = False then
      begin
        case Field.ItemIndex of
          0: SQL.Add('provider = :value ');
          1: SQL.Add('inid = :value');
          2: SQL.Add('bookname = :value');
          3: SQL.Add('barcode = :value');
        end;
        Parameters.ParamByName('Value').Value := Trim(Value.Text);
        Open;
        if t_data.Query1.RecordCount>0 then
        begin
          Source.DataSet := t_data.Query1;
          With t_data.Query2 do
          begin
            Close;
            SQL.Clear;
            SQL.Add('select sum(num)as num,sum(money)as money from v_indepotquery where ');
            case Field.ItemIndex of
              0: SQL.Add('provider = :value ');
              1: SQL.Add('inid = :value');
              2: SQL.Add('bookname = :value');
              3: SQL.Add('barcode = :value');
            end;
            Parameters.ParamByName('Value').Value := Trim(Value.Text);
            Open;
          end;
          Sum.Text := t_data.Query2.FieldByName('num').AsString;
          Summoney.Text := t_data.Query2.FieldByName('money').AsString;
        end
        else
        begin
          Source.DataSet := nil;
          Sum.Clear;
          Summoney.Clear;
          t_data.Query1.Close;
          Application.MessageBox('没有找到符合条件的记录.','提示',64);
        end;
      end
      else if (Timedate.Checked = True) and(Not Condition.Checked) then
      begin
        SQL.Add('timedate >= :fromdate and timedate < :todate');
        Parameters.ParamByName('fromdate').Value := Trunc(Fromdate.DateTime);
        Parameters.ParamByName('todate').Value := Trunc(ToDate.DateTime)+1;
        Open;
        if t_Data.Query1.RecordCount>0 then
        begin
          Source.DataSet := t_data.Query1;
          With t_data.Query2 do
          begin
            Close;
            SQL.Clear;
            SQL.Add('select sum(num)as num,sum(money)as money from v_indepotquery where timedate >= :Fromdate and timedate < :todate ');
            Parameters.ParamByName('fromdate').Value := Trunc(Fromdate.DateTime);
            Parameters.ParamByName('todate').Value := Trunc(ToDate.DateTime)+1;
            Open;
          end;
          Sum.Text := t_data.Query2.FieldByName('num').AsString;
          Summoney.Text := t_data.Query2.FieldByName('money').AsString;
        end
        else
        begin
          Source.DataSet := nil;
          Sum.Clear;
          Summoney.Clear;
          t_data.Query1.Close;
          Application.MessageBox('没有找到符合条件的记录.','提示',64);
        end;
      end
      else
      begin
        if Field.ItemIndex<>-1 then
        begin
          case Field.ItemIndex of
            0: SQL.Add('provider = :value ');
            1: SQL.Add('inid = :value');
            2: SQL.Add('bookname = :value');
            3: SQL.Add('barcode = :value');
          end;
          SQL.Add(' and timedate >= :Fromdate and timedate < :todate ');
          Parameters.ParamByName('value').Value := Trim(Value.Text);
          Parameters.ParamByName('fromdate').Value := Trunc(Fromdate.DateTime);
          Parameters.ParamByName('todate').Value := Trunc(ToDate.DateTime)+1;
          Open;
          if t_Data.Query1.RecordCount>0 then
          begin
            Source.DataSet := t_data.Query1;
            With t_data.Query2 do
            begin
              Close;
              SQL.Clear;
              SQL.Add('select sum(num)as num,sum(money)as money from v_indepotquery where  timedate >= :Fromdate and timedate < :todate and ');
              case Field.ItemIndex of
                0: SQL.Add('provider = :value ');
                1: SQL.Add('inid = :value');
                2: SQL.Add('bookname = :value');
                3: SQL.Add('barcode = :value');
              end;
              Parameters.ParamByName('value').Value := Trim(value.Text);
              Parameters.ParamByName('fromdate').Value := Trunc(Fromdate.DateTime);
              Parameters.ParamByName('todate').Value := Trunc(ToDate.DateTime)+1;
              Open;
            end;
            Sum.Text := t_data.Query2.FieldByName('num').AsString;
            Summoney.Text := t_data.Query2.FieldByName('money').AsString;
          end
          else
          begin
            Source.DataSet := nil;
            Sum.Clear;
            Summoney.Clear;
            t_data.Query1.Close;
            Application.MessageBox('没有找到符合条件的记录.','提示',64);
          end;
        end
        else
          Application.MessageBox('请选择查询字段.','提示',64);
      end;
    end;
  end;
end;

end.

⌨️ 快捷键说明

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