D10szGerun/E03梭织坯布检验/U_SCPersonColor.pas
2026-10-24 15:05:39 +08:00

232 lines
6.1 KiB
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_SCPersonColor;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, DB, ADODB, StdCtrls;
type
TfrmSCPersonColor = class(TForm)
ScrollBox1: TScrollBox;
btn58: TSpeedButton;
btn9: TSpeedButton;
btn10: TSpeedButton;
btn11: TSpeedButton;
btn12: TSpeedButton;
btn59: TSpeedButton;
btn16: TSpeedButton;
btn17: TSpeedButton;
btn18: TSpeedButton;
btn19: TSpeedButton;
btn60: TSpeedButton;
btn23: TSpeedButton;
btn24: TSpeedButton;
btn25: TSpeedButton;
btn26: TSpeedButton;
btn61: TSpeedButton;
btn31: TSpeedButton;
btn32: TSpeedButton;
btn33: TSpeedButton;
ADOTmp: TADOQuery;
Label27: TLabel;
Label1: TLabel;
Button3: TButton;
Button1: TButton;
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure btn1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
CPage: Integer;
procedure InitPerson(page: Integer);
{ Private declarations }
public
FlagStr: string;
FName, FSJZL, FType: string;
{ Public declarations }
end;
var
frmSCPersonColor: TfrmSCPersonColor;
implementation
uses
U_DataLink;
{$R *.dfm}
procedure TfrmSCPersonColor.FormDestroy(Sender: TObject);
begin
frmSCPersonColor := nil;
end;
procedure TfrmSCPersonColor.InitPerson(page: Integer);
type
FdDy = record
inc: integer;
FDdys: string[32];
FdDysName: string[32];
end;
var
BB: array[0..500] of FdDy;
i, j: Integer;
begin
if ftype = '机台号' then
begin
end;
with ADOTmp do
begin
Close;
sql.Clear;
if ftype = '机台产品' then
//列出该机台绑定的产品(FlagStr传机台号),按钮Hint存产品编号
sql.Add('select AA.*,row_number () over (order by code) as keyNo from(select DISTINCT B.C_Code as code, B.C_Name as name from Bs_Machine A join Bs_Cloth_Info B on B.C_Code in (A.C_CodeName, A.C_CodeName2) where A.MCNO=' + QuotedStr(Trim(FlagStr)) + ')AA')
else if ftype = '机台合同' then
begin
//列出该机台绑定的合同(FlagStr传机台号),按钮显示"合同号+产品名",Hint存"合同号|产品编号"
sql.Add('select AA.*,row_number () over (order by code) as keyNo from(');
sql.Add('select DISTINCT A.m_ConNo as code, ISNULL(B.C_Name,'''') as name, A.C_CodeName as pcode from Bs_Machine A');
sql.Add(' left join Bs_Cloth_Info B on B.C_Code = A.C_CodeName');
sql.Add(' where A.MCNO=' + QuotedStr(Trim(FlagStr)) + ' and ISNULL(A.m_ConNo,'''')<>''''');
sql.Add(' union');
sql.Add(' select DISTINCT A.m_ConNo2 as code, ISNULL(C.C_Name,'''') as name, A.C_CodeName2 as pcode from Bs_Machine A');
sql.Add(' left join Bs_Cloth_Info C on C.C_Code = A.C_CodeName2');
sql.Add(' where A.MCNO=' + QuotedStr(Trim(FlagStr)) + ' and ISNULL(A.m_ConNo2,'''')<>''''');
sql.Add(')AA');
end
else
sql.Add('select AA.*,row_number () over (order by name) as keyNo from(select DISTINCT MCNO as name from Bs_Machine where ISNULL(Status,0)=5 )AA');
// showmessage(sql.text);
Open;
end;
if ADOTmp.IsEmpty then
begin
Application.MessageBox('没有定义数据!', '提示', 0);
Exit;
end;
j := (StrToInt(Label1.Caption) - 1) * 20 + 1;
for i := 0 to 19 do
begin
with ScrollBox1 do
begin
if ADOTmp.locate('keyNo', j + i, []) then
begin
// application.MessageBox(pchar(CDS_Kuang.FieldByName('ZDYName').AsString), '提示信息', 0);
TSpeedButton(Controls[i]).Visible := True;
if ftype = '机台产品' then
begin
TSpeedButton(Controls[i]).Caption := Trim(ADOTmp.FieldByName('name').AsString);
TSpeedButton(Controls[i]).Hint := Trim(ADOTmp.FieldByName('code').AsString);
end
else if ftype = '机台合同' then
begin
TSpeedButton(Controls[i]).Caption := Trim(ADOTmp.FieldByName('code').AsString) + #13 + Trim(ADOTmp.FieldByName('name').AsString);
TSpeedButton(Controls[i]).Hint := Trim(ADOTmp.FieldByName('code').AsString) + '|' + Trim(ADOTmp.FieldByName('pcode').AsString);
end
else
TSpeedButton(Controls[i]).Caption := Trim(ADOTmp.FieldByName('name').AsString);
end
else
begin
TSpeedButton(Controls[i]).Visible := False;
// application.MessageBox(pchar('没找到' + inttostr(i)), '提示信息', 0);
end;
end;
end;
// with ADOTmp do
// begin
// First;
// i := 0;
// while not Eof do
// begin
// BB[i].inc := i;
// BB[i].FdDysName := Trim(fieldbyname('name').AsString);
// i := i + 1;
// Next;
// end;
// end;
// i := i - 1;
// if i > 19 then
// begin
// i := 19;
// end;
// for j := 0 to 19 do
// begin
// with ScrollBox1 do
// begin
// TSpeedButton(Controls[j]).Visible := false;
// TSpeedButton(Controls[j]).Caption := '';
// TSpeedButton(Controls[j]).Hint := '';
// end;
// end;
// for j := 0 to i do
// begin
// with ScrollBox1 do
// begin
// TSpeedButton(Controls[j]).Visible := True;
// TSpeedButton(Controls[j]).Caption := BB[j].FdDysName;
// end;
// end;
end;
procedure TfrmSCPersonColor.FormShow(Sender: TObject);
begin
InitPerson(1);
CPage := 1;
end;
procedure TfrmSCPersonColor.btn1Click(Sender: TObject);
begin
//机台产品模式下按钮Hint存的是产品编号,其余模式返回按钮文字
if Trim(TSpeedButton(Sender).Hint) <> '' then
FName := Trim(TSpeedButton(Sender).Hint)
else
FName := Trim(TSpeedButton(Sender).Caption);
ModalResult := 1;
end;
procedure TfrmSCPersonColor.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caHide;
end;
procedure TfrmSCPersonColor.Button1Click(Sender: TObject);
begin
if CPage <= 1 then
begin
Label1.Caption := '1';
InitPerson(1);
end
else
begin
CPage := CPage - 1;
Label1.Caption := IntToStr(CPage);
InitPerson(CPage);
end;
end;
procedure TfrmSCPersonColor.Button3Click(Sender: TObject);
begin
CPage := CPage + 1;
Label1.Caption := IntToStr(CPage);
InitPerson(CPage);
end;
end.