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

📄 u_hpfbjk.pas

📁 相关的销售服务管理行业的一个软件
💻 PAS
字号:
unit U_HPFBJK;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  BaseCell, Db, DBTables, ImgList, OleCtrls, CELLLib_TLB, TB97Ctls, TB97,
  TB97Tlbr, StdCtrls, ADODB;

type
  TfrmHPFBJK = class(TBaseCellForm)
    S_CKQuery: TADOQuery;
    S_GOODSQuery: TADOQuery;
    ADOQuery1: TADOQuery;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);    
    procedure ToolbarButton975Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
  private
    EXITFLAG:BOOLEAN;
    fromDate,OverDate :String;
    procedure WriteDate;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmHPFBJK: TfrmHPFBJK;

implementation
uses U_DM,U_HPFBJKDlg,ProcessBar,Umain;
{$R *.DFM}

procedure TfrmHPFBJK.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  inherited;
  if not Assigned(frmHPFBJK) then
  frmHPFBJK:=nil;
  frmmain.Outlook1.Visible:=true;
  frmmain.Panel2.Visible:=true;
end;
procedure TfrmHPFBJK.ToolbarButton975Click(Sender: TObject);
begin
 inherited;
 EXITFLAG:=FALSE;
 WITH TfrmHPFBJKDlgDlg.Create(SELF) DO
 if ShowModal=MROK then
 begin
 fromDate :=FormatDateTime('yyyy-mm-dd',DateTimePicker1.DateTime);
 overDate :=FormatDateTime('yyyy-mm-dd',DateTimePicker2.DateTime);
 end
 ELSE
 begin
 EXITFLAG:=True;
 Release;
 end;
 IF NOT EXITFLAG THEN
 begin
 WriteDate;
 Cell1.DoRedrawAll;
 end;
end;

PROCEDURE TfrmHPFBJK.WriteDate;
var
JRL:ARRAY[0..3,0..30] OF String;
i,j,Mcol,x:integer;
s,sHsl : String;
iHSL:Real;
BEGIN
ProcessBarForm:=TProcessBarForm.Create(Self);
processbarform.show;
ProcessBarForm.Panel1.Caption:='正在填充数据...';
ProcessBarForm.Update;

