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

442 lines
11 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;
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;
TBAdd: TToolButton;
TBEdit: TToolButton;
TBDel: TToolButton;
TBClose: TToolButton;
Tv1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
cxGrid1: TcxGrid;
cxGridPopupMenu1: TcxGridPopupMenu;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DataSource1: TDataSource;
TBExport: TToolButton;
Order_Main: TClientDataSet;
ToolButton1: TToolButton;
Panel1: TPanel;
Label9: TLabel;
KHNameJC: TEdit;
v1Column2: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
Label2: TLabel;
KHCode: TEdit;
v1Column1: TcxGridDBColumn;
Label34: TLabel;
v1Column3: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
v1Column11: TcxGridDBColumn;
KHType: TEdit;
v1Column4: TcxGridDBColumn;
Label1: TLabel;
TJKHName: TEdit;
CheckBox1: TCheckBox;
ToolButton2: TToolButton;
v1Column5: TcxGridDBColumn;
PopupMenu1: TPopupMenu;
N2: TMenuItem;
N1: TMenuItem;
v1Column8: TcxGridDBColumn;
ToolButton3: TToolButton;
v1Column12: TcxGridDBColumn;
v1Column13: 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 TBEditClick(Sender: TObject);
procedure TBDelClick(Sender: TObject);
procedure TBExportClick(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure TBAddClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure CustomerNoNameChange(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
private
canshu1:string;
DQdate:TDateTime;
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_GYSInPutTab, U_ZDYHelpSel;
{$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.* ');
sql.Add(' from ZH_KH_Info A ');
sql.Add(' where Type=''GYS'' ');
if CheckBox1.Checked=false then
begin
sql.Add(' and Valid=''Y'' ');
end;
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmGYSList.InitForm();
begin
ReadCxGrid('<27><>Ӧ<EFBFBD>̵Ǽ<CCB5>',Tv1,'<27><>Ӧ<EFBFBD>̹<EFBFBD><CCB9><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;
try
frmGYSInPutTab:=TfrmGYSInPutTab.Create(Application);
with frmGYSInPutTab do
begin
PState:=1;
FMainId:=Trim(Self.Order_Main.fieldbyname('ZKId').AsString);
frmGYSInPutTab.canshu1:=Trim(Self.canshu1);
if ShowModal=1 then
begin
end;
end;
finally
frmGYSInPutTab.Free;
end;
end;
procedure TfrmGYSList.TBDelClick(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select Top 1* from JYOrder_Main_MD_DuiZhang ');
sql.Add(' where FactoryNo='''+Trim(Order_Main.fieldbyname('ZKId').AsString)+'''');
Open;
end;
if ADOQueryTemp.IsEmpty=False then
begin
Application.MessageBox('<27><><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>ɾ<EFBFBD><C9BE>!','<27><>ʾ',0);
Exit;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select Top 1* from YF_Money_PaiKuan ');
sql.Add(' where FactoryNo='''+Trim(Order_Main.fieldbyname('ZKId').AsString)+'''');
Open;
end;
if ADOQueryTemp.IsEmpty=False then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>ɾ<EFBFBD><C9BE>!','<27><>ʾ',0);
Exit;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select Top 1* from JYOrder_Main_MD ');
sql.Add(' where FactoryNo='''+Trim(Order_Main.fieldbyname('ZKId').AsString)+'''');
Open;
end;
if ADOQueryTemp.IsEmpty=False then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB5A5><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>ɾ<EFBFBD><C9BE>!','<27><>ʾ',0);
Exit;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select Top 1* from YF_Money_CR ');
sql.Add(' where FactoryNo='''+Trim(Order_Main.fieldbyname('ZKId').AsString)+'''');
Open;
end;
if ADOQueryTemp.IsEmpty=False then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>ɾ<EFBFBD><C9BE>!','<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.TBExportClick(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then Exit;
TcxGridToExcel('<27><>Ӧ<EFBFBD><D3A6><EFBFBD>б<EFBFBD>',cxGrid1);
end;
procedure TfrmGYSList.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmGYSList.TBAddClick(Sender: TObject);
var
maxno:string;
begin
try
frmGYSInPutTab:=TfrmGYSInPutTab.Create(Application);
with frmGYSInPutTab do
begin
PState:=0;
FMainId:='';
if ShowModal=1 then
begin
end;
end;
finally
frmGYSInPutTab.Free;
end;
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.ToolButton1Click(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
try
frmGYSInPutTab:=TfrmGYSInPutTab.Create(Application);
with frmGYSInPutTab do
begin
PState:=1;
FMainId:=Trim(Self.Order_Main.fieldbyname('ZKId').AsString);
TBSave.Visible:=False;
if ShowModal=1 then
begin
end;
end;
finally
frmGYSInPutTab.Free;
end;
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.ToolButton2Click(Sender: TObject);
begin
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>Ҫ<EFBFBD><D2AA><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 ZH_KH_Info Set ');
sql.Add(' LockFlag=1');
sql.Add(' where ZKID='''+Order_Main.fieldbyname('ZKID').AsString+'''');
ExecSQL;
end;
Edit;
FieldByName('SSel').Value:=False;
FieldByName('LockFlag').Value:=True;
Post;
end;
end;
Order_Main.EnableControls;
ADOQueryCmd.Connection.CommitTrans;
//Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!','<27><>ʾ',0);
Exit;
except
Order_Main.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
end;
end;
procedure TfrmGYSList.N2Click(Sender: TObject);
begin
SelOKNo(Order_Main,True);
end;
procedure TfrmGYSList.N1Click(Sender: TObject);
begin
SelOKNo(Order_Main,False);
end;
procedure TfrmGYSList.ToolButton3Click(Sender: TObject);
begin
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>Ҫ<EFBFBD><D2AA><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 ZH_KH_Info Set ');
sql.Add(' LockFlag=0');
sql.Add(' where ZKID='''+Order_Main.fieldbyname('ZKID').AsString+'''');
ExecSQL;
end;
Edit;
FieldByName('SSel').Value:=False;
FieldByName('LockFlag').Value:=False;
Post;
end;
end;
Order_Main.EnableControls;
ADOQueryCmd.Connection.CommitTrans;
//Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!','<27><>ʾ',0);
Exit;
except
Order_Main.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
end;
end;
end.