777 lines
20 KiB
ObjectPascal
777 lines
20 KiB
ObjectPascal
![]() |
unit U_JYSQlist;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, ComCtrls, ToolWin, StdCtrls, ExtCtrls, cxStyles, cxCustomData,
|
|||
|
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData,
|
|||
|
cxButtonEdit, cxDropDownEdit, cxGridLevel, cxGridCustomTableView,
|
|||
|
cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView,
|
|||
|
cxGrid, DBClient, ADODB, cxGridCustomPopupMenu, cxGridPopupMenu, RM_Common,
|
|||
|
RM_Class, RM_e_Xls, RM_GridReport, RM_System, RM_Dataset, cxPC, cxLookAndFeels,
|
|||
|
cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu, cxTextEdit, cxCalendar,
|
|||
|
cxCheckBox;
|
|||
|
|
|||
|
type
|
|||
|
TfrmJYSQLIST = class(TForm)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBRafresh: TToolButton;
|
|||
|
TBFind: TToolButton;
|
|||
|
TBAdd: TToolButton;
|
|||
|
TBEdit: TToolButton;
|
|||
|
TBExport: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
Panel1: TPanel;
|
|||
|
BegDate: TDateTimePicker;
|
|||
|
EndDate: TDateTimePicker;
|
|||
|
Label3: TLabel;
|
|||
|
Label4: TLabel;
|
|||
|
P_CodeName: TEdit;
|
|||
|
P_Code: TEdit;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryTmp: TADOQuery;
|
|||
|
DataSource1: TDataSource;
|
|||
|
CDS_Main: TClientDataSet;
|
|||
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|||
|
ckName: TComboBox;
|
|||
|
Label6: TLabel;
|
|||
|
ADOPrint: TADOQuery;
|
|||
|
RMDB_MD: TRMDBDataSet;
|
|||
|
RM1: TRMGridReport;
|
|||
|
RMXLSExport1: TRMXLSExport;
|
|||
|
kuwei: TEdit;
|
|||
|
Label8: TLabel;
|
|||
|
cxTabControl1: TcxTabControl;
|
|||
|
P_Color: TEdit;
|
|||
|
Label9: TLabel;
|
|||
|
custName: TEdit;
|
|||
|
Label2: TLabel;
|
|||
|
btnDelData: TToolButton;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
v1P_Code: TcxGridDBColumn;
|
|||
|
v1P_CodeName: TcxGridDBColumn;
|
|||
|
v1Column4: TcxGridDBColumn;
|
|||
|
v1P_SPEC: TcxGridDBColumn;
|
|||
|
v1P_Color: TcxGridDBColumn;
|
|||
|
v1Qty: TcxGridDBColumn;
|
|||
|
v1QtyUnit: TcxGridDBColumn;
|
|||
|
v1Note: TcxGridDBColumn;
|
|||
|
v1Column5: TcxGridDBColumn;
|
|||
|
v1Column6: TcxGridDBColumn;
|
|||
|
v1Column9: TcxGridDBColumn;
|
|||
|
v1Column3: TcxGridDBColumn;
|
|||
|
v1P_MF: TcxGridDBColumn;
|
|||
|
v1P_KZ: TcxGridDBColumn;
|
|||
|
v1Column10: TcxGridDBColumn;
|
|||
|
Tv1Column5: TcxGridDBColumn;
|
|||
|
v1Column7: TcxGridDBColumn;
|
|||
|
v1Column11: TcxGridDBColumn;
|
|||
|
Tv1Column2: TcxGridDBColumn;
|
|||
|
Tv1Column3: TcxGridDBColumn;
|
|||
|
Tv1Column4: TcxGridDBColumn;
|
|||
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
Tv1Column6: TcxGridDBColumn;
|
|||
|
Tv1Column7: TcxGridDBColumn;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
ToolButton2: TToolButton;
|
|||
|
Tv1Column8: TcxGridDBColumn;
|
|||
|
Tv1Column1: TcxGridDBColumn;
|
|||
|
Tv1Column9: TcxGridDBColumn;
|
|||
|
ToolButton3: TToolButton;
|
|||
|
CDS_PRT: TClientDataSet;
|
|||
|
Tv1Column10: TcxGridDBColumn;
|
|||
|
Tv1Column11: TcxGridDBColumn;
|
|||
|
Tv1Column12: TcxGridDBColumn;
|
|||
|
Tv1Column13: TcxGridDBColumn;
|
|||
|
Label5: TLabel;
|
|||
|
FILLER: TEdit;
|
|||
|
ComboBox1: TComboBox;
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure TBAddClick(Sender: TObject);
|
|||
|
procedure P_CodeNameChange(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
procedure TBEditClick(Sender: TObject);
|
|||
|
procedure TBDelClick(Sender: TObject);
|
|||
|
procedure TBRafreshClick(Sender: TObject);
|
|||
|
procedure TBPrintClick(Sender: TObject);
|
|||
|
procedure TBExportClick(Sender: TObject);
|
|||
|
procedure TbPrint1Click(Sender: TObject);
|
|||
|
procedure cxTabControl1Change(Sender: TObject);
|
|||
|
procedure TchkClick(Sender: TObject);
|
|||
|
procedure TnochkClick(Sender: TObject);
|
|||
|
procedure btnDelDataClick(Sender: TObject);
|
|||
|
procedure btnDelCXClick(Sender: TObject);
|
|||
|
procedure Tv1CustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
procedure ToolButton2Click(Sender: TObject);
|
|||
|
procedure ToolButton3Click(Sender: TObject);
|
|||
|
procedure Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
|||
|
procedure Tv1Column12PropertiesEditValueChanged(Sender: TObject);
|
|||
|
procedure ComboBox1Change(Sender: TObject);
|
|||
|
procedure P_ColorKeyPress(Sender: TObject; var Key: Char);
|
|||
|
private
|
|||
|
procedure InitGrid();
|
|||
|
procedure SetStatus();
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
fCKName: string;
|
|||
|
canshu1: string;
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmJYSQLIST: TfrmJYSQLIST;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_Fun10, U_ZDYHelp, U_JYSQINPUT, U_FUN;
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.SetStatus();
|
|||
|
begin
|
|||
|
TBedit.Visible := false;
|
|||
|
|
|||
|
btnDelData.Visible := false;
|
|||
|
ToolButton1.Visible := False;
|
|||
|
ToolButton2.Visible := False;
|
|||
|
case cxTabControl1.TabIndex of
|
|||
|
0:
|
|||
|
begin
|
|||
|
TBedit.Visible := true;
|
|||
|
btnDelData.Visible := True;
|
|||
|
if canshu1 = '<27><><EFBFBD><EFBFBD>' then
|
|||
|
begin
|
|||
|
ToolButton1.Visible := true;
|
|||
|
end;
|
|||
|
end;
|
|||
|
1:
|
|||
|
begin
|
|||
|
if canshu1 = '<27><><EFBFBD><EFBFBD>' then
|
|||
|
begin
|
|||
|
ToolButton2.Visible := true;
|
|||
|
end;
|
|||
|
end;
|
|||
|
2:
|
|||
|
begin
|
|||
|
|
|||
|
end;
|
|||
|
3:
|
|||
|
begin
|
|||
|
|
|||
|
btnDelData.Visible := true;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.InitGrid();
|
|||
|
var
|
|||
|
Pwhere: string;
|
|||
|
begin
|
|||
|
if SGetFilters(Panel1, 1, 2) <> '' then
|
|||
|
Pwhere := ' and ' + SGetFilters(Panel1, 1, 2);
|
|||
|
try
|
|||
|
with adoqueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select A.* ');
|
|||
|
SQL.Add(',CKDATE=ISNULL(ChkTime,(SELECT TOP 1 CRTIME FROM CK_Sample_CR B WHERE B.JYSQD=A.CRID ORDER BY CRTIME DESC))');
|
|||
|
SQL.Add(',BZFLAG=(CASE WHEN STATUS=''1'' AND ( select COUNT(*) from CK_Sample_CR c where c.JYSQD=A.CRID and valid=''Y'' )=0 THEN 1 ELSE 0 END)');
|
|||
|
SQL.Add(' from YP_InOut2 A');
|
|||
|
|
|||
|
if ComboBox1.Text = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
|
|||
|
begin
|
|||
|
sql.Add('where CRTime>=''' + formatdateTime('yyyy-MM-dd', begdate.Date) + ''' ');
|
|||
|
sql.Add('and CRTime<''' + formatdateTime('yyyy-MM-dd', enddate.Date + 1) + ''' ');
|
|||
|
end
|
|||
|
else if ComboBox1.Text = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
|
|||
|
begin
|
|||
|
sql.Add('where ISNULL(ChkTime,(SELECT TOP 1 CRTIME FROM CK_Sample_CR B WHERE B.JYSQD=A.CRID ORDER BY CRTIME DESC))>=''' + formatdateTime('yyyy-MM-dd', begdate.Date) + ''' ');
|
|||
|
sql.Add('and ISNULL(ChkTime,(SELECT TOP 1 CRTIME FROM CK_Sample_CR B WHERE B.JYSQD=A.CRID ORDER BY CRTIME DESC))<''' + formatdateTime('yyyy-MM-dd', enddate.Date + 1) + ''' ');
|
|||
|
end;
|
|||
|
sql.Add('and CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
|
|||
|
sql.Add('and ckname=''<27><><EFBFBD>뵥''');
|
|||
|
SQL.Add('and valid=''Y''');
|
|||
|
case cxTabControl1.TabIndex of
|
|||
|
0:
|
|||
|
begin
|
|||
|
sql.Add(' and A.status=''0'' ');
|
|||
|
end;
|
|||
|
1:
|
|||
|
begin
|
|||
|
sql.Add('and A.status=''1'' ');
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
sql.Add(Pwhere);
|
|||
|
if canshu1 = '¼<><C2BC>' then
|
|||
|
begin
|
|||
|
sql.Add('and (filler in (select UserName from SY_User where Udept=(select Udept from SY_User where SY_User.UserName=' + QuotedStr(Trim(DName)));
|
|||
|
sql.Add('))');
|
|||
|
SQL.Add('OR FILLER=' + QuotedStr(Trim(DName)));
|
|||
|
sql.Add(')');
|
|||
|
end;
|
|||
|
|
|||
|
sql.add('order by filltime desc');
|
|||
|
// ShowMessage(SQL.Text);
|
|||
|
open;
|
|||
|
end;
|
|||
|
SCreateCDS20(adoqueryTmp, CDS_Main);
|
|||
|
SInitCDSData20(adoqueryTmp, CDS_Main);
|
|||
|
finally
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
|
|||
|
Action := cafree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
frmJYSQLIST := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.TBAddClick(Sender: TObject);
|
|||
|
begin
|
|||
|
frmJYSQinput := TfrmJYSQinput.create(self);
|
|||
|
with frmJYSQinput do
|
|||
|
begin
|
|||
|
fkeyNo := '';
|
|||
|
fType := 0;
|
|||
|
fckName := self.fckName;
|
|||
|
|
|||
|
if showmodal = 1 then
|
|||
|
begin
|
|||
|
TBRafresh.Click;
|
|||
|
self.CDS_Main.Locate('crNo', trim(fkeyNo), []);
|
|||
|
end;
|
|||
|
free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.P_CodeNameChange(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryTmp.Active = False then
|
|||
|
Exit;
|
|||
|
SDofilter(ADOQueryTmp, SGetFilters(Panel1, 1, 2));
|
|||
|
SCreateCDS20(ADOQueryTmp, CDS_Main);
|
|||
|
SInitCDSData20(ADOQueryTmp, CDS_Main);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.FormShow(Sender: TObject);
|
|||
|
var
|
|||
|
fsj: string;
|
|||
|
begin
|
|||
|
readCxGrid(self.Caption, Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
|||
|
|
|||
|
SetStatus();
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
BegDate.Date := SGetServerDate10(ADOQueryTmp) - 7;
|
|||
|
EndDate.Date := SGetServerDate10(ADOQueryTmp);
|
|||
|
cxGrid1.Align := alclient;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
writeCxGrid(self.Caption, Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
|||
|
close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.TBEditClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if cds_main.IsEmpty then
|
|||
|
exit;
|
|||
|
|
|||
|
frmJYSQinput := TfrmJYSQinput.create(self);
|
|||
|
with frmJYSQinput do
|
|||
|
begin
|
|||
|
fkeyNo := self.cds_main.fieldbyname('CRNO').AsString;
|
|||
|
fType := 1;
|
|||
|
fckName := self.fckName;
|
|||
|
if showmodal = 1 then
|
|||
|
begin
|
|||
|
TBRafresh.Click;
|
|||
|
self.CDS_Main.Locate('crNo', trim(fkeyNo), []);
|
|||
|
end;
|
|||
|
free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.TBDelClick(Sender: TObject);
|
|||
|
var
|
|||
|
YFID, CRID: string;
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
|
|||
|
if Application.MessageBox('<27>Ƿ<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
Exit;
|
|||
|
|
|||
|
try
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
|
|||
|
sql.Add('update YP_InOut2 SET valid=''N'' ');
|
|||
|
sql.Add(',editer=' + quotedstr(trim(DName)));
|
|||
|
sql.Add(',edittime=getdate()');
|
|||
|
SQL.Add('where CRNO=''' + Trim(CDS_Main.fieldbyname('CRNO').AsString) + ''' ');
|
|||
|
//
|
|||
|
// sql.Add('delete from YF_money_CR ');
|
|||
|
// SQL.Add('where mainID=''' + Trim(CDS_Main.fieldbyname('CRNO').AsString) + ''' ');
|
|||
|
// SQL.Add('and subID=''' + Trim(CDS_Main.fieldbyname('CRID').AsString) + ''' ');
|
|||
|
|
|||
|
execsql;
|
|||
|
end;
|
|||
|
TBRafresh.Click;
|
|||
|
except
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
initGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.TBPrintClick(Sender: TObject);
|
|||
|
var
|
|||
|
filepath: string;
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
exit;
|
|||
|
|
|||
|
with AdoPrint do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('exec P_Print_cpCkMd ');
|
|||
|
sql.Add('@inoutNo=' + quotedstr(trim(CDS_Main.fieldbyname('inoutNO').AsString)));
|
|||
|
sql.Add(',@flag=' + quotedstr(trim('')));
|
|||
|
open;
|
|||
|
end;
|
|||
|
|
|||
|
try
|
|||
|
filepath := ExtractFilePath(Application.ExeName) + 'report\<5C><><EFBFBD><EFBFBD><EFBFBD>뵥.rmf';
|
|||
|
if not FileExists(Pchar(filepath)) then
|
|||
|
begin
|
|||
|
application.MessageBox(pchar('<27>ļ<EFBFBD>[' + filepath + ']<5D><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>'), '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_IConError);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
RMVariables['dtxz'] := FormatDateTime('yyyy-mm-dd', date());
|
|||
|
RMVariables['zdr'] := trim(DName);
|
|||
|
RMVariables['Filler'] := trim(CDS_Main.fieldbyname('Filler').AsString);
|
|||
|
RM1.LoadFromFile(filepath);
|
|||
|
RM1.ShowReport;
|
|||
|
finally
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.TBExportClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
TcxGridToExcel(self.Caption, cxgrid1);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.TbPrint1Click(Sender: TObject);
|
|||
|
var
|
|||
|
filepath: string;
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
exit;
|
|||
|
|
|||
|
with AdoPrint do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' select A.*,B.CYMF,B.CYKZ,A.SHAZHI defnote5, ');
|
|||
|
sql.Add(' FilesOther=(select top 1 X1.FilesOther from TP_File X1,CP_YDang X2 where X1.WBID=X2.CYID and X2.CYNo=A.P_Code and X1.TFType=''<27><>Ʒ'') ');
|
|||
|
sql.Add(' from YP_INout2 A ');
|
|||
|
sql.Add(' left join CP_YDang B on B.CYNO=A.P_Code');
|
|||
|
sql.Add(' where A.CRNo=' + quotedstr(trim(CDS_Main.fieldbyname('CRNO').AsString)));
|
|||
|
open;
|
|||
|
end;
|
|||
|
|
|||
|
try
|
|||
|
filepath := ExtractFilePath(Application.ExeName) + 'report\<5C><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.rmf';
|
|||
|
if not FileExists(Pchar(filepath)) then
|
|||
|
begin
|
|||
|
application.MessageBox(pchar('<27>ļ<EFBFBD>[' + filepath + ']<5D><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>'), '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_IConError);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
RMVariables['dtxz'] := FormatDateTime('yyyy-mm-dd', date());
|
|||
|
RMVariables['zdr'] := trim(DName);
|
|||
|
RMVariables['Filler'] := trim(CDS_Main.fieldbyname('Filler').AsString);
|
|||
|
RM1.LoadFromFile(filepath);
|
|||
|
RM1.ShowReport;
|
|||
|
finally
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.cxTabControl1Change(Sender: TObject);
|
|||
|
begin
|
|||
|
SetStatus();
|
|||
|
initGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.TchkClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
exit;
|
|||
|
try
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('update YP_InOut2 SET status=''1'' ');
|
|||
|
sql.Add('where CRNO=' + quotedstr(trim(CDS_Main.fieldbyname('CRNO').AsString)));
|
|||
|
execsql;
|
|||
|
end;
|
|||
|
application.MessageBox('<27><><EFBFBD>˳ɹ<CBB3><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
|||
|
TBRafresh.Click;
|
|||
|
except
|
|||
|
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.TnochkClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
exit;
|
|||
|
try
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('update YP_InOut2 SET status=''0'' ');
|
|||
|
sql.Add('where CRNO=' + quotedstr(trim(CDS_Main.fieldbyname('CRNO').AsString)));
|
|||
|
execsql;
|
|||
|
end;
|
|||
|
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳ɹ<CBB3><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
|||
|
TBRafresh.Click;
|
|||
|
except
|
|||
|
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.btnDelDataClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
|
|||
|
if Application.MessageBox('<27>Ƿ<EFBFBD>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
Exit;
|
|||
|
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('delete YP_InOut2 where CRID=' + quotedstr(CDS_Main.fieldbyname('CRID').AsString));
|
|||
|
execsql;
|
|||
|
end;
|
|||
|
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
CDS_Main.Delete;
|
|||
|
except
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.btnDelCXClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
|
|||
|
if Application.MessageBox('<27>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
Exit;
|
|||
|
|
|||
|
try
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
|
|||
|
sql.Add('update YP_InOut2 SET valid=''Y'' ');
|
|||
|
sql.Add(',editer=' + quotedstr(trim(DName)));
|
|||
|
sql.Add(',edittime=getdate()');
|
|||
|
SQL.Add('where CRNO=''' + Trim(CDS_Main.fieldbyname('CRNO').AsString) + ''' ');
|
|||
|
|
|||
|
execsql;
|
|||
|
end;
|
|||
|
TBRafresh.Click;
|
|||
|
except
|
|||
|
Application.MessageBox('<27><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>ɾ<EFBFBD><C9BE>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.Tv1CustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
|
|||
|
var
|
|||
|
FValue: string;
|
|||
|
FBounds: TRect;
|
|||
|
begin
|
|||
|
FBounds := AViewInfo.Bounds;
|
|||
|
if (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
|
|||
|
begin
|
|||
|
ACanvas.FillRect(FBounds);
|
|||
|
ACanvas.DrawComplexFrame(FBounds, clBtnHighlight, clBtnShadow, [bBottom, bLeft, bRight], 1);
|
|||
|
FValue := IntToStr(TcxGridIndicatorRowItemViewInfo(AViewInfo).GridRecord.Index + 1);
|
|||
|
InflateRect(FBounds, -1, -1); //Platform specific. May not work on Linux.
|
|||
|
ACanvas.Font.Color := clBlack;
|
|||
|
ACanvas.Brush.Style := bsClear;
|
|||
|
ACanvas.DrawText(FValue, FBounds, cxAlignCenter or cxAlignTop);
|
|||
|
ADone := True;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.ToolButton1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
exit;
|
|||
|
if CDS_Main.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_Main 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 YP_InOut2 SET status=''1'',ChkTime=GETDATE()');
|
|||
|
sql.Add('where CRID=' + quotedstr(trim(CDS_Main.fieldbyname('CRID').AsString)));
|
|||
|
execsql;
|
|||
|
end;
|
|||
|
end;
|
|||
|
next;
|
|||
|
end;
|
|||
|
First;
|
|||
|
EnableControls;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
application.MessageBox('<27><><EFBFBD>dzɹ<C7B3><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
|||
|
TBRafresh.Click;
|
|||
|
except
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.ToolButton2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
exit;
|
|||
|
if CDS_Main.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_Main 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 YP_InOut2 SET status=''0'',ChkTime=NULL');
|
|||
|
sql.Add('where CRID=' + quotedstr(trim(CDS_Main.fieldbyname('CRID').AsString)));
|
|||
|
execsql;
|
|||
|
end;
|
|||
|
end;
|
|||
|
next;
|
|||
|
end;
|
|||
|
First;
|
|||
|
EnableControls;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
|||
|
TBRafresh.Click;
|
|||
|
except
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.ToolButton3Click(Sender: TObject);
|
|||
|
var
|
|||
|
fPrintFile: string;
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
//if Trim(CDS_Main.fieldbyname('CRType').AsString)<>'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then Exit;
|
|||
|
if CDS_Main.Locate('SSel', True, []) = False then
|
|||
|
begin
|
|||
|
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
ExportFtErpFile('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵥.rmf', ADOQueryTmp);
|
|||
|
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵥.rmf';
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('delete TBSubID where DName=''' + Trim(DCode) + '''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('SELECT * FROM TBSubID where 1=2 ');
|
|||
|
open;
|
|||
|
end;
|
|||
|
with cds_main do
|
|||
|
begin
|
|||
|
CDS_Main.DisableControls;
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
with CDS_Main do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while not Eof do
|
|||
|
begin
|
|||
|
if Fieldbyname('Ssel').AsBoolean then
|
|||
|
begin
|
|||
|
|
|||
|
ADOQueryCmd.append;
|
|||
|
ADOQueryCmd.fieldbyname('SubId').Value := Trim(CDS_Main.fieldbyname('crid').AsString);
|
|||
|
ADOQueryCmd.fieldbyname('Dname').Value := Trim(DCode);
|
|||
|
ADOQueryCmd.post;
|
|||
|
end;
|
|||
|
Next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
except
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
end;
|
|||
|
CDS_Main.EnableControls;
|
|||
|
with ADOPrint do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.add('exec P_Print_JYSQD ');
|
|||
|
sql.add('@DCODE=' + quotedstr(Trim(DCode)));
|
|||
|
// ShowMessage(SQL.Text);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOPrint, CDS_PRT);
|
|||
|
SInitCDSData20(ADOPrint, CDS_PRT);
|
|||
|
|
|||
|
RMXLSExport1 := TRMXLSExport.Create(RMXLSExport1);
|
|||
|
if FileExists(fPrintFile) then
|
|||
|
begin
|
|||
|
// RMVariables['QRBARCODE'] := fImagePath;
|
|||
|
RM1.LoadFromFile(fPrintFile);
|
|||
|
RM1.ShowReport;
|
|||
|
// RM1.PrintReport;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
CDS_Main.EnableControls;
|
|||
|
Application.MessageBox(PChar('û<><C3BB><EFBFBD>ҵ<EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
Edit;
|
|||
|
FieldByName('SSel').Value := False;
|
|||
|
Post;
|
|||
|
end;
|
|||
|
CDS_Main.EnableControls;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
|||
|
begin
|
|||
|
if (AViewInfo.GridRecord.Values[Tv1Column11.Index] = 1) then
|
|||
|
begin
|
|||
|
ACanvas.font.Color := clRed;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.Tv1Column12PropertiesEditValueChanged(Sender: TObject);
|
|||
|
var
|
|||
|
mvalue, FFieldName: string;
|
|||
|
begin
|
|||
|
|
|||
|
mvalue := TcxTextEdit(Sender).EditingText;
|
|||
|
FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
|
|||
|
with CDS_Main do
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
FieldByName(FFieldName).Value := mvalue;
|
|||
|
Post;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('update YP_INOUT2 set ' + FFieldName + '=' + QUOTEDSTR(Trim(mvalue)));
|
|||
|
sql.Add('where CRID=' + quotedstr(Trim(CDS_Main.fieldbyname('CRID').AsString)));
|
|||
|
// ShowMessage(SQL.Text);
|
|||
|
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
tv1.Controller.EditingController.ShowEdit();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.ComboBox1Change(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmJYSQLIST.P_ColorKeyPress(Sender: TObject; var Key: Char);
|
|||
|
begin
|
|||
|
if Key = #13 then
|
|||
|
begin
|
|||
|
initgrid();
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|