489 lines
12 KiB
ObjectPascal
489 lines
12 KiB
ObjectPascal
unit U_DyeTechnicsinput;
|
||
|
||
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,
|
||
U_BaseInput, dxDateRanges, System.ImageList, Vcl.ImgList;
|
||
|
||
type
|
||
TfrmDyeTechnicsinput = class(TfrmBaseinput)
|
||
ADOQueryTemp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
GPM_2: TcxGridPopupMenu;
|
||
DS_2: TDataSource;
|
||
CDS_2: TClientDataSet;
|
||
DS_1: TDataSource;
|
||
CDS_1: TClientDataSet;
|
||
ADOQuery1: TADOQuery;
|
||
GPM_1: TcxGridPopupMenu;
|
||
PM_1: TPopupMenu;
|
||
N2: TMenuItem;
|
||
cxSplitter1: TcxSplitter;
|
||
Panel2: TPanel;
|
||
cxGrid2: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
v2PSName: TcxGridDBColumn;
|
||
v2PSNote: TcxGridDBColumn;
|
||
v2Column1: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
Panel1: TPanel;
|
||
Panel3: TPanel;
|
||
cxGrid1: TcxGrid;
|
||
TV1: TcxGridDBTableView;
|
||
VC_PSNO: TcxGridDBColumn;
|
||
cxGridDBColumn1: TcxGridDBColumn;
|
||
cxGridLevel2: TcxGridLevel;
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBClose: TToolButton;
|
||
Label5: TLabel;
|
||
Label1: TLabel;
|
||
SYRName: TEdit;
|
||
PSName: TEdit;
|
||
ToolButton2: TToolButton;
|
||
btnSave: TToolButton;
|
||
Panel4: TPanel;
|
||
Label2: TLabel;
|
||
Label3: TLabel;
|
||
DTMName: TEdit;
|
||
DTMNo: TEdit;
|
||
Label4: TLabel;
|
||
DTMPrice: TEdit;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure v2Column4PropertiesEditValueChanged(Sender: TObject);
|
||
procedure v2Column2PropertiesEditValueChanged(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
procedure Tv2FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
procedure PSNameChange(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure Tv2DblClick(Sender: TObject);
|
||
procedure btnSaveClick(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
|
||
procedure InitGrid();
|
||
procedure InitGlide();
|
||
procedure SetXH();
|
||
function SaveData(): boolean;
|
||
public
|
||
FDTMID, PState: string;
|
||
{ Public declarations }
|
||
RKFlag, FCYID, fmanage: string;
|
||
end;
|
||
|
||
var
|
||
frmDyeTechnicsinput: TfrmDyeTechnicsinput;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun, U_ZDYHelp, U_DyeProcessSel;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmDyeTechnicsinput.SetXH();
|
||
var
|
||
i: Integer;
|
||
begin
|
||
with CDS_1 do
|
||
begin
|
||
First;
|
||
i := 1;
|
||
while not Eof do
|
||
begin
|
||
with CDS_1 do
|
||
begin
|
||
Edit;
|
||
FieldByName('XHNoTemp').Value := i;
|
||
Post;
|
||
end;
|
||
i := i + 1;
|
||
Next;
|
||
end;
|
||
end;
|
||
|
||
with CDS_1 do
|
||
begin
|
||
CDS_1.IndexFieldNames := '';
|
||
First;
|
||
i := 1;
|
||
while not Eof do
|
||
begin
|
||
with CDS_1 do
|
||
begin
|
||
Edit;
|
||
FieldByName('PSNO').Value := FieldByName('XHNoTemp').AsInteger;
|
||
Post;
|
||
end;
|
||
i := i + 1;
|
||
Next;
|
||
end;
|
||
CDS_1.IndexFieldNames := 'PSNO';
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.InitGlide();
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select * FROM Dye_Technics_Main where DTMID=' + quotedstr(FDTMID));
|
||
Open;
|
||
end;
|
||
SCSHData(ADOQueryTemp, Panel4, 2);
|
||
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select A.*,B.* FROM Dye_Technics_Sub A inner join Dye_Process B on A.PSId=B.PSId ');
|
||
sql.Add(' Where A.DTMID=''' + FDTMID + '''');
|
||
SQL.Add(' ORDER BY A.PSNO');
|
||
Open;
|
||
end;
|
||
SCreateCDS(ADOQueryTemp, CDS_1);
|
||
SInitCDSData(ADOQueryTemp, CDS_1);
|
||
|
||
end;
|
||
|
||
function TfrmDyeTechnicsinput.SaveData(): boolean;
|
||
var
|
||
DTMPSlist, maxno: string;
|
||
begin
|
||
result := false;
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
try
|
||
|
||
if Trim(FDTMID) = '' then
|
||
begin
|
||
if GetLSNo(ADOQueryCmd, maxno, 'GY', 'Dye_Technics_Main', 3, 1) = False then
|
||
raise Exception.Create('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
|
||
end
|
||
else
|
||
begin
|
||
maxno := FDTMID;
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete Dye_Technics_Sub where DTMID=' + quotedstr(trim(maxno)));
|
||
execsql;
|
||
end;
|
||
|
||
DTMPSlist := '';
|
||
with CDS_1 do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('SELECT * FROM Dye_Technics_Sub WHERE 1=2');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Append;
|
||
FieldByName('PSNO').Value := Trim(CDS_1.fieldbyname('PSNO').AsString);
|
||
FieldByName('DTMID').Value := Trim(maxno);
|
||
FieldByName('PSId').Value := Trim(CDS_1.fieldbyname('PSId').AsString);
|
||
Post;
|
||
end;
|
||
if DTMPSlist = '' then
|
||
begin
|
||
DTMPSlist := Trim(CDS_1.fieldbyname('PSNO').AsString) + '.' + Trim(CDS_1.fieldbyname('PSName').AsString);
|
||
end
|
||
else
|
||
begin
|
||
DTMPSlist := DTMPSlist + '<27><>' + Trim(CDS_1.fieldbyname('PSNO').AsString) + '.' + Trim(CDS_1.fieldbyname('PSName').AsString);
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from Dye_Technics_Main where DTMID =' + quotedstr(Trim(maxno)));
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
if ADOQueryCmd.IsEmpty then
|
||
begin
|
||
Append;
|
||
FieldByName('Filler').Value := Trim(DName);
|
||
FieldByName('DTMID').Value := Trim(maxno);
|
||
end
|
||
else
|
||
begin
|
||
Edit;
|
||
FieldByName('Editer').Value := Trim(DName);
|
||
FieldByName('Edittime').Value := SGetServerDateTime(ADOQueryTemp);
|
||
end;
|
||
RTSetsavedata(ADOQueryCmd, 'Dye_Technics_Main', Panel4, 2);
|
||
FieldByName('DTMPSlist').Value := Trim(DTMPSlist);
|
||
|
||
Post;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from Dye_Technics_Main where DTMNo=''' + Trim(DTMNo.Text) + '''');
|
||
Open;
|
||
end;
|
||
if ADOQueryCmd.RecordCount > 1 then
|
||
raise Exception.Create('<27><><EFBFBD>ձ<EFBFBD><D5B1><EFBFBD><EFBFBD>ظ<EFBFBD>!');
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from Dye_Technics_Main where DTMName=''' + Trim(DTMName.Text) + '''');
|
||
Open;
|
||
end;
|
||
if ADOQueryCmd.RecordCount > 1 then
|
||
raise Exception.Create('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>!');
|
||
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
result := true;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
result := false;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered := False;
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select *,PSXH=0 from Dye_Process ');
|
||
Open;
|
||
end;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS(ADOQueryMain, CDS_2);
|
||
SInitCDSData(ADOQueryMain, CDS_2);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.FormDestroy(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
frmDyeTechnicsinput := nil;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.TBCloseClick(Sender: TObject);
|
||
begin
|
||
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
ReadCxGrid(trim(self.Caption) + 'Tv1', Tv1, '<27><><EFBFBD>չ<EFBFBD><D5B9><EFBFBD>');
|
||
ReadCxGrid(trim(self.Caption) + 'Tv2', Tv2, '<27><><EFBFBD>չ<EFBFBD><D5B9><EFBFBD>');
|
||
InitGrid();
|
||
InitGlide();
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
ReadCxGrid(trim(self.Caption) + 'Tv1', Tv1, '<27><><EFBFBD>չ<EFBFBD><D5B9><EFBFBD>');
|
||
ReadCxGrid(trim(self.Caption) + 'Tv2', Tv2, '<27><><EFBFBD>չ<EFBFBD><D5B9><EFBFBD>');
|
||
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.v2Column4PropertiesEditValueChanged(Sender: TObject);
|
||
var
|
||
mvalue: string;
|
||
begin
|
||
mvalue := TcxTextEdit(Sender).EditingText;
|
||
if Trim(mvalue) = '' then
|
||
mvalue := '';
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from Dye_Technics_Main where DTMNo =' + quotedstr(Trim(mvalue)));
|
||
Open;
|
||
end;
|
||
if ADOQueryCmd.IsEmpty = false then
|
||
begin
|
||
application.MessageBox('<27>Ѵ<EFBFBD><D1B4>ڹ<EFBFBD><DAB9>ձ<EFBFBD><D5B1><EFBFBD>', '<27><>ʾ');
|
||
CDS_2.Edit;
|
||
CDS_2.FieldByName('DTMNo').AsString := '';
|
||
exit;
|
||
end;
|
||
with CDS_2 do
|
||
begin
|
||
Edit;
|
||
FieldByName('DTMNo').Value := Trim(mvalue);
|
||
//Post;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('update Dye_Technics_Main set DTMNo=''' + trim(mvalue) + ''' ');
|
||
sql.Add(',Editer=''' + trim(DName) + '''');
|
||
sql.Add(',Edittime=getdate()');
|
||
sql.add(' where DTMID=''' + trim(CDS_2.fieldbyname('DTMID').AsString) + '''');
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.btnSaveClick(Sender: TObject);
|
||
begin
|
||
if trim(DTMNo.Text) = '' then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD>ձ<EFBFBD><D5B1>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>', '<27><>ʾ');
|
||
Exit;
|
||
end;
|
||
if trim(DTMName.Text) = '' then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>', '<27><>ʾ');
|
||
Exit;
|
||
end;
|
||
if SaveData() then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.v2Column2PropertiesEditValueChanged(Sender: TObject);
|
||
var
|
||
mvalue: string;
|
||
begin
|
||
mvalue := TcxTextEdit(Sender).EditingText;
|
||
if Trim(mvalue) = '' then
|
||
mvalue := '';
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from Dye_Technics_Main where DTMName =' + quotedstr(Trim(mvalue)));
|
||
Open;
|
||
end;
|
||
if ADOQueryCmd.IsEmpty = false then
|
||
begin
|
||
application.MessageBox('<27>Ѵ<EFBFBD><D1B4>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ');
|
||
CDS_2.Edit;
|
||
CDS_2.FieldByName('DTMName').AsString := '';
|
||
exit;
|
||
end;
|
||
with CDS_2 do
|
||
begin
|
||
Edit;
|
||
FieldByName('DTMName').Value := Trim(mvalue);
|
||
//Post;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('update Dye_Technics_Main set DTMName=''' + trim(mvalue) + ''' ');
|
||
sql.Add(',Editer=''' + trim(DName) + '''');
|
||
sql.Add(',Edittime=getdate()');
|
||
sql.add(' where DTMID=''' + trim(CDS_2.fieldbyname('DTMID').AsString) + '''');
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.Tv2DblClick(Sender: TObject);
|
||
begin
|
||
with CDS_1 do
|
||
begin
|
||
Append;
|
||
FieldByName('PSNO').Value := CDS_1.RecordCount + 1;
|
||
FieldByName('PSName').Value := CDS_2.fieldbyname('PSName').AsString;
|
||
FieldByName('PSId').Value := CDS_2.fieldbyname('PSId').AsString;
|
||
post;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.Tv2FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
begin
|
||
InitGlide();
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.FormCreate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
fmanage := Trim(DParameters1);
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.N2Click(Sender: TObject);
|
||
var
|
||
i: Integer;
|
||
DTMPSlist: string;
|
||
begin
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
||
Exit;
|
||
|
||
CDS_1.Delete;
|
||
SetXH();
|
||
end;
|
||
|
||
procedure TfrmDyeTechnicsinput.PSNameChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS(ADOQueryMain, CDS_2);
|
||
SInitCDSData(ADOQueryMain, CDS_2);
|
||
end;
|
||
end;
|
||
|
||
end.
|
||
|