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

📄 ubacthdataquery.pas

📁 适合行业为眼镜业
💻 PAS
📖 第 1 页 / 共 2 页
字号:
          1..4:
             begin
               Tname:=' b.goods_no,b.goods_name,b.type,b.brand,b.breed,a.nuOutQuantity as amount,a.id FROM SendDetailTable  as a ,goods_code as b where a.vcPtypeid=b.goods_no and  vcSendBillid='+''''+trim(dbgrid1.DataSource.DataSet.fieldbyname('Bno').AsString)+'''';
             end;
        end;
      end;
    end;
  end;
  dbgCur:=dbgrid2;
  Sql:=SelTop+Tname;
  try
    screen.Cursor :=  crHourGlass;
    datas:=null;
    cdsdtable.Close;
    cdsdtable.Data:=null;
    cdsdtable.IndexName:='';
    cdsdtable.IndexDefs.Clear;
    datas:=adisp.execSql(sql);
    filedsname:=tname;
    flag:=2;
    if not varisnull(datas) then
    begin
      cdsdtable.Data:=datas;
      cdsdtable.Open;
      datas:=null;
      cdsdtable.Last;
      DCount:=GetKeyFieldValue('id',cdsdtable);
      btnpagedown.Enabled:=true;
      dbgrid1.Visible:=false;
      dbgrid3.Visible:=false;
      dbgrid2.Visible:=true;
      dbgrid2.SetFocus;
    end;
     screen.Cursor :=  crdefault;
  except
  end;
end;

procedure TfmBacthQuery.DBGrid2TitleClick(Column: TColumn);
begin
  inherited;
  if (not dbgrid2.DataSource.DataSet.Active ) then exit;
   if trim(column.Field.AsString)='' then exit;
   sortgrid(column.Field.FieldName,cdsdtable,dbgrid2,column);
end;

procedure TfmBacthQuery.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
   IF DBGRID2.Visible THEN
  BEGIN
    if key=vk_Escape then
    begin
      dbgrid3.Visible:=false;
      dbgrid2.Visible:=false;
      dbgrid1.Visible:=true;
      dbgCur:=dbgrid1;
    end;
  END ELSE
  BEGIN
    IF (KEY=VK_F1) and (dbgrid1.Visible) THEN
    begin
      DBgrid1DblClick(DBgrid1);
      dbgrid1.Visible:=false;
      dbgrid3.Visible:=false;
      dbgCur:=dbgrid2;
    end;
    IF (KEY=VK_F2) and (dbgrid1.Visible) THEN
    begin
      bitbtn3click(nil);
      dbgrid1.Visible:=false;
      dbgrid2.Visible:=false;
      dbgrid3.Visible:=true;
      dbgCur:=dbgrid3;
    end;
    if (key=vk_Escape) and (dbgrid3.Visible) then
    begin
      dbgrid2.Visible:=false;
      dbgrid3.Visible:=false;
      dbgrid1.Visible:=true;
      dbgCur:=dbgrid1;
    end;
  END;
end;

procedure TfmBacthQuery.BitBtn3Click(Sender: TObject);
var
  TableType,temp,Tname:String;
  i:integer;
  Sql:widestring;
  datas:olevariant;
begin
  inherited;
  if dbgrid1.DataSource.DataSet.IsEmpty  then exit;
  for i:=0 to self.ComponentCount-1 do
  begin
    if (self.Components[i] is TRadioButton) then
    begin
      if (self.Components[i] as TRadioButton).Checked  then
      begin
        CASE (self.Components[i] as TRadioButton).Tag of
          0: begin
               Tname:=' max(b.id) as id, b.goods_no,b.goods_name,b.type,b.brand,b.breed,sum(c.NQty) as amount FROM GetGoodsPlan  as c ,goods_code as b,getgoodsplanmaster as a where a.vcgetgoodsplanid=c.vcgetgoodsplanid and c. VCPtyieID=b.goods_no '+querys;
             end;
          1..4:
             begin
               Tname:='max(b.id) as id, b.goods_no,b.goods_name,b.type,b.brand,b.breed,sum(c.nuOutQuantity) as amount FROM SendDetailTable  as c ,goods_code as b,sendmastertable as a where a.vcsendbillid=c.vcsendbillid and  c.vcPtypeid=b.goods_no '+querys;
             end;
        end;
      end;
    end;
  end;
  dbgCur:=dbgrid3;
  tgroup:=' group by b.goods_no,b.goods_name,b.type,b.brand,b.breed';
  Sql:=SelTop+Tname+tgroup;
  try
    screen.Cursor :=  crHourGlass;
    datas:=null;
    cdstotal.Close;
    cdstotal.Data:=null;
    cdstotal.IndexName:='';
    cdstotal.IndexDefs.Clear;
    datas:=adisp.execSql(sql);
    filedsname:=tname;
    flag:=2;
    if not varisnull(datas) then
    begin
      cdstotal.Data:=datas;
      cdstotal.Open;
      datas:=null;
      cdstotal.Last;
      tCount:=GetKeyFieldValue('id',cdstotal);
      btnpagedown.Enabled:=true;
      dbgrid1.Visible:=false;
      dbgrid2.Visible:=false;
      dbgrid3.Visible:=true;
       dbgrid3.SetFocus;
    end;
     screen.Cursor :=  crdefault;
  except
  end;

