397 lines
9.3 KiB
ObjectPascal
397 lines
9.3 KiB
ObjectPascal
unit U_frameBads;
|
||
|
||
interface
|
||
|
||
uses
|
||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
|
||
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics,
|
||
cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit,
|
||
Vcl.StdCtrls, Vcl.ExtCtrls, cxTextEdit, MovePanel, Vcl.Buttons, cxGeometry,
|
||
dxFramedControl, Vcl.Menus, cxButtons, dxPanel, cxScrollBox,
|
||
dxLayoutcxEditAdapters, dxLayoutContainer, cxClasses, dxLayoutControl, Data.DB,
|
||
Data.Win.ADODB, cxCheckBox, cxLabel, cxMaskEdit, cxButtonEdit, cxDropDownEdit;
|
||
|
||
type
|
||
TframeBads = class(TFrame)
|
||
dxPanel1: TdxPanel;
|
||
RadioGroup1: TRadioGroup;
|
||
dxPanel3: TdxPanel;
|
||
cxButton1: TcxButton;
|
||
cxButton2: TcxButton;
|
||
CIFBeg: TcxTextEdit;
|
||
CIFEnd: TcxTextEdit;
|
||
CIFQty: TcxTextEdit;
|
||
CIFNumber: TcxTextEdit;
|
||
dxLayoutControl1Group_Root: TdxLayoutGroup;
|
||
dxLayoutControl1: TdxLayoutControl;
|
||
dxLayoutGroup1: TdxLayoutGroup;
|
||
dxLayoutGroup2: TdxLayoutGroup;
|
||
dxLayoutItem2: TdxLayoutItem;
|
||
lblCIFName: TdxLayoutLabeledItem;
|
||
dxLayoutEmptySpaceItem1: TdxLayoutEmptySpaceItem;
|
||
dxLayoutLabeledItem1: TdxLayoutLabeledItem;
|
||
dxLayoutItem1: TdxLayoutItem;
|
||
dxLayoutItem3: TdxLayoutItem;
|
||
dxLayoutItem4: TdxLayoutItem;
|
||
dxLayoutItem5: TdxLayoutItem;
|
||
dxLayoutItem6: TdxLayoutItem;
|
||
lblLenUnit1: TdxLayoutLabeledItem;
|
||
ADOTmp: TADOQuery;
|
||
IsSubtract: TcxCheckBox;
|
||
cxScrollBox1: TcxScrollBox;
|
||
SubtractQty: TcxTextEdit;
|
||
dxLayoutAutoCreatedGroup1: TdxLayoutAutoCreatedGroup;
|
||
cxCheck_len: TcxCheckBox;
|
||
dxLayoutItem_checkLen: TdxLayoutItem;
|
||
cxLabel1: TcxLabel;
|
||
CIFPoints111: TcxButtonEdit;
|
||
cxLabel2: TcxLabel;
|
||
CIFnote: TcxButtonEdit;
|
||
CIFPoints: TcxComboBox;
|
||
procedure cxButton2Click(Sender: TObject);
|
||
procedure cxButton1Click(Sender: TObject);
|
||
procedure CIFBegPropertiesEditValueChanged(Sender: TObject);
|
||
procedure IsSubtractClick(Sender: TObject);
|
||
procedure SubtractQtyPropertiesEditValueChanged(Sender: TObject);
|
||
procedure CIFEndPropertiesChange(Sender: TObject);
|
||
private
|
||
procedure SpeedButtonClick(Sender: TObject);
|
||
public
|
||
fBadBtnSize: Integer;
|
||
fRowNumber: Integer;
|
||
procedure InitBadPanel();
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_iniParam;
|
||
{$R *.dfm}
|
||
|
||
procedure TframeBads.CIFBegPropertiesEditValueChanged(Sender: TObject);
|
||
var
|
||
mvalue: Double;
|
||
begin
|
||
if Trim(CIFBeg.Text) <> '' then
|
||
begin
|
||
if TryStrToFloat(CIFBeg.Text, mvalue) = False then
|
||
begin
|
||
Application.MessageBox('<27>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
Exit;
|
||
end;
|
||
if Trim(CIFEnd.Text) = '' then
|
||
begin
|
||
CIFQty.Text := '';
|
||
exit;
|
||
end;
|
||
|
||
CIFQty.Text := FloatToStr(StrToFloat(CIFEnd.Text) - StrToFloat(CIFBeg.Text));
|
||
if IsSubtract.Checked = true then
|
||
SubtractQty.text := CIFQty.Text;
|
||
end;
|
||
|
||
procedure TframeBads.CIFEndPropertiesChange(Sender: TObject);
|
||
var
|
||
mvalue: Double;
|
||
begin
|
||
if Trim(CIFEnd.Text) <> '' then
|
||
begin
|
||
if TryStrToFloat(CIFEnd.Text, mvalue) = False then
|
||
begin
|
||
Application.MessageBox('<27>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
|
||
if trim(CIFBeg.Text) = '' then
|
||
CIFQty.Text := ''
|
||
else
|
||
begin
|
||
CIFQty.Text := FloatToStr(StrToFloatDef(trim(CIFEnd.Text), 0) - StrToFloatdef(trim(CIFBeg.Text), 0));
|
||
if IsSubtract.Checked = true then
|
||
SubtractQty.text := CIFQty.Text;
|
||
end;
|
||
end;
|
||
|
||
procedure TframeBads.cxButton1Click(Sender: TObject);
|
||
begin
|
||
RadioGroup1.ItemIndex := -1;
|
||
end;
|
||
|
||
procedure TframeBads.cxButton2Click(Sender: TObject);
|
||
var
|
||
mvalue: Double;
|
||
begin
|
||
|
||
if Trim(CIFBeg.Text) <> '' then
|
||
begin
|
||
if Trim(CIFEnd.Text) <> '' then
|
||
begin
|
||
if StrToFloat(CIFEnd.Text) < StrToFloat(CIFBeg.Text) then
|
||
begin
|
||
Application.MessageBox('<27>õ<EFBFBD>λ<EFBFBD><CEBB>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
end;
|
||
if CIFQty.Text <> '' then
|
||
begin
|
||
if TryStrToFloat(CIFQty.Text, mvalue) = False then
|
||
begin
|
||
Application.MessageBox('<27>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
|
||
if strTofloatdef(Trim(SubtractQty.Text), 0) > 0 then
|
||
begin
|
||
IsSubtract.Checked := true;
|
||
end
|
||
else
|
||
begin
|
||
IsSubtract.Checked := false;
|
||
end;
|
||
|
||
end;
|
||
|
||
//procedure TframeBads.InitBadPanel();
|
||
//var
|
||
// speedBtn: TSpeedButton;
|
||
// zdyName, ZdyType, LastZdyType: string;
|
||
// i, k, j: Integer;
|
||
// typeLabel: TLabel;
|
||
//begin
|
||
// with ADOTmp do
|
||
// begin
|
||
// Close;
|
||
// sql.Clear;
|
||
// sql.Add('select ZDYName,Note1 from KH_Zdy where Type=''WFBCD'' order by Note1 desc');
|
||
// Open;
|
||
// end;
|
||
// if ADOTmp.IsEmpty then
|
||
// begin
|
||
// Application.MessageBox('û<>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>õ㣡', '<27><>ʾ', 0);
|
||
// Exit;
|
||
// end;
|
||
// if fRowNumber = 0 then
|
||
// fRowNumber := 5;
|
||
//
|
||
// j := fRowNumber;
|
||
// if fBadBtnSize < 30 then
|
||
// fBadBtnSize := 40;
|
||
//
|
||
// cxScrollBox1.DisableAlign;
|
||
// with ADOTmp do
|
||
// begin
|
||
// First;
|
||
// i := 0;
|
||
// while not Eof do
|
||
// begin
|
||
// ZdyType := Trim(fieldbyname('Note1').AsString);
|
||
// k := i div j;
|
||
// zdyName := Trim(fieldbyname('ZDYName').AsString);
|
||
//
|
||
// speedBtn := TSpeedButton.Create(self);
|
||
// speedBtn.OnClick := SpeedButtonClick;
|
||
//
|
||
// speedBtn.Width := fBadBtnSize;
|
||
// speedBtn.Height := fBadBtnSize;
|
||
//
|
||
// speedBtn.Left := 5 + (i mod j) * speedBtn.Width;
|
||
// speedBtn.Top := 3 + k * speedBtn.Height;
|
||
//
|
||
// speedBtn.Parent := cxScrollBox1;
|
||
// speedBtn.Hint := zdyName;
|
||
// if Length(zdyName) > 4 then
|
||
// begin
|
||
// speedBtn.Caption := Copy(zdyName, 1, 4) + #13 + Copy(zdyName, 5, Length(zdyName) - 4);
|
||
// end
|
||
// else
|
||
// speedBtn.Caption := zdyName;
|
||
//
|
||
// i := i + 1;
|
||
// Next;
|
||
// end;
|
||
// end;
|
||
// cxScrollBox1.EnableAlign;
|
||
// if gFlawscore then
|
||
// begin
|
||
// RadioGroup1.Items.Text := '1' + #13#10 + '2' + #13#10 + '3' + #13#10 + '4' + #13#10 + '<27><>ƥ' + #13#10 + '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>覴<EFBFBD>';
|
||
// end;
|
||
//end;
|
||
|
||
procedure TframeBads.InitBadPanel();
|
||
const
|
||
nBtnHeight = 50; // <20>õ㰴ť<E3B0B4>߶<EFBFBD>=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵĸ߶<C4B8>
|
||
var
|
||
speedBtn: TSpeedButton;
|
||
typeLabel: TLabel;
|
||
zdyName, ZdyType, LastZdyType: string;
|
||
i, j: Integer;
|
||
col, row: Integer;
|
||
begin
|
||
with ADOTmp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
SQL.Add('select ZDYName, Note1 from KH_Zdy ' +
|
||
'where Type=''WFBCD'' order by Note1 desc');
|
||
Open;
|
||
end;
|
||
|
||
if ADOTmp.IsEmpty then
|
||
begin
|
||
Application.MessageBox('û<>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>õ㣡', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
|
||
if fRowNumber = 0 then
|
||
fRowNumber := 5;
|
||
|
||
j := fRowNumber;
|
||
|
||
if fBadBtnSize < 30 then
|
||
fBadBtnSize := 40;
|
||
|
||
cxScrollBox1.DisableAlign;
|
||
|
||
// <20><><EFBFBD><EFBFBD> InitBadPanel <20><><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>վɿؼ<C9BF>
|
||
while cxScrollBox1.ControlCount > 0 do
|
||
cxScrollBox1.Controls[0].Free;
|
||
|
||
with ADOTmp do
|
||
begin
|
||
First;
|
||
|
||
i := 0;
|
||
col := 0;
|
||
row := 0;
|
||
LastZdyType := '';
|
||
|
||
while not Eof do
|
||
begin
|
||
ZdyType := Trim(FieldByName('Note1').AsString);
|
||
zdyName := Trim(FieldByName('ZDYName').AsString);
|
||
|
||
// ZdyType <20><><EFBFBD><EFBFBD><EFBFBD>仯<EFBFBD><E4BBAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD>
|
||
if (i = 0) or (ZdyType <> LastZdyType) then
|
||
begin
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>һ<EFBFBD>飬<EFBFBD><E9A3AC><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>հ<EFBFBD>
|
||
if i > 0 then
|
||
Inc(row);
|
||
|
||
// <20><><EFBFBD><EFBFBD> ZdyType <20><><EFBFBD><EFBFBD>
|
||
typeLabel := TLabel.Create(Self);
|
||
typeLabel.Parent := cxScrollBox1;
|
||
|
||
typeLabel.Left := 5;
|
||
// typeLabel.Top := 3 + row * (fBadBtnSize + 5);
|
||
typeLabel.Top := 3 + row * nBtnHeight; // <20><>ť<EFBFBD>߶ȸ<DFB6>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(40)<29><EFBFBD><F3A3ACB1><EFBFBD>Topͬ<70><CDAC><EFBFBD><EFBFBD><EFBFBD>¸߶ȼ<DFB6><C8BC>㣬<EFBFBD><E3A3AC>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD>밴ť<EBB0B4>ص<EFBFBD><D8B5><EFBFBD>λ
|
||
|
||
typeLabel.Width := cxScrollBox1.ClientWidth - 15;
|
||
typeLabel.Height := 20;
|
||
|
||
typeLabel.Caption := '<27><>' + ZdyType + '<27><>';
|
||
|
||
typeLabel.Font.Style := [fsBold];
|
||
typeLabel.Font.Size := 10;
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>濪ʼ<E6BFAA>Ŵõ㰴ť
|
||
Inc(row);
|
||
|
||
col := 0;
|
||
end;
|
||
|
||
//==========================================================
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD>õ㰴ť
|
||
//==========================================================
|
||
speedBtn := TSpeedButton.Create(Self);
|
||
speedBtn.Parent := cxScrollBox1;
|
||
speedBtn.OnClick := SpeedButtonClick;
|
||
|
||
// speedBtn.Width := fBadBtnSize;
|
||
// speedBtn.Height := fBadBtnSize;
|
||
speedBtn.Width := 65; // <20><><EFBFBD>ȱ<EFBFBD><C8B1>ֲ<EFBFBD><D6B2><EFBFBD>
|
||
speedBtn.Height := nBtnHeight; // ֻ<>ĸ߶ȣ<DFB6><C8A3><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵĸ߶<C4B8>(40)
|
||
|
||
speedBtn.Font.Size := 8; // <20>ֺ<EFBFBD>
|
||
|
||
speedBtn.Left := 5 + col * speedBtn.Width;
|
||
speedBtn.Top := 3 + row * speedBtn.Height; //
|
||
|
||
speedBtn.Hint := zdyName;
|
||
|
||
if Length(zdyName) > 4 then
|
||
begin
|
||
speedBtn.Caption :=
|
||
Copy(zdyName, 1, 4) + #13 +
|
||
Copy(zdyName, 5, Length(zdyName) - 4);
|
||
end
|
||
else
|
||
speedBtn.Caption := zdyName;
|
||
|
||
Inc(i);
|
||
Inc(col);
|
||
|
||
// <20><>ǰ<EFBFBD><C7B0><EFBFBD>Ѿ<EFBFBD><D1BE>ﵽ<EFBFBD><EFB5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>
|
||
if col >= j then
|
||
begin
|
||
col := 0;
|
||
Inc(row);
|
||
end;
|
||
|
||
LastZdyType := ZdyType;
|
||
|
||
Next;
|
||
end;
|
||
end;
|
||
|
||
cxScrollBox1.EnableAlign;
|
||
|
||
if gFlawscore then
|
||
begin
|
||
RadioGroup1.Items.Text :=
|
||
'1' + #13#10 +
|
||
'2' + #13#10 +
|
||
'3' + #13#10 +
|
||
'4' + #13#10 +
|
||
'<27><>ƥ' + #13#10 +
|
||
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>覴<EFBFBD>';
|
||
end;
|
||
end;
|
||
|
||
|
||
|
||
procedure TframeBads.IsSubtractClick(Sender: TObject);
|
||
begin
|
||
|
||
end;
|
||
|
||
//
|
||
|
||
procedure TframeBads.SpeedButtonClick(Sender: TObject);
|
||
begin
|
||
dxPanel1.Visible := true;
|
||
|
||
lblCIFName.Caption := Trim(TSpeedButton(Sender).Hint);
|
||
|
||
// CIFNumber.SetFocus;
|
||
|
||
end;
|
||
|
||
procedure TframeBads.SubtractQtyPropertiesEditValueChanged(Sender: TObject);
|
||
begin
|
||
if trim(SubtractQty.Text) <> '' then
|
||
isSubTract.Checked := true
|
||
else
|
||
isSubTract.Checked := false;
|
||
end;
|
||
|
||
end.
|
||
|