328 lines
10 KiB
ObjectPascal
328 lines
10 KiB
ObjectPascal
unit U_JTSel;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
|
||
cxEdit, DB, cxDBData, ToolWin, ComCtrls, cxGridCustomTableView,
|
||
cxGridTableView, cxGridDBTableView, cxGridLevel, cxClasses, cxControls,
|
||
cxGridCustomView, cxGrid, DBClient, ADODB, ImgList, StdCtrls, ExtCtrls,
|
||
cxCheckBox, cxTextEdit, cxPC, cxLookAndFeels, cxLookAndFeelPainters,
|
||
dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel,
|
||
dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide, dxSkinDevExpressDarkStyle,
|
||
dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast,
|
||
dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
|
||
dxSkinMcSkin, dxSkinMetropolis, dxSkinMetropolisDark, dxSkinMoneyTwins,
|
||
dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
|
||
dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
|
||
dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinOffice2013DarkGray,
|
||
dxSkinOffice2013LightGray, dxSkinOffice2013White, dxSkinPumpkin, dxSkinSeven,
|
||
dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver,
|
||
dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld,
|
||
dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint,
|
||
dxSkinXmas2008Blue, dxSkinscxPCPainter, cxNavigator, dxBarBuiltInMenu;
|
||
|
||
type
|
||
TfrmJTSel = class(TForm)
|
||
TV1: TcxGridDBTableView;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
cxGrid1: TcxGrid;
|
||
V1Name: TcxGridDBColumn;
|
||
ToolBar1: TToolBar;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
ClientDataSet1: TClientDataSet;
|
||
TBClose: TToolButton;
|
||
ToolButton1: TToolButton;
|
||
V1Note: TcxGridDBColumn;
|
||
Panel1: TPanel;
|
||
Label1: TLabel;
|
||
MCNO: TEdit;
|
||
ThreeImgList: TImageList;
|
||
V1Column1: TcxGridDBColumn;
|
||
cxTabControl1: TcxTabControl;
|
||
Label2: TLabel;
|
||
V1Column2: TcxGridDBColumn;
|
||
V1Column3: TcxGridDBColumn;
|
||
V1Column4: TcxGridDBColumn;
|
||
Label3: TLabel;
|
||
MCCJ: TComboBox;
|
||
cxGrid2: TcxGrid;
|
||
TV2: TcxGridDBTableView;
|
||
cxGridDBColumn2: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
ClientDataSet2: TClientDataSet;
|
||
DataSource2: TDataSource;
|
||
TV2Column1: TcxGridDBColumn;
|
||
TV2Column2: TcxGridDBColumn;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure MCNOChange(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure TV1DblClick(Sender: TObject);
|
||
procedure TV2DblClick(Sender: TObject);
|
||
private
|
||
procedure InitGrid();
|
||
{ Private declarations }
|
||
public
|
||
flag, flagname, snote, MainType, ReturnStr, FGStr: string;
|
||
fnote, forderno: Boolean;
|
||
PPSTE, JiangeStr: integer;
|
||
FBIAOSHI: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmJTSel: TfrmJTSel;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_Fun;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmJTSel.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
MCNO.SetFocus;
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmJTSel.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select MCNO,MCCJ ');
|
||
sql.Add(' ,ZYConNo=(select Top 1 ConNo from Cloth_Main CM inner join Cloth_JiTai CJ on CM.MainId=CJ.MainId');
|
||
sql.Add(' where CJ.CarNo=A.MCNO and CJ.StopFlag=0)');
|
||
sql.Add(' ,C_Code=(select Top 1 C_Code from Cloth_Sub CM inner join Cloth_JiTai CJ on CM.MainId=CJ.MainId');
|
||
sql.Add(' where CJ.CarNo=A.MCNO and CJ.StopFlag=0)');
|
||
sql.Add(' ,jtid=(select Top 1 jtid from Cloth_Sub CM inner join Cloth_JiTai CJ on CM.MainId=CJ.MainId');
|
||
sql.Add(' where CJ.CarNo=A.MCNO and CJ.StopFlag=0)');
|
||
sql.Add(' ,CARNO=(select Top 1 CARNO from Cloth_Sub CM inner join Cloth_JiTai CJ on CM.MainId=CJ.MainId');
|
||
sql.Add(' where CJ.CarNo=A.MCNO and CJ.StopFlag=0)');
|
||
sql.Add(' ,C_CodeName=(select Top 1 C_CodeName from Cloth_Sub CM inner join Cloth_JiTai CJ on CM.MainId=CJ.MainId');
|
||
sql.Add(' where CJ.CarNo=A.MCNO and CJ.StopFlag=0)');
|
||
sql.Add(' from Machine A');
|
||
sql.Add(' where ');
|
||
if cxTabControl1.TabIndex = 0 then
|
||
begin
|
||
sql.Add(' not exists(select StopFlag from Cloth_JiTai B inner join cloth_main X on B.mainid=X.mainid where B.CarNo=A.MCNO and B.StopFlag=0)');
|
||
end
|
||
else if cxTabControl1.TabIndex = 1 then
|
||
begin
|
||
sql.Add(' exists(select StopFlag from Cloth_JiTai B inner join cloth_main X on B.mainid=X.mainid where B.CarNo=A.MCNO and B.StopFlag=0)');
|
||
end;
|
||
sql.Add(' order by MCCJ,MCNO');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain, ClientDataSet1);
|
||
SInitCDSData20(ADOQueryMain, ClientDataSet1);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJTSel.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmJTSel.FormShow(Sender: TObject);
|
||
var
|
||
fsj: string;
|
||
begin
|
||
fsj := 'select Name=MCCJ from Machine Group by MCCJ ';
|
||
SInitComBoxBySql(ADOQueryTemp, MCCJ, False, fsj);
|
||
InitGrid();
|
||
with ADOQueryMain do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select MCNO,MCCJ ');
|
||
|
||
sql.Add(' from Machine A');
|
||
sql.Add(' where 1<>1 ');
|
||
|
||
sql.Add(' order by MCCJ,MCNO');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain, ClientDataSet2);
|
||
SInitCDSData20(ADOQueryMain, ClientDataSet2);
|
||
end;
|
||
|
||
procedure TfrmJTSel.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
|
||
if ClientDataSet2.ISEMPTY = FALSE then
|
||
begin
|
||
ReturnStr := '';
|
||
with ClientDataSet2 do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if ClientDataSet2.FieldByName('SSel').AsBoolean = True then
|
||
begin
|
||
if JiangeStr <> 99 then
|
||
begin
|
||
if FGStr <> '' then
|
||
ReturnStr := ReturnStr + Trim(ClientDataSet2.fieldbyname('MCNO').AsString) + FGStr
|
||
else
|
||
ReturnStr := ReturnStr + Trim(ClientDataSet2.fieldbyname('MCNO').AsString) + ';'
|
||
end
|
||
else
|
||
ReturnStr := ReturnStr + Trim(ClientDataSet2.fieldbyname('MCNO').AsString);
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
if JiangeStr <> 99 then
|
||
ReturnStr := Copy(ReturnStr, 1, Length(ReturnStr) - 1);
|
||
ModalResult := 1;
|
||
FBIAOSHI := '1';
|
||
end
|
||
else
|
||
begin
|
||
|
||
if ClientDataSet1.Locate('SSel', True, []) = False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
if cxTabControl1.TabIndex <> 0 then
|
||
begin
|
||
if Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>øó<C3B8><C3B3><EFBFBD>,ȷ<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
||
begin
|
||
Exit;
|
||
|
||
end;
|
||
|
||
end;
|
||
ReturnStr := '';
|
||
with ClientDataSet1 do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if FieldByName('SSel').AsBoolean = True then
|
||
begin
|
||
if JiangeStr <> 99 then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update Cloth_JiTai SET StopFlag=1,DOTime=getdate(),DOPerson=''' + Trim(DName) + '''');
|
||
sql.Add(',TYTime=getdate(),TYPerson=''' + Trim(DName) + '''');
|
||
sql.Add('where JTID=' + quotedstr(trim(ClientDataSet1.fieldbyname('JTID').AsString)));
|
||
sql.Add(' and CarNo=''' + Trim(ClientDataSet1.fieldbyname('CarNo').AsString) + ''' and StopFlag=0 ');
|
||
execsql;
|
||
end;
|
||
|
||
if FGStr <> '' then
|
||
ReturnStr := ReturnStr + Trim(fieldbyname('MCNO').AsString) + FGStr
|
||
else
|
||
ReturnStr := ReturnStr + Trim(fieldbyname('MCNO').AsString) + ';'
|
||
end
|
||
else
|
||
ReturnStr := ReturnStr + Trim(fieldbyname('MCNO').AsString);
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
if JiangeStr <> 99 then
|
||
ReturnStr := Copy(ReturnStr, 1, Length(ReturnStr) - 1);
|
||
ModalResult := 1;
|
||
|
||
FBIAOSHI := '2';
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmJTSel.MCNOChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS20(ADOQueryMain, ClientDataSet1);
|
||
SInitCDSData20(ADOQueryMain, ClientDataSet1);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJTSel.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmJTSel.TV1DblClick(Sender: TObject);
|
||
begin
|
||
if ClientDataSet2.Locate('MCNO', VarArrayOf([trim(ClientDataSet1.fieldbyname('MCNO').AsString)]), []) then
|
||
begin
|
||
Application.MessageBox('<27>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
if cxTabControl1.tabINDEX = 0 then
|
||
begin
|
||
with ClientDataSet2 do
|
||
begin
|
||
APPEND;
|
||
ClientDataSet2.fieldbyname('SSEL').VALUE := TRUE;
|
||
ClientDataSet2.fieldbyname('MCNO').VALUE := ClientDataSet1.fieldbyname('MCNO').ASSTRING;
|
||
ClientDataSet2.fieldbyname('MCCJ').VALUE := ClientDataSet1.fieldbyname('MCCJ').ASSTRING;
|
||
|
||
// ClientDataSet2.fieldbyname('').VALUE := ClientDataSet1.fieldbyname('').ASSTRING;
|
||
POST;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
if Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>øó<C3B8><C3B3><EFBFBD>,ȷ<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
||
begin
|
||
Exit;
|
||
|
||
end
|
||
else
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update Cloth_JiTai SET StopFlag=1,DOTime=getdate(),DOPerson=''' + Trim(DName) + '''');
|
||
sql.Add(',TYTime=getdate(),TYPerson=''' + Trim(DName) + '''');
|
||
sql.Add('where JTID=' + quotedstr(trim(ClientDataSet1.fieldbyname('JTID').AsString)));
|
||
sql.Add(' and CarNo=''' + Trim(ClientDataSet1.fieldbyname('CarNo').AsString) + ''' and StopFlag=0 ');
|
||
execsql;
|
||
end;
|
||
end;
|
||
|
||
with ClientDataSet2 do
|
||
begin
|
||
APPEND;
|
||
ClientDataSet2.fieldbyname('SSEL').VALUE := TRUE;
|
||
ClientDataSet2.fieldbyname('MCNO').VALUE := ClientDataSet1.fieldbyname('MCNO').ASSTRING;
|
||
ClientDataSet2.fieldbyname('MCCJ').VALUE := ClientDataSet1.fieldbyname('MCCJ').ASSTRING;
|
||
// ClientDataSet2.fieldbyname('').VALUE := ClientDataSet1.fieldbyname('').ASSTRING;
|
||
POST;
|
||
end;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmJTSel.TV2DblClick(Sender: TObject);
|
||
begin
|
||
ClientDataSet2.delete;
|
||
end;
|
||
|
||
end.
|
||
|