805 lines
22 KiB
ObjectPascal
805 lines
22 KiB
ObjectPascal
unit U_CPFHSQList;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
|
||
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses, cxControls,
|
||
cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
||
cxGrid, DBClient, cxCheckBox, cxCalendar, cxSplitter, RM_Dataset, RM_System,
|
||
RM_Common, RM_Class, RM_GridReport, RM_e_Xls, Menus, cxPC, cxButtonEdit,
|
||
RM_E_llPDF, cxDropDownEdit, cxTextEdit, IdBaseComponent, IdComponent,
|
||
IdTCPConnection, IdTCPClient, IdHTTP, cxLookAndFeels, cxLookAndFeelPainters,
|
||
cxNavigator, dxBarBuiltInMenu, dxSkinsCore,
|
||
dxSkinDarkRoom,
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
dxSkinOffice2013White,
|
||
dxSkinSharpPlus,
|
||
dxSkinSpringTime,
|
||
dxSkinsDefaultPainters,
|
||
dxSkinscxPCPainter;
|
||
|
||
type
|
||
TfrmCPFHSQList = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBFind: TToolButton;
|
||
TBAdd: TToolButton;
|
||
TBEdit: TToolButton;
|
||
TBDel: TToolButton;
|
||
TBPrint: TToolButton;
|
||
TBClose: TToolButton;
|
||
Tv1: TcxGridDBTableView;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
cxGrid1: TcxGrid;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
v1OrdDate: TcxGridDBColumn;
|
||
v1OrdPerson1: TcxGridDBColumn;
|
||
Order_Main: TClientDataSet;
|
||
RMDB_Main: TRMDBDataSet;
|
||
RMXLSExport1: TRMXLSExport;
|
||
ToolButton1: TToolButton;
|
||
ADOQueryPrint: TADOQuery;
|
||
CDS_Print: TClientDataSet;
|
||
v1Column4: TcxGridDBColumn;
|
||
Panel1: TPanel;
|
||
Label1: TLabel;
|
||
Label4: TLabel;
|
||
Label5: TLabel;
|
||
Label8: TLabel;
|
||
Label9: TLabel;
|
||
Label12: TLabel;
|
||
Label13: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
SHDWName: TEdit;
|
||
YwyName: TEdit;
|
||
MPRTCodeName: TEdit;
|
||
toconno: TEdit;
|
||
MPRTKZ: TEdit;
|
||
MPRTMF: TEdit;
|
||
cxTabControl1: TcxTabControl;
|
||
tchk: TToolButton;
|
||
Tnochk: TToolButton;
|
||
cxSplitter1: TcxSplitter;
|
||
ADOQuerySub: TADOQuery;
|
||
DataSource2: TDataSource;
|
||
v1Column8: TcxGridDBColumn;
|
||
Label2: TLabel;
|
||
//RMllPDFExport1: TRMllPDFExport;
|
||
cxGrid2: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
v1Column5: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
ClientDataSet2: TClientDataSet;
|
||
cxGridPopupMenu2: TcxGridPopupMenu;
|
||
CDS_Note: TClientDataSet;
|
||
RM1: TRMGridReport;
|
||
v1Column11: TcxGridDBColumn;
|
||
v1Column13: TcxGridDBColumn;
|
||
v1Column17: TcxGridDBColumn;
|
||
v1Column18: TcxGridDBColumn;
|
||
v1Column19: TcxGridDBColumn;
|
||
v2Column1: TcxGridDBColumn;
|
||
v2Column3: TcxGridDBColumn;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column7: TcxGridDBColumn;
|
||
v1Column10: TcxGridDBColumn;
|
||
v1Column21: TcxGridDBColumn;
|
||
v1Column25: TcxGridDBColumn;
|
||
v2Column8: TcxGridDBColumn;
|
||
v2Column12: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
CDSUser: TClientDataSet;
|
||
IdHTTP1: TIdHTTP;
|
||
ToolButton2: TToolButton;
|
||
ToolButton3: TToolButton;
|
||
Tv2Column1: TcxGridDBColumn;
|
||
Tv2Column2: TcxGridDBColumn;
|
||
Tv1Column1: TcxGridDBColumn;
|
||
Tv2Column3: TcxGridDBColumn;
|
||
Tv1Column2: TcxGridDBColumn;
|
||
Tv1Column3: TcxGridDBColumn;
|
||
Tv1Column4: TcxGridDBColumn;
|
||
Label3: TLabel;
|
||
HZP_CODE: TEdit;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBFindClick(Sender: TObject);
|
||
procedure TBEditClick(Sender: TObject);
|
||
procedure TBDelClick(Sender: TObject);
|
||
procedure TBPrintClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure TBAddClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure CheckBox1Click(Sender: TObject);
|
||
procedure CheckBox2Click(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure SHDWNameChange(Sender: TObject);
|
||
procedure tchkClick(Sender: TObject);
|
||
procedure TnochkClick(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure Tv1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
private
|
||
procedure InitGrid();
|
||
procedure InitSubGrid();
|
||
procedure InitForm();
|
||
procedure SetStatus();
|
||
function DelData(): Boolean;
|
||
{ Private declarations }
|
||
public
|
||
FFInt: Integer;
|
||
canshu1: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_CPFHSQInPut, U_Fun, U_ZDYHelp;
|
||
|
||
{$R *.dfm}
|
||
procedure TfrmCPFHSQList.SetStatus();
|
||
begin
|
||
tchk.Visible := False;
|
||
Tnochk.Visible := False;
|
||
TBDel.Visible := False;
|
||
TBEdit.Visible := False;
|
||
TBAdd.Visible := False;
|
||
ToolButton2.Visible := False;
|
||
ToolButton3.Visible := False;
|
||
if canshu1 = '¼<><C2BC>' then
|
||
begin
|
||
TBAdd.Visible := true;
|
||
case cxTabControl1.TabIndex of
|
||
0:
|
||
begin
|
||
TBEdit.Visible := true;
|
||
TBDel.Visible := true;
|
||
end;
|
||
1:
|
||
begin
|
||
|
||
end;
|
||
2:
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
end
|
||
else if canshu1 = '<27><><EFBFBD><EFBFBD>' then
|
||
begin
|
||
TBAdd.Visible := true;
|
||
case cxTabControl1.TabIndex of
|
||
0:
|
||
begin
|
||
tchk.Visible := true;
|
||
TBEdit.Visible := true;
|
||
TBDel.Visible := true;
|
||
end;
|
||
1:
|
||
begin
|
||
Tnochk.Visible := true;
|
||
ToolButton2.Visible := True;
|
||
end;
|
||
2:
|
||
begin
|
||
ToolButton3.Visible := True;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
WriteCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3');
|
||
WriteCxGrid(trim(self.Caption) + 'TV2', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3');
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered := False;
|
||
Close;
|
||
sql.Clear;
|
||
Sql.Add(' select A.*');
|
||
SQL.Add(' ,HZP_CODE= STUFF(( SELECT '','' +convert(VARCHAR, P_CODE) FROM SQ_FH_SUB B WHERE B.FHMAINID=A.FHMAINID FOR XML PATH('''')), 1, 1, '''') ');
|
||
sql.Add(' from SQ_FH_Main A');
|
||
sql.Add(' where 1=1');
|
||
if cxTabControl1.TabIndex <> 0 then
|
||
begin
|
||
sql.Add(' and filltime>=''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.Date)) + '''');
|
||
sql.Add(' and filltime<''' + Trim(FormatDateTime('yyyy-MM-dd', EndDate.Date + 1)) + '''');
|
||
end;
|
||
if cxTabControl1.TabIndex = 0 then
|
||
begin
|
||
SQL.Add(' and isnull(A.Chker,'''')='''' ');
|
||
end
|
||
else if cxTabControl1.TabIndex = 1 then
|
||
begin
|
||
SQL.Add(' and isnull(A.Chker,'''')<>'''' ');
|
||
SQL.Add(' and isnull(A.ChkStatus,'''')=''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>'' ');
|
||
end
|
||
else if cxTabControl1.TabIndex = 2 then
|
||
begin
|
||
SQL.Add(' and isnull(A.Chker,'''')<>'''' ');
|
||
SQL.Add(' and isnull(A.ChkStatus,'''')=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
|
||
end;
|
||
if Trim(canshu1) = '¼<><C2BC>' then
|
||
begin
|
||
sql.Add(' and isnull(A.Filler,'''')=''' + Trim(DName) + '''');
|
||
end;
|
||
// showmessage(sql.text);
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain, Order_Main);
|
||
SInitCDSData20(ADOQueryMain, Order_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.InitForm();
|
||
begin
|
||
|
||
ReadCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3');
|
||
ReadCxGrid(trim(self.Caption) + 'TV2', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3');
|
||
|
||
EndDate.DateTime := SGetServerDate10(ADOQueryTemp);
|
||
BegDate.DateTime := EndDate.DateTime;
|
||
SetStatus();
|
||
InitGrid();
|
||
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.TBFindClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS20(ADOQueryMain, Order_Main);
|
||
SInitCDSData20(ADOQueryMain, Order_Main);
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.TBEditClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
Exit;
|
||
if cxTabControl1.TabIndex <> 0 then
|
||
Exit;
|
||
if Trim(canshu1) <> '<27><>Ȩ<EFBFBD><C8A8>' then
|
||
begin
|
||
if Trim(Order_Main.fieldbyname('Filler').AsString) <> Trim(DName) then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
// with ADOQueryTemp do
|
||
// begin
|
||
// close;
|
||
// sql.Clear;
|
||
// sql.Add('select * from SQ_FH_Main');
|
||
// sql.Add('where FHMainId=' + quotedstr(trim(Order_Main.fieldbyname('FHMainId').AsString)));
|
||
// Open;
|
||
// end;
|
||
// if Trim(ADOQueryTemp.fieldbyname('YSID').AsString) <> '' then
|
||
// begin
|
||
// Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>˿<CBBF><EEB2BB><EFBFBD><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
// Exit;
|
||
// end;
|
||
try
|
||
frmPBFHSQInPut := TfrmPBFHSQInPut.Create(Application);
|
||
with frmPBFHSQInPut do
|
||
begin
|
||
PState := 1;
|
||
FMainId := Trim(Self.Order_Main.fieldbyname('FHMainId').AsString);
|
||
|
||
if ShowModal = 1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmPBFHSQInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.TBDelClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
Exit;
|
||
if cxTabControl1.TabIndex <> 0 then
|
||
Exit;
|
||
if Trim(Order_Main.fieldbyname('Filler').AsString) <> Trim(DName) then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from SQ_FH_Sub where FHMainId=''' + Trim(Order_Main.fieldbyname('FHMainId').AsString) + '''');
|
||
sql.add(' and isnull(FHPiQty,0)>0');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty = False then
|
||
begin
|
||
Application.MessageBox('<27>ѷ<EFBFBD><D1B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
exit;
|
||
end;
|
||
// with ADOQueryTemp do
|
||
// begin
|
||
// close;
|
||
// sql.Clear;
|
||
// sql.Add('select * from SQ_FH_Main');
|
||
// sql.Add('where FHMainId=' + quotedstr(trim(Order_Main.fieldbyname('FHMainId').AsString)));
|
||
// Open;
|
||
// end;
|
||
// if Trim(ADOQueryTemp.fieldbyname('YSID').AsString) <> '' then
|
||
// begin
|
||
// Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>˿<CBBF><EEB2BB>ɾ<EFBFBD><C9BE>!', '<27><>ʾ', 0);
|
||
// Exit;
|
||
// end;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
||
Exit;
|
||
if DelData() then
|
||
begin
|
||
Order_Main.Delete;
|
||
InitSubGrid();
|
||
end;
|
||
end;
|
||
|
||
function TfrmCPFHSQList.DelData(): Boolean;
|
||
begin
|
||
try
|
||
Result := false;
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete SQ_FH_Sub where FHMainId=''' + Trim(Order_Main.fieldbyname('FHMainId').AsString) + '''');
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete SQ_FH_Main where FHMainId=''' + Trim(Order_Main.fieldbyname('FHMainId').AsString) + '''');
|
||
ExecSQL;
|
||
end;
|
||
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
Result := True;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Result := False;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>쳣<EFBFBD><ECB3A3>', '<27><>ʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.TBPrintClick(Sender: TObject);
|
||
var
|
||
fPrintFile: string;
|
||
Txt, fImagePath: string;
|
||
Moudle: THandle;
|
||
Makebar: TMakebar;
|
||
Mixtext: TMixtext;
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
Exit;
|
||
if cxTabControl1.TabIndex <> 1 then
|
||
Exit;
|
||
if Order_Main.Locate('SSel', True, []) = False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
Order_Main.DisableControls;
|
||
with Order_Main do
|
||
begin
|
||
First;
|
||
while Order_Main.Locate('SSel', True, []) = True do
|
||
begin
|
||
begin
|
||
with ADOQueryPrint do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
Sql.Add(' select A.*,B.*'); //and Y.ClothType=B.ClothType
|
||
sql.Add(' from SQ_FH_Main A inner join SQ_FH_Sub B on A.FHMainId=B.FHMainId ');
|
||
sql.Add(' where A.FHMainId=''' + Trim(Order_Main.fieldbyname('FHMainId').AsString) + '''');
|
||
open;
|
||
|
||
end;
|
||
ExportFtErpFile('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵥.rmf', ADOQueryTemp);
|
||
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵥.rmf';
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
try
|
||
Moudle := LoadLibrary('MakeQRBarcode.dll');
|
||
@Makebar := GetProcAddress(Moudle, 'Make');
|
||
@Mixtext := GetProcAddress(Moudle, 'MixText');
|
||
Txt := Trim(Order_Main.fieldbyname('FHMainId').AsString);
|
||
fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
|
||
if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
|
||
CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
|
||
if FileExists(fImagePath) then
|
||
DeleteFile(fImagePath);
|
||
Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
|
||
except
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
|
||
RMVariables['QRBARCODE'] := fImagePath;
|
||
RM1.LoadFromFile(fPrintFile);
|
||
RM1.printReport;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵥.rmf'), '<27><>ʾ', 0);
|
||
end;
|
||
Order_Main.Delete;
|
||
end;
|
||
end;
|
||
end;
|
||
Order_Main.EnableControls;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
// application.MessageBox('<27><><EFBFBD>˳ɹ<CBB3><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
Exit;
|
||
except
|
||
|
||
Order_Main.EnableControls;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
// application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
|
||
// with ADOQueryPrint do
|
||
// begin
|
||
// Close;
|
||
// sql.Clear;
|
||
// Sql.Add(' select A.*,B.*'); //and Y.ClothType=B.ClothType
|
||
// sql.Add(' from SQ_FH_Main A inner join SQ_FH_Sub B on A.FHMainId=B.FHMainId ');
|
||
// sql.Add(' where A.FHMainId=''' + Trim(Order_Main.fieldbyname('FHMainId').AsString) + '''');
|
||
// open;
|
||
//
|
||
// end;
|
||
// ExportFtErpFile('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵥.rmf', ADOQueryTemp);
|
||
// fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵥.rmf';
|
||
// if FileExists(fPrintFile) then
|
||
// begin
|
||
// try
|
||
// Moudle := LoadLibrary('MakeQRBarcode.dll');
|
||
// @Makebar := GetProcAddress(Moudle, 'Make');
|
||
// @Mixtext := GetProcAddress(Moudle, 'MixText');
|
||
// Txt := Trim(Order_Main.fieldbyname('FHMainId').AsString);
|
||
// fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
|
||
// if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
|
||
// CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
|
||
// if FileExists(fImagePath) then
|
||
// DeleteFile(fImagePath);
|
||
// Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
|
||
// except
|
||
// application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
// exit;
|
||
// end;
|
||
//
|
||
// RMVariables['QRBARCODE'] := fImagePath;
|
||
// RM1.LoadFromFile(fPrintFile);
|
||
// RM1.ShowReport;
|
||
// end
|
||
// else
|
||
// begin
|
||
// Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵥.rmf'), '<27><>ʾ', 0);
|
||
// end;
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
TBFind.Click;
|
||
InitSubGrid();
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.TBAddClick(Sender: TObject);
|
||
var
|
||
maxno: string;
|
||
begin
|
||
try
|
||
frmPBFHSQInPut := TfrmPBFHSQInPut.Create(Application);
|
||
with frmPBFHSQInPut do
|
||
begin
|
||
PState := 0;
|
||
FMainId := '';
|
||
|
||
if ShowModal = 1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmPBFHSQInPut.Free;
|
||
end;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.FormShow(Sender: TObject);
|
||
begin
|
||
InitForm();
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.CheckBox1Click(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.CheckBox2Click(Sender: TObject);
|
||
begin
|
||
TBRafresh.Click;
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
Exit;
|
||
try
|
||
frmPBFHSQInPut := TfrmPBFHSQInPut.Create(Application);
|
||
with frmPBFHSQInPut do
|
||
begin
|
||
PState := 1;
|
||
FMainId := Trim(Self.Order_Main.fieldbyname('FHMainId').AsString);
|
||
ToolBar2.Visible := False;
|
||
TBSave.Visible := False;
|
||
ScrollBox1.Enabled := False;
|
||
Tv1.OptionsSelection.CellSelect := False;
|
||
if ShowModal = 1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmPBFHSQInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.SHDWNameChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS20(ADOQueryMain, Order_Main);
|
||
SInitCDSData20(ADOQueryMain, Order_Main);
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.tchkClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
exit;
|
||
if cxTabControl1.TabIndex <> 0 then
|
||
exit;
|
||
if Order_Main.Locate('SSel', True, []) = False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
Order_Main.DisableControls;
|
||
with Order_Main do
|
||
begin
|
||
First;
|
||
while Order_Main.Locate('SSel', True, []) = True do
|
||
begin
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update SQ_FH_Main SET Chker=''' + Trim(DName) + ''',ChkTime=getdate(),ChkStatus=''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>'' ');
|
||
sql.Add('where FHMainId=' + quotedstr(trim(Order_Main.fieldbyname('FHMainId').AsString)));
|
||
execsql;
|
||
end;
|
||
|
||
Order_Main.Delete;
|
||
end;
|
||
end;
|
||
end;
|
||
Order_Main.EnableControls;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
application.MessageBox('<27><><EFBFBD>˳ɹ<CBB3><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
Exit;
|
||
except
|
||
|
||
Order_Main.EnableControls;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.InitSubGrid();
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
if Order_Main.IsEmpty = False then
|
||
sql.Add('select * from SQ_FH_Sub A where A.FHMainId=''' + Trim(Order_Main.fieldbyname('FHMainId').AsString) + '''')
|
||
else
|
||
sql.Add('select * from SQ_FH_Sub A where 1=2');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp, ClientDataSet2);
|
||
SInitCDSData20(ADOQueryTemp, ClientDataSet2);
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.TnochkClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
exit;
|
||
if cxTabControl1.TabIndex <> 1 then
|
||
exit;
|
||
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
Order_Main.DisableControls;
|
||
with Order_Main do
|
||
begin
|
||
First;
|
||
while Order_Main.Locate('SSel', True, []) = True do
|
||
begin
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from SQ_FH_Main');
|
||
sql.Add('where FHMainId=' + quotedstr(trim(Order_Main.fieldbyname('FHMainId').AsString)));
|
||
|
||
Open;
|
||
end;
|
||
if Trim(ADOQueryTemp.fieldbyname('CWID').AsString) <> '' then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>˿<CBBF>ܳ<EFBFBD><DCB3><EFBFBD>!', '<27><>ʾ', 0);
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Exit;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update SQ_FH_Main SET Chker=Null,ChkTime=Null,ChkStatus=Null ');
|
||
sql.Add('where FHMainId=' + quotedstr(trim(Order_Main.fieldbyname('FHMainId').AsString)));
|
||
execsql;
|
||
end;
|
||
|
||
Order_Main.Delete;
|
||
end;
|
||
end;
|
||
end;
|
||
Order_Main.EnableControls;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳ɹ<CBB3><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
Exit;
|
||
except
|
||
|
||
Order_Main.EnableControls;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
SetStatus();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.Tv1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
if Order_Main.IsEmpty = False then
|
||
begin
|
||
sql.Add('select A.* from SQ_FH_Sub A ');
|
||
// sql.Add(' inner join PD_Plan_Sub B on A.FromSubId=B.SubId');
|
||
// sql.Add(' inner join PD_Plan_Main C on B.MainId=C.MainId');
|
||
sql.Add(' where A.FHMainId=''' + Trim(Order_Main.fieldbyname('FHMainId').AsString) + '''');
|
||
end
|
||
else
|
||
begin
|
||
sql.Add('select A.* from SQ_FH_Sub A ');
|
||
// sql.Add(' inner join PD_Plan_Sub B on A.FromSubId=B.SubId');
|
||
// sql.Add(' inner join PD_Plan_Main C on B.MainId=C.MainId');
|
||
sql.Add(' where 1=2');
|
||
end;
|
||
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp, ClientDataSet2);
|
||
SInitCDSData20(ADOQueryTemp, ClientDataSet2);
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
exit;
|
||
if cxTabControl1.TabIndex <> 1 then
|
||
exit;
|
||
try
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update SQ_FH_Main SET Chker=''' + Trim(DName) + ''',ChkTime=getdate(),ChkStatus=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
|
||
sql.Add('where FHMainId=' + quotedstr(trim(Order_Main.fieldbyname('FHMainId').AsString)));
|
||
execsql;
|
||
end;
|
||
Order_Main.Delete;
|
||
InitSubGrid();
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɳɹ<C9B3><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
except
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCPFHSQList.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then
|
||
exit;
|
||
if cxTabControl1.TabIndex <> 2 then
|
||
exit;
|
||
|
||
try
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update SQ_FH_Main SET Chker=''' + Trim(DName) + ''',ChkTime=getdate(),ChkStatus=''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>'' ');
|
||
sql.Add('where FHMainId=' + quotedstr(trim(Order_Main.fieldbyname('FHMainId').AsString)));
|
||
execsql;
|
||
end;
|
||
Order_Main.Delete;
|
||
InitSubGrid();
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɳɹ<C9B3><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
except
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
end.
|
||
|