D7YPDJlingyao/贸易管理(TradeManage.dll)/U_Samplelist_LY.pas
DESKTOP-E401PHE\Administrator 43fbfa8db2 ~
2025-07-19 16:53:04 +08:00

327 lines
8.2 KiB
ObjectPascal
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_Samplelist_LY;
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, cxPC, cxCalendar, RM_Common, RM_Class, RM_GridReport,
RM_System, RM_Dataset, RM_e_Xls;
type
TfrmSamplelist_LY = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBFind: TToolButton;
TBAdd: TToolButton;
TBEdit: TToolButton;
TBDel: TToolButton;
TBExport: TToolButton;
TBPrint: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
Label1: TLabel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1P_CodeName: TcxGridDBColumn;
v1Note: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
v1CRTime: TcxGridDBColumn;
v1Filler: TcxGridDBColumn;
v1FillTime: TcxGridDBColumn;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
P_CodeName: TEdit;
P_Code: TEdit;
CRType: TComboBox;
Label5: TLabel;
ADOQueryCmd: TADOQuery;
ADOQueryTmp: TADOQuery;
DataSource1: TDataSource;
CDS_Main: TClientDataSet;
cxGridPopupMenu1: TcxGridPopupMenu;
ckName: TComboBox;
Label6: TLabel;
v1P_Code: TcxGridDBColumn;
v1INoutNo: TcxGridDBColumn;
cxTabControl1: TcxTabControl;
Label9: TLabel;
defstr6: TEdit;
RMDBMain: TRMDBDataSet;
RM1: TRMGridReport;
RMXLSExport1: TRMXLSExport;
v1Column6: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
v1Column1: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
custName: TEdit;
Label7: TLabel;
ywy: TEdit;
Label8: TLabel;
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 cxTabControl1Change(Sender: TObject);
procedure Tv1CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
private
procedure InitGrid();
procedure SetComboBox();
procedure Setstatus();
{ Private declarations }
public
fCKName:string;
fCRFlag:string;
canshu1:string;
{ Public declarations }
end;
var
frmSamplelist_LY: TfrmSamplelist_LY;
implementation
uses
U_DataLink,U_Fun10,U_ZDYHelp, U_SampleLR_Ly;
{$R *.dfm}
procedure TfrmSamplelist_LY.SetStatus();
begin
TBedit.Visible:=false;
Tbdel.Visible:=false;
case cxTabControl1.TabIndex of
0:begin
TBedit.Visible:=true;
Tbdel.Visible:=true;
end;
1:begin
// tbcdel.Visible:=true;
end;
end;
end;
procedure TfrmSamplelist_LY.SetComboBox();
begin
ckName.Items.Clear;
with adoQueryTmp do
begin
close;
sql.Clear;
sql.Add('select * from KH_ZDY where Type=''YPCK'' ');
if trim(fCKName)<>'' then
sql.Add('and zdyName='+quotedstr(trim(fCKName)));
open;
while not eof do
begin
ckName.Items.Add(trim(fieldbyname('zdyName').AsString));
next;
end;
end;
if ckName.Items.Count>0 then ckName.ItemIndex:=0;
CRType.Items.Clear;
CRType.Items.Add('');
with adoQueryTmp do
begin
close;
sql.Clear;
sql.Add('select * from KH_ZDY where Type=''YPRKTYPE''');
if trim(fCKName)<>'' then
sql.Add('and note='+quotedstr(trim(fCKName)));
open;
while not eof do
begin
CRType.Items.Add(trim(fieldbyname('zdyName').AsString));
next;
end;
end;
if CRType.Items.Count>0 then CRType.ItemIndex:=0;
end;
procedure TfrmSamplelist_LY.InitGrid();
begin
try
with adoqueryTmp do
begin
close;
sql.Clear;
sql.Add('select A.* from JY_Sample A');
sql.Add('where CRTime>='''+formatdateTime('yyyy-MM-dd',begdate.Date)+''' ');
sql.Add('and CRTime<'''+formatdateTime('yyyy-MM-dd',enddate.Date+1)+''' ');
sql.Add('and CRFlag='''+trim(fCRFlag)+''' ');
IF trim(canshu1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
sql.Add('and ywy='''+trim(DName)+''' ');
open;
end;
SCreateCDS20(adoqueryTmp,CDS_Main);
SInitCDSData20(adoqueryTmp,CDS_Main);
finally
end;
end;
procedure TfrmSamplelist_LY.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
writeCxGrid(self.Caption,Tv1);
Action:=cafree;
end;
procedure TfrmSamplelist_LY.FormDestroy(Sender: TObject);
begin
frmSamplelist_LY:=nil;
end;
procedure TfrmSamplelist_LY.TBAddClick(Sender: TObject);
begin
frmSampleLR_Ly:=TfrmSampleLR_Ly.create(self);
with frmSampleLR_Ly do
begin
fkeyNo:='';
fCRFlag:=self.fCRFlag;
fckName:=self.fckName;
canshu1:=self.canshu1;
if showmodal=1 then
begin
TBRafresh.Click;
self.CDS_Main.Locate('JSNo',trim(fkeyNo),[]) ;
end;
free;
end;
end;
procedure TfrmSamplelist_LY.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 TfrmSamplelist_LY.FormShow(Sender: TObject);
begin
readCxGrid(self.Caption,Tv1);
// SetComboBox();
SetStatus();
InitGrid();
end;
procedure TfrmSamplelist_LY.FormCreate(Sender: TObject);
begin
BegDate.Date:=DServerDate-7;
EndDate.Date:=DServerDate;
cxGrid1.Align:=alclient;
canshu1:=trim(DParameters1);
end;
procedure TfrmSamplelist_LY.TBCloseClick(Sender: TObject);
begin
close;
end;
procedure TfrmSamplelist_LY.TBEditClick(Sender: TObject);
var
rkNum,ckNum:double;
begin
if CDS_Main.IsEmpty then Exit;
frmSampleLR_Ly:=TfrmSampleLR_Ly.create(self);
with frmSampleLR_Ly do
begin
fkeyNo:=self.cds_main.fieldbyname('JSNO').AsString;
fCRFlag:=self.fCRFlag;
canshu1:=self.canshu1;
if showmodal=1 then
begin
TBRafresh.Click;
self.CDS_Main.Locate('JSNo',trim(fkeyNo),[]) ;
end;
free;
end;
end;
procedure TfrmSamplelist_LY.TBDelClick(Sender: TObject);
var
rkNum,ckNum:double;
begin
if CDS_Main.IsEmpty then Exit;
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
try
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete JY_Sample ');
SQL.Add('where JSNO='''+Trim(CDS_Main.fieldbyname('JSNO').AsString)+''' ');
SQL.Add('and JSID='''+Trim(CDS_Main.fieldbyname('JSID').AsString)+''' ');
execsql;
end;
TBRafresh.Click;
except
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
end;
end;
procedure TfrmSamplelist_LY.TBRafreshClick(Sender: TObject);
begin
initGrid();
end;
procedure TfrmSamplelist_LY.TBPrintClick(Sender: TObject);
var
fPrintFile:string;
begin
if CDS_Main.IsEmpty then Exit;
IF fCRFlag='SY' then
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\SO<53><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.rmf' ;
IF fCRFlag='CY' then
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\ɫ<><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.rmf' ;
if FileExists(fPrintFile) then
begin
RM1.LoadFromFile(fPrintFile);
RM1.ShowReport;
end else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+'Report\'+Trim(fPrintFile)+'.rmf'),'<27><>ʾ',0);
end;
end;
procedure TfrmSamplelist_LY.TBExportClick(Sender: TObject);
begin
if CDS_Main.IsEmpty then Exit;
TcxGridToExcel(self.Caption,cxgrid1);
end;
procedure TfrmSamplelist_LY.cxTabControl1Change(Sender: TObject);
begin
SetStatus();
initGrid();
end;
procedure TfrmSamplelist_LY.Tv1CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
begin
TBedit.Click;
end;
end.