D10szGerun/E03梭织坯布检验/U_SCPersonColor3.pas
2026-09-11 17:23:39 +08:00

461 lines
11 KiB
ObjectPascal
Raw Permalink 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_SCPersonColor3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, DB, ADODB, StdCtrls, cxGraphics, cxControls, cxLookAndFeels,
cxLookAndFeelPainters, cxContainer, cxEdit, dxSkinsCore,
dxSkinsDefaultPainters, cxTextEdit, Vcl.Touch.Keyboard, Vcl.ExtCtrls,
dxSkinWXI;
type
TfrmSCPersonColor3 = 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;
c_name: TcxTextEdit;
TouchKeyboard1: TTouchKeyboard;
Button2: TButton;
Button4: TButton;
Panel1: TPanel;
bb1: TButton;
MF: TcxTextEdit;
Label2: TLabel;
KZ: TcxTextEdit;
Label3: TLabel;
Button5: TButton;
NAME2: TcxTextEdit;
Label4: TLabel;
CODE: TcxTextEdit;
Label5: TLabel;
ADOQuery1: TADOQuery;
ADOCmd: TADOQuery;
Button6: TButton;
Timer1: TTimer;
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);
procedure c_namePropertiesChange(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure bb1Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure btn58MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure btn58MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure btn58MouseLeave(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
CPage: Integer;
FMouseDown: Boolean; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EAB0B4>
FDownTick: Cardinal; // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> GetTickCount
FPressedBtn: TSpeedButton;
procedure InitPerson(page: Integer);
function SaveData(): Boolean;
{ Private declarations }
public
FlagStr: string;
FName, FSJZL, FType: string;
{ Public declarations }
end;
var
frmSCPersonColor3: TfrmSCPersonColor3;
implementation
uses
U_DataLink, U_RTFun;
{$R *.dfm}
procedure TfrmSCPersonColor3.FormDestroy(Sender: TObject);
begin
frmSCPersonColor3 := nil;
end;
procedure TfrmSCPersonColor3.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 = '<27><>̨<EFBFBD><CCA8>' then
begin
end;
with ADOTmp do
begin
Close;
sql.Clear;
sql.Add('select AA.*,row_number () over (order by code) as keyNo from(select DISTINCT C_CODE as code from Bs_CLOTH_INFO ');
//sql.Add('select AA.*,row_number () over (order by name) as keyNo from(select DISTINCT C_NAME as name from Bs_CLOTH_INFO ');
if C_NAME.Text <> '' then
begin
//SQL.Add(' WHERE C_NAME LIKE ' + QUOTEDSTR('%' + C_NAME.Text + '%'));
SQL.Add(' WHERE C_CODE LIKE ' + QUOTEDSTR('%' + C_NAME.Text + '%'));
end;
SQL.Add(')AA');
// showmessage(sql.text);
Open;
end;
if ADOTmp.IsEmpty then
begin
Application.MessageBox(<>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>', '<27><>ʾ', 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), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
TSpeedButton(Controls[i]).Visible := True;
//TSpeedButton(Controls[i]).Caption := Trim(ADOTmp.FieldByName('name').AsString);
TSpeedButton(Controls[i]).Caption := Trim(ADOTmp.FieldByName('CODE').AsString);
end
else
begin
TSpeedButton(Controls[i]).Visible := False;
// application.MessageBox(pchar('û<>ҵ<EFBFBD>' + inttostr(i)), '<27><>ʾ<EFBFBD><CABE>Ϣ', 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;
function TfrmSCPersonColor3.SaveData(): Boolean;
var
MaxBCIID, MaxBCPID: string;
begin
try
ADOCmd.Connection.BeginTrans;
//////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //////////////////////
if GetLSNo(ADOCmd, MaxBCIID, 'Y', 'BS_Cloth_Info', 4, 1) = False then
begin
Result := False;
ADOCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
// BCIID.Text := trim(MaxBCIID);
with ADOCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from BS_Cloth_Info where 1<>1');
Open;
end;
with ADOCmd do
begin
Append;
FieldByName('CTID').Value := Trim('CT2606060001');
FieldByName('FILLID').Value := Trim(DCode);
FieldByName('FILLER').Value := Trim(DName);
FieldByName('FILLTIME').Value := SGetServerDateTime(ADOTMP);
FieldByName('BCIID').Value := Trim(MaxBCIID);
FieldByName('C_CODE').Value := Trim(CODE.Text);
FieldByName('C_NAME').Value := Trim(NAME2.Text);
FieldByName('C_Width').Value := Trim(MF.Text);
FieldByName('C_GramWeight').Value := Trim(KZ.Text);
if trim(Code.Text) = '' then
Code.Text := Trim(MaxBCIID);
// RTSetsavedata(ADOQueryCmd, 'BS_Cloth_Info', ScrollBox1, 2);
Post;
end;
with ADOTmp do
begin
Close;
sql.Clear;
sql.Add('select count(*) as AA from BS_Cloth_Info where C_NAME=''' + Trim(NAME2.Text) + '''');
Open;
if FieldByName('AA').AsInteger > 1 then
begin
ADOCmd.Connection.RollbackTrans;
Result := False;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
end;
//////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //////////////////////
///
///
///
ADOCmd.Connection.CommitTrans;
Result := True;
except
Result := False;
ADOCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
end;
end;
procedure TfrmSCPersonColor3.Timer1Timer(Sender: TObject);
const
LONG_PRESS_MS = 1000;
var
elapse: Cardinal;
sCap: string;
begin
if not FMouseDown then
Exit;
elapse := GetTickCount - FDownTick;
if elapse >= LONG_PRESS_MS then
begin
Timer1.Enabled := False; //ֻ<><D6BB><EFBFBD><EFBFBD>һ<EFBFBD>γ<EFBFBD><CEB3><EFBFBD>
sCap := Trim(FPressedBtn.Caption);
// <20><><EFBFBD><EFBFBD>ǰ<EFBFBD>Ȱ<EFBFBD>״̬<D7B4><CCAC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>ֹģ̬<C4A3><CCAC>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
FMouseDown := False;
FPressedBtn := nil;
if Application.MessageBox(PChar(<><C8B7>Ҫɾ<D2AA><C9BE>' + sCap), '<27><>ʾ', MB_ICONINFORMATION + MB_YESNO) = IDYES then
begin
// ========== <20><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>ҵ<EFBFBD><D2B5>д<EFBFBD><D0B4><EFBFBD><EFBFBD> ==========
with ADOCmd do
begin
Close;
Sql.Clear;
//sql.Add('delete bs_cloth_info where C_Name=' + quotedstr(sCap));
sql.Add('delete bs_cloth_info where C_Code=' + quotedstr(sCap));
sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( ');
sql.Add(' ' + quotedstr(trim(DName)));
sql.Add(',getdate() ');
sql.Add(',' + quotedstr(trim(self.Caption)));
sql.Add(',' + quotedstr(trim('<27><>Ʒɾ<C6B7><C9BE>')));
sql.Add(',' + quotedstr(trim('<27><><EFBFBD>ţ<EFBFBD>' + trim(sCap))));
//sql.Add(',' + quotedstr(trim('<27><><EFBFBD>ƣ<EFBFBD>' + trim(sCap))));
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
sql.Add(')');
execsql;
end;
InitPerson(1);
CPage := 1;
end;
end;
end;
procedure TfrmSCPersonColor3.FormShow(Sender: TObject);
begin
InitPerson(1);
CPage := 1;
end;
procedure TfrmSCPersonColor3.bb1Click(Sender: TObject);
begin
panel1.Visible := true;
end;
procedure TfrmSCPersonColor3.btn1Click(Sender: TObject);
begin
FName := Trim(TSpeedButton(Sender).Caption);
ModalResult := 1;
end;
procedure TfrmSCPersonColor3.btn58MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
begin
FMouseDown := True;
FDownTick := GetTickCount;
FPressedBtn := TSpeedButton(Sender); // ?<3F><><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>ť
Timer1.Enabled := True;
end;
end;
procedure TfrmSCPersonColor3.btn58MouseLeave(Sender: TObject);
begin
FMouseDown := False;
Timer1.Enabled := False;
FPressedBtn := nil;
end;
procedure TfrmSCPersonColor3.btn58MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
FMouseDown := False;
Timer1.Enabled := False;
FPressedBtn := nil;
end;
procedure TfrmSCPersonColor3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caHide;
end;
procedure TfrmSCPersonColor3.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 TfrmSCPersonColor3.Button2Click(Sender: TObject);
begin
TouchKeyboard1.Visible := true;
C_NAME.SetFocus();
end;
procedure TfrmSCPersonColor3.Button3Click(Sender: TObject);
begin
CPage := CPage + 1;
Label1.Caption := IntToStr(CPage);
InitPerson(CPage);
end;
procedure TfrmSCPersonColor3.Button4Click(Sender: TObject);
begin
TouchKeyboard1.Visible := false;
C_NAME.SetFocus();
end;
procedure TfrmSCPersonColor3.Button5Click(Sender: TObject);
var
MC_Code: string;
begin
if KZ.Text = '' then
begin
Application.MessageBox('<27><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
if mf.Text = '' then
begin
Application.MessageBox('<27>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
if GetLSNo(ADOTmp, MC_Code, 'C', 'BS_Cloth_Info', 4, 0) = False then
begin
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
Exit;
end;
Code.Text := MC_Code;
NAME2.Text := TRIM(KZ.Text) + '/' + TRIM(MF.Text);
if SaveData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ', 0);
panel1.Visible := false;
kz.Text := '';
mf.Text := '';
//FName := Trim(name2.Text);
FName := Trim(Code.Text);
name2.Text := '';
code.Text := '';
ModalResult := 1;
end;
end;
procedure TfrmSCPersonColor3.Button6Click(Sender: TObject);
begin
panel1.Visible := false;
kz.Text := '';
mf.Text := '';
name2.Text := '';
code.Text := '';
end;
procedure TfrmSCPersonColor3.c_namePropertiesChange(Sender: TObject);
begin
INITPERSON(1);
end;
end.