362 lines
8.5 KiB
ObjectPascal
362 lines
8.5 KiB
ObjectPascal
unit U_DyeTechnicsList;
|
||
|
||
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,
|
||
cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
|
||
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
|
||
cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
|
||
RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
|
||
IdTCPClient, IdFTP, ShellAPI, IniFiles, cxCheckBox, cxCalendar, cxButtonEdit,
|
||
cxTextEdit, cxPC, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator,
|
||
dxBarBuiltInMenu, Menus, U_BaseList, dxSkinsCore, dxSkinsDefaultPainters,
|
||
dxDateRanges;
|
||
|
||
type
|
||
TfrmDyeTechnicsList = class(TfrmBaseList)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBDel: TToolButton;
|
||
TBClose: TToolButton;
|
||
ADOQueryTemp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
Panel1: TPanel;
|
||
ToolButton2: TToolButton;
|
||
Label1: TLabel;
|
||
DTMName: TEdit;
|
||
ADOQueryMain: TADOQuery;
|
||
Label3: TLabel;
|
||
DTMNo: TEdit;
|
||
cxGrid2: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
cxGridLevel1: TcxGridLevel;
|
||
GPM_2: TcxGridPopupMenu;
|
||
DS_2: TDataSource;
|
||
CDS_2: TClientDataSet;
|
||
cxTabControl1: TcxTabControl;
|
||
Tchk: TToolButton;
|
||
TNochk: TToolButton;
|
||
v2GYGX: TcxGridDBColumn;
|
||
v2Ssel: TcxGridDBColumn;
|
||
v2GYName: TcxGridDBColumn;
|
||
v2GYNO: TcxGridDBColumn;
|
||
ToolButton3: TToolButton;
|
||
ToolButton1: TToolButton;
|
||
ToolButton4: TToolButton;
|
||
Tv2Column1: TcxGridDBColumn;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBDelClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure DTMNoChange(Sender: TObject);
|
||
procedure TchkClick(Sender: TObject);
|
||
procedure TNochkClick(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
|
||
procedure InitGrid();
|
||
procedure SetStatus();
|
||
public
|
||
fmanage: string;
|
||
end;
|
||
|
||
var
|
||
frmDyeTechnicsList: TfrmDyeTechnicsList;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun, U_ZDYHelp, U_DyeTechnicsinput;
|
||
|
||
{$R *.dfm}
|
||
|
||
|
||
procedure TfrmDyeTechnicsList.SetStatus();
|
||
begin
|
||
|
||
Tchk.Visible := false;
|
||
TNochk.Visible := false;
|
||
TBDel.Visible := false;
|
||
case cxTabControl1.TabIndex of
|
||
0:
|
||
begin
|
||
Tchk.Visible := true;
|
||
TBDel.Visible := true;
|
||
end;
|
||
1:
|
||
begin
|
||
TNochk.Visible := true;
|
||
end;
|
||
2:
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered := False;
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select * FROM Dye_Technics_Main');
|
||
if cxTabControl1.TabIndex < 2 then
|
||
sql.Add(' where isnull(status,''0'')=''' + inttostr(cxTabControl1.TabIndex) + ''' ');
|
||
Open;
|
||
end;
|
||
SCreateCDS(ADOQueryMain, CDS_2);
|
||
SInitCDSData(ADOQueryMain, CDS_2);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
ToolButton2.Click;
|
||
//CDS_1.EmptyDataSet;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.FormDestroy(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
frmDyeTechnicsList := nil;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.TBCloseClick(Sender: TObject);
|
||
begin
|
||
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.TBDelClick(Sender: TObject);
|
||
begin
|
||
if CDS_2.IsEmpty then
|
||
Exit;
|
||
if CDS_2.Locate('ssel', true, []) = false then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
||
Exit;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with CDS_2 do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
if Fieldbyname('ssel').AsBoolean then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('delete Dye_Technics_Main where DTMID=''' + Trim(CDS_2.fieldbyname('DTMID').AsString) + '''');
|
||
sql.Add('delete Dye_Technics_Sub where DTMID=''' + Trim(CDS_2.fieldbyname('DTMID').AsString) + '''');
|
||
execsql;
|
||
end;
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
InitGrid();
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
ReadCxGrid(trim(self.Caption) + 'Tv2', Tv2, '<27><><EFBFBD>չ<EFBFBD><D5B9><EFBFBD>');
|
||
SetStatus();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
try
|
||
frmDyeTechnicsinput := TfrmDyeTechnicsinput.Create(Application);
|
||
with frmDyeTechnicsinput do
|
||
begin
|
||
PState := '<27><><EFBFBD><EFBFBD>';
|
||
FDTMID := '';
|
||
if ShowModal = 1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmDyeTechnicsinput.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS(ADOQueryMain, CDS_2);
|
||
SInitCDSData(ADOQueryMain, CDS_2);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(trim(self.Caption) + 'Tv2', Tv2, '<27><><EFBFBD>չ<EFBFBD><D5B9><EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.ToolButton4Click(Sender: TObject);
|
||
begin
|
||
try
|
||
frmDyeTechnicsinput := TfrmDyeTechnicsinput.Create(Application);
|
||
with frmDyeTechnicsinput do
|
||
begin
|
||
PState := '<27><EFBFBD>';
|
||
FDTMID := Trim(self.CDS_2.fieldbyname('DTMID').AsString);
|
||
if ShowModal = 1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmDyeTechnicsinput.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.DTMNoChange(Sender: TObject);
|
||
begin
|
||
ToolButton2.Click;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.TchkClick(Sender: TObject);
|
||
begin
|
||
if CDS_2.IsEmpty then
|
||
exit;
|
||
|
||
if CDS_2.Locate('ssel', true, []) = false then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with CDS_2 do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
if Fieldbyname('ssel').AsBoolean then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update Dye_Technics_Main SET status=''1'' ');
|
||
sql.Add('where DTMID =' + quotedstr(trim(CDS_2.fieldbyname('DTMID').AsString)));
|
||
execsql;
|
||
end;
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
|
||
InitGrid();
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.TNochkClick(Sender: TObject);
|
||
begin
|
||
if CDS_2.IsEmpty then
|
||
exit;
|
||
|
||
if CDS_2.Locate('ssel', true, []) = false then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with CDS_2 do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
if Fieldbyname('ssel').AsBoolean then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update Dye_Technics_Main SET status=''0'' ');
|
||
sql.Add('where DTMID =' + quotedstr(trim(CDS_2.fieldbyname('DTMID').AsString)));
|
||
execsql;
|
||
end;
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
InitGrid();
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
SetStatus();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsList.FormCreate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
fmanage := Trim(DParameters1);
|
||
end;
|
||
|
||
end.
|
||
|