451 lines
12 KiB
ObjectPascal
451 lines
12 KiB
ObjectPascal
unit U_JWLInOutList;
|
||
|
||
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, cxCalendar, cxButtonEdit, cxDropDownEdit,
|
||
DBClient, Menus, cxSplitter, cxTextEdit, RM_Common, RM_Class,
|
||
RM_GridReport, RM_System, RM_Dataset, RM_e_Xls, dxPSGlbl, dxPSUtl,
|
||
dxPSEngn, dxPrnPg, dxBkgnd, dxWrap, dxPrnDev, dxPSCompsProvider,
|
||
dxPSFillPatterns, dxPSEdgePatterns, dxPSCore, dxPScxCommon, dxPScxGridLnk;
|
||
|
||
type
|
||
TfrmJWLInOutList = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBFind: TToolButton;
|
||
TBAdd: TToolButton;
|
||
TBEdit: TToolButton;
|
||
TBDel: TToolButton;
|
||
TBPrint: TToolButton;
|
||
TBClose: TToolButton;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
TBExport: TToolButton;
|
||
Panel1: TPanel;
|
||
Label1: TLabel;
|
||
Label2: TLabel;
|
||
Label3: TLabel;
|
||
Label4: TLabel;
|
||
Label7: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
YCLName: TEdit;
|
||
YCLSpec: TEdit;
|
||
GYSName: TEdit;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1DepotClass: TcxGridDBColumn;
|
||
v1P_ChnName: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1ShortName: TcxGridDBColumn;
|
||
v1Quantity: TcxGridDBColumn;
|
||
v1UnitName: TcxGridDBColumn;
|
||
v1Note: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
CDS_Main: TClientDataSet;
|
||
v1Column3: TcxGridDBColumn;
|
||
RMDB_Main: TRMDBDataSet;
|
||
RM1: TRMGridReport;
|
||
RMXLSExport1: TRMXLSExport;
|
||
KCPlace: TEdit;
|
||
Label6: TLabel;
|
||
Label8: TLabel;
|
||
CRType: TComboBox;
|
||
v1Column4: TcxGridDBColumn;
|
||
v1Column6: TcxGridDBColumn;
|
||
ToolButton1: TToolButton;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBFindClick(Sender: TObject);
|
||
procedure TBEditClick(Sender: TObject);
|
||
procedure TBDelClick(Sender: TObject);
|
||
procedure TBExportClick(Sender: TObject);
|
||
procedure TBPrintClick(Sender: TObject);
|
||
procedure TBAddClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure YCLNameChange(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure Tv1StylesGetContentStyle(Sender: TcxCustomGridTableView;
|
||
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
|
||
out AStyle: TcxStyle);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
private
|
||
canshu1,canshu2,canshu3:String;
|
||
procedure InitGrid();
|
||
procedure InitForm();
|
||
function DelYFData():Boolean;
|
||
{ Private declarations }
|
||
public
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmJWLInOutList: TfrmJWLInOutList;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_RTFun,U_JWLChkIn, U_ModuleNote;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmJWLInOutList.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmJWLInOutList:=nil;
|
||
end;
|
||
|
||
procedure TfrmJWLInOutList.FormClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
Application:=MainApplication;
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmJWLInOutList.FormCreate(Sender: TObject);
|
||
begin
|
||
cxgrid1.Align:=alClient;
|
||
canshu1:=Trim(DParameters1);
|
||
canshu2:=Trim(DParameters2);
|
||
canshu3:=Trim(DParameters3);
|
||
end;
|
||
|
||
procedure TfrmJWLInOutList.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
WriteCxGrid('X<><58><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',Tv1,'ԭ<><D4AD><EFBFBD>ϲֿ<CFB2>');
|
||
end;
|
||
|
||
procedure TfrmJWLInOutList.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.* ');
|
||
sql.Add(' from CK_YCLONE_CR A');
|
||
SQL.Add(' where CRTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+'''');
|
||
SQL.Add(' and CRTime<'''+Trim(FormatDateTime('yyyy-MM-dd',EndDate.DateTime+1))+'''');
|
||
sql.Add(' and CKName='''+Trim(canshu1)+'''');
|
||
SQL.Add(' and CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
|
||
{if Trim(canshu3)<>'<27><>Ȩ<EFBFBD><C8A8>' then
|
||
begin
|
||
sql.Add(' and isnull(FillerCode,'''')='''+Trim(DCode)+'''');
|
||
end; }
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJWLInOutList.InitForm();
|
||
begin
|
||
ReadCxGrid('X<><58><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',Tv1,'ԭ<><D4AD><EFBFBD>ϲֿ<CFB2>');
|
||
EndDate.DateTime:=SGetServerDate10(ADOQueryTemp);
|
||
BegDate.DateTime:=EndDate.DateTime-7;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmJWLInOutList.TBFindClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then Exit;
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
end;
|
||
|
||
procedure TfrmJWLInOutList.TBEditClick(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then Exit;
|
||
if Trim(canshu2)<>'<27><>Ȩ<EFBFBD><C8A8>' then
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from CK_YCLONE_CR where RKID='''+Trim(CDS_Main.fieldbyname('MSID').AsString)+'''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from CK_YCLONE_CR where MSID='''+Trim(CDS_Main.fieldbyname('MSID').AsString)+'''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.FieldByName('Chker').AsString<>'' then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
|
||
try
|
||
frmJWLChkIn:=TfrmJWLChkIn.Create(Application);
|
||
with frmJWLChkIn do
|
||
begin
|
||
frmJWLChkIn.Canshu1:=Trim(Self.canshu1);
|
||
FMainId:=Trim(self.CDS_Main.fieldbyname('MSId').AsString);
|
||
ToolButton2.Visible:=False;
|
||
ToolButton3.Visible:=False;
|
||
v1Column3.Options.Focusing:=False;
|
||
if ShowModal=1 then
|
||
begin
|
||
Self.InitGrid();
|
||
Self.TBFind.Click;
|
||
Self.CDS_Main.Locate('MSId',FMainID,[]);
|
||
end;
|
||
end;
|
||
finally
|
||
frmJWLChkIn.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJWLInOutList.TBDelClick(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then Exit;
|
||
with ADOQueryTemp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from CK_YCLONE_CR where RKID='''+Trim(CDS_Main.fieldbyname('MSID').AsString)+'''');
|
||
sql.Add(' and JSFlag=-1 ');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty=False then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>ɾ<EFBFBD><C9BE>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from CK_YCLONE_CR where MSID='''+Trim(CDS_Main.fieldbyname('MSID').AsString)+'''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.FieldByName('Chker').AsString<>'' then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' delete from CK_YCLONE_CR where MSID='''+Trim(CDS_Main.fieldbyname('MSID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
CDS_Main.Delete;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>쳣<EFBFBD><ECB3A3>','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
|
||
|
||
procedure TfrmJWLInOutList.TBExportClick(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then Exit;
|
||
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',cxGrid1);
|
||
end;
|
||
|
||
procedure TfrmJWLInOutList.TBPrintClick(Sender: TObject);
|
||
var
|
||
fPrintFile,FConNoM,RPTName:string;
|
||
begin
|
||
if CDS_Main.IsEmpty then Exit;
|
||
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C><>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD><EFBFBD>ձ<EFBFBD><D5B1><EFBFBD>.rmf' ;
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
RMVariables['begdate']:=BegDate.DateTime;
|
||
RMVariables['enddate']:=enddate.DateTime;
|
||
//RMVariables['printtime']:=Now;
|
||
//RMVariables['printer']:=Trim(gUserName);
|
||
RM1.LoadFromFile(fPrintFile);
|
||
RM1.ShowReport;
|
||
end else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+RPTName),'<27><>ʾ',0);
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmJWLInOutList.TBAddClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmJWLChkIn:=TfrmJWLChkIn.Create(Application);
|
||
with frmJWLChkIn do
|
||
begin
|
||
FMainID:='';
|
||
frmJWLChkIn.Canshu1:=Trim(Self.canshu1);
|
||
if ShowModal=1 then
|
||
begin
|
||
Self.InitGrid();
|
||
Self.TBFind.Click;
|
||
Self.CDS_Main.Locate('MSId',FMainID,[]);
|
||
end;
|
||
end;
|
||
finally
|
||
frmJWLChkIn.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJWLInOutList.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
BegDate.SetFocus;
|
||
InitGrid();
|
||
end;
|
||
|
||
|
||
|
||
procedure TfrmJWLInOutList.YCLNameChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active=False then Exit;
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
end;
|
||
|
||
procedure TfrmJWLInOutList.FormShow(Sender: TObject);
|
||
begin
|
||
InitForm();
|
||
end;
|
||
function TfrmJWLInOutList.DelYFData():Boolean;
|
||
var
|
||
CRID,OrdMainId,YFID:String;
|
||
begin
|
||
Result:=False;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_CR where YFTypeId='''+Trim(CDS_Main.fieldbyname('MSID').AsString)+'''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty then
|
||
begin
|
||
Result:=True;
|
||
Exit;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from YF_Money_KC where FactoryName='''+Trim(CDS_Main.fieldbyname('GYSName').AsString)+'''');
|
||
SQL.Add(' and ZdyStr1=''Ӧ<><D3A6><EFBFBD><EFBFBD>'' ');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty=False then
|
||
begin
|
||
CRID:=ADOQueryTemp.fieldbyname('CRID').AsString;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete from YF_Money_CR where YFTypeId='''+Trim(CDS_Main.fieldbyname('MSID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update YF_Money_KC Set KCMoney=(select isnull(Sum(Money*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)');
|
||
sql.Add(',KCBBMoney=(select isnull(Sum(BBMoney*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)');
|
||
sql.Add(' where CRID='+CRID);
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_CR where CRID='+CRID);
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete YF_Money_KC where CRID='+CRID);
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
end;
|
||
Result:=True;
|
||
end;
|
||
|
||
|
||
|
||
procedure TfrmJWLInOutList.Tv1StylesGetContentStyle(
|
||
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
|
||
AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
|
||
var
|
||
id,id10:Integer;
|
||
begin
|
||
{if Trim(DParameters7)='<27>Ѹ<EFBFBD><D1B8><EFBFBD><EFBFBD><EFBFBD>' then
|
||
begin
|
||
try
|
||
if Tv1.GroupedItemCount=0 then
|
||
begin
|
||
Id:=Tv1.GetColumnByFieldName('YFMoney').Index-tv1.GroupedItemCount;
|
||
if Trim(VarToStr(ARecord.Values[id]))='' then Exit;
|
||
if Id<=0 then Exit;
|
||
if ARecord.Values[id]>0 then
|
||
AStyle:=DataLink_JWLCK.Red;
|
||
end else
|
||
begin
|
||
|
||
end;
|
||
except
|
||
end;
|
||
end; }
|
||
|
||
end;
|
||
|
||
procedure TfrmJWLInOutList.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
try
|
||
frmModuleNote:=TfrmModuleNote.Create(Application);
|
||
with frmModuleNote do
|
||
begin
|
||
flag:='<27>칫<EFBFBD><ECB9AB>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>';
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmModuleNote.Free;
|
||
end;
|
||
end;
|
||
|
||
end.
|