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

📄 sumsjplc.pas

📁 根据箱号
💻 PAS
字号:
unit sumsjplC;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Cmodel, Menus, StdCtrls, ExtCtrls, Buttons, DB, ADODB, Gauges;

type
  Tsumsjpl = class(Tmodel)
    Panel1: TPanel;
    Label1: TLabel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    ADOQuery1: TADOQuery;
    Memo1: TMemo;
    ADOQuery2: TADOQuery;
    ADOQuery3: TADOQuery;
    ADOQuery4: TADOQuery;
    Label3: TLabel;
    Gauge_process: TGauge;
    ADOCommand1: TADOCommand;
    Panel2: TPanel;
    Label4: TLabel;
    ComboBox1: TComboBox;
    BitBtn3: TBitBtn;
    Gauge1: TGauge;
    procedure BitBtn1Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  sumsjpl: Tsumsjpl;
  mess:string;
implementation

{$R *.dfm}

procedure Tsumsjpl.BitBtn1Click(Sender: TObject);
begin
  inherited;
  combobox1.Enabled:=false;
  combobox1.Clear;
  bitbtn3.Enabled:=false;
  adoquery1.Close;
  adoquery1.SQL.Clear;
  adoquery1.SQL.Add('select * from 串号管理');
  adoquery1.Open;
  mess:='当前数据库共有〖'+inttostr(adoquery1.RecordCount)+'〗条记录:'; 
  adoquery3.Close;
  adoquery3.SQL.Clear;
  adoquery3.SQL.Add('select DISTINCT 发货机率 from 串号管理 ');
  adoquery3.Open;  
  memo1.Text:=mess;
  begin
    Gauge_process.Visible:=true;
      With Gauge_process do
           begin
             Gauge_process.MaxValue:=adoquery3.recordcount;
             Gauge_process.Progress:=0;
             while not adoquery3.Eof do
               begin
                 adoquery4.Close;
                 adoquery4.SQL.Clear;
                 adoquery4.SQL.Add('select * from 串号管理 where 发货机率='''+adoquery3.fieldbyname('发货机率').AsString+'''');
                 adoquery4.Open;
                 mess:=mess+#13#10+'  发货机率为【'+adoquery3.fieldbyname('发货机率').AsString+'】的电子串号数据有【'+inttostr(adoquery4.RecordCount)+'】条,占数据库比例为:【'+formatfloat('##.##',adoquery4.RecordCount/adoquery1.RecordCount*100)+'%】';
                 memo1.Text:=mess;
                 adoquery3.Next;
                 Gauge_process.Progress :=Gauge_process.Progress +1;
               end;
           end;
    end;
    if adoquery3.RecordCount>1 then
       begin
         combobox1.Enabled:=true;
         adoquery3.First;
         while not adoquery3.Eof do
           begin
             if (adoquery3.FieldByName('发货机率').AsString>'1') then
                combobox1.Items.Add(adoquery3.FieldByName('发货机率').AsString);
             adoquery3.Next;
           end;
       end;
end;

procedure Tsumsjpl.ComboBox1Change(Sender: TObject);
begin
  inherited;
  if trim(combobox1.Text)<>'' then
     begin
       bitbtn3.Enabled:=true;
     end
  else
       bitbtn3.Enabled:=false;
end;

procedure Tsumsjpl.BitBtn3Click(Sender: TObject);
var
  number0,number1,number2,number3,number4:real;
begin
  inherited;
  adoquery1.Close;
  adoquery1.SQL.Clear;
  adoquery1.SQL.Add('select DISTINCT 箱号 from 串号管理 where 发货机率='''+combobox1.Text+'''');  //
  adoquery1.Open;
  Gauge1.Visible:=true;
  With Gauge1 do
    begin
      Gauge1.MaxValue:=adoquery1.recordcount;
      Gauge1.Progress:=0;
  while not adoquery1.Eof do
    begin
      adoquery2.Close;
      adoquery2.SQL.Clear;
      adoquery2.SQL.Add('select * from 串号管理 where 箱号='''+adoquery1.fieldbyname('箱号').AsString+''' and 发货机率='''+combobox1.Text+'''');  //
      adoquery2.Open;
      if adoquery2.RecordCount=5 then
         number0:=number0+1
      else
      if adoquery2.RecordCount=10 then
         number1:=number1+1
      else
      if adoquery2.RecordCount=15 then
         number2:=number2+1
      else
      if adoquery2.RecordCount=20 then
         number3:=number3+1
      else
      if adoquery2.RecordCount=30 then
         number4:=number4+1;
      adoquery1.Next;
      Gauge1.Progress :=Gauge1.Progress +1;
      mess:='箱数为【05】:有【'+floattostr(number0)+'】条,合计为【'+floattostr(number0*5)+'】条'+#13+'箱数为【10】:有【'+floattostr(number1)+'】条,合计为【'+floattostr(number1*10)+'】条'+#13+'箱数为【15】:有【'+floattostr(number2)+'】条,合计为【'+floattostr(number2*15)+'】条'+#13+'箱数为【20】:有【'+floattostr(number3)+'】条,合计为【'+floattostr(number3*20)+'】条'+#13+'箱数为【30】:有【'+floattostr(number4)+'】条,合计为【'+floattostr(number4*30)+'】条'+#13+'                       总合计:【'+floattostr(number0*5+number1*10+number2*15+number3*20+number4*30)+'】条';
    end;
    end;
    if messagedlg(pchar(mess),mtinformation,[mbyes,mbno],0)=mryes then
       begin
         adocommand1.CommandText:='delete * from 串号管理 where 发货机率='''+combobox1.Text+'''';
         adocommand1.Execute;
         gauge1.Visible:=false;
         self.BitBtn1Click(sender);  
       end;
end;

end.

⌨️ 快捷键说明

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