D7wmoukai/贸易管理(TradeManage.dll)/U_Samplelist.pas
DESKTOP-E401PHE\Administrator 451d1bbba9 ~
2025-07-19 17:24:07 +08:00

324 lines
8.1 KiB
ObjectPascal
Raw 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;
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 = 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;
v1Qty: 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;
v1Column1: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
RMDBMain: TRMDBDataSet;
RM1: TRMGridReport;
RMXLSExport1: TRMXLSExport;
v1Column6: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
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: TfrmSamplelist;
implementation
uses
U_DataLink,U_Fun10,U_ZDYHelp, U_SampleLR;
{$R *.dfm}
procedure TfrmSamplelist.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.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.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 Filler='''+trim(DName)+''' ');
open;
end;
SCreateCDS20(adoqueryTmp,CDS_Main);
SInitCDSData20(adoqueryTmp,CDS_Main);
finally
end;
end;
procedure TfrmSamplelist.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
writeCxGrid(self.Caption,Tv1);
Action:=cafree;
end;
procedure TfrmSamplelist.FormDestroy(Sender: TObject);
begin
frmSamplelist:=nil;
end;
procedure TfrmSamplelist.TBAddClick(Sender: TObject);
begin
frmSampleLR:=TfrmSampleLR.create(self);
with frmSampleLR 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.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.FormShow(Sender: TObject);
begin
readCxGrid(self.Caption,Tv1);
// SetComboBox();
SetStatus();
InitGrid();
end;
procedure TfrmSamplelist.FormCreate(Sender: TObject);
begin
BegDate.Date:=DServerDate-7;
EndDate.Date:=DServerDate;
cxGrid1.Align:=alclient;
canshu1:=trim(DParameters1);
end;
procedure TfrmSamplelist.TBCloseClick(Sender: TObject);
begin
close;
end;
procedure TfrmSamplelist.TBEditClick(Sender: TObject);
var
rkNum,ckNum:double;
begin
if CDS_Main.IsEmpty then Exit;
frmSampleLR:=TfrmSampleLR.create(self);
with frmSampleLR 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.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.TBRafreshClick(Sender: TObject);
begin
initGrid();
end;
procedure TfrmSamplelist.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.TBExportClick(Sender: TObject);
begin
if CDS_Main.IsEmpty then Exit;
TcxGridToExcel(self.Caption,cxgrid1);
end;
procedure TfrmSamplelist.cxTabControl1Change(Sender: TObject);
begin
SetStatus();
initGrid();
end;
procedure TfrmSamplelist.Tv1CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
begin
TBedit.Click;
end;
end.