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

564 lines
16 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_PRTOrderPriceList;
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, RM_DsgGridReport, RM_Designer, cxPC;
type
TfrmPRTOrderPriceList = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBFind: 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;
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;
ADOQueryPrint: TADOQuery;
CDS_Print: TClientDataSet;
v1Column2: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
Label9: TLabel;
Label2: TLabel;
ConNo: TEdit;
LiDanPerson: TEdit;
v1Column1: TcxGridDBColumn;
RMDBDataSet1: TRMDBDataSet;
RM2: TRMGridReport;
ToolButton3: TToolButton;
v1Column4: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
RMXLSExport2: TRMXLSExport;
v1Column6: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
cxTabControl1: TcxTabControl;
v1Column10: TcxGridDBColumn;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
v1Column11: TcxGridDBColumn;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure TBFindClick(Sender: TObject);
procedure TBRafreshClick(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 OrderNoKeyPress(Sender: TObject; var Key: Char);
procedure ConNoKeyPress(Sender: TObject; var Key: Char);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure cxTabControl1Change(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
private
CanShu1,CanShu2:string;
DQdate:TDateTime;
procedure InitGrid();
procedure InitForm();
{ Private declarations }
public
{ Public declarations }
end;
var
frmPRTOrderPriceList: TfrmPRTOrderPriceList;
implementation
uses
U_DataLink,U_OrderInPut,U_RTFun, U_ZDYHelp, U_ZDYHelpSel, U_ModuleNote,U_OrderInPutPrice
,U_ContractSelList;
{$R *.dfm}
procedure TfrmPRTOrderPriceList.FormDestroy(Sender: TObject);
begin
frmPRTOrderPriceList:=nil;
end;
procedure TfrmPRTOrderPriceList.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmPRTOrderPriceList.FormCreate(Sender: TObject);
begin
cxgrid1.Align:=alClient;
CanShu1:=Trim(DParameters1);
CanShu2:=Trim(DParameters2);
//BegDate.DateTime:=SGetServerDateTime(ADOQueryTemp)-7;
//EndDate.DateTime:=SGetServerDateTime(ADOQueryTemp);
DQdate:=SGetServerDate(ADOQueryTemp);
end;
procedure TfrmPRTOrderPriceList.TBCloseClick(Sender: TObject);
begin
Close;
WriteCxGrid(ʾ<D6B8><CABE><EFBFBD>б<EFBFBD>Price',Tv1,'<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure TfrmPRTOrderPriceList.InitGrid();
var
fsj:String;
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.add('exec P_View_OrderSub :begdate,:enddate,:WSql') ;
if Trim(CanShu1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
fsj:=' and Filler in(select UserName from SY_User where DPID in'+
'(select DPID from SY_User where UserName='''+Trim(DName)+'''))';
end else
begin
fsj:='';
end;
if cxTabControl1.TabIndex=0 then
begin
//fsj:=fsj+' and exists(select * from JYOrderCon_Main JCM where JCM.ConNo=A.ConNo )';
fsj:=fsj+' and isnull(B.PISubId,'''')='''' ';
end else
if cxTabControl1.TabIndex=1 then
begin
fsj:=fsj+' and isnull(B.PISubId,'''')<>'''' ';
end;
Parameters.ParamByName('WSql').Value:=fsj;
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 TfrmPRTOrderPriceList.InitForm();
begin
ReadCxGrid(ʾ<D6B8><CABE><EFBFBD>б<EFBFBD>Price',Tv1,'<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
BegDate.DateTime:=SGetServerDate10(ADOQueryTemp)-30;
EndDate.DateTime:=SGetServerDate10(ADOQueryTemp);
end;
procedure TfrmPRTOrderPriceList.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 TfrmPRTOrderPriceList.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmPRTOrderPriceList.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 TfrmPRTOrderPriceList.FormShow(Sender: TObject);
begin
InitForm();
end;
procedure TfrmPRTOrderPriceList.Tv1CellDblClick(
Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
begin
if TBView.Visible=False then Exit;
TBView.Click;
end;
procedure TfrmPRTOrderPriceList.CheckBox1Click(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmPRTOrderPriceList.CheckBox2Click(Sender: TObject);
begin
TBRafresh.Click;
end;
procedure TfrmPRTOrderPriceList.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 TfrmPRTOrderPriceList.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 TfrmPRTOrderPriceList.TBViewClick(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
try
frmOrderInPutPrice:=TfrmOrderInPutPrice.Create(Application);
with frmOrderInPutPrice 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;
ToolButton20.Visible:=False;
ToolButton21.Visible:=False;
if ShowModal=1 then
begin
end;
end;
finally
frmOrderInPutPrice.Free;
end;
end;
procedure TfrmPRTOrderPriceList.OrderNoKeyPress(Sender: TObject;
var Key: Char);
var
fsj:String;
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_OrderSub :begdate,:enddate,:WSql') ;
if Trim(CanShu1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
fsj:=' and Filler in(select UserName from SY_User where DPID in'+
'(select DPID from SY_User where UserName='''+Trim(DName)+'''))';
end else
begin
fsj:='';
end;
if cxTabControl1.TabIndex=0 then
begin
//fsj:=fsj+' and exists(select * from JYOrderCon_Main JCM where JCM.ConNo=A.ConNo )';
fsj:=fsj+' and isnull(B.PISubId,'''')='''' ';
end else
if cxTabControl1.TabIndex=1 then
begin
fsj:=fsj+' and isnull(B.PISubId,'''')<>'''' ';
end;
fsj:=fsj+' and OrderNo like '''+'%'+Trim(OrderNo.Text)+'%'+'''';
Parameters.ParamByName('WSql').Value:=fsj;
Parameters.ParamByName('begdate').Value:='';
Parameters.ParamByName('enddate').Value:='';
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
end;
procedure TfrmPRTOrderPriceList.ConNoKeyPress(Sender: TObject;
var Key: Char);
var
fsj:String;
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_OrderSub :begdate,:enddate,:WSql') ;
if Trim(CanShu1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
fsj:=' and Filler in(select UserName from SY_User where DPID in'+
'(select DPID from SY_User where UserName='''+Trim(DName)+'''))';
end else
begin
fsj:='';
end;
if cxTabControl1.TabIndex=0 then
begin
//fsj:=fsj+' and exists(select * from JYOrderCon_Main JCM where JCM.ConNo=A.ConNo )';
fsj:=fsj+' and isnull(B.PISubId,'''')='''' ';
end else
if cxTabControl1.TabIndex=1 then
begin
fsj:=fsj+' and isnull(B.PISubId,'''')<>'''' ';
end;
fsj:=fsj+' and conno like '''+'%'+Trim(conno.Text)+'%'+'''';
Parameters.ParamByName('WSql').Value:=fsj;
Parameters.ParamByName('begdate').Value:='';
Parameters.ParamByName('enddate').Value:='';
ExecSQL;
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
end;
procedure TfrmPRTOrderPriceList.ToolButton3Click(Sender: TObject);
begin
try
frmModuleNote:=TfrmModuleNote.Create(Application);
with frmModuleNote do
begin
flag:='<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>';
if ShowModal=1 then
begin
end;
end;
finally
frmModuleNote.Free;
end;
end;
procedure TfrmPRTOrderPriceList.ToolButton1Click(Sender: TObject);
var
ConPrice,ConSubId:String;
begin
if cxTabControl1.TabIndex<>0 then Exit;
if Order_Main.Locate('SSel',True,[])=False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
ConSubId:='';
try
frmContractSelList:=TfrmContractSelList.Create(Application);
with frmContractSelList do
begin
if ShowModal=1 then
begin
ConSubId:=Trim(frmContractSelList.Order_Main.fieldbyname('SubId').AsString);
ConPrice:=Trim(frmContractSelList.Order_Main.fieldbyname('PRTPrice').AsString);
end;
end;
finally
frmContractSelList.Free;
end;
if Trim(ConSubId)<>'' then
begin
if Application.MessageBox(<><C8B7>Ҫִ<D2AA>д˲<D0B4><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
Order_Main.DisableControls;
with Order_Main do
begin
First;
while Locate('SSel',True,[]) do
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add(' Update JYOrder_Sub Set PISubId='''+Trim(ConSubId)+'''');
sql.Add(' where SubId='''+Trim(Order_Main.fieldbyname('SubId').AsString)+'''');
ExecSQL;
end;
Order_Main.Delete;
end;
end;
Order_Main.EnableControls;
end;
end;
procedure TfrmPRTOrderPriceList.ToolButton2Click(Sender: TObject);
begin
if cxTabControl1.TabIndex<>1 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>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
Order_Main.DisableControls;
with Order_Main do
begin
First;
while Locate('SSel',True,[]) do
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add(' Update JYOrder_Sub Set PISubId=Null');
sql.Add(' where SubId='''+Trim(Order_Main.fieldbyname('SubId').AsString)+'''');
ExecSQL;
end;
Order_Main.Delete;
end;
end;
Order_Main.EnableControls;
end;
procedure TfrmPRTOrderPriceList.cxTabControl1Change(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmPRTOrderPriceList.N1Click(Sender: TObject);
begin
SelOKNo(Order_Main,True);
end;
procedure TfrmPRTOrderPriceList.N2Click(Sender: TObject);
begin
SelOKNo(Order_Main,False);
end;
end.