end;

procedure TfmBacthQuery.DBGrid3TitleClick(Column: TColumn);
begin
  inherited;
  if (not dbgrid3.DataSource.DataSet.Active ) then exit;
   if trim(column.Field.AsString)='' then exit;
   sortgrid(column.Field.FieldName,cdstotal,dbgrid3,column);
end;

procedure TfmBacthQuery.btnpagedownClick(Sender: TObject);
var
  idcount:integer;
  temp:widestring;
  datas:olevariant;
begin
  inherited;
  screen.Cursor := crhourglass;
  case flag of
    1:
    begin
      if not cdsmtable.Active then exit;
      cdsmtable.DisableControls;
      idcount:=localcount;
      temp:=seltop+filedsname+Querys;
    end;
    2:
    begin
      if not cdsdtable.Active then exit;
      cdsdtable.DisableControls;
      idcount:=dcount;
      temp:=seltop+filedsname;
    end;
    3:
    begin
      if not cdstotal.Active then exit;
      cdstotal.DisableControls;
      idcount:=tcount;
      temp:=seltop+filedsname+Tgroup;
    end;
  end;
  try
  temp:=Temp+' and id>'+inttostr(idcount);
  datas:=null;
  try
  datas:=adisp.execsql(temp);
  except
    application.MessageBox('服务器发生故障!',pchar(application.Title),mb_iconwarning);
    screen.Cursor :=  crdefault;
    exit;
  end;
  if not varisnull(datas) then
  begin
     case flag of
    1:
    begin
      with cdsmtable do
      begin
        close;
        AppendData(datas,true);
        open;
        last;
        LocalCount := GetKeyFieldValue('id',cdsmtable);
        cdsmtable.EnableControls;
      end;
    end;
    2:
    begin
      with cdsdtable do
      begin
        close;
        AppendData(datas,true);
        open;
        last;
        dCount := GetKeyFieldValue('id',cdsdtable);
        EnableControls;
      end;
    end;
    3:
    begin
      with cdstotal do
      begin
        close;
        AppendData(datas,true);
        open;
        last;
        tCount := GetKeyFieldValue('id',cdstotal);
        EnableControls;
      end;
    end;
  end;
  //////////////////////////////////////       dmmain.cdsquery.Last;
    //重新打开
    end else
    begin
       //不再有数据
      case flag of
        1:
        begin
          with cdsmtable do
          begin
            cdsmtable.EnableControls;
          end;
        end;
        2:
        begin
          with cdsdtable do
          begin
            EnableControls;
          end;
        end;
        3:
        begin
          with cdstotal do
          begin
            EnableControls;
          end;
        end;
      end;  
       btnpagedown.Enabled := false;
       screen.Cursor :=  crdefault;
      exit;
    end;
  except
  end;
  screen.Cursor :=  crdefault;
  btnpagedown.Enabled:=true;
end;

procedure TfmBacthQuery.DBGrid1TitleClick(Column: TColumn);
begin
  inherited;
   if (not dbgrid1.DataSource.DataSet.Active ) then exit;
   if trim(column.Field.AsString)='' then exit;
   sortgrid(column.Field.FieldName,cdsMtable,dbgrid1,column);
end;

end.

⌨️ 快捷键说明

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