D10gmBitao/A02基础产品管理/U_ClothType.pas
DESKTOP-E401PHE\Administrator 630f9184a2 12345
2025-04-11 10:54:54 +08:00

252 lines
6.5 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_ClothType;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin, StdCtrls,
ExtCtrls, DBClient, U_BaseList, cxLookAndFeels, cxLookAndFeelPainters,
cxTLdxBarBuiltInMenu, dxSkinsCore, dxSkinsDefaultPainters;
type
TfrmClothType = class(TfrmBaseList)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBAdd: TToolButton;
TBDel: TToolButton;
TBClose: TToolButton;
cxDBTreeList1: TcxDBTreeList;
cxDBTreeList1cxDBTreeListColumn2: TcxDBTreeListColumn;
DataSource1: TDataSource;
ADOQueryTree10: TADOQuery;
ToolButton1: TToolButton;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
CTTopName: TEdit;
CTName: TEdit;
CTNo: TEdit;
ADOQueryTree: TClientDataSet;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBRafreshClick(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure TBAddClick(Sender: TObject);
procedure cxDBTreeList1Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure TBDelClick(Sender: TObject);
procedure CTNameKeyPress(Sender: TObject; var Key: Char);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
PState: Integer;
FCTID, FTopID: string;
procedure InitTree();
public
{ Public declarations }
end;
var
frmClothType: TfrmClothType;
implementation
uses
U_DataLink, U_RTFun;
{$R *.dfm}
procedure TfrmClothType.InitTree();
var
i: Integer;
begin
with ADOQueryTree10 do
begin
Close;
SQL.Clear;
SQL.Add('select * from BS_Cloth_Type order by CTlevel,CTOrder,CTName');
Open;
end;
SCreateCDS(ADOQueryTree10, ADOQueryTree);
SInitCDSData(ADOQueryTree10, ADOQueryTree);
if ADOQueryTree.IsEmpty then
Exit;
cxDBTreeList1.Items[0].Expand(True);
end;
procedure TfrmClothType.FormDestroy(Sender: TObject);
begin
inherited;
frmClothType := nil;
end;
procedure TfrmClothType.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
end;
procedure TfrmClothType.TBRafreshClick(Sender: TObject);
begin
InitTree();
end;
procedure TfrmClothType.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmClothType.TBAddClick(Sender: TObject);
begin
PState := 11;
CTTopName.Text := Trim(ADOQueryTree.fieldbyname('CTName').AsString);
FCTID := '';
CTName.Text := '';
CTNo.Text := '';
CTName.SetFocus;
end;
procedure TfrmClothType.cxDBTreeList1Click(Sender: TObject);
begin
PState := 22;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from BS_Cloth_Type where CTID=''' + Trim(ADOQueryTree.fieldbyname('CTParent').AsString) + '''');
Open;
end;
FCTID := Trim(ADOQueryTree.fieldbyname('CTID').AsString);
CTTopName.Text := Trim(ADOQueryTemp.fieldbyname('CTName').AsString);
CTName.Text := Trim(ADOQueryTree.fieldbyname('CTName').AsString);
CTNo.Text := Trim(ADOQueryTree.fieldbyname('CTNo').AsString);
end;
procedure TfrmClothType.ToolButton1Click(Sender: TObject);
var
maxId, FLMainId: string;
begin
if Trim(CTName.Text) = '' then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
try
ADOQueryCmd.Connection.BeginTrans;
if PState = 11 then
begin
if GetLSNo(ADOQueryCmd, maxId, 'CT', 'BS_Cloth_Type', 4, 1) = False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
end
else
begin
maxId := Trim(FCTID);
end;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from BS_Cloth_Type where CTID=''' + Trim(FCTID) + '''');
Open;
end;
with ADOQueryCmd do
begin
if PState = 11 then
begin
Append;
FieldByName('CTID').Value := Trim(maxId);
FieldByName('CTName').Value := Trim(CTName.Text);
FieldByName('CTNo').Value := Trim(CTNo.Text);
FieldByName('CTParent').Value := Trim(ADOQueryTree.fieldbyname('CTID').AsString);
FieldByName('CTLevel').Value := ADOQueryTree.fieldbyname('CTLevel').AsInteger + 1;
Post;
end
else if PState = 22 then
begin
Edit;
FieldByName('CTID').Value := Trim(maxId);
FieldByName('CTName').Value := Trim(CTName.Text);
FieldByName('CTNo').Value := Trim(CTNo.Text);
//FieldByName('CTParent').Value:=Trim(ADOQueryTree.fieldbyname('CTID').AsString);
//FieldByName('CPOrder').Value:=ADOQueryTree.fieldbyname('CPOrder').AsInteger+1;
Post;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
FLMainId := Trim(ADOQueryTree.fieldbyname('CTID').AsString);
InitTree();
ADOQueryTree.Locate('CTID', FLMainId, []);
except
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
end;
end;
procedure TfrmClothType.TBDelClick(Sender: TObject);
begin
if ADOQueryTree.FieldByName('CTLevel').AsInteger = 0 then
Exit;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from BS_Cloth_Type where CTParent=''' + Trim(ADOQueryTree.fieldbyname('CTID').AsString) + '''');
Open;
if not IsEmpty then
begin
Application.MessageBox('<27>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E0B2BB>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from BS_Cloth_Info where CTID=''' + Trim(ADOQueryTree.fieldbyname('CTID').AsString) + '''');
Open;
if not IsEmpty then
begin
Application.MessageBox('<27>Ѿ<EFBFBD><D1BE>в<EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><E0B2BB>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
end;
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
Exit;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('delete BS_Cloth_Type where CTID=''' + Trim(ADOQueryTree.fieldbyname('CTID').AsString) + '''');
sql.Add('delete BS_Cloth_Type where CTParent=''' + Trim(ADOQueryTree.fieldbyname('CTID').AsString) + '''');
ExecSQL;
end;
InitTree();
end;
procedure TfrmClothType.CTNameKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
CTNo.SetFocus;
end;
procedure TfrmClothType.FormShow(Sender: TObject);
begin
inherited;
InitTree();
end;
end.