D7wmguihua/桂华管理系统/U_GetPGJBInList.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

269 lines
7.0 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_GetPGJBInList;
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, cxSplitter;
type
TfrmGetPGJBInList = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBFind: TToolButton;
TBClose: TToolButton;
cxGridPopupMenu1: TcxGridPopupMenu;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DataSource1: TDataSource;
TBExport: TToolButton;
Panel1: TPanel;
ToolButton1: TToolButton;
cxSplitter1: TcxSplitter;
DataSource2: TDataSource;
ADOQuery2: TADOQuery;
ClientDataSet1: TClientDataSet;
ClientDataSet2: TClientDataSet;
cxGridPopupMenu2: TcxGridPopupMenu;
Label3: TLabel;
Label4: TLabel;
Label7: TLabel;
YCLName: TEdit;
YCLSpec: TEdit;
GYSName: TEdit;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1P_ChnName: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v1ShortName: TcxGridDBColumn;
v1Quantity: TcxGridDBColumn;
v1UnitName: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
cxGrid3: TcxGrid;
TV2: TcxGridDBTableView;
cxGridDBColumn13: TcxGridDBColumn;
cxGridDBColumn14: TcxGridDBColumn;
cxGridDBColumn15: TcxGridDBColumn;
cxGridDBColumn16: TcxGridDBColumn;
cxGridDBColumn17: TcxGridDBColumn;
cxGridLevel2: TcxGridLevel;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure TBFindClick(Sender: TObject);
procedure TBExportClick(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure PlanNoChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure P_ChnNameChange(Sender: TObject);
procedure Tv1CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure TV2CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure YCLNameChange(Sender: TObject);
private
procedure InitGrid();
procedure InitGrid10();
procedure InitForm();
function DelData():Boolean;
{ Private declarations }
public
{ Public declarations }
end;
var
frmGetPGJBInList: TfrmGetPGJBInList;
implementation
uses
U_DataLink,U_Fun,U_ZDYHelp;
{$R *.dfm}
procedure TfrmGetPGJBInList.FormDestroy(Sender: TObject);
begin
frmGetPGJBInList:=nil;
end;
procedure TfrmGetPGJBInList.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmGetPGJBInList.FormCreate(Sender: TObject);
begin
cxgrid1.Align:=alClient;
end;
procedure TfrmGetPGJBInList.TBCloseClick(Sender: TObject);
begin
Close;
WriteCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',Tv1,<><D4AD><EFBFBD>ϲֿ<CFB2>');
WriteCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>ѡ<EFBFBD><D1A1>',Tv2,<><D4AD><EFBFBD>ϲֿ<CFB2>');
end;
procedure TfrmGetPGJBInList.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add(' select YCLName=(select ZdyName from KH_Zdy KK where KK.ZdyNo=A.YCLCode), ');
sql.Add(' A.*,GYSName=(select ZdyName from KH_ZDY B where A.GYS=B.ZdyNo) ');
sql.Add(' from CK_YCL_KC A where A.KCQty>0');
sql.Add(' and A.CKName='<><D4AD><EFBFBD>ϲֿ<CFB2>'' ');
Open;
SCreateCDS20(ADOQueryMain,ClientDataSet1);
SInitCDSData20(ADOQueryMain,ClientDataSet1);
end;
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmGetPGJBInList.InitGrid10();
begin
try
ADOQuery2.DisableControls;
with ADOQuery2 do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add(' select YCLName=(select ZdyName from KH_Zdy KK where KK.ZdyNo=A.YCLCode), ');
sql.Add(' A.*,GYSName=(select ZdyName from KH_ZDY B where A.GYS=B.ZdyNo) ');
sql.Add('from CK_YCL_KC A where 1<>1');
Open;
SCreateCDS20(ADOQuery2,ClientDataSet2);
SInitCDSData20(ADOQuery2,ClientDataSet2);
end;
finally
ADOQuery2.EnableControls;
end;
end;
procedure TfrmGetPGJBInList.InitForm();
begin
ReadCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',Tv1,<><D4AD><EFBFBD>ϲֿ<CFB2>');
ReadCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>ѡ<EFBFBD><D1A1>',Tv2,<><D4AD><EFBFBD>ϲֿ<CFB2>');
InitGrid();
InitGrid10();
end;
procedure TfrmGetPGJBInList.TBFindClick(Sender: TObject);
begin
if not ADOQueryMain.Active then Exit;
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
SCreateCDS20(ADOQueryMain,ClientDataSet1);
SInitCDSData20(ADOQueryMain,ClientDataSet1);
end;
function TfrmGetPGJBInList.DelData():Boolean;
begin
try
Result:=false;
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('');
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 TfrmGetPGJBInList.TBExportClick(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then Exit;
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',cxGrid1);
end;
procedure TfrmGetPGJBInList.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmGetPGJBInList.PlanNoChange(Sender: TObject);
begin
if ADOQueryMain.Active then
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
end;
procedure TfrmGetPGJBInList.FormShow(Sender: TObject);
begin
InitForm();
end;
procedure TfrmGetPGJBInList.ToolButton1Click(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then
ModalResult:=-1
else
ModalResult:=1;
end;
procedure TfrmGetPGJBInList.P_ChnNameChange(Sender: TObject);
begin
TBFind.Click;
end;
procedure TfrmGetPGJBInList.Tv1CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
var
i:Integer;
begin
if ClientDataSet1.IsEmpty then exit;
ClientDataSet2.Append;
for i:=0 to ClientDataSet2.FieldCount-1 do
begin
ClientDataSet2.Fields[i].Value:=ClientDataSet1.Fields[i].Value;
end;
ClientDataSet2.Post;
ClientDataSet1.Delete;
end;
procedure TfrmGetPGJBInList.TV2CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
var
i:Integer;
begin
if ClientDataSet2.IsEmpty then exit;
ClientDataSet1.Append;
for i:=0 to ClientDataSet1.FieldCount-1 do
begin
ClientDataSet1.Fields[i].Value:=ClientDataSet2.Fields[i].Value;
end;
ClientDataSet1.Post;
ClientDataSet2.Delete;
end;
procedure TfrmGetPGJBInList.YCLNameChange(Sender: TObject);
begin
TBFind.Click;
end;
end.