Fillchar(JRL,sizeof(JRL),0);
//打开仓库信息表
S_CKQuery.Close;
S_CKQuery.Sql.Clear;
S_CKQuery.Sql.Add('select nCKCode,nCKTCode,nCKName from s_CK');
S_CKQuery.Open;
//打开货品信息表
S_GOODSQuery.Close;
S_GOODSQuery.SQL.Clear;
S_GOODSQuery.SQL.Add('select nGdCode,nGdName,nGDColor from s_goods');
S_GOODSQuery.Open;
//打开结果集
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.ADD('SELECT T4.nGdName nGoodName,T2.nColor,T1.nCkCode,sum(T2.nFsCount*T1.nRedBlue*T3.iSFTag) nFsCount');
ADOQuery1.SQL.ADD('from kc_Goodmaster T1,kc_Gooddetail T2,s_SFtype T3,s_Goods T4');
ADOQuery1.SQL.ADD('where T1.nBillid=T2.nBillid and T1.nSfTType=T3.nSFTCode and T4.nGdCode=T2.nGoodCode');
if  fromDate<>'' then
ADOQuery1.SQL.ADD('and T1.nDateRk>='''+fromDate+'''');
if  overDate<>'' then
ADOQuery1.SQL.ADD('and T1.nDateRk<='''+overDate+'''');
ADOQuery1.SQL.ADD('group by T4.nGdName,T2.nColor,T1.nCkCode');
ADOQuery1.SQL.ADD('order by T2.nGoodName,T2.nColor');
ADOQuery1.Open;

ProcessBarForm.Gauge1.MaxValue:=ADOQuery1.RecordCount;;
ProcessBarForm.Gauge1.Progress:=0;

ClearCell;
Cell1.Rows :=5;
Cell1.Cols :=S_CKQuery.RecordCount+3;

//画表头
Cell1.DoJoinCells(0,0,Cell1.Cols-1,0);
Cell1.DoSetCellString(0,0,'货 品 分 布 状 况 汇 总 表');
Cell1.DoSetCellFont(0,0,14,5,'宋体');
Cell1.DoSetCellReadOnly(0,0,true);
Cell1.DoSetCellAlignment(0,0,100);
Cell1.DoSetRowHeight(0,50);

Cell1.DoJoinCells(0,2,2,2);
Cell1.DoSetCellString(0,2,'开始日期:'+fromDate);
Cell1.DoJoinCells(3,2,Cell1.Cols-1,2);
Cell1.DoSetCellString(3,2,'结束日期:'+overDate);
Cell1.DoJoinCells(2,3,Cell1.Cols-2,3);
Cell1.DoSetCellString(2,3,'仓     库');
Cell1.DoJoinCells(0,3,0,4);
Cell1.DoSetCellString(0,3,'型体');
Cell1.DoJoinCells(1,3,1,4);
Cell1.DoSetCellString(1,3,'颜色');
Cell1.DoJoinCells(Cell1.Cols-1,3,Cell1.Cols-1,4);
Cell1.DoSetCellString(Cell1.Cols-1,3,'合计');
Cell1.DoDrawLine(0,3,Cell1.Cols-1,Cell1.Rows,0,1,1);

S_CKQuery.First;
for j:=2 to S_CKQuery.RecordCount+1 do
begin
Cell1.DoSetCellString(j,4,S_CKQuery.Fieldbyname('nCKName').AsString);
JRL[0][j]:=S_CKQuery.Fieldbyname('nCKTCode').AsString;
Cell1.DoSetCellAlignment(j,4,100);
S_CKQuery.Next;
end;
//ADOQuery1循环填数
ADOQuery1.First;
for i:=0 to ADOQuery1.RecordCount -1 do
  begin
      if (i<>0) and (s<>ADOQuery1.Fieldbyname('nGoodName').Asstring+ADOQuery1.Fieldbyname('nColor').Asstring)  then
       begin
        Cell1.Rows :=Cell1.Rows+1;
        Cell1.DoDrawLine(0,Cell1.Rows-1,Cell1.Cols-1,Cell1.Rows-1,0,1,1);
        for j:=0 to  Cell1.Cols-1 do
         begin
         if (JRL[1][j]<>'') and (j<>0) and (j<>1) then
             begin
             if JRL[1][cell1.Cols-1]='' then JRL[1][cell1.Cols-1]:='0';
             if (j<>Cell1.Cols-1) then
             JRL[1][cell1.Cols-1]:=FloatToStr(StrToFloat(JRL[1][cell1.Cols-1])+StrToFloat(JRL[1][j]));
             if JRL[2][cell1.Cols-1]='' then JRL[2][cell1.Cols-1]:='0';
             if JRL[2][j]<>'' then
             JRL[2][j]:=FloatToStr(StrToFloat(JRL[2][j])+StrToFloat(JRL[1][j]))
             else
             JRL[2][j]:=JRL[1][j];
             end;
         Cell1.DoSetCellString(j,Cell1.Rows-1,JRL[1][j]);
         end;
        for j:=2 to Cell1.Cols-1 do
         JRL[1][j]:='';
        s:=ADOQuery1.Fieldbyname('nGoodName').Asstring+ADOQuery1.Fieldbyname('nColor').Asstring;
       end;

  for j:=2 to S_CKQuery.RecordCount+1 do
  if JRL[0][j]=ADOQuery1.Fieldbyname('nCkCode').Asstring then
      if JRL[1][j]<>'' then
      JRL[1][j]:=FloatToStr(StrToFloat(JRL[1][j])+ADOQuery1.Fieldbyname('nFsCount').AsFloat)
      else
      JRL[1][j]:=ADOQuery1.Fieldbyname('nFsCount').AsString;
JRL[1][0]:=ADOQuery1.Fieldbyname('nGoodName').Asstring;
JRL[1][1]:=ADOQuery1.Fieldbyname('nColor').Asstring;

ADOQuery1.next;
ProcessBarForm.Gauge1.Progress:=i;
ProcessBarForm.Update;
end;
        Cell1.Rows :=Cell1.Rows+1;
        Cell1.DoDrawLine(0,Cell1.Rows-1,Cell1.Cols-1,Cell1.Rows-1,0,1,1);
        for j:=0 to  Cell1.Cols-1 do
         begin
         if (JRL[1][j]<>'') and  (j<>0) and (j<>1) then
             begin
             if JRL[1][cell1.Cols-1]='' then JRL[1][cell1.Cols-1]:='0';
             if (j<>Cell1.Cols-1) then
             JRL[1][cell1.Cols-1]:=FloatToStr(StrToFloat(JRL[1][cell1.Cols-1])+StrToFloat(JRL[1][j]));
             if JRL[2][cell1.Cols-1]='' then JRL[2][cell1.Cols-1]:='0';
             if JRL[2][j]<>'' then
             JRL[2][j]:=FloatToStr(StrToFloat(JRL[2][j])+StrToFloat(JRL[1][j]))
             else
             JRL[2][j]:=JRL[1][j];
             end;
         Cell1.DoSetCellString(j,Cell1.Rows-1,JRL[1][j]);
         end;
        for j:=2 to Cell1.Cols do
         JRL[1][j]:='';
Cell1.Rows :=Cell1.Rows+1;
Cell1.DoDrawLine(0,Cell1.Rows-1,Cell1.Cols-1,Cell1.Rows-1,0,1,1);
Cell1.DoJoinCells(0,Cell1.Rows-1,1,Cell1.Rows-1);
Cell1.DoSetCellString(0,Cell1.Rows-1,'总 计:');
for i:=0 to Cell1.cols - 1 do
    Cell1.DoSetCellColor(i,cell1.rows-1,0,rgb(255,255,128));
for i:=3 to Cell1.Rows - 1 do
    Cell1.DoSetCellColor(cell1.Cols-1,i,0,rgb(255,255,128));

for j:=2 to  Cell1.Cols-1 do
    begin
    Cell1.DoSetCellString(j,Cell1.Rows-1,JRL[2][j]);
    JRL[2][j]:='';
    end;
ProcessBarForm.Free;


{Cell1.Rows :=Cell1.Rows+1;
Cell1.DoDrawLine(0,Cell1.Rows-1,Cell1.Cols-2,Cell1.Rows-1,0,1,1);
Cell1.DoJoinCells(0,Cell1.Rows-1,3,Cell1.Rows-1);
Cell1.DoJoinCells(10,cell1.rows-1,12,cell1.rows-1);
Cell1.DoSetCellString(0,Cell1.Rows-1,'合计:');
for i := 4 to Cell1.Cols-2  do
if JRL[i]<>0 then
  Cell1.DoSetCellValue(i,Cell1.Rows-1,JRL[i]);

Cell1.Rows :=Cell1.Rows+1;
Cell1.DoJoinCells(0,Cell1.Rows-1,Cell1.Cols-2,Cell1.Rows-1);
Cell1.DoSetCellString(0,Cell1.Rows-1,ss);
}

//设置只读 设置字体
    for i := 0 to Cell1.Cols-1  do
       for j :=1 to cell1.rows-1 do
       begin
       Cell1.DoSetCellReadOnly(i,j,true);
       Cell1. DoSetCellTextStyle(i,j,1);
       Cell1.DoSetCellAlignment(i,j,100);
       Cell1.DoSetCellFont(i,j,8,0,'宋体');
       if (j>4) or  (j=2) then
       begin
       Cell1.DoSetCellAlignment(0,j,1);
       Cell1.DoSetCellAlignment(1,j,1);
       Cell1.DoSetCellAlignment(i,j,2);
       end;
       end;


       Cell1.DoSetSkipReadOnlyCell(0);
       Cell1.DoRedrawAll;
END;
procedure TfrmHPFBJK.FormShow(Sender: TObject);
begin
  inherited;
 ToolbarButton975Click(NIL);
 IF EXITFLAG THEN
  CLOSE;
 SELF.ONSHOW:=NIL;
end;

procedure TfrmHPFBJK.FormCreate(Sender: TObject);
begin
  inherited;
  aPrintCol:=60;
  aPrintRow:=43;
  aStartCol:=1;
  aStartRow:=5;
//  STARTROW:=7;
//  STARTCOL:=1;
end;

procedure TfrmHPFBJK.SpeedButton1Click(Sender: TObject);
begin
  inherited;
	PrintCell(False,False);
end;


end.

⌨️ 快捷键说明

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