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

884 lines
27 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_PRTOrderViewList;
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, cxCheckBox, cxCalendar, cxSplitter,
RM_Dataset, RM_System, RM_Common, RM_Class, RM_GridReport, RM_e_Xls,
Menus;
type
TfrmPRTOrderViewList = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBFind: TToolButton;
TBAdd: TToolButton;
TBEdit: TToolButton;
TBDel: TToolButton;
TBPrint: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
Label1: TLabel;
Tv1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
cxGrid1: TcxGrid;
cxGridPopupMenu1: TcxGridPopupMenu;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DataSource1: TDataSource;
Label3: TLabel;
OrderNo: TEdit;
TBExport: TToolButton;
v1OrderNo: TcxGridDBColumn;
v1OrdDate: TcxGridDBColumn;
v1DeliveryDate: TcxGridDBColumn;
v1MPRTSpec: TcxGridDBColumn;
Order_Main: TClientDataSet;
RM1: TRMGridReport;
RMDBMain: TRMDBDataSet;
RMXLSExport1: TRMXLSExport;
v1CustomerNoName: TcxGridDBColumn;
Label4: TLabel;
CustomerNoName: TEdit;
v1MPRTCodeName: TcxGridDBColumn;
v1MPRTMF: TcxGridDBColumn;
TBView: TToolButton;
Label8: TLabel;
MPRTCodeHZ: TEdit;
v1MPRTKZ: TcxGridDBColumn;
Label10: TLabel;
MPRTSpec: TEdit;
Label12: TLabel;
MPRTKZ: TEdit;
Label13: TLabel;
MPRTMF: TEdit;
ToolButton2: TToolButton;
ADOQueryPrint: TADOQuery;
CDS_Print: TClientDataSet;
ComboBox1: TComboBox;
v1Column2: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
Label9: TLabel;
Label2: TLabel;
ConNo: TEdit;
LiDanPerson: TEdit;
v1Column1: TcxGridDBColumn;
ComboBox2: TComboBox;
ToolButton1: TToolButton;
RMDBDataSet1: TRMDBDataSet;
RM2: TRMGridReport;
ToolButton3: TToolButton;
ComboBox3: TComboBox;
v1Column4: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
CheckBox1: TCheckBox;
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 TBRafreshClick(Sender: TObject);
procedure TBAddClick(Sender: TObject);
procedure OrderNoChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Tv1CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure Tv1StylesGetContentStyle(Sender: TcxCustomGridTableView;
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
out AStyle: TcxStyle);
procedure v1DeliveryDateCustomDrawCell(Sender: TcxCustomGridTableView;
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
var ADone: Boolean);
procedure TBViewClick(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure OrderNoKeyPress(Sender: TObject; var Key: Char);
procedure ConNoKeyPress(Sender: TObject; var Key: Char);
procedure Tv1CellClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
private
CanShu1,CanShu2:string;
DQdate:TDateTime;
procedure InitGrid();
procedure InitForm();
function DelData():Boolean;
procedure InitGridFH();
{ Private declarations }
public
FFInt,FCloth:Integer;
{ Public declarations }
end;
var
frmPRTOrderViewList: TfrmPRTOrderViewList;
implementation
uses
U_DataLink,U_OrderInPut,U_RTFun, U_ZDYHelp, U_ZDYHelpSel, U_ModuleNote;
{$R *.dfm}
procedure TfrmPRTOrderViewList.FormDestroy(Sender: TObject);
begin
frmPRTOrderViewList:=nil;
end;
procedure TfrmPRTOrderViewList.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmPRTOrderViewList.FormCreate(Sender: TObject);
begin
cxgrid1.Align:=alClient;
//BegDate.DateTime:=SGetServerDateTime(ADOQueryTemp)-7;
//EndDate.DateTime:=SGetServerDateTime(ADOQueryTemp);
DQdate:=SGetServerDate(ADOQueryTemp);
end;
procedure TfrmPRTOrderViewList.TBCloseClick(Sender: TObject);
begin
Close;
WriteCxGrid(ʾ<D6B8><CABE><EFBFBD>б<EFBFBD>',Tv1,'<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure TfrmPRTOrderViewList.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.add('exec P_View_Order :begdate,:enddate,:WSql') ;
Parameters.ParamByName('WSql').Value:='';
Parameters.ParamByName('begdate').Value:=FormatDateTime('yyyy-MM-dd',BegDate.DateTime);
Parameters.ParamByName('enddate').Value:=FormatDateTime('yyyy-MM-dd',enddate.DateTime+1);
ExecSQL;
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmPRTOrderViewList.InitGridFH();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add('exec Order_QryList :MainId,:WSql');
Parameters.ParamByName('WSql').Value:=' and FillTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+''''
+' and FillTime<'''+Trim(FormatDateTime('yyyy-MM-dd',EndDate.DateTime+1))+'''';
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmPRTOrderViewList.InitForm();
begin
ReadCxGrid(ʾ<D6B8><CABE><EFBFBD>б<EFBFBD>',Tv1,'<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
BegDate.DateTime:=SGetServerDate10(ADOQueryTemp)-92;
EndDate.DateTime:=SGetServerDate10(ADOQueryTemp);
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select Top 10* from JYOrder_Main Order by FillTime desc');
Open;
end;
ComboBox1.Clear;
with ADOQueryTemp do
begin
First;
while not Eof do
begin
ComboBox1.Items.Add(Trim(ADOQueryTemp.fieldbyname('OrderNO').AsString));
Next;
end;
end;
//InitGrid();
end;
procedure TfrmPRTOrderViewList.TBFindClick(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 TfrmPRTOrderViewList.TBEditClick(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
if Trim(CanShu1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
if Trim(Order_Main.fieldbyname('Filler').AsString)<>Trim(DName) then
begin
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
end;
try
frmOrderInPut:=TfrmOrderInPut.Create(Application);
with frmOrderInPut do
begin
PState:=1;
FMainId:=Trim(Self.Order_Main.fieldbyname('MainId').AsString);
FOrderNo:=Trim(Self.Order_Main.fieldbyname('OrderNo').AsString);
if ShowModal=1 then
begin
end;
end;
finally
frmOrderInPut.Free;
end;
end;
procedure TfrmPRTOrderViewList.TBDelClick(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
if Trim(Order_Main.fieldbyname('Filler').AsString)<>Trim(DName) then
begin
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from JYOrder_Main_MD where ORDMainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
Open;
end;
if ADOQueryTemp.IsEmpty=false then
begin
Application.MessageBox('<27>Ѿ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EBB5A5><EFBFBD><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;
if DelData() then
begin
Order_Main.Delete;
end;
end;
function TfrmPRTOrderViewList.DelData():Boolean;
begin
try
Result:=false;
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete JYOrder_Main where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
sql.Add('delete JYOrder_Sub where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
ExecSQL;
end;
{with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from JYOrder_Sub where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
Open;
if IsEmpty then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete JYOrder_Main where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
ExecSQL;
end;
end;
end;
if Trim(Order_Main.fieldbyname('SubId').AsString)='' then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete JYOrder_Main where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
ExecSQL;
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 TfrmPRTOrderViewList.TBExportClick(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then Exit;
end;
procedure TfrmPRTOrderViewList.TBPrintClick(Sender: TObject);
var
fPrintFile:string;
Porderno,PFTPUnit,LD,LDTel,GD,GDTel,CPQtyStr,BPQtyStr,QtyUnit:string;
i,j:Integer;
begin
if Order_Main.IsEmpty then Exit;
if Trim(ComboBox2.Text)='' then Exit;
if Trim(ComboBox3.Text)='' then Exit;
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\'+Trim(ComboBox3.Text)+'.rmf' ;
with ADOQueryPrint do
begin
Close;
sql.Clear;
sql.Add('select A.*,B.PSName,B.PSNote,C.ClothOneQty,C.MPRTOneQty,C.OneQtyUnit,C.OrderNo,C.MPRTCode,C.MPRTCodeName,C.MPRTCF ');
sql.Add(' ,C.MPRTSpec,C.MPRTMF,C.MPRTKZ,C.ChuanY,C.MPRTGY,C.MPRTGYHZ,D.*');
sql.Add(',GSTT=(select Top 1 ZdyStr1 from KH_Zdy A where A.ZdyName=C.ComTaiTou)');
sql.Add(',Case when RTrim(A.PFTPUnit)=''KG'' then '',''+Cast(Cast(A.PFTPQty*B.KgZM as int) as varchar(20))+''M'' ');
sql.Add(' else '''' end as MStr');
sql.Add(',C.LiDanPerson,LDTel10=(select Top 1 Note from KH_Zdy KZ where KZ.ZdyName=C.LiDanPerson and KZ.Type=''LiDanPerson'' )');
sql.Add(',GDTel10=(select Top 1 Note from KH_Zdy KZ where KZ.ZdyName=A.PFGenDanPerson and KZ.Type=''PFGenDanPerson'' )');
sql.Add(' from JYOrder_PCS_Sub A');
SQL.Add(' inner join JYOrder_Process B on A.PSID=B.PSID');
sql.Add(' inner join JYOrder_Main C on A.MainId=C.Mainid');
sql.Add(' left join JYOrder_Sub D on A.Subid=D.SubId');
sql.Add(' where A.MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
SQL.Add(' and A.FactoryName='''+Trim(ComboBox2.Text)+'''');
SQL.Add(' order by D.SubId');
Open;
end;
SCreateCDS20(ADOQueryPrint,CDS_Print);
SInitCDSData20(ADOQueryPrint,CDS_Print);
PFTPUnit:=Trim(CDS_Print.fieldbyname('PFTPUnit').AsString);
LD:=Trim(CDS_Print.fieldbyname('LiDanPerson').AsString);
LDTel:=Trim(CDS_Print.fieldbyname('LDTel10').AsString);
GD:=Trim(CDS_Print.fieldbyname('PFGenDanPerson').AsString);
GDTel:=Trim(CDS_Print.fieldbyname('GDTel10').AsString);
if (CDS_Print.RecordCount mod 2)=1 then
begin
CDS_Print.Append;
CDS_Print.Post;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select sum(PFTPQty) PFTPQtyHZ,sum(PFTPPS) PFTPPSHZ ');
sql.Add(' from JYOrder_PCS_Sub A');
SQL.Add(' inner join JYOrder_Process B on A.PSID=B.PSID');
sql.Add(' inner join JYOrder_Main C on A.MainId=C.Mainid');
sql.Add(' left join JYOrder_Sub D on A.Subid=D.SubId');
sql.Add(' where A.MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
SQL.Add(' and A.FactoryName='''+Trim(ComboBox2.Text)+'''');
sql.Add(' group by A.FactoryName');
Open;
end;
if FileExists(fPrintFile) then
begin
RMVariables['PFTPQtyHZ']:=ADOQueryTemp.fieldbyname('PFTPQtyHZ').Value;
RMVariables['PFTPPSHZ']:=ADOQueryTemp.fieldbyname('PFTPPSHZ').Value;
RMVariables['ZQty']:=Order_Main.fieldbyname('ZQty').Value;
RMVariables['OrderUnit']:=Order_Main.fieldbyname('OrderUnit').Value;
RMVariables['QtyUnit']:=Order_Main.fieldbyname('OneQtyUnit').Value;
RMVariables['CPQtyStr']:=Order_Main.fieldbyname('MPRTOneQty').Value;
RMVariables['BPQtyStr']:=Order_Main.fieldbyname('ClothOneQty').Value;
RMVariables['PFTPUnitHZ']:=Trim(PFTPUnit);
RMVariables['LD']:=Trim(LD);
RMVariables['LDTel']:=Trim(LDTel);
RMVariables['GD']:=Trim(GD);
RMVariables['GDTel']:=Trim(GDTel);
RM1.LoadFromFile(fPrintFile);
RM1.ShowReport;
end else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+'Report\<5C><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>.rmf'),'<27><>ʾ',0);
end;
// Panel4.Visible:=True;
end;
procedure TfrmPRTOrderViewList.TBRafreshClick(Sender: TObject);
begin
InitGrid();
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select Top 10* from JYOrder_Main Order by FillTime desc');
Open;
end;
ComboBox1.Clear;
with ADOQueryTemp do
begin
First;
while not Eof do
begin
ComboBox1.Items.Add(Trim(ADOQueryTemp.fieldbyname('OrderNO').AsString));
Next;
end;
end;
if Order_Main.IsEmpty=False then
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select distinct(FactoryName) FactoryName from JYOrder_PCS_Sub ');
sql.Add(' where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
Open;
end;
ComboBox2.Clear;
with ADOQueryTemp do
begin
First;
while not Eof do
begin
ComboBox2.Items.Add(Trim(ADOQueryTemp.fieldbyname('FactoryName').AsString));
Next;
end;
end;
end;
end;
procedure TfrmPRTOrderViewList.TBAddClick(Sender: TObject);
var
maxno:string;
begin
try
frmOrderInPut:=TfrmOrderInPut.Create(Application);
with frmOrderInPut do
begin
PState:=0;
FMainId:='';
if ShowModal=1 then
begin
end;
end;
finally
frmOrderInPut.Free;
end;
end;
procedure TfrmPRTOrderViewList.OrderNoChange(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 TfrmPRTOrderViewList.FormShow(Sender: TObject);
begin
InitForm();
end;
procedure TfrmPRTOrderViewList.Tv1CellDblClick(
Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
begin
if TBView.Visible=False then Exit;
TBView.Click;
end;
procedure TfrmPRTOrderViewList.CheckBox1Click(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmPRTOrderViewList.CheckBox2Click(Sender: TObject);
begin
TBRafresh.Click;
end;
procedure TfrmPRTOrderViewList.Tv1StylesGetContentStyle(
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
var
id,id10:Integer;
begin
{try
if Tv1.GroupedItemCount=0 then
begin
Id:=Tv1.GetColumnByFieldName('DeliveryDate').Index-tv1.GroupedItemCount;
Id10:=Tv1.GetColumnByFieldName('SubStatus').Index-tv1.GroupedItemCount;
if Trim(VarToStr(ARecord.Values[id]))='' then Exit;
if Id<0 then Exit;
if ARecord.Values[id10]='<27><><EFBFBD><EFBFBD>' then exit;
if (ARecord.Values[id]-DQdate)>=4 then Exit;
if ((ARecord.Values[id]-DQdate)>=0) and ((ARecord.Values[id]-DQdate)<4) then
AStyle:=DataLink_.QHuangSe
else
if ARecord.Values[id]-DQdate<0 then
begin
AStyle:=DataLink_OrderManage.FenHongS;
end;
end else
begin
end;
except
end; }
end;
procedure TfrmPRTOrderViewList.v1DeliveryDateCustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
{ Id:=TV1.GetColumnByFieldName('DeliveryDate').Index;//;-TV1.GroupedItemCount;
Id10:=TV1.GetColumnByFieldName('SubStatus').Index;
if Id<0 then Exit;
if AViewInfo.GridRecord.Values[Id10]='<27><><EFBFBD><EFBFBD>' then Exit;
if AViewInfo.GridRecord.Values[Id]-SGetServerDate(ADOQueryTemp)>=4 then Exit;
if ((AViewInfo.GridRecord.Values[id]-SGetServerDate10(ADOQueryTemp))>=0) and ((AViewInfo.GridRecord.Values[id]-SGetServerDate(ADOQueryTemp))<4) then
ACanvas.Brush.Color:=clYellow
else
if (AViewInfo.GridRecord.Values[id])-(SGetServerDate10(ADOQueryTemp)<0) then
begin
ACanvas.Brush.Color:=clRed;
end;
begin
ACanvas.Brush.Color:=clRed;
end else
if AViewInfo.GridRecord.Values[Id]='Purple' then
begin
ACanvas.Brush.Color:=clPurple;
end else
if AViewInfo.GridRecord.Values[Id]='Olive' then
begin
ACanvas.Brush.Color:=clOlive;
end else
if AViewInfo.GridRecord.Values[Id]='Teal' then
begin
ACanvas.Brush.Color:=clTeal;
end else
if AViewInfo.GridRecord.Values[Id]='Background' then
begin
ACanvas.Brush.Color:=clBackground;
end; }
end;
procedure TfrmPRTOrderViewList.TBViewClick(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
try
frmOrderInPut:=TfrmOrderInPut.Create(Application);
with frmOrderInPut do
begin
PState:=1;
FMainId:=Trim(Self.Order_Main.fieldbyname('MainId').AsString);
ToolBar2.Visible:=False;
//ToolBar3.Visible:=False;
ToolBar4.Visible:=False;
ToolBar5.Visible:=False;
TBSave.Visible:=False;
ToolButton4.Visible:=False;
ToolButton5.Visible:=False;
ToolButton8.Visible:=False;
ToolButton10.Visible:=False;
ToolButton11.Visible:=False;
//ScrollBox1.Enabled:=False;
Tv1.OptionsSelection.CellSelect:=False;
ToolBar6.Visible:=False;
ToolButton20.Visible:=False;
ToolButton21.Visible:=False;
if ShowModal=1 then
begin
end;
end;
finally
frmOrderInPut.Free;
end;
end;
procedure TfrmPRTOrderViewList.ToolButton2Click(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
try
frmOrderInPut:=TfrmOrderInPut.Create(Application);
with frmOrderInPut do
begin
PState:=1;
CopyInt:=99;
FMainId:=Trim(Self.Order_Main.fieldbyname('MainId').AsString);
if ShowModal=1 then
begin
end;
end;
finally
frmOrderInPut.Free;
end;
end;
procedure TfrmPRTOrderViewList.OrderNoKeyPress(Sender: TObject;
var Key: Char);
begin
if Key=#13 then
begin
if Length(OrderNo.Text)<3 then Exit;
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.add('exec P_View_Order :begdate,:enddate,:WSql') ;
Parameters.ParamByName('WSql').Value:=' and orderno like '''+'%'+Trim(OrderNo.Text)+'%'+'''';
Parameters.ParamByName('begdate').Value:='1899-01-01';
Parameters.ParamByName('enddate').Value:='2050-01-01';
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
end;
procedure TfrmPRTOrderViewList.ConNoKeyPress(Sender: TObject;
var Key: Char);
begin
if Key=#13 then
begin
if Length(conno.Text)<3 then Exit;
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.add('exec P_View_Order :begdate,:enddate,:WSql') ;
Parameters.ParamByName('WSql').Value:=' and conno like '''+'%'+Trim(conno.Text)+'%'+'''';
Parameters.ParamByName('begdate').Value:='1899-01-01';
Parameters.ParamByName('enddate').Value:='2050-01-01';
ExecSQL;
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
end;
procedure TfrmPRTOrderViewList.Tv1CellClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
begin
if Order_Main.IsEmpty then Exit;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select distinct(FactoryName) FactoryName from JYOrder_PCS_Sub ');
sql.Add(' where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
Open;
end;
ComboBox2.Clear;
with ADOQueryTemp do
begin
First;
while not Eof do
begin
ComboBox2.Items.Add(Trim(ADOQueryTemp.fieldbyname('FactoryName').AsString));
Next;
end;
end;
end;
procedure TfrmPRTOrderViewList.ToolButton1Click(Sender: TObject);
var
fPrintFile:string;
Porderno,PFTPUnit,LD,LDTel,GD,GDTel,PSID:string;
i,j:Integer;
begin
if Order_Main.IsEmpty then Exit;
//if Trim(ComboBox2.Text)='' then Exit;
if CheckBox1.Checked=False then
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C><>װָʾ<D6B8><CABE>.rmf'
else
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C><>װָʾ<D6B8><CABE>Ⱦɫ.rmf';
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from JYOrder_Process where Mainid='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
sql.Add(' and PSName=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ'' ');
Open;
end;
if ADOQueryTemp.IsEmpty then Exit;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from JYOrder_Process where Mainid='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
sql.Add(' and PSName=''<27><>Ʒ'' ');
Open;
end;
if ADOQueryTemp.IsEmpty then
begin
i:=1;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װǰһ<C7B0><D2BB>
end else
begin
if ADOQueryTemp.FieldByName('PSXH').AsInteger=1 then
begin
i:=1;
end else
begin
i:=2;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װǰ<D7B0><C7B0><EFBFBD><EFBFBD>
end;
end;
with ADOQueryPrint do
begin
Close;
sql.Clear;
sql.Add('select A.*,B.PSName,B.PSNote,C.OrderNo,C.MPRTCode,C.MPRTCodeName,C.MPRTCF, ');
sql.Add(' C.MPRTSpec,C.MPRTMF,C.MPRTKZ,C.ChuanY,C.MPRTGY,D.PRTHX,D.PRTColorNo');
sql.Add(',C.MPRTMFNOte,C.MPRTKZNote,C.CJNote,C.DHNote,C.BZNote,C.CHNote,C.MPRTGYHZ,D.*');
sql.Add(',GSTT=(select Top 1 ZdyStr1 from KH_Zdy A where A.ZdyName=C.ComTaiTou)');
sql.Add(',Case when RTrim(A.PFTPUnit)=''KG'' then '',''+Cast(Cast(A.PFTPQty*B.KgZM as int) as varchar(20))+''M'' ');
sql.Add(' else '''' end as MStr');
sql.Add(',C.LiDanPerson,LDTel10=(select Top 1 Note from KH_Zdy KZ where KZ.ZdyName=C.LiDanPerson and KZ.Type=''LiDanPerson'' )');
sql.Add(',GDTel10=(select Top 1 Note from KH_Zdy KZ where KZ.ZdyName=A.PFGenDanPerson and KZ.Type=''PFGenDanPerson'' )');
sql.Add(' from JYOrder_PCS_Sub A');
SQL.Add(' inner join JYOrder_Process B on A.PSID=B.PSID');
sql.Add(' inner join JYOrder_Main C on A.MainId=C.Mainid');
sql.Add(' inner join JYOrder_Sub D on A.Subid=D.SubId');
//sql.Add(' left join JYOrder_Sub D on A.Subid=D.SubId');
sql.Add(' where A.MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
if i=1 then
begin
sql.Add(' and B.PSID=(select Top 1 PSID from JYOrder_Process JP where JP.MainId=C.MainId');
sql.Add(' and JP.PSXH<(select PSXH from JYOrder_Process JPP where JPP.MainId=C.MainId and JPP.PSName=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ'' )');
sql.Add(' order by PSXH DESC)');
end else
if i=2 then
begin
sql.Add(' and B.PSID in (select Top 2 PSID from JYOrder_Process JP where JP.MainId=C.MainId');
sql.Add(' and JP.PSXH<(select PSXH from JYOrder_Process JPP where JPP.MainId=C.MainId and JPP.PSName=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ'' )');
sql.Add(' order by PSXH DESC)');
end;
//SQL.Add(' and A.FactoryName='''+Trim(ComboBox2.Text)+'''');
sql.Add(' order by D.SubId');
//ShowMessage(sql.Text);
Open;
end;
SCreateCDS20(ADOQueryPrint,CDS_Print);
SInitCDSData20(ADOQueryPrint,CDS_Print);
PFTPUnit:=Trim(CDS_Print.fieldbyname('PFTPUnit').AsString);
LD:=Trim(CDS_Print.fieldbyname('LiDanPerson').AsString);
LDTel:=Trim(CDS_Print.fieldbyname('LDTel10').AsString);
GD:=Trim(CDS_Print.fieldbyname('PFGenDanPerson').AsString);
GDTel:=Trim(CDS_Print.fieldbyname('GDTel10').AsString);
if (CDS_Print.RecordCount mod 2)=1 then
begin
CDS_Print.Append;
CDS_Print.Post;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select sum(PFTPQty) PFTPQtyHZ,sum(PFTPPS) PFTPPSHZ ');
sql.Add(' from JYOrder_PCS_Sub A');
SQL.Add(' inner join JYOrder_Process B on A.PSID=B.PSID');
sql.Add(' inner join JYOrder_Main C on A.MainId=C.Mainid');
//sql.Add(' left join JYOrder_Sub D on A.Subid=D.SubId');
sql.Add(' inner join JYOrder_Sub D on A.Subid=D.SubId');
sql.Add(' where A.MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
if i=1 then
begin
sql.Add(' and B.PSID=(select Top 1 PSID from JYOrder_Process JP where JP.MainId=C.MainId');
sql.Add(' and JP.PSXH<(select PSXH from JYOrder_Process JPP where JPP.MainId=C.MainId and JPP.PSName=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ'' )');
sql.Add(' order by PSXH DESC)');
end else
if i=2 then
begin
sql.Add(' and B.PSID in (select Top 2 PSID from JYOrder_Process JP where JP.MainId=C.MainId');
sql.Add(' and JP.PSXH<(select PSXH from JYOrder_Process JPP where JPP.MainId=C.MainId and JPP.PSName=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ'' )');
sql.Add(' order by PSXH DESC)');
end;
// sql.Add(' group by A.FactoryName');
Open;
end;
if FileExists(fPrintFile) then
begin
RMVariables['PFTPQtyHZ']:=ADOQueryTemp.fieldbyname('PFTPQtyHZ').Value;
RMVariables['PFTPPSHZ']:=ADOQueryTemp.fieldbyname('PFTPPSHZ').Value;
RMVariables['ZQty']:=Order_Main.fieldbyname('ZQty').Value;
RMVariables['OrderUnit']:=Order_Main.fieldbyname('OrderUnit').Value;
RMVariables['QtyUnit']:=Order_Main.fieldbyname('OneQtyUnit').Value;
RMVariables['CPQtyStr']:=Order_Main.fieldbyname('MPRTOneQty').Value;
RMVariables['BPQtyStr']:=Order_Main.fieldbyname('ClothOneQty').Value;
RMVariables['PFTPUnitHZ']:=Trim(PFTPUnit);
RMVariables['LD']:=Trim(LD);
RMVariables['LDTel']:=Trim(LDTel);
RMVariables['GD']:=Trim(GD);
RMVariables['GDTel']:=Trim(GDTel);
RM1.LoadFromFile(fPrintFile);
RM1.ShowReport;
end else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+'Report\<5C><>װָʾ<D6B8><CABE>.rmf'),'<27><>ʾ',0);
end;
// Panel4.Visible:=True;
end;
procedure TfrmPRTOrderViewList.ToolButton3Click(Sender: TObject);
begin
try
frmModuleNote:=TfrmModuleNote.Create(Application);
with frmModuleNote do
begin
flag:='<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>';
if ShowModal=1 then
begin
end;
end;
finally
frmModuleNote.Free;
end;
end;
end.