D7wmguihua/坯布码单待检(PBMDDJ.dll)/U_PKQTList.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

613 lines
17 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_PKQTList;
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, cxCalendar, cxButtonEdit, cxSplitter,
RM_Common, RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport,
cxTextEdit, cxPC, cxCheckBox, Menus;
type
TfrmPKQTList = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBAdd: TToolButton;
TBEdit: TToolButton;
TBDel: TToolButton;
TBClose: TToolButton;
cxGridPopupMenu1: TcxGridPopupMenu;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DataSource1: TDataSource;
TBExport: TToolButton;
Order_Main: TClientDataSet;
RM1: TRMGridReport;
RMDBMain: TRMDBDataSet;
RMXLSExport1: TRMXLSExport;
CDS_PRT: TClientDataSet;
ToolButton3: TToolButton;
cxGridPopupMenu2: TcxGridPopupMenu;
Panel1: TPanel;
Label2: TLabel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
FactoryName: TEdit;
Label6: TLabel;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column6: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
v1Column11: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
v1ShipDate: TcxGridDBColumn;
v1Column12: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
Label1: TLabel;
v1Column21: TcxGridDBColumn;
v1Column22: TcxGridDBColumn;
ToolButton1: TToolButton;
ToolButton4: TToolButton;
v1Column1: TcxGridDBColumn;
cxTabControl1: TcxTabControl;
ToolButton2: TToolButton;
v1Column16: TcxGridDBColumn;
v1Column17: TcxGridDBColumn;
v1Column18: TcxGridDBColumn;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
ToolButton5: TToolButton;
v1Column19: TcxGridDBColumn;
v1Column20: TcxGridDBColumn;
v1Column23: TcxGridDBColumn;
v1Column25: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
Label3: TLabel;
Label4: TLabel;
PayMent: TEdit;
ComTaiTou: TEdit;
Label7: TLabel;
JBPerson: TEdit;
Label8: TLabel;
PKName: TEdit;
v1Column9: TcxGridDBColumn;
Label5: TLabel;
BZType: TComboBox;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure TBEditClick(Sender: TObject);
procedure TBDelClick(Sender: TObject);
procedure TBExportClick(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure TBAddClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure cxPageControl1Change(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure cxTabControl1Change(Sender: TObject);
procedure FactoryNameChange(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure Tv1StylesGetContentStyle(Sender: TcxCustomGridTableView;
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
out AStyle: TcxStyle);
procedure v1Column22CustomDrawCell(Sender: TcxCustomGridTableView;
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
var ADone: Boolean);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
private
FInt,PFInt:Integer;
canshu1,canshu2:string;
FNowDate:TDateTime;
procedure InitGrid();
procedure InitForm();
function DelData():Boolean;
{ Private declarations }
public
{ Public declarations }
end;
var
frmPKQTList: TfrmPKQTList;
implementation
uses
U_DataLink,U_RTFun,U_ModuleNote, U_ZDYHelp,U_PKInPutQT;
{$R *.dfm}
procedure TfrmPKQTList.FormDestroy(Sender: TObject);
begin
frmPKQTList:=nil;
end;
procedure TfrmPKQTList.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmPKQTList.TBCloseClick(Sender: TObject);
begin
Close;
WriteCxGrid('<27>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure TfrmPKQTList.InitGrid();
var
fsj:String;
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add(' select A.*');
SQL.Add(' from YF_Money_PaiKuan A where ');
sql.Add(' A.PKDate>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+'''');
sql.Add(' and A.PKDate<'''+Trim(FormatDateTime('yyyy-MM-dd',Enddate.Date+1))+'''');
sql.Add(' and isnull(HZType,'''')=''<27><><EFBFBD><EFBFBD>'' ');
if cxTabControl1.TabIndex=0 then
begin
sql.Add(' and isnull(ChkStatus,'''')='''' ');
end else
if cxTabControl1.TabIndex=1 then
begin
sql.Add(' and isnull(ChkStatus,'''')=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
end else
if cxTabControl1.TabIndex=2 then
begin
sql.Add(' and isnull(ChkStatus,'''')=''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>'' ');
end else
if cxTabControl1.TabIndex=3 then
begin
sql.Add(' and isnull(ChkStatus,'''')=''<27><><EFBFBD>˲<EFBFBD>ͨ<EFBFBD><CDA8>'' ');
end;
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmPKQTList.InitForm();
begin
FNowDate:=SGetServerDate(ADOQueryTemp);
EndDate.Date:=FNowDate+7;
BegDate.Date:=FNowDate-7;
ReadCxGrid('<27>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure TfrmPKQTList.TBEditClick(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
if (cxTabControl1.TabIndex=0) or (cxTabControl1.TabIndex=3) then
begin
{if Trim(DName)<>Trim(Order_Main.fieldbyname('Filler').AsString) then
begin
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ!','<27><>ʾ',0);
Exit;
end;}
try
frmPKInPutQT:=TfrmPKInPutQT.Create(Application);
with frmPKInPutQT do
begin
PState:=1;
FMainId:=Trim(Self.Order_Main.fieldbyname('PKID').AsString);
ToolButton3.Visible:=False;
ToolButton4.Visible:=False;
ToolButton1.Visible:=False;
if ShowModal=1 then
begin
end;
end;
finally
frmPKInPutQT.Free;
end;
end;
end;
procedure TfrmPKQTList.TBDelClick(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
if cxTabControl1.TabIndex<>0 then Exit;
{if Trim(DName)<>Trim(Order_Main.fieldbyname('Filler').AsString) then
begin
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ!','<27><>ʾ',0);
Exit;
end; }
if Order_Main.Locate('SSel',True,[])=False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><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;
if DelData() then
begin
//Order_Main.Delete;
end;
end;
function TfrmPKQTList.DelData():Boolean;
begin
try
Result:=false;
ADOQueryCmd.Connection.BeginTrans;
with Order_Main do
begin
First;
while Locate('SSel',True,[]) do
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete YF_Money_PaiKuan where PKId='''+Trim(Order_Main.fieldbyname('PKId').AsString)+'''');
ExecSQL;
end;
Order_Main.Delete;
end;
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 TfrmPKQTList.TBExportClick(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
TcxGridToExcel('<27>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>(<28><><EFBFBD><EFBFBD>)',cxGrid1);
end;
procedure TfrmPKQTList.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmPKQTList.TBAddClick(Sender: TObject);
begin
try
frmPKInPutQT:=TfrmPKInPutQT.Create(Application);
with frmPKInPutQT do
begin
PState:=0;
FMainId:='';
if ShowModal=1 then
begin
end;
end;
finally
frmPKInPutQT.Free;
end;
end;
procedure TfrmPKQTList.FormShow(Sender: TObject);
begin
InitForm();
end;
procedure TfrmPKQTList.cxPageControl1Change(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmPKQTList.ToolButton3Click(Sender: TObject);
begin
try
frmModuleNote:=TfrmModuleNote.Create(Application);
with frmModuleNote do
begin
flag:='<27>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>)';
if ShowModal=1 then
begin
end;
end;
finally
frmModuleNote.Free;
end;
end;
procedure TfrmPKQTList.FormCreate(Sender: TObject);
begin
canshu1:=Trim(DParameters1);
canshu2:=Trim(DParameters2);
end;
procedure TfrmPKQTList.cxTabControl1Change(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmPKQTList.FactoryNameChange(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 TfrmPKQTList.ToolButton1Click(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 TfrmPKQTList.ToolButton4Click(Sender: TObject);
var
fPrintFile:string;
begin
if Order_Main.IsEmpty then Exit;
if cxTabControl1.TabIndex<>2 then Exit;
if Order_Main.Locate('SSel',True,[])=False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.rmf' ;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('delete TBSubID where DName='''+Trim(DName)+'''');
ExecSQL;
end;
Order_Main.DisableControls;
with Order_Main do
begin
First;
while not Eof do
begin
if Order_Main.FieldByName('SSel').AsBoolean=True then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('insert into TBSubID');
sql.Add(' select '''+Trim(Order_Main.fieldbyname('PKID').AsString)+'''');
sql.Add(','''+Trim(DName)+'''');
ExecSQL;
end;
Edit;
FieldByName('PrtFlag').Value:=True;
Post;
end;
Next;
end;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update YF_Money_PaiKuan Set PrtFlag=1,PrtTime=getdate(),Prter='''+Trim(DName)+'''');
sql.Add(',PrtCount=PrtCount+1');
sql.Add(' where PKID in(select SubId from TBSubID A where A.DName='''+Trim(DName)+''')');
ExecSQL;
end;
Order_Main.EnableControls;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add(' select AA.*,');
sql.Add(' Case when isnull(FactoryNameOther,'''')<>'''' then RTrim(FactoryNameOther)+''<27><>''+RTrim(FactoryName) ');
sql.Add(' else RTrim(FactoryNameQC)+''<27><>''+RTrim(FactoryName) end as FactoryNameHZ');
sql.Add(' from (');
sql.Add(' select A.PKID,A.ComTaiTou,A.PKYongTu,A.PayMent,A.FactoryNameOther,A.FactoryName,isnull(A.PKMoney,0) PKMoney,A.ChkNote,A.Note ');
sql.Add(' ,isnull(A.BQKKMoney,0) BQKKMoney,isnull(A.HZKKMoney,0) HZKKMoney,isnull(A.BQYFMoney,0) BQYFMoney,isnull(A.HZYFMoney,0) HZYFMoney');
sql.Add(',isnull(A.DDuiZhangMoney,0) DDuiZhangMoney,isnull(A.MaxHZYFMoney,0) MaxHZYFMoney,A.PKDate,A.Filler');
sql.Add(' ,FYear=Rtrim(Convert(varchar(4),A.PKDate,120))+''<27><>''');
sql.Add(' ,FactoryNameQC=(select KHName from ZH_KH_Info B where B.KHNameJC=A.FactoryName and B.Type=''GYS'' ) ');
sql.Add(' from YF_Money_PaiKuan A');
sql.Add(' where PKID in(select SubId from TBSubID where DName='''+Trim(DName)+'''))AA');
Open;
end;
SCreateCDS20(ADOQueryTemp,CDS_PRT);
SInitCDSData20(ADOQueryTemp,CDS_PRT);
if FileExists(fPrintFile) then
begin
//RMVariables['FMonth']:=Order_Main.fieldbyname('KQDate10').AsString;
RM1.ShowPrintDialog:=True;
RM1.LoadFromFile(fPrintFile);
RM1.ShowReport;
end else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+'<27>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'),'<27><>ʾ',0);
end;
end;
procedure TfrmPKQTList.Tv1StylesGetContentStyle(
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
var
id,id10,id20:Integer;
begin
{try
if Tv1.GroupedItemCount=0 then
begin
Id:=Tv1.GetColumnByFieldName('YuJinagDate1').Index-tv1.GroupedItemCount;
Id10:=Tv1.GetColumnByFieldName('YuJinagDate2').Index-tv1.GroupedItemCount;
Id20:=TV1.GetColumnByFieldName('MoneyKC').Index;
if ARecord.Values[id20]<=0 then Exit;
if ARecord.Values[Id10]-FNowDate<=0 then
begin
AStyle:=DataLink_KangChi.Red;
end else
begin
if ARecord.Values[Id]-FNowDate<=0 then
begin
AStyle:=DataLink_KangChi.Yellow;
end;
end;
end else
begin
end;
except
end; }
end;
procedure TfrmPKQTList.v1Column22CustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
Id,Id10,Id20:Integer;
begin
{Id:=TV1.GetColumnByFieldName('PKMoney').Index;//;-TV1.GroupedItemCount;
Id10:=TV1.GetColumnByFieldName('BQYFMoney').Index;
Id20:=TV1.GetColumnByFieldName('HZYFMoney').Index;
if Id<0 then Exit;
if AViewInfo.GridRecord.Values[id]>AViewInfo.GridRecord.Values[id20] then
begin
ACanvas.Brush.Color:=clRed;
end else
begin
if AViewInfo.GridRecord.Values[id]>AViewInfo.GridRecord.Values[id10] then
begin
ACanvas.Brush.Color:=clPurple;
end else
begin
ACanvas.Brush.Color:=clSkyBlue;
end;
end; }
end;
procedure TfrmPKQTList.N1Click(Sender: TObject);
begin
SelOKNo(Order_Main,True);
end;
procedure TfrmPKQTList.N2Click(Sender: TObject);
begin
SelOKNo(Order_Main,False);
end;
procedure TfrmPKQTList.ToolButton2Click(Sender: TObject);
begin
if cxTabControl1.TabIndex<>0 then Exit;
if Order_Main.IsEmpty then Exit;
if Order_Main.Locate('SSel',True,[])=False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫִ<D2AA><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
try
ADOQueryCmd.Connection.BeginTrans;
Order_Main.DisableControls;
with Order_Main do
begin
First;
while Order_Main.Locate('SSel',True,[]) do
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update YF_Money_PaiKuan Set SSTime=getdate(),SSPerson='''+Trim(DName)+'''');
sql.Add(',ChkStatus=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
sql.Add(' where PKID='''+Trim(Order_Main.fieldbyname('PKID').AsString)+'''');
ExecSQL;
end;
Order_Main.Delete;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
Order_Main.EnableControls;
except
Order_Main.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
end;
end;
procedure TfrmPKQTList.ToolButton5Click(Sender: TObject);
begin
if cxTabControl1.TabIndex<>1 then Exit;
if Order_Main.IsEmpty then Exit;
if Order_Main.Locate('SSel',True,[])=False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫִ<D2AA>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
try
ADOQueryCmd.Connection.BeginTrans;
Order_Main.DisableControls;
with Order_Main do
begin
First;
while Order_Main.Locate('SSel',True,[]) do
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from YF_Money_PaiKuan ');
sql.Add(' where PKID='''+Trim(Order_Main.fieldbyname('PKID').AsString)+'''');
sql.Add(' and isnull(ChkStatus,'''')=''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>'' ');
Open;
end;
if ADOQueryTemp.IsEmpty=False then
begin
Order_Main.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD>ˢ<EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update YF_Money_PaiKuan Set SSTime=NUll,SSPerson=Null');
sql.Add(',ChkStatus=Null ');
sql.Add(' where PKID='''+Trim(Order_Main.fieldbyname('PKID').AsString)+'''');
ExecSQL;
end;
Order_Main.Delete;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
Order_Main.EnableControls;
except
Order_Main.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
end;
end;
end.