📄 u_draw.pas
字号:
unit u_Draw;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls,U_Constant,U_DM,EasyGrid;
//////////
procedure DrawTableX(ctrl:TControl;iTop,iLeft,Rows,Cols,iWidth,iHeight:integer;s_ID:string);
procedure DrawTableX1(ctrl:TControl;iTop,iLeft,Rows,Cols,iWidth,iHeight:integer;s_ID:string);
procedure DrawTableX2(ctrl:TControl;iTop,iLeft,Rows,Cols,iWidth,iHeight:integer;s_ID:string);
procedure DrawGrid(ctrl:TControl;s_Id:string);
implementation
procedure DrawGrid(ctrl:TControl;s_Id:string);
var
i:integer;
j:integer;
x:integer;
iPerUnit:integer;
iPerUnit1:integer;
CurrentPath:string;
R_CPData:Array[1..100,1..100] of integer;
FieldIndex:string;
begin
if (ctrl is TEasyGrid) then
begin
with TEasyGrid(ctrl) do
begin
with Canvas do
begin
////存储表格的坐标//////////
brush.Color:=rgb(255,0,0);
pen.Color:=rgb(255,0,0);
//////取得数据库数据////////////
CurrentPath:=ExtractFilePath(paramstr(0));
//Ellipse(rect(PointX[1],PointY[1],PointX[1]+strToInt(formatFloat('##0',(iHeight/Rows))),PointY[1]+strToInt(formatFloat('##0',(iWidth/cols)))));
//brush.Color:=rgb(255,255,255);
for i:=1 to 6 do
begin
with DataM.ADOQuery1 do
begin
connectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+CurrentPath+'\sale.mdb;Persist Security Info=False';
close;
sql.Clear;
sql.Add('select * from CPdata Where sID=:sID');
parameters.ParamByName('sID').Value:=s_ID;
prepared;
open;
if RecordCount<>0 then
begin
FieldIndex:='R'+InttoStr(i);
R_CPData[1,i]:=FieldByName(FieldIndex).AsInteger;
end;//if
end;//with
end;///
for i:=1 to 6 do
begin
for j:=1 to 33 do
begin
if R_CPData[1,i]=j then
begin
case R_CPData[1,i] of
1..6:
Canvas.Ellipse(cellRect(j+1,i+1) );
7..12:
begin
x:=j-6;
//Ellipse(rect(PointX[x],PointY[2],PointX[x]+strToInt(formatFloat('##0',(iHeight/Rows))),PointY[2]+strToInt(formatFloat('##0',(iWidth/cols)))));
end;
13..18:
begin
x:=j-12;
//Ellipse(rect(PointX[x],PointY[3],PointX[x]+strToInt(formatFloat('##0',(iHeight/Rows))),PointY[3]+strToInt(formatFloat('##0',(iWidth/cols)))));
end;
19..24:
begin
x:=j-18;
//Ellipse(rect(PointX[x],PointY[4],PointX[x]+strToInt(formatFloat('##0',(iHeight/Rows))),PointY[4]+strToInt(formatFloat('##0',(iWidth/cols)))));
end;
25..30:
begin
x:=j-24;
//Ellipse(rect(PointX[x],PointY[5],PointX[x]+strToInt(formatFloat('##0',(iHeight/Rows))),PointY[5]+strToInt(formatFloat('##0',(iWidth/cols)))));
end;
31..36:
begin
x:=j-30;
//Ellipse(rect(PointX[x],PointY[6],PointX[x]+strToInt(formatFloat('##0',(iHeight/Rows))),PointY[6]+strToInt(formatFloat('##0',(iWidth/cols)))));
end;
end;
end;///if
end;//j
end;///fori
{
for i:=1 to 6 do
begin
showmessage(inttostr(R_CPData[1,i]));
end;//
}
///////取得数据库数据结束//////////////////////////
brush.Style:=Bsclear;
//////画圆///////////
//Ellipse(PointX[4],PointY[4],PointX[4]+strToInt(formatFloat('##0',(iHeight/Rows))),PointY[4]+strToInt(formatFloat('##0',(iWidth/cols))));
end;///withcanvas
end;//with
end;//ifctrl
//////////////////////////////
end;////
//////////////////////
procedure DrawTableX2(ctrl:TControl;iTop,iLeft,Rows,Cols,iWidth,iHeight:integer;s_ID:string);
var
i:integer;
j:integer;
x:integer;
iPerUnit:integer;
iPerUnit1:integer;
CurrentPath:string;
R_CPData:Array[1..100,1..100] of integer;
FieldIndex:string;
begin
if (ctrl is TPaintBox) then
begin
with TPaintBox(ctrl) do
begin
with Canvas do
begin
brush.Style:=BSSolid;
Brush.Color:=rgb(255,255,255);
Pen.Color:=rgb(0,0,255);
//FillRect(rect(iTop,iLeft,iWidth+iLeft,iHeight+iTop));
for i:=0 to Cols do
begin
iPerUnit:=strToInt(formatFloat('##0',iLeft+(i)*(iWidth/cols)));
moveTo(iPerUnit,iTop);
LineTo(iPerUnit,iHeight+iTop);
PointX[i+1]:=strToInt(formatFloat('##0',iLeft+(i)*(iWidth/cols)));
end;//for i
for i:=0 to Rows do
begin
iPerUnit1:=strToInt(formatFloat('##0',iTop+(i)*(iHeight/Rows)));
moveTo(iLeft,iPerUnit1);
LineTo(iwidth+iLeft,iPerUnit1);
PointY[i+1]:=strToInt(formatFloat('##0',iTop+(i)*(iHeight/Rows)));
end;//forirows
////存储表格的坐标//////////
brush.Color:=rgb(255,0,0);
pen.Color:=rgb(255,0,0);
//////取得数据库数据////////////
CurrentPath:=ExtractFilePath(paramstr(0));
//Ellipse(rect(PointX[1],PointY[1],PointX[1]+strToInt(formatFloat('##0',(iHeight/Rows))),PointY[1]+strToInt(formatFloat('##0',(iWidth/cols)))));
//brush.Color:=rgb(255,255,255);
for i:=1 to 6 do
begin
with DataM.ADOQuery1 do
begin
connectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+CurrentPath+'\sale.mdb;Persist Security Info=False';
close;
sql.Clear;
sql.Add('select * from CPdata Where sID=:sID');
parameters.ParamByName('sID').Value:=s_ID;
prepared;
open;
if RecordCount<>0 then
begin
FieldIndex:='R'+InttoStr(i);
R_CPData[1,i]:=FieldByName(FieldIndex).AsInteger;
end;//if
end;//with
end;///
for i:=1 to 6 do
begin
for j:=1 to 33 do
begin
if R_CPData[1,i]=j then
begin
case R_CPData[1,i] of
1..11:
Ellipse(rect(PointX[1],PointY[j],PointX[1]+strToInt(formatFloat('##0',(iHeight/Rows))),PointY[j]+strToInt(formatFloat('##0',(iWidth/cols)))));
12..22:
begin
x:=j-11;
Ellipse(rect(PointX[2],PointY[x],PointX[2]+strToInt(formatFloat('##0',(iHeight/Rows))),PointY[x]+strToInt(formatFloat('##0',(iWidth/cols)))));
end;
23..33:
begin
x:=j-22;
Ellipse(rect(PointX[3],PointY[x],PointX[3]+strToInt(formatFloat('##0',(iHeight/Rows))),PointY[x]+strToInt(formatFloat('##0',(iWidth/cols)))));
end;
end;
end;///if
end;//j
end;///fori
{
for i:=1 to 6 do
begin
showmessage(inttostr(R_CPData[1,i]));
end;//
}
///////取得数据库数据结束//////////////////////////
brush.Style:=Bsclear;
//pen.Color:=rgb(0,0,0);
for i:=1 to cols do
begin
for j:=1 to rows do
begin
textOut(PointX[i]+5,PointY[j]+5,inttostr(11*(i-1)+j));
end;
end;
//////画圆///////////
//Ellipse(PointX[4],PointY[4],PointX[4]+strToInt(formatFloat('##0',(iHeight/Rows))),PointY[4]+strToInt(formatFloat('##0',(iWidth/cols))));
end;///withcanvas
end;//with
end;//ifctrl
end;////过程结束
///////画第二行的表格////////
procedure DrawTableX1(ctrl:TControl;iTop,iLeft,Rows,Cols,iWidth,iHeight:integer;s_ID:string);
var
i:integer;
j:integer;
x:integer;
iPerUnit:integer;
iPerUnit1:integer;
CurrentPath:string;
R_CPData:Array[1..100,1..100] of integer;
FieldIndex:string;
R_ColTitle:Array[1..100,1..100] of string;
begin
if (ctrl is TPaintBox) then
begin
with TPaintBox(ctrl) do
begin
with Canvas do
begin
brush.Style:=BSSolid;
Brush.Color:=rgb(255,255,255);
Pen.Color:=rgb(0,0,255);
//FillRect(rect(iTop,iLeft,iWidth+iLeft,iHeight+iTop));
for i:=0 to Cols do
begin
iPerUnit:=strToInt(formatFloat('##0',iLeft+(i)*(iWidth/cols)));
moveTo(iPerUnit,iTop);
LineTo(iPerUnit,iHeight+iTop);
PointX[i+1]:=strToInt(formatFloat('##0',iLeft+(i)*(iWidth/cols)));
end;//for i
for i:=0 to Rows do
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -