RTFormwork/项目代码/RTBasicsV1/F05染色检验/DbPanel/.svn/text-base/JkPanel.pas.svn-base

1124 lines
37 KiB
Plaintext
Raw Normal View History

2024-07-07 09:35:27 +08:00
unit JkPanel;
interface
uses
Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,
ExtCtrls,dbctrls,stdctrls,db,ADODB,ComCtrls,Variants,Gauges,
SqlExpr,Grids,DBGrids,MovePanel,JKFootpanel,Buttons,dsr;
type
TEditorstyle = (TsMemo,Tscombox,Tsedit);
type
TJkPanel = class(TPanel)
private
{ Private declarations }
This_Jth :string; //<2F><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>
This_TaskOrder :string; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
FEditorstyle:Teditorstyle;
FLeft :Integer;
FTop :Integer;
maxTextLen :Integer;
maxLabelLen :Integer;
maxDgheight :Integer;
maxFootHeight :integer;
FTitleVisible :Boolean;
FEditorVisible :Boolean;
FDataReadOnly :Boolean;
FPageCount :Integer;
FPass_Grid :TDBGrid;
FP_Move :TMovePanel;
FP_Parent :TPanel;
ColorLabels :array of TLabel;
Co_Shapes :array of TShape;
Co_DllBtn :array of TSpeedButton;
Co_Panels :array of TPanel;
FPageControl: TPageControl; {<7B><>ҳ<EFBFBD>ؼ<EFBFBD>}
FTabSheets :array of TTabSheet;
ScrollBoxs :array of TScrollBox; {<7B><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD>}
Splitters :array of TSplitter; {<7B>ָ<EFBFBD><D6B8>ؼ<EFBFBD>}
FootPanels :array of TJKFootpanel; {Footҳ<74><D2B3>ʾ<EFBFBD>ؼ<EFBFBD>}
FLineHeight :Integer;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
MemoEditors :array of TMemo;
comEditors :array of TCombobox;
edEditors :array of Tedit;
DGLists :array of TDbGrid;
AdoLists :array of TadoDataset;
DsLists :array of TDataSource;
DGGlides :array of TDbGrid;
AdoGlides :TadoDataset;
DsGlides :TDataSource;
ProgressEditor :array of Tedit;
Labels :array of TLabel; //<2F>ֶα<D6B6><CEB1><EFBFBD><E2A3AC>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
ProgressBars :array of TGauge;
Shapes :array of TShape;
FDataSource :TDataSource; // <20><><EFBFBD><EFBFBD>Դ
FDataField_A :String; // DataField
FDataField_B :String; // DataField
FDataField_C :String; // DataField
FDataField_ColA :String; // DataField
FDataField_ColB :String; // DataField
Fcnnstr :String;
FPageSql :string;
FListSql :String;
FFootSql :string;
FGlideSql :String;
FCheJianFieldName :String;
FColumns :Integer; //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
tmpado :TadoDataset;
tmpDs :TDataSource;
TmpDgListIdx,TmpDgListCol:integer;
procedure FreeEditors; //<2F>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD>ڴ<EFBFBD>
procedure AKeyDown(Sender:TObject; var Key :Word; Shift:TShiftState);
procedure AKeyPress(Sender:TObject; var Key :Char);
procedure AProgressEditorChange(Sender :TObject);
//procedure inti_Grid(sender :TObject);
procedure LabelsClick(Sender: TObject);
procedure Co_DllBtnClick(Sender: TObject);
procedure AdolistsAfterScroll(DataSet: TDataSet);
procedure DGListsCellClick(Column: TColumn);
procedure DGListsDrawColumnCell(Sender: TObject;
const Rect: TRect;DataCol: Integer;
Column: TColumn;State: TGridDrawState);
procedure refreshFootpanel(Tag :integer);
procedure DGGlideDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
procedure FP_MovePanelDblClick(Sender: TObject);
procedure FootPanelDblclick(Sender: TObject);
//function comEditor(Index :Integer):TComboBox;
//function edEditor(Index :Integer):Tedit;
//function MemoEditor(Index :Integer) :TMemo;
protected
{ Protected declarations }
public
constructor Create(AOwner:TComponent); override;
// destructor Destroy; override;
procedure Setedit(Value :TEditorstyle);
procedure CreateEditors(var DS :TDataSource; cnnstr :String;
Const Defaultsheet :String = ''); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶε<D6B6><CEB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD>
procedure ClearHits(ItemIndex :Integer);
procedure AddHits(ItemIndex:Integer; Hits :array of string);
{ Public declarations }
published
property LimitLeft :Integer read FLeft write FLeft default 10;
property LimitTop :Integer read FTop write FTop default 10;
property Editorstyle :TEditorstyle read FEditorstyle write Setedit default TsMemo;
property EditorWidth :Integer read maxTextLen write maxTextLen default 100;
property TitleWidth :Integer read maxLabelLen write maxLabelLen default 100;
property DgHeight :Integer read maxDgheight write maxDgheight default 300;
property FootHeight :Integer read maxFootHeight write maxFootHeight default 200;
property TitleVisible :Boolean read FTitleVisible write FTitleVisible default True;
property EditorVisible :Boolean read FEditorVisible write FEditorVisible default True;
property DataReadOnly :Boolean read FDataReadOnly write FDataReadOnly; //default True;
property LineHeight :Integer read FLineHeight write FLineHeight default 15;
property DataSource :TDataSource read FDataSource write FDataSource; //<2F><><EFBFBD><EFBFBD>Դ
property DataField_ColA :String read FDataField_A write FDataField_ColA;
property DataField_ColB :String read FDataField_B write FDataField_ColB;
property DataField_Editor :String read FDataField_A write FDataField_A;
property DataField_Title :String read FDataField_B write FDataField_B;
property DataField_Progress :String read FDataField_C write FDataField_C;
property Data_PageSql :String read FPageSql write FPageSql;
property Data_DgListSql :String read FListSql write FListSql;
property Data_FootSql :String read FFootSql write FFootSql;
property Data_GlideSql :String read FGlideSql write FGlideSql;
property Data_CheJianField :String read FCheJianFieldName write FCheJianFieldName;
property Columns :Integer read FColumns write FColumns default 4;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{ Published declarations }
end;
procedure Register;
implementation
constructor TJkPanel.Create(AOwner :TComponent);
begin
Inherited Create(AOWner);
FLeft := 20;
FTop := 20;
maxTextLen := 250;
maxLabelLen := 250;
maxDgheight := 200;
maxFootHeight := 150;
FLineHeight := 15;
FTitleVisible := True;
FDataReadOnly := True;
end;
procedure TJkPanel.Setedit(Value :TEditorstyle);
begin
if FEditorstyle <> Value then
begin
FEditorstyle := Value;
Invalidate;
end;
end;
{ Ϊ<><CEAA>I<EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ϣ<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>}
procedure TJkPanel.AddHits(ItemIndex :Integer; Hits :array of string);
var
m,n,i :Integer;
begin
if FEditorstyle = Tscombox then
begin
n := Length(comEditors);
m := Length(Hits);
if ItemIndex< n then
for i:= 0 to m - 1 do
comEditors[ItemIndex].Items.Add(Hits[i]);
end
else if FEditorstyle = Tsedit then
begin
n := Length(edEditors);
m := Length(Hits);
if ItemIndex< n then
for i:=0 to m-1 do
edEditors[ItemIndex].Hint:= Hits[i];
end
else if FEditorstyle = TsMemo then
begin
n := Length(memoEditors);
m := Length(Hits);
if ItemIndex< n then
for i:=0 to m-1 do
memoEditors[ItemIndex].Hint:= Hits[i];
end;
end;
procedure TJkPanel.AKeyDown(Sender :TObject; var Key :Word; Shift :TShiftState);
begin
//
end;
procedure TJkPanel.AProgressEditorChange(Sender :TObject);
begin
//
end;
procedure TJkPanel.AKeyPress(Sender :TObject; var Key :Char);
begin
if (Sender is TComboBox) or (Sender is Tedit) or (Sender is TMemo) then
if Key=#13 then
(Owner as TForm).Perform(WM_NEXTDLGCTL, 0, 0);
end;
procedure TJkPanel.ClearHits(ItemIndex :Integer);
var
n :Integer;
begin
if FEditorstyle = Tscombox then
begin
n := Length(comEditors);
if ItemIndex< n then comEditors[ItemIndex].Items.Clear;
end
else if FEditorstyle = Tsedit then
begin
n := Length(edEditors);
if ItemIndex< n then edEditors[ItemIndex].Hint:='';;
end
else if FEditorstyle = TsMemo then
begin
n := Length(MemoEditors);
if ItemIndex< n then MemoEditors[ItemIndex].Hint:='';;
end;
end;
{ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶε<D6B6><CEB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC>ķ<EFBFBD><C4B7><EFBFBD>}
procedure TJkPanel.CreateEditors(var DS :TDataSource; cnnstr :String; Const Defaultsheet :String = '');
var
Tmp_CheJian,Tmp_Parm :String;
i,j,n,k,This_Index,TextHeight :Integer;
tmp_col0,Tmp_Row0,Tmp_Row1 :Integer;
XXX :TStringList;
kkk,RRR :array of integer;
DefaultIndex :Integer; //Ĭ<>ϳ<EFBFBD><CFB3><EFBFBD>
begin
if (Data_CheJianField = '') then exit;
{ <20>ͷ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD>ؼ<EFBFBD><D8BC>ڴ<EFBFBD>}
FreeEditors;
if DS = nil then exit;
if DataSource = nil then FDataSource := Ds;
if not DataSource.DataSet.Active then exit;
if (DataSource.DataSet is TAdoDataSet) = False then exit;
TmpDgListIdx := -1;
FPageCount := 0;
DefaultIndex := 0;
n := DataSource.DataSet.RecordCount;
if n <= 0 then exit;
DataSource.DataSet.DisableControls;
if TitleWidth < maxTextLen then
maxTextLen := TitleWidth;
{ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>}
DataSource.DataSet.First;
{ <20><><EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD>}
TextHeight := Canvas.TextHeight(DataSource.DataSet.Fields[0].DisplayLabel) + LineHeight; //10;
{ <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>}
SetLength(AdoLists,n);
SetLength(DsLists,n);
SetLength(DGLists,n);
SetLength(Labels,n);
SetLength(ColorLabels,n);
SetLength(ProgressEditor,n);
SetLength(Shapes,n);
{ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD>֪<EFBFBD>ؼ<EFBFBD> AdoGlides<65><73>DsGlides}
AdoGlides := TadoDataset.Create(owner);
DsGlides := TDatasource.Create(owner);
DsGlides.DataSet := AdoGlides;
if Columns = 0 then Columns := 6;
try
tmpado := TadoDataset.Create(Owner);
tmpDs := TDatasource.Create(Owner);
tmpDs.DataSet := tmpado;
with tmpado do
begin
Active := False;
Fcnnstr := cnnstr;
tmpado.ConnectionString := Fcnnstr;
tmpado.CommandText := Data_PageSql;
Active := True;
FPageCount := RecordCount;
if FPageCount = 0 then exit;
setlength(kkk,FPageCount);
for i := 0 to high(kkk) do
kkk[i] := -1;
SetLength(RRR,FPageCount);
for i := 0 to high(RRR) do
RRR[i] := 0;
first;
// <20><><EFBFBD><EFBFBD>PageControl
FPageControl := TPageControl.Create(Owner);
FPageControl.Parent := Self;
FPageControl.Font.Name := '<27><><EFBFBD><EFBFBD>';
FPageControl.Font.Size := 9;
FPageControl.Align := alClient;
FPageControl.Visible := False;
{ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>}
setlength(FTabSheets,FPageCount+1);
setlength(ScrollBoxs,FPageCount+1);
setlength(FootPanels,FPageCount+1);
setlength(Splitters,FPageCount+1);
setlength(Co_Shapes,FPageCount+1);
setlength(Co_DllBtn,FPageCount+1);
setlength(Co_Panels,FPageCount+1);
SetLength(DGGlides,FPageCount+1);
XXX := TStringList.Create();
for j := 0 to FPageCount do
begin
{ FPageControl<6F><6C>ҳ}
FTabSheets[j] := TTabSheet.Create(Owner);
FTabSheets[j].Parent := FPageControl;
FTabSheets[j].ParentFont := True;
FTabSheets[j].PageControl := FPageControl;
FTabSheets[j].Visible := True;
FTabSheets[j].PageIndex := j;
if j < FPageCount then
begin
Tmp_CheJian := trim(fieldByName(Data_CheJianField).AsString);
if Defaultsheet <> '' then //ָ<><D6B8>Ĭ<EFBFBD>ϳ<EFBFBD><CFB3><EFBFBD>
begin
if Tmp_CheJian = Defaultsheet then
DefaultIndex := j;
end;
FTabSheets[j].Caption := '<27><><EFBFBD>䣺' + Tmp_CheJian;
FTabSheets[j].Hint := Tmp_CheJian;
XXX.Append(Tmp_CheJian);
end
else
begin
Tmp_CheJian := '';
FTabSheets[j].Caption := 'δָ<CEB4><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
FTabSheets[j].Hint := Tmp_CheJian;
XXX.Append('δָ<CEB4><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
FTabSheets[j].ShowHint := False;
FTabSheets[j].Visible := True;
FTabSheets[j].Align := alClient;
//<2F><><EFBFBD><EFBFBD>Footҳ<74><D2B3>ʾ<EFBFBD>ؼ<EFBFBD>
FootPanels[j] := TJKFootpanel.Create(Owner);
with FootPanels[j] do
begin
Visible := True;
Parent := FTabSheets[j];
// BevelInner := bvLowered;
//BevelOuter := bvRaised;
Left := 0;
Width := 1;
Align := alRight;
Hint := FTabSheets[j].Hint;
ShowHint := False;
onDblclick := FootPanelDblclick;
LimitLeft := 8;
Ctl3D := False;
end;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ʾ<EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>
Co_Panels[j] := Tpanel.Create(Owner);
with Co_Panels[j] do
begin
Visible := True;
Parent := FootPanels[j];
BevelInner := bvLowered;
BevelOuter := bvRaised;
height := 40;
Co_Panels[j].BorderWidth := 2;
Align := alTop;
end;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ʾ<EFBFBD>ؼ<EFBFBD>
Co_Shapes[j] := TShape.Create(Owner);
with Co_Shapes[j] do
begin
Visible := True;
Parent := Co_Panels[j];
Width := FootHeight;
Align := alClient;
end;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť<EFBFBD>ؼ<EFBFBD>
Co_DllBtn[j] := TSpeedButton.Create(Owner);
with Co_DllBtn[j] do
begin
Visible := True;
Parent := FootPanels[j];
height := 25;
Tag := j;
Font.name := '<27><><EFBFBD><EFBFBD>';
Font.Size := 9;
Align := alTop;
Font.Color := ClBlue;
//Flat := true;
caption := '<27><><EFBFBD>̴<EFBFBD><CCB4><EFBFBD>';
OnClick := Co_DllBtnClick;
end;
{ <20><><EFBFBD><EFBFBD>DbGrid<69>ؼ<EFBFBD> DGGlides}
DGGlides[j]:= TDBGrid.Create(owner);
with DGGlides[j] do
begin
Visible := True;
Parent := FootPanels[j];
height := 110;
Align := alTop;
Tag := j;
Font.name := '<27><><EFBFBD><EFBFBD>';
Font.Size := 9;
ReadOnly := True;
Options := [dgEditing,dgMultiSelect]; //,dgRowLines,dgColumnResize,
FixedColor := clSkyBlue;
OnDrawColumnCell := DGGlideDrawColumnCell;
end;
//<2F><><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>ؼ<EFBFBD>
Splitters[j] := TSplitter.Create(Owner);
with Splitters[j] do
begin
Visible := True;
Parent := FTabSheets[j];
Width := 4;
Align := alRight;
end;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ScrollBoxs[j] := TScrollBox.Create(Owner);
with ScrollBoxs[j] do
begin
Visible := True;
Parent := FTabSheets[j];
Color := RGB(100,100,100);//clTeal;
Align := alClient;
Hint := FTabSheets[j].Hint;
ShowHint := False;
end;
next;
end;
end;
if FEditorstyle = Tscombox then
SetLength(comEditors,n)
else if FEditorstyle = Tsedit then
SetLength(edEditors,n)
else
SetLength(MemoEditors,n);
{ <20><><EFBFBD><EFBFBD><EFBFBD>༭}
for i := 0 to n - 1 do
begin
if DataSource.DataSet.Fieldbyname(Data_CheJianField).AsVariant = null then
This_Index := FPageCount
else
This_Index := XXX.IndexOf(trim(DataSource.DataSet.Fieldbyname(Data_CheJianField).Asstring));
if kkk[This_Index] >= Columns -1 then
begin
kkk[This_Index] := 0;
RRR[This_Index] := RRR[This_Index] +1;
end
else
kkk[This_Index] := kkk[This_Index] + 1;
tmp_col0 := kkk[This_Index];
tmp_Row0 := RRR[This_Index];
{ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD>֪<EFBFBD>ؼ<EFBFBD> AdoLists<74><73>DsLists}
AdoLists[i] := TadoDataset.Create(owner);
AdoLists[i].Tag := i;
AdoLists[i].AfterScroll:= AdolistsAfterScroll;
DsLists[i] := TDatasource.Create(owner);
DsLists[i].DataSet := AdoLists[i];
DsLists[i].Tag := i;
//DsLists[i].OnDataChange := DsListsDataChange;
{ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>}
Labels[i] := TLabel.Create(owner);
Labels[i].visible := FTitleVisible;
Labels[i].Parent := (ScrollBoxs[This_Index] as TScrollBox);
Labels[i].Font.Name := '<27><><EFBFBD><EFBFBD>';
Labels[i].Font.Size := 9;
Labels[i].Font.Color := ClBlue;
Labels[i].OnClick := LabelsClick;
Labels[i].Tag := i;
//Labels[i].Font.Style := [FsBold];
Labels[i].Transparent := True;
//<2F><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>
if DataSource.DataSet.Fieldbyname(DataField_Title).AsVariant <> null then
Labels[i].caption := DataSource.DataSet.Fieldbyname(DataField_Title).AsString
else
Labels[i].caption := '';
Tmp_CheJian := trim((ScrollBoxs[This_Index] as TScrollBox).Hint);
//<2F><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>
if DataSource.DataSet.Fieldbyname(DataField_ColA).AsVariant <> null then
Labels[i].Hint := trim(DataSource.DataSet.Fieldbyname(DataField_ColA).AsString)
else
Labels[i].Hint := '';
Labels[i].ShowHint := False;
if FEditorstyle = TsMemo then
begin
Labels[i].Top := FTop + tmp_Row0 * (TextHeight*3+DgHeight+5) + 2;
Labels[i].Left := FLeft + (TitleWidth + 20) * tmp_Col0 + 5;
Labels[i].Width := TitleWidth;
end
else
begin
Labels[i].Top := FTop + tmp_Row0 * (TextHeight*2+DgHeight+5) + 2;
Labels[i].Left := FLeft + (TitleWidth + 12) * tmp_Col0;
Labels[i].Width := TitleWidth;
end;
{ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ʾ<EFBFBD><CABE><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD>}
if FEditorstyle = Tscombox then
begin
comEditors[i] := TComboBox.Create(Owner);
comEditors[i].Parent := ScrollBoxs[This_Index]; //Self;
comEditors[i].Left := Labels[i].Left; //+ Labels[i].Width;
comEditors[i].Width := maxTextLen;
if FTitleVisible then
comEditors[i].Top := Labels[i].Top+14
else
comEditors[i].Top := Labels[i].Top;
if DataSource.DataSet.Fieldbyname(DataField_Editor).AsVariant <> null then
comEditors[i].Text := DataSource.DataSet.Fieldbyname(DataField_Editor).AsString;
comEditors[i].OnKeyPress := OnKeyPress;
comEditors[i].OnKeyDown := OnKeyDown;
comEditors[i].Visible := EditorVisible;
comEditors[i].Tag := i;
DGLists[i] := TDbGrid.Create(Owner);
DGLists[i].Parent := ScrollBoxs[This_Index];
DGLists[i].Font.name := '<27><><EFBFBD><EFBFBD>';
DGLists[i].Font.Size := 9;
DGLists[i].ReadOnly := True;
DGLists[i].FixedColor := clSkyBlue;
DGLists[i].Left := comEditors[i].Left;
DGLists[i].Width := comEditors[i].Width;
DGLists[i].Height := DgHeight;
DGLists[i].Options := [dgRowSelect];
if EditorVisible then
DGLists[i].Top := comEditors[i].Top+comEditors[i].height+2
else
DGLists[i].Top := comEditors[i].Top+2;
DGLists[i].Hint := trim(Labels[i].caption);
DGLists[i].ShowHint := False;
DGLists[i].OnDrawColumnCell := DGListsDrawColumnCell;
DGLists[i].OnCellClick := DGListsCellClick;
DGLists[i].Tag := i;
ColorLabels[i] := TLabel.Create(Owner);
ColorLabels[i].Parent := ScrollBoxs[This_Index];
ColorLabels[i].AutoSize := true;
ColorLabels[i].Font.name := '<27><><EFBFBD><EFBFBD>';
ColorLabels[i].Font.Size := 9;
ColorLabels[i].Top := Labels[i].top;
ColorLabels[i].Left := Labels[i].Left + round(Labels[i].Width/2)+20;
ColorLabels[i].Width := round(Labels[i].Width/2)-20;
ColorLabels[i].BringToFront;
ColorLabels[i].Tag := i;
ColorLabels[i].Font.Color := ClWhite;
ColorLabels[i].Color := RGB(100,100,100);
ColorLabels[i].Caption := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
end
else if FEditorstyle = Tsedit then
begin
edEditors[i] := Tedit.Create(Owner);
edEditors[i].Parent := ScrollBoxs[This_Index];
edEditors[i].Left := Labels[i].Left; //+ Labels[i].Width;
edEditors[i].Width := maxTextLen;
if FTitleVisible then
edEditors[i].Top := Labels[i].Top+14
else
edEditors[i].Top := Labels[i].Top;
edEditors[i].ReadOnly := DataReadOnly;
if DataSource.DataSet.Fieldbyname(DataField_Editor).AsVariant <> null then
edEditors[i].Text := DataSource.DataSet.Fieldbyname(DataField_Editor).AsString;
edEditors[i].OnKeyPress := OnKeyPress;
edEditors[i].OnKeyDown := OnKeyDown;
edEditors[i].Visible := EditorVisible;
DGLists[i] := TDbGrid.Create(Owner);
DGLists[i].Parent := ScrollBoxs[This_Index];
DGLists[i].Font.name := '<27><><EFBFBD><EFBFBD>';
DGLists[i].Font.Size := 9;
DGLists[i].ReadOnly := True;
DGLists[i].Options := [dgRowSelect];
DGLists[i].FixedColor := clSkyBlue;
DGLists[i].Left := edEditors[i].Left;
DGLists[i].Width := edEditors[i].Width;
DGLists[i].Height := DgHeight;
DGLists[i].Tag := i;
if EditorVisible then
DGLists[i].Top := edEditors[i].Top+edEditors[i].height+2
else
DGLists[i].Top := edEditors[i].Top+2;
DGLists[i].Hint := trim(Labels[i].caption);
DGLists[i].ShowHint := False;
DGLists[i].OnDrawColumnCell := DGListsDrawColumnCell;
DGLists[i].OnCellClick := DGListsCellClick;
DGLists[i].Tag := i;
ColorLabels[i] := TLabel.Create(Owner);
ColorLabels[i].Parent := ScrollBoxs[This_Index];
ColorLabels[i].AutoSize := False;
ColorLabels[i].Font.name := '<27><><EFBFBD><EFBFBD>';
ColorLabels[i].Font.Size := 9;
ColorLabels[i].Top := Labels[i].top;
ColorLabels[i].Left := Labels[i].Left + round(Labels[i].Width/2)+20;
ColorLabels[i].Width := round(Labels[i].Width/2)-20;
ColorLabels[i].BringToFront;
ColorLabels[i].Tag := i;
ColorLabels[i].Font.Color := ClWhite;
ColorLabels[i].Color := RGB(100,100,100);
ColorLabels[i].Caption := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
end
else
begin
MemoEditors[i] := Tmemo.Create(Owner);
MemoEditors[i].Parent := ScrollBoxs[This_Index];
MemoEditors[i].Left := Labels[i].Left;
MemoEditors[i].Width := maxTextLen;
if FTitleVisible then
MemoEditors[i].Top := Labels[i].Top+14
else
MemoEditors[i].Top := Labels[i].Top;
MemoEditors[i].Height := 60;
MemoEditors[i].ReadOnly := DataReadOnly;
if DataSource.DataSet.Fieldbyname(DataField_Editor).AsVariant <> null then
MemoEditors[i].Lines.Add(DataSource.DataSet.Fieldbyname(DataField_Editor).AsString);
MemoEditors[i].OnKeyPress := OnKeyPress;
MemoEditors[i].OnKeyDown := OnKeyDown;
MemoEditors[i].Visible := EditorVisible;
MemoEditors[i].Tag := i;
DGLists[i] := TDbGrid.Create(Owner);
DGLists[i].Parent := ScrollBoxs[This_Index];
DGLists[i].Font.name := '<27><><EFBFBD><EFBFBD>';
DGLists[i].Font.Size := 9;
DGLists[i].ReadOnly := True;
DGLists[i].FixedColor := clSkyBlue;
DGLists[i].Left := MemoEditors[i].Left;
DGLists[i].Width := MemoEditors[i].Width;
DGLists[i].Height := DgHeight;
DGLists[i].Options := [dgRowSelect];
if EditorVisible then
DGLists[i].Top := MemoEditors[i].Top+MemoEditors[i].height+2
else
DGLists[i].Top := MemoEditors[i].Top+2;
DGLists[i].Hint := trim(Labels[i].caption);
DGLists[i].ShowHint := False;
DGLists[i].OnDrawColumnCell := DGListsDrawColumnCell;
DGLists[i].OnCellClick := DGListsCellClick;
DGLists[i].Tag := i;
ColorLabels[i] := TLabel.Create(Owner);
ColorLabels[i].Parent := ScrollBoxs[This_Index];
ColorLabels[i].AutoSize := False;
ColorLabels[i].Font.name := '<27><><EFBFBD><EFBFBD>';
ColorLabels[i].Font.Size := 9;
ColorLabels[i].Left := DGLists[i].Left + DGLists[i].Width +1;
ColorLabels[i].Height := DGLists[i].Height + MemoEditors[i].Height;
ColorLabels[i].Top := DGLists[i].Top;
ColorLabels[i].Tag := i;
ColorLabels[i].Font.Color := ClWhite;
ColorLabels[i].Color := RGB(100,100,100);
ColorLabels[i].Caption := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
end;
Tmp_Parm := trim(DataSource.DataSet.Fieldbyname(DataField_Editor).Value);
with AdoLists[i] do
begin
DisableConTrols;
Active := False;
ConnectionString := Fcnnstr; //<2F><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>Ӵ<EFBFBD>
CursorType := ctStatic;
LockType := ltReadOnly;
CommandText := Data_DgListSql;
Parameters.ParamValues['ListParm'] := Tmp_Parm;
Active := True;
{
tmpSql := 'select a.AutoID,case a.MachMiss when ''0000000000'' then '
+ 'convert(varchar(20),f.GlideName) else convert(varchar(20),d.ShortName) end'
+ ' as ShortName,rtrim(b.MP_Crock) as MP_Crock,'
+ 'convert(varchar(20),c.ChnName) as ChnName,a.MachLen,'
+ 'convert(varchar(20),f.GlideName) as GlideName,'
+ 'a.MachMiss,a.TaskOrder,a.Status,'
+ 'c.RedCode,c.GreenCode,c.BlueCode'
+ ' from MD_Dev_Mission a '+#10#13
+ ' left join MD_PlanCrock b on b.mp_autocrk = left(a.MachMiss,10)'
+ ' left join Mc_color c on c.ColorId = b.MP_Color '
+ ' left join Mc_Glide f on f.GlideNo = a.MachGlide'+#10#13
+ ' left join BC_Customer d on d.customno = b.MP_Customno'+#10#13
+ ' where a.Status <> ''6'''
+ ' and a.Machine =:ListParm'+#10#13
+ ' order by a.Machine,a.TaskOrder';
}
for k := 0 to Fields.Count -1 do
Fields[k].Visible := False;
Fieldbyname('ShortName').Visible := True; //<2F>ӹ<EFBFBD><D3B9><EFBFBD>λ
Fieldbyname('MP_Crock').Visible := True; //<2F><><EFBFBD>Ǹ׺<C7B8>
Fieldbyname('ChnName').Visible := True; //<2F><>ɫ
Fieldbyname('MachLen').Visible := True; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Fieldbyname('GlideName').Visible := True; //<2F><><EFBFBD><EFBFBD>
DGLists[i].DataSource := DsLists[i];
EnableConTrols;
DGLists[i].Columns[0].width := 50;
DGLists[i].Columns[1].width := 30;
DGLists[i].Columns[2].width := 55;
DGLists[i].Columns[3].width := 45;
DGLists[i].Columns[4].width := 50;
//DGLists[i].Columns[0].Alignment := TaCenter;
//DGLists[i].Columns[1].Alignment := TaCenter;
//DGLists[i].Columns[2].Alignment := TaCenter;
//DGLists[i].Columns[3].Alignment := TaCenter;
//DGLists[i].Columns[4].Alignment := TaCenter;
First;
end;
Shapes[i] := TShape.Create(Owner);
Shapes[i].Parent := ScrollBoxs[This_Index];
Shapes[i].Left := Labels[i].Left - 5;
Shapes[i].top := Labels[i].Top - 5;
if FEditorstyle = TsMemo then
begin
Shapes[i].height := ColorLabels[i].height + Labels[i].height +20 +10;
Shapes[i].Width := (ColorLabels[i].left - Labels[i].left) + ColorLabels[i].Width + 10;
end
else
begin
Shapes[i].height := (DGLists[i].Top + DGLists[i].Height - Labels[i].Top)+ 10;
Shapes[i].Width := Labels[i].Width +10;
end;
Shapes[i].Brush.Color := clSkyBlue;
Shapes[i].Visible := True;
Shapes[i].SendToBack;
Shapes[i].Tag := i;
if not DataSource.DataSet.Eof then
DataSource.DataSet.next;
end;
DataSource.DataSet.EnableControls;
tmpado.Close;
XXX.Free;
if FPageControl.PageCount > 0 then
begin
FPageControl.ActivePageIndex := FPageControl.PageCount-1;
FPageControl.ActivePageIndex := DefaultIndex;
end;
Finally
FPageControl.Visible := True;
end;
end;
procedure TJkPanel.Co_DllBtnClick(Sender: TObject);
var
this_Gh :String;
k :Integer;
begin
if not CanLCCL then //<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB9A6>
begin
application.messagebox('<27>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD>Ŀǰ<C4BF><C7B0><EFBFBD><EFBFBD>û<EFBFBD>б<EFBFBD><D0B1><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܡ<EFBFBD>','<27><>Ϣ<EFBFBD><CFA2>ʾ',mb_ok or MB_ICONInformation);
Exit;
end;
k := (sender as TSpeedButton).Tag;
if not FootPanels[k].DataSource.dataset.active then exit;
if Co_DllBtn[k].Caption = '<27><><EFBFBD>̴<EFBFBD><CCB4><EFBFBD>' then
begin
if FootPanels[k].DataSource.dataset.FieldValues['<27>׺<EFBFBD>'] = null then exit;
this_Gh := FootPanels[k].DataSource.dataset.fieldbyname('<27>׺<EFBFBD>').AsString;
//ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD>̴<EFBFBD><CCB4><EFBFBD>
DoAbnormalC(TmpHandle,cnn_Base,V_UserId,V_User,this_Gh);
end
else
begin
//ִ<><D6B4>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if This_Jth <> '' then
DoRinseprt(TmpHandle,cnn_Base,V_UserId,V_User,This_Jth,This_TaskOrder);
end;
end;
procedure TJkPanel.DGListsDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
var
Redcode,GreenCode,BlueCode,TmpStatus :Integer;
begin
with (Sender as TdbGrid) do
begin
if DataSource = nil then exit;
if not DataSource.DataSet.Active then exit;
Redcode := (DataSource.DataSet as TAdoDataset).fieldByName('Redcode').AsInteger;
Greencode := (DataSource.DataSet as TAdoDataset).fieldByName('Greencode').AsInteger;
Bluecode := (DataSource.DataSet as TAdoDataset).fieldByName('Bluecode').AsInteger;
TmpStatus := (DataSource.DataSet as TAdoDataset).fieldByName('Status').AsInteger;
if gdFocused in State then
begin
Canvas.Brush.Color := clblack;
Canvas.Font.Color := Clred;
end
else if TmpStatus = 5 then
begin
Canvas.Font.Color := clBlue;
Canvas.Brush.Color := clWhite;
Canvas.Font.Style := [fsBold]; //fsItalic
ColorLabels[(Sender as TDbGrid).Tag].Color := RGB(Redcode,Greencode,Bluecode);
if (Redcode <=10) or (Bluecode <=10) or (Greencode <=10) then
ColorLabels[(Sender as TDbGrid).Tag].Font.Color := ClWhite
else
ColorLabels[(Sender as TDbGrid).Tag].Font.Color := ClBlack;
ColorLabels[(Sender as TDbGrid).Tag].Caption := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
end
else if (Redcode <=100) or (Greencode <=100) then
begin
Canvas.Font.Color := ClWhite;
Canvas.Brush.Color := RGB(Redcode,Greencode,Bluecode);
end
else
begin
Canvas.Font.Color := ClBlack;
Canvas.Brush.Color := RGB(Redcode,Greencode,Bluecode);
end;
DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
end;
procedure TJkPanel.DGGlideDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
with (Sender as TDbGrid) do
begin
if DataSource = nil then exit;
if not DataSource.DataSet.Active then exit;
if gdFocused in State then exit;
if (Sender as TDbGrid).SelectedRows.CurrentRowSelected then
begin
Canvas.Brush.Color := clHighlight;
Canvas.Font.Color := ClWhite;
end
else if DataSource.DataSet.RecNo mod 2 = 0 then
begin
Canvas.Brush.Color := $00DEDEDE;
Canvas.Font.Color := ClBlack;
end
else
begin
Canvas.Brush.Color := clwhite;
Canvas.Font.Color := ClBlack;
end;
DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
end;
procedure TJkPanel.refreshFootpanel(Tag :integer);
var
i,Listindex,PageIndex :integer;
R,G,B :Integer;
tmpCarN0 :String;
TmpMachMiss :String; //<2F><><EFBFBD>׺<EFBFBD>
begin
try
PageIndex := FPageControl.ActivePageIndex;
Listindex := Tag;
if AdoLists[Listindex].RecordCount = 0 then
begin
FootPanels[PageIndex].DataSource := Nil;
exit;
end;
//<2F><>ȡ<EFBFBD><C8A1>̨<EFBFBD><CCA8>
This_Jth := Labels[Listindex].Hint;
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
This_TaskOrder := trim(AdoLists[Listindex].FieldByName('TaskOrder').AsString);
TmpMachMiss := trim(AdoLists[Listindex].FieldByName('MachMiss').AsString);
if TmpMachMiss = '0000000000' then
Co_DllBtn[PageIndex].Caption := 'ϴ<><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
else
Co_DllBtn[PageIndex].Caption := '<27><><EFBFBD>̴<EFBFBD><CCB4><EFBFBD>';
with tmpado do
begin
DisableConTrols;
Active := False;
ConnectionString := Fcnnstr;
CursorType := ctStatic;
LockType := ltReadOnly;
CommandText := Data_FootSql;
Parameters.ParamValues['FootParm'] := AdoLists[Listindex].Fields[0].Value;
Active := True;
for i := 0 to fieldCount -1 do
tmpado.Fields[i].Alignment := taLeftJustify;
tmpDs.dataset := tmpado;
EnableConTrols;
end;
with adoGlides do
begin
DisableConTrols;
Active := False;
ConnectionString := Fcnnstr;
CursorType := ctStatic;
LockType := ltReadOnly;
CommandText := Data_GlideSql;
if AdoLists[Listindex].Fieldbyname('MachMiss').AsString <> null then
begin
tmpCarN0 := trim(AdoLists[Listindex].Fieldbyname('MachMiss').AsString);
tmpCarN0 := Copy(tmpCarN0,1,10);
end
else
tmpCarN0 := '////';
Parameters.ParamValues['PCarNo'] := tmpCarN0;
Active := True;
First;
EnableConTrols;
end;
DGGlides[PageIndex].DataSource := DsGlides;
DGGlides[PageIndex].Columns[0].Width := 74;
DGGlides[PageIndex].Columns[1].Width := 40;
FootPanels[PageIndex].Width := 140;
FootPanels[PageIndex].Columns := 1;
FootPanels[PageIndex].DataSource := tmpDs;
FootPanels[PageIndex].CreateEditors(tmpDs,1);
R := 255; G:= 255; B := 255;
R := AdoLists[Listindex].Fieldbyname('RedCode').AsInteger;
G := AdoLists[Listindex].Fieldbyname('GreenCode').AsInteger;
B := AdoLists[Listindex].Fieldbyname('BlueCode').AsInteger;
Co_Shapes[PageIndex].Brush.Color := RGB(R,G,B);
except
//
end;
end;
procedure TJkPanel.DGListsCellClick(Column: TColumn);
var
tmpIdx,TmpCol,TmpTag :Integer;
begin
if not Column.Grid.DataSource.DataSet.Active then exit;
if Column.Grid.DataSource.DataSet.RecordCount = 0 then exit;
if Column.Grid.DataSource.DataSet.RecNo = 1 then
begin
tmpIdx := (Column.Grid as TCustomDbGrid).ComponentIndex;
TmpCol := Column.Index;
if TmpDgListIdx = -1 then
begin
TmpDgListIdx := tmpIdx;
TmpDgListCol := TmpCol;
refreshFootpanel((Column.Grid as TCustomDbGrid).DataSource.DataSet.Tag);
end
else
begin
if TmpDgListIdx <> tmpIdx then
refreshFootpanel((Column.Grid as TCustomDbGrid).DataSource.DataSet.Tag);
TmpDgListIdx := tmpIdx;
TmpDgListCol := TmpCol;
end;
(Column.Grid as TCustomDbGrid).SetFocus;
end
end;
procedure TJkPanel.AdolistsAfterScroll(DataSet: TDataSet);
begin
//ˢ<><CBA2> Footpanel
refreshFootpanel(DataSet.tag);
end;
//<2F><>ӦLabels[i]<5D><>Click<63>¼<EFBFBD>
procedure TJkPanel.LabelsClick(Sender: TObject);
begin
//
end;
{
procedure TJkPanel.LabelsClick(Sender: TObject);
var
i :integer;
Tmp_CheJian,Tmp_JiTai :String;
begin
try
if FP_Parent = nil then inti_Grid(Sender);
if FP_Parent = nil then exit;
Tmp_JiTai := trim((Sender as Tlabel).Caption);
Tmp_CheJian := trim(((Sender as Tlabel).Parent as TScrollBox).Hint);
if tmpado.Active then
begin
if tmpado.FieldValues['<27><>̨'] <> null then
if tmpado.FieldByName('<27><>̨').AsString = Tmp_JiTai then
exit;
end;
screen.Cursor := crSQLWait;
//FP_Parent.Visible := False;
//FP_Parent.Left := FPageControl.Left + (Sender as Tlabel).Left + (Sender as Tlabel).Width + 28;
//FP_Parent.Top := FPageControl.Top + (Sender as Tlabel).top + (Sender as Tlabel).Height +4;
FP_Move.Caption := trim((Sender as Tlabel).Hint) + '<27><>ϸ<EFBFBD>б<EFBFBD>';
with tmpado do
begin
DisableConTrols;
Active := False;
ConnectionString := Fcnnstr;
tmpado.CursorType := ctStatic;
tmpado.LockType := ltReadOnly;
CommandText := 'Exec '+Data_BerthListSql+' '''+Tmp_CheJian+''','''+Tmp_JiTai+'''';
Active := True;
First;
EnableConTrols;
for i := 0 to Fields.Count -1 do
begin
Fields[i].Alignment := taCenter;
if i = 0 then
fields[i].DisplayWidth := 20
else
fields[i].DisplayWidth := 8;
Fpass_Grid.Columns[i].Title.Alignment := taCenter;
Fpass_Grid.Columns[i].Title.Font.Style:= [];
end;
end;
screen.Cursor := crDefault;
FP_Parent.Visible := True;
except
screen.Cursor := crDefault;
end;
end;
}
procedure TJkPanel.FootPanelDblclick(Sender: TObject);
begin
if sender is TScrollBox then
(sender as TScrollBox).Parent.width := 1;
end;
procedure TJkPanel.FP_MovePanelDblClick(Sender: TObject);
begin
FP_Parent.Visible := False;
end;
//Register<65>ؼ<EFBFBD>
procedure Register;
begin
RegisterComponents('Data Controls', [TJkPanel]);
end;
// <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>Ҫ<EFBFBD><D2AA>˳<EFBFBD><CBB3><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E0B7B4>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD>и<EFBFBD><D0B8>ӹ<EFBFBD>ϵʱ
procedure TJkPanel.FreeEditors;
begin
if FPageControl <> nil then
begin
if FP_Parent <> nil then
begin
try
FPass_Grid.Free;
FP_Move.Free;
FP_Parent.Free;
except
//
end;
end;
DGGlides := nil;
DsGlides := nil;
AdoGlides := nil;
DsGlides.Free;
AdoGlides.Free;
DGLists := nil;
DsLists := nil;
AdoLists := nil;
FPass_Grid := nil;
FP_Move := nil;
FP_Parent := nil;
Shapes := nil;
ProgressBars := nil;
comEditors := nil;
edEditors := nil;
MemoEditors := nil;
ScrollBoxs := nil;
Splitters := nil;
Co_Shapes:= nil;
Co_DllBtn := Nil;
Co_Panels:= nil;
FootPanels := nil;
tmpDs.Free;
tmpado.Free;
FPageControl.Free;
end;
end;
end.