D7myYunxiang/云翔基础资料(BaseInfoYX.dll)/U_GYSList_BF.pas
DESKTOP-E401PHE\Administrator 1011cb7292 1
2025-01-20 13:04:03 +08:00

488 lines
14 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_GYSList_BF;
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, cxButtonEdit, cxDropDownEdit;
type
TfrmGYSList = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBFind: TToolButton;
TBClose: TToolButton;
Tv1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
cxGrid1: TcxGrid;
cxGridPopupMenu1: TcxGridPopupMenu;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
DataSource1: TDataSource;
Order_Main: TClientDataSet;
RM1: TRMGridReport;
RMDBDataSet1: TRMDBDataSet;
RMXLSExport1: TRMXLSExport;
ToolButton3: TToolButton;
Panel1: TPanel;
Label9: TLabel;
KHNameJC: TEdit;
v1Column2: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
Label2: TLabel;
KHCode: TEdit;
v1Column1: TcxGridDBColumn;
Label34: TLabel;
KHType: TComboBox;
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 TBPrintClick(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure FormShow(Sender: TObject);
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 N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure CustomerNoNameChange(Sender: TObject);
procedure KHNameJCKeyPress(Sender: TObject; var Key: Char);
procedure Tv2CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure Tv1DblClick(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
private
DQdate:TDateTime;
XZKHTYpe:string;
procedure InitGrid();
procedure InitForm();
function DelData():Boolean;
{ Private declarations }
public
FFInt,FCloth:Integer;
{ Public declarations }
end;
var
frmGYSList: TfrmGYSList;
implementation
uses
U_DataLink,U_RTFun,U_ZDYHelp,U_SCPerson,U_PBGYSInPutMain;
{$R *.dfm}
procedure TfrmGYSList.FormDestroy(Sender: TObject);
begin
frmGYSList:=nil;
end;
procedure TfrmGYSList.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmGYSList.FormCreate(Sender: TObject);
begin
cxgrid1.Align:=alClient;
end;
procedure TfrmGYSList.TBCloseClick(Sender: TObject);
begin
Close;
WriteCxGrid('<27><>Ӧ<EFBFBD>̵Ǽ<CCB5>',Tv1,'<27><>Ӧ<EFBFBD>̹<EFBFBD><CCB9><EFBFBD>');
end;
procedure TfrmGYSList.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add('select A.*,HZEmail=dbo.F_Get_KHInfo(A.ZKID,''Email'') ');
sql.Add(' from ZH_KH_Info A ');
sql.Add(' where Type=''GYS'' ');
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmGYSList.InitForm();
begin
ReadCxGrid(self.Caption,Tv1,<><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
InitGrid();
end;
procedure TfrmGYSList.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 TfrmGYSList.TBEditClick(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
if Trim(DParameters1)='' 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;
end;
procedure TfrmGYSList.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;
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 TfrmGYSList.DelData():Boolean;
begin
try
Result:=false;
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update ZH_KH_Info Set Valid=''N'' where ZKId='''+Trim(Order_Main.fieldbyname('ZKId').AsString)+'''');
ExecSQL;
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 TfrmGYSList.TBPrintClick(Sender: TObject);
var
fPrintFile:string;
begin
{ if Order_Main.IsEmpty then Exit;
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.rmf' ;
with ADOQueryPrint do
begin
Close;
sql.Clear;
SQL.Add(' select A.OrdConPrcNote,A.OrdConPrcShuoM,A.OrdConPrcUnit,C.ZdyName,A.CustomerNo ');
sql.Add(' ,B.Mainid,PRTEngCodeName,PRTMF,PRTKZ,PRTKZNote,PRTPrice,OrderUnit');
sql.Add(' ,Sum(PRTOrderQty) PRTOrderQty,Sum(PRTOrderQty*PRTPrice) ConMoney');
sql.Add(',Cast(Cast(Sum(PRTOrderQty*PRTPrice) as decimal(18,2)) as varchar(20)) ConMoneyStr');
sql.Add(' from JYOrderCon_Sub B');
sql.Add(' inner join JYOrderCon_Main A on B.MainId=A.MainId');
SQL.Add(' left join KH_Zdy_Attachment C on A.CustomerNo=C.ZdyCode');
SQL.Add(' where A.ConNo='''+Trim(Order_Main.fieldbyname('ConNo').AsString)+''' and A.ChkStatus=''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>'' and A.ZuoFeiFlag=0 ');
sql.Add(' Group by B.MainId,B.PRTEngCodeName,B.PRTMF,B.PRTKZ,B.PRTKZNote,B.PRTPrice,B.OrderUnit,A.OrdConPrcNote,A.OrdConPrcShuoM,A.OrdConPrcUnit,C.ZdyName,A.CustomerNo');
Open;
end;
SCreateCDS20(ADOQueryPrint,CDS_Print);
SInitCDSData20(ADOQueryPrint,CDS_Print);
if FileExists(fPrintFile) then
begin
RMVariables['TolConMoney']:=ADOQueryTemp.fieldbyname('TolConMoney').AsString;
RMVariables['YWY']:=Order_Main.fieldbyname('YWY').Value;
RM1.LoadFromFile(fPrintFile);
RM1.ShowReport;
end else
begin
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.rmf'),'<27><>ʾ',0);
end; }
end;
procedure TfrmGYSList.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmGYSList.FormShow(Sender: TObject);
begin
InitForm();
end;
procedure TfrmGYSList.CheckBox1Click(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmGYSList.CheckBox2Click(Sender: TObject);
begin
TBRafresh.Click;
end;
procedure TfrmGYSList.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 TfrmGYSList.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 TfrmGYSList.N1Click(Sender: TObject);
var
fPrintFile:string;
Porderno:string;
begin
if Order_Main.IsEmpty then Exit;
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>10.rmf' ;
SDofilter(ADOQueryMain,' OrderNoM='''+Trim(Order_Main.fieldbyname('OrderNoM').AsString)+'''');
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
Porderno:=Trim(Order_Main.fieldbyname('OrderNoM').AsString);
if FileExists(fPrintFile) then
begin
//RMVariables['begindate']:=begindate.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)+'Report\<5C><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>10.rmf'),'<27><>ʾ',0);
end;
SDofilter(ADOQueryMain,'');
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
Order_Main.Locate('ordernoM',Porderno,[]);
end;
procedure TfrmGYSList.N2Click(Sender: TObject);
var
fPrintFile:string;
Porderno:string;
begin
if Order_Main.IsEmpty then Exit;
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>.rmf' ;
SDofilter(ADOQueryMain,' OrderNoM='''+Trim(Order_Main.fieldbyname('OrderNoM').AsString)+'''');
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
Porderno:=Trim(Order_Main.fieldbyname('OrderNoM').AsString);
if FileExists(fPrintFile) then
begin
//RMVariables['begindate']:=begindate.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)+'Report\<5C><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>.rmf'),'<27><>ʾ',0);
end;
SDofilter(ADOQueryMain,'');
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
Order_Main.Locate('ordernoM',Porderno,[]);
end;
procedure TfrmGYSList.ToolButton3Click(Sender: TObject);
begin
ModalResult:=1;
end;
procedure TfrmGYSList.CustomerNoNameChange(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 TfrmGYSList.KHNameJCKeyPress(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('select A.* ');
sql.Add(' from JYOrderCon_TT A where 1=1 ');
if Trim(DParameters1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
sql.Add('and A.Filler='''+Trim(DName)+'''');
end;
sql.Add(' and ConNo like '''+'%'+Trim(ConNo.Text)+'%'+'''');
sql.Add(' and TTType='''+Trim(DParameters2)+'''');
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end; }
end;
end;
procedure TfrmGYSList.Tv2CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
begin
{if Order_Main.FieldByName('ConFlag1').AsBoolean=False then
begin
if CDS_Chk.IsEmpty then Exit;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete OrdCon_Chk where CKID='''+Trim(CDS_Chk.fieldbyname('CKID').AsString)+'''');
ExecSQL;
end;
CDS_Chk.Delete;
end; }
end;
procedure TfrmGYSList.Tv1DblClick(Sender: TObject);
begin
ToolButton3.Click;
end;
procedure TfrmGYSList.ToolButton1Click(Sender: TObject);
begin
try
frmSCPerson:=TfrmSCPerson.Create(Application);
with frmSCPerson do
begin
FlagStr:='GYSType';
if ShowModal=1 then
begin
XZKHTYpe:=Trim(FSDPerson);
end;
end;
finally
frmSCPerson.Free;
end;
if Trim(XZKHTYpe)='' then Exit;
try
frmPBGYSInPutMain:=TfrmPBGYSInPutMain.Create(Application);
with frmPBGYSInPutMain do
begin
FKHMainid:='';
FKHFlag:='GYS';
frmPBGYSInPutMain.KHType.Text:=Trim(XZKHTYpe);
frmPBGYSInPutMain.KHType.Enabled:=False;
frmPBGYSInPutMain.KHType.Color:=clMenu;
if ShowModal=1 then
begin
TBRafresh.Click;
Order_Main.Locate('KHMainId',FKHMainid,[]);
end;
end;
finally
frmPBGYSInPutMain.Free;
end;
end;
end.