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

📄 cx110unit.pas

📁 货物配送管理系统对配送服务
💻 PAS
字号:
unit CX110Unit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, PublicUnit, jpeg, ExtCtrls, DBCtrls, ComCtrls, StdCtrls, Grids,
  DBGrids;

type
  TCX110Form = class(TPublicUnit)
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label5: TLabel;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    CheckBox1: TCheckBox;
    DateTimePicker1: TDateTimePicker;
    DateTimePicker2: TDateTimePicker;
    DBNavigator1: TDBNavigator;
    DBGrid1: TDBGrid;
    RadioGroup1: TRadioGroup;
    procedure CheckBox1Click(Sender: TObject);
    procedure ComboBox1DropDown(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure RadioGroup1Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  CX110Form: TCX110Form;

implementation

uses DMUnit;
{$R *.dfm}

procedure TCX110Form.CheckBox1Click(Sender: TObject);
begin
  inherited; // 判断是否可用
  DateTimePicker1.Enabled := CheckBox1.Checked;
  DateTimePicker2.Enabled := CheckBox1.Checked;
end;

procedure TCX110Form.ComboBox1DropDown(Sender: TObject);
var
  i: Integer;
begin
  inherited;
  ComBobox1.Clear;
  for i := 0 to DM.JCD.FieldList.Count - 1 do
  begin //取得所有的列名作为搜索条件
    ComBobox1.Items.Add(DM.JCD.Fields[i].FieldName);
  end;
end;

procedure TCX110Form.ComboBox1Change(Sender: TObject);
var
  I: Integer;
begin
  inherited;
  combobox2.Clear;
  with DM.Querytemp do
  begin
    SQL.clear;
    SQl.Text := 'select ' + trim(combobox1.Text) + ' from 进仓单 ';
    Close;
    Active := False;
    prepared := False;
    prepared := True;
    Active := True;
    if (recordcount > 0) then
      first;
    for i := 0 to recordcount - 1 do
    begin //取得该列所有的数据到combobox2控件中
      combobox2.Items.add(FieldByName(ComboBox1.Text).asstring);
      next;
    end;
  end;
end;

procedure TCX110Form.RadioGroup1Click(Sender: TObject);
begin
  inherited;
  case RadioGroup1.ItemIndex of
    0:
      begin
        with DM.Querytemp do
        begin
        {--- 取得所有的货运统计列表 ---}
          SQL.clear;
          SQl.Text := 'select * from 仓库统计';
          Close;
          Active := False;
          prepared := False;
          prepared := True;
          Active := True;
          if RecordCount <= 0 then
            MessageBox(0, '没有符合要求记录发现', '提示', MB_OK +
              MB_ICONINFORMATION);
          DBGrid1.DataSource := DM.dsQuerytemp;
          DBNavigator1.DataSource := DM.dsQueryTemp;
        end;
      end;
    1:
      begin
        with DM.Querytemp do
        begin
        {--- 取得所有的货运统计列表 ---}
          SQL.clear;
          SQl.Text := 'select * from 仓库统计 where 结余数量 > 0';
          Close;
          Active := False;
          prepared := False;
          prepared := True;
          Active := True;
          if RecordCount <= 0 then
            MessageBox(0, '没有符合要求记录发现', '提示', MB_OK +
              MB_ICONINFORMATION);
          DBGrid1.DataSource := DM.dsQuerytemp;
          DBNavigator1.DataSource := DM.dsQueryTemp;
        end;
      end;
    2:
      begin
        with DM.Querytemp do
        begin
        {--- 取得所有的货运统计列表 ---}
          SQL.clear;
          SQl.Text := 'select * from 仓库统计 where 结余数量 <= 0';
          Close;
          Active := False;
          prepared := False;
          prepared := True;
          Active := True;
          if RecordCount <= 0 then
            MessageBox(0, '没有符合要求记录发现', '提示', MB_OK +
              MB_ICONINFORMATION);
          DBGrid1.DataSource := DM.dsQuerytemp;
          DBNavigator1.DataSource := DM.dsQueryTemp;
        end;
      end;
  end;
end;

procedure TCX110Form.Button7Click(Sender: TObject);
begin
  inherited;
  {--- 判断搜索的条件是否为空  ---}
  if (Combobox1.Text <> '') and (Combobox2.Text <> '') then
  begin
    with DM.Querytemp do
    begin
      SQL.clear;
      if CheckBox1.Checked then
        SQl.Text := 'select * from 仓库统计 where ' + trim(combobox1.Text) + ' like '
          + #39 + '%' + trim(combobox2.Text) + '%' + #39 + 'and 日期 > #'
          + FormatDateTime('yyyy/mm/dd', DateTimePicker1.DateTime) + '# and 日期 < #' + FormatDateTime('yyyy/mm/dd', DateTimePicker2.DateTime) + '#'
      else
        SQl.Text := 'select * from 仓库统计 where ' + trim(combobox1.Text) + ' like '
          + #39 + '%' + trim(combobox2.Text) + '%' + #39;
      Close;
      Active := False;
      prepared := False;
      prepared := True;
      Active := True;
      open;
      DBGrid1.DataSource := DM.dsQuerytemp;
      DBNavigator1.DataSource := DM.dsQuerytemp;
    end;
  end
  else
    MessageBox(0, '搜寻条件错误', '错误', MB_OK + MB_ICONSTOP);
end;

end.

⌨️ 快捷键说明

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