📄 unit5.pas
字号:
Image1.Canvas.CopyRect(Rect(493,3+27*endy,506,19+27*endy),Image2.Canvas,Rect(493,138,506,154));
Image1.Canvas.Rectangle(endx,8+endy*27,493,16+endy*27);
Image1.Canvas.Rectangle(99,8+(endy+1)*27,buf,16+(endy+1)*27);
for p:=1 to (j2 div 10000)-endy-1 do
begin
Image1.Canvas.CopyRect(Rect(84,3+27*(endy+p+1),99,19+27*(endy+p+1)),Image2.Canvas,Rect(84,138,99,154));
Image1.Canvas.CopyRect(Rect(493,3+27*(endy+p),506,19+27*(endy+p)),Image2.Canvas,Rect(493,138,506,154));
Image1.Canvas.Rectangle(buf,8+(endy+p)*27,493,16+(endy+p)*27);
Image1.Canvas.Rectangle(99,8+(endy+p+1)*27,buf,16+(endy+p+1)*27);
end;
Image1.Canvas.Pen.Color:=clBlue;
Image1.Canvas.Pen.Mode :=pmNotXor;
end;
nowx:=493;
end;
if(kong=1) then nowx:=startx;
endy:=j2 div 10000;
end
else
begin
Image1.Canvas.Pen.Mode :=pmCopy;
Image1.Canvas.Pen.Color:=clWhite;
Image1.Canvas.Brush.Color:=clWhite;
Image1.Canvas.Brush.Style :=bsSolid;
Image1.Canvas.Rectangle(nowx,8+endy*27,endx,16+endy*27);
Image1.Canvas.Pen.Color:=clBlue;
Image1.Canvas.Pen.Mode :=pmNotXor;
if nowx<buf then
Image1.Canvas.CopyRect(Rect(nowx,8+endy*27,buf,16+endy*27),Image2.Canvas,Rect(198,64,361,72))
else
Image1.Canvas.CopyRect(Rect(buf,8+endy*27,nowx,16+endy*27),Image2.Canvas,Rect(198,64,361,72));
end;
endx:=buf;
end
//拖拽鼠标----------------------
else
begin
k:=99;
for i:=0 to cycl*p_unit-1 do
if (Y>(8+i*27))and (Y<(16+i*27)) then
k:=i;
i2:=(X-98)*24 div (492-98);
j2:=(X-98-(i2*(492-98) div 24));
j2:=j2*60*24 div (492-98);
j2:=k*10000+i2*100+j2;
i:=Length(timedata) div 12;
for k:=0 to i-1 do
begin
bufs:=Copy(timedata,k*12+1,12);
bufe:=bufs;
Delete(bufs,7,6);
Delete(bufe,1,6);
i1:=StrToInt(bufs);
j1:=StrToInt(bufe);
if (j2<=(j1+15))and(j2>=i1-15) then
okdown:=false;
if(j2>i1-10)and(j2<i1+10) then
begin
nowtime:=k;
Image1.Cursor :=crSizeWE;
cl:=true;
cr:=false;
ig:=i1 div 10000;
temps:=IntToStr(i1+1000000);
Delete(temps,1,3);
jg:=StrToInt(temps) div 100;
temps:=IntToStr(i1+1000000);
Delete(temps,1,5);
kg:=StrToInt(temps);
jg:=jg*(492-98) div 24+kg*(492-98)div 24 div 60+98;
endx:=jg+1;
endy:=ig;
okdown:=true;
ig:=j1 div 10000;
temps:=IntToStr(j1+1000000);
Delete(temps,1,3);
jg:=StrToInt(temps) div 100;
temps:=IntToStr(j1+1000000);
Delete(temps,1,5);
kg:=StrToInt(temps);
jg:=jg*(492-98) div 24+kg*(492-98)div 24 div 60+98;
startx:=jg+1;
starty:=ig;
end;
if (j2>j1-10)and(j2<j1+10) then
begin
nowtime:=k;
Image1.Cursor :=crSizeWE;
cr:=true;
cl:=false;
ig:=i1 div 10000;
temps:=IntToStr(i1+1000000);
Delete(temps,1,3);
jg:=StrToInt(temps)div 100;
temps:=IntToStr(i1+1000000);
Delete(temps,1,5);
kg:=StrToInt(temps);
jg:=jg*(492-98)div 24+kg*(492-98)div 24 div 60+98;
startx:=jg+1;
starty:=ig;
okdown:=true;
ig:=j1 div 10000;
temps:=IntToStr(j1+1000000);
Delete(temps,1,3);
jg:=StrToInt(temps)div 100;
temps:=IntToStr(j1+1000000);
Delete(temps,1,5);
kg:=StrToInt(temps);
jg:=jg*(492-98)div 24+kg*(492-98)div 24 div 60+98;
endx:=jg+1;
endy:=ig;
end;
end;
end;
end;
procedure Tfbanci.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
bufstr,bufstr1:String;
i1,i2,j1,j2,k:integer;
bufjs,bufstrs:String;
begin
if startdraw then
begin
i1:=(startx-98)*24 div (492-98);
j1:=(startx-98-(i1*(492-98)div 24));
j1:=j1*60*24 div (492-98);
if(j1>0)and(j1<=10) then
j1:=0;
if(j1>=54)and(i1<>23) then
begin
i1:=i1+1;
j1:=0;
end;
if ((i1=23)and(j1>=57))or(i1=24) then
begin
i1:=23;
j1:=59;
end;
j1:=(starty+100)*10000+i1*100+j1;
i2:=(endx-98)*24 div (492-98);
j2:=(endx-98-(i2*(492-98)div 24));
j2:=j2*60*24 div (492-98);
if(j2>0)and(j2<=10) then
j2:=0;
if(j2>=54)and(i2<>23) then
begin
j2:=0;
i2:=i2+1;
end;
if ((i2=23)and(j2>=57))or(i2=24) then
begin
i2:=23;
j2:=59;
end;
j2:=(endy+100)*10000+i2*100+j2;
if((j1-j2)>50)or((j1-j2)<-50) then
begin
bufstr:='';
bufstr1:='';
if j2>j1 then
begin
bufstr:=IntToStr(j1);
Delete(bufstr,1,1);
bufstr1:=bufstr ;
bufstr:=IntToStr(j2);
Delete(bufstr,1,1);
bufstr:=bufstr1+bufstr ;
end
else
begin
bufstr:=IntToStr(j2);
Delete(bufstr,1,1);
bufstr1:=bufstr ;
bufstr:=IntToStr(j1);
Delete(bufstr,1,1);
bufstr:=bufstr1+bufstr;
end;
Delete(timedata,12*nowtime+1,12);
bufstrs:=Copy(bufstr,1,6);
k:=0;
for i1:=0 to (Length(timedata) div 12)-1 do
begin
bufjs:=Copy(timedata,i1*12+7,6);
if StrToInt(bufstrs)>StrToInt(bufjs) then
k:=i1+1;
end;
Insert(bufstr,timedata,k*12+1);
end
else
begin
Delete(timedata,12*nowtime+1,12);
end;
startdraw:=false;
Displaybc;
banci.Edit;
banci.FieldByName('banci_time').AsString:=timedata;
banci.Post;
end;
end;
procedure Tfbanci.displaybc;
var
i,k,i1,j1,m,ig,jg,kg:integer;
bufs,bufe:AnsiString;
const
bili=512;
begin
tmpbmp.Width:=bili;
tmpbmp.Height:=27*cycl*p_unit;
for i:=0 to cycl*p_unit-1 do begin
tmpbmp.Canvas.CopyRect(Rect(0,27*i,bili,27*(i+1)),Image2.Canvas,Rect(0,135,bili,162));
end;
tmpbmp.Canvas.Pen.Mode:=pmCopy;
tmpbmp.Canvas.Pen.Color:=clBtnShadow;
tmpbmp.Canvas.Pen.Width :=1;
tmpbmp.Canvas.MoveTo(0,27*i-1);
tmpbmp.Canvas.LineTo(bili,27*i-1);
tmpbmp.Canvas.Font.Name:='宋体';
tmpbmp.Canvas.Font.Size:=10;
for i:=0 to cycl-1 do
begin
if p_unit=1 then
tmpbmp.Canvas.TextOut(14,6+27*i,'第 '+IntToStr(i+1)+' 天');
if p_unit=7 then
begin
tmpbmp.Canvas.TextOut(16,6+27*i*7,'星期日');
tmpbmp.Canvas.TextOut(16,6+27*(i*7+1),'星期一');
tmpbmp.Canvas.TextOut(16,6+27*(i*7+2),'星期二');
tmpbmp.Canvas.TextOut(16,6+27*(i*7+3),'星期三');
tmpbmp.Canvas.TextOut(16,6+27*(i*7+4),'星期四');
tmpbmp.Canvas.TextOut(16,6+27*(i*7+5),'星期五');
tmpbmp.Canvas.TextOut(16,6+27*(i*7+6),'星期六');
end;
end;
i:=Length(timedata) div 12;
for k:=0 to i-1 do
begin
bufs:=Copy(timedata,k*12+1,12);
ig:=StrToInt(Copy(bufs,1,2));
jg:=StrToint(Copy(bufs,3,2));
kg:=StrToint(Copy(bufs,5,2));
jg:=jg*(492-98)div 24+kg*(492-98) div 24 div 60+98;
endx:=jg+1;
endy:=ig;
ig:=StrToInt(Copy(bufs,7,2));
jg:=StrToInt(Copy(bufs,9,2));
kg:=StrToInt(Copy(bufs,11,2));
jg:=jg*(492-98) div 24+kg*(492-98)div 24 div 60+98;
startx:=jg+1;
starty:=ig;
h_time:=Copy(bufs,3,2)+':'+Copy(bufs,5,2)+'-'+COpy(bufs,9,2)+':'+COpy(bufs,11,2);
//如为同一天
if(starty=endy) then
tmpbmp.Canvas.CopyRect(Rect(endx,8+endy*27,startx,16+endy*27),Image2.Canvas,Rect(198,64,361,72))
else
begin
tmpbmp.Canvas.CopyRect(Rect(493,8+endy*27,endx,16+endy*27),Image2.Canvas,Rect(198,64,361,72));
tmpbmp.Canvas.CopyRect(Rect(493,3+27*(endy),506,19+27*(endy)),Image2.Canvas,Rect(493,8,506,24));
tmpbmp.Canvas.CopyRect(Rect(startx,8+starty*27,99,16+starty*27),Image2.Canvas,Rect(198,64,361,72));
tmpbmp.Canvas.CopyRect(Rect(84,3+27*(starty),99,19+27*(starty)),Image2.Canvas,Rect(84,8,99,24));
for m:=1 to starty-endy-1 do
begin
tmpbmp.Canvas.CopyRect(Rect(84,3+27*(endy+m),99,19+27*(endy+m)),Image2.Canvas,Rect(84,8,99,24));
tmpbmp.Canvas.CopyRect(Rect(493,3+27*(endy+m),506,19+27*(endy+m)),Image2.Canvas,Rect(493,8,506,24));
tmpbmp.Canvas.CopyRect(Rect(493,7+(endy+m)*27,99,16+(endy+m)*27),Image2.Canvas,Rect(198,64,361,72));
end;
end;
tmpbmp.Canvas.Brush.Style:=bsClear;
tmpbmp.Canvas.Font.Name:='Arial';
tmpbmp.Canvas.Font.Size :=7;
tmpbmp.Canvas.TextOut(endx+2,6+endy*27,h_time);
tmpbmp.Canvas.Brush.Style:=bsSolid;
end;
Image1.Picture.Graphic:=tmpbmp;
end;
procedure Tfbanci.BitBtn1Click(Sender: TObject);
begin
if banci.Active=false then
exit;
Image1.Visible:=false;
banci.Append;
DBEdit1.SetFocus;
BitBtn1.Enabled:=false;
timedata:='';
end;
procedure Tfbanci.BitBtn2Click(Sender: TObject);
begin
if banci.Active=false then
exit;
if DBEdit1.Text='' then
begin
MessageBox(0,'班次名称不能为空','警告',MB_OK);
exit;
end;
try
banci.Edit;
banci.Post;
except
MessageBox(0,'班次名称不能为空','警告',MB_OK);
exit;
end;
BitBtn1.Enabled:=true;
end;
procedure Tfbanci.BitBtn4Click(Sender: TObject);
begin
Close;
end;
procedure Tfbanci.BitBtn3Click(Sender: TObject);
begin
if banci.Active=false then
exit;
if MessageBox(0,'确认删除班次吗?','提示',MB_OK)<>IDOK then
exit;
if banci.RecordCount>0 then
banci.Delete;
BitBtn1.Enabled:=true;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -