732 lines
21 KiB
ObjectPascal
732 lines
21 KiB
ObjectPascal
unit U_SXJGDZList;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
||
cxDataStorage, cxEdit, DB, cxDBData, cxGridCustomTableView,
|
||
cxGridTableView, cxGridBandedTableView, cxGridDBBandedTableView,
|
||
cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridDBTableView,
|
||
cxGrid, StdCtrls, ComCtrls, ExtCtrls, ToolWin, cxGridCustomPopupMenu,
|
||
cxGridPopupMenu, ADODB, DBClient, cxDropDownEdit, cxCheckBox, RM_Common,
|
||
RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, Menus,
|
||
cxCalendar, cxButtonEdit, cxTextEdit, cxPC, cxSplitter;
|
||
|
||
type
|
||
TfrmSXJGDZList = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBFind: TToolButton;
|
||
TBExport: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
Label1: TLabel;
|
||
Label2: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
CDS_Main: TClientDataSet;
|
||
TBRKCX: TToolButton;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
N2: TMenuItem;
|
||
ToolButton1: TToolButton;
|
||
ToolButton2: TToolButton;
|
||
ToolButton3: TToolButton;
|
||
ToolButton4: TToolButton;
|
||
Panel2: TPanel;
|
||
cxGrid0: TcxGrid;
|
||
Tv0: TcxGridDBTableView;
|
||
cxGridDBColumn2: TcxGridDBColumn;
|
||
cxGridDBColumn3: TcxGridDBColumn;
|
||
cxGridDBColumn4: TcxGridDBColumn;
|
||
cxGridDBColumn6: TcxGridDBColumn;
|
||
cxGridDBColumn10: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
Panel3: TPanel;
|
||
Panel4: TPanel;
|
||
Panel5: TPanel;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1Column4: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v2Column1: TcxGridDBColumn;
|
||
v1Column14: TcxGridDBColumn;
|
||
v1Column9: TcxGridDBColumn;
|
||
v2Column6: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column5: TcxGridDBColumn;
|
||
v1Column12: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
cxSplitter2: TcxSplitter;
|
||
cxGridPopupMenu0: TcxGridPopupMenu;
|
||
DataSource0: TDataSource;
|
||
ClientDataSet0: TClientDataSet;
|
||
cxTabControl1: TcxTabControl;
|
||
cxSplitter1: TcxSplitter;
|
||
cxTabControl2: TcxTabControl;
|
||
cxSplitter3: TcxSplitter;
|
||
Label3: TLabel;
|
||
Label4: TLabel;
|
||
MPRTCodeName: TEdit;
|
||
FactoryName: TEdit;
|
||
Label5: TLabel;
|
||
Label6: TLabel;
|
||
Label7: TLabel;
|
||
SPName: TEdit;
|
||
SXFactoryName: TEdit;
|
||
Label8: TLabel;
|
||
ADOQueryMain10: TADOQuery;
|
||
ToolButton5: TToolButton;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure ConNoMChange(Sender: TObject);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBExportClick(Sender: TObject);
|
||
procedure TBFindClick(Sender: TObject);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
procedure TBRKCXClick(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure FactoryNameChange(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
procedure SPNameChange(Sender: TObject);
|
||
procedure MPRTCodeNameChange(Sender: TObject);
|
||
procedure SXFactoryNameChange(Sender: TObject);
|
||
procedure ToolButton5Click(Sender: TObject);
|
||
private
|
||
procedure InitGrid();
|
||
procedure InitGrid10();
|
||
function YFHZData(FDZID:String):Boolean;
|
||
function DelYFHZData():Boolean;
|
||
{ Private declarations }
|
||
public
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmSXJGDZList: TfrmSXJGDZList;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_RTFun,U_SXJGDZInPut;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmSXJGDZList.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmSXJGDZList:=nil;
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.FormClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.FormCreate(Sender: TObject);
|
||
begin
|
||
//cxGrid1.Align:=alClient;
|
||
EndDate.DateTime:=SGetServerDate10(ADOQueryTemp);
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select BegDate=Cast(convert(varchar(7),dateadd(month,-3,getdate()),120)+''-01'' as datetime) ');
|
||
Open;
|
||
end;
|
||
BegDate.DateTime:=ADOQueryTemp.fieldbyname('BegDate').Value;
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select A.* ');
|
||
sql.Add(' from JYOrder_Main_MD_DuiZhang A');
|
||
sql.Add(' where isnull(DZType,'''')=''ɴ<>ӹ<DFBC>''');
|
||
if cxTabControl1.TabIndex=0 then
|
||
begin
|
||
sql.Add(' and isnull(Status,'''')=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
|
||
end else
|
||
begin
|
||
sql.Add(' and isnull(Status,'''')=''<27>Ѷ<EFBFBD><D1B6><EFBFBD>'' ');
|
||
end;
|
||
if cxTabControl1.TabIndex<>0 then
|
||
begin
|
||
sql.add(' and A.DZDate>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+'''');
|
||
sql.Add(' and A.DZDate<='''+Trim(FormatDateTime('yyyy-MM-dd',enddate.DateTime+1))+'''');
|
||
end;
|
||
if Trim(FactoryName.Text)<>'' then
|
||
begin
|
||
SQL.Add(' and isnull(A.FactoryName,'''') like '''+'%'+Trim(FactoryName.Text)+'%'+'''');
|
||
end;
|
||
if Trim(MPRTCodeName.Text)<>'' then
|
||
begin
|
||
SQL.Add(' and isnull(A.MPRTCodeName,'''') like '''+'%'+Trim(MPRTCodeName.Text)+'%'+'''');
|
||
end;
|
||
Open;
|
||
//ShowMessage(SQL.Text);
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
procedure TfrmSXJGDZList.InitGrid10();
|
||
begin
|
||
try
|
||
ADOQueryMain10.DisableControls;
|
||
with ADOQueryMain10 do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add(' select AA.* from(');
|
||
sql.Add(' select A.*,SXFactoryName=(select KHName from ZH_KH_Info where ZKID=A.FromFactoryNo) ');
|
||
sql.Add(' from CK_SXPB_CR A');
|
||
sql.Add(' where isnull(CKName,'''')=''ɴ<><C9B4>'' and isnull(CRType,'''')=''<27>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD>'' ');
|
||
sql.add(' and A.CRTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+'''');
|
||
sql.Add(' and A.CRTime<='''+Trim(FormatDateTime('yyyy-MM-dd',enddate.DateTime+1))+''')AA where 1=1');
|
||
if Trim(SPName.Text)<>'' then
|
||
begin
|
||
SQL.Add(' and isnull(SPName,'''') like '''+'%'+Trim(SPName.Text)+'%'+'''');
|
||
end;
|
||
if Trim(SXFactoryName.Text)<>'' then
|
||
begin
|
||
SQL.Add(' and isnull(SXFactoryName,'''') like '''+'%'+Trim(SXFactoryName.Text)+'%'+'''');
|
||
end;
|
||
Open;
|
||
//ShowMessage(SQL.Text);
|
||
end;
|
||
SCreateCDS20(ADOQueryMain10,ClientDataSet0);
|
||
SInitCDSData20(ADOQueryMain10,ClientDataSet0);
|
||
finally
|
||
ADOQueryMain10.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
BegDate.SetFocus;
|
||
InitGrid();
|
||
InitGrid10();
|
||
TBFind.Click;
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.ConNoMChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid('ɴ<>ӹ<DFBC><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
WriteCxGrid('ɴ<>߷<EFBFBD><DFB7><EFBFBD><EFBFBD>б<EFBFBD>',Tv0,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.FormShow(Sender: TObject);
|
||
begin
|
||
ReadCxGrid('ɴ<>ӹ<DFBC><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
ReadCxGrid('ɴ<>߷<EFBFBD><DFB7><EFBFBD><EFBFBD>б<EFBFBD>',Tv0,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
//InitGrid();
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.TBExportClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then exit;
|
||
TcxGridToExcel('<27>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',cxGrid1);
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.TBFindClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel5,1,2));
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
end;
|
||
if ADOQueryMain10.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain10,SGetFilters(Panel3,1,2));
|
||
SCreateCDS20(ADOQueryMain10,ClientDataSet0);
|
||
SInitCDSData20(ADOQueryMain10,ClientDataSet0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.N1Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main,True);
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.N2Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main,False);
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.TBRKCXClick(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then exit;
|
||
if cxTabControl1.TabIndex<>0 then Exit;
|
||
if CDS_Main.Locate('SSel',True,[])=False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><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;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
CDS_Main.DisableControls;
|
||
with CDS_Main do
|
||
begin
|
||
First;
|
||
while Locate('SSel',True,[]) do
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(CDS_Main.fieldbyname('DZID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
CDS_Main.Delete;
|
||
end;
|
||
end;
|
||
CDS_Main.EnableControls;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
CDS_Main.EnableControls;
|
||
Application.MessageBox('ɾ<><C9BE><EFBFBD>쳣!','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
try
|
||
frmSXJGDZInPut:=TfrmSXJGDZInPut.Create(Application);
|
||
with frmSXJGDZInPut do
|
||
begin
|
||
FBCId:='';
|
||
if ShowModal=1 then
|
||
begin
|
||
Self.InitGrid();
|
||
end;
|
||
end;
|
||
finally
|
||
frmSXJGDZInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
if cxTabControl1.TabIndex<>0 then Exit;
|
||
try
|
||
frmSXJGDZInPut:=TfrmSXJGDZInPut.Create(Application);
|
||
with frmSXJGDZInPut do
|
||
begin
|
||
FBCId:=Trim(CDS_Main.fieldbyname('DZID').AsString);
|
||
TBDel.Visible:=False;
|
||
TBAdd.Visible:=False;
|
||
if ShowModal=1 then
|
||
begin
|
||
Self.InitGrid();
|
||
end;
|
||
end;
|
||
finally
|
||
frmSXJGDZInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.FactoryNameChange(Sender: TObject);
|
||
begin
|
||
SXFactoryName.Text:=Trim(FactoryName.Text);
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel5,1,2));
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
end;
|
||
if ADOQueryMain10.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain10,SGetFilters(Panel3,1,2));
|
||
SCreateCDS20(ADOQueryMain10,ClientDataSet0);
|
||
SInitCDSData20(ADOQueryMain10,ClientDataSet0);
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then exit;
|
||
if cxTabControl1.TabIndex<>0 then Exit;
|
||
if CDS_Main.Locate('SSel',True,[])=False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫִ<D2AA>ж<EFBFBD><D0B6>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
CDS_Main.DisableControls;
|
||
with CDS_Main do
|
||
begin
|
||
First;
|
||
while Locate('SSel',True,[]) do
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(CDS_Main.fieldbyname('DZID').AsString)+'''');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Edit;
|
||
FieldByName('DuiZhangPerson').Value:=Trim(DName);
|
||
FieldByName('DuiZhangTime').Value:=SGetServerDateTime(ADOQueryTemp);
|
||
FieldByName('Status').Value:='<27>Ѷ<EFBFBD><D1B6><EFBFBD>';
|
||
Post;
|
||
end;
|
||
YFHZData(Trim(CDS_Main.fieldbyname('DZID').AsString));
|
||
CDS_Main.Delete;
|
||
end;
|
||
end;
|
||
CDS_Main.EnableControls;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
CDS_Main.EnableControls;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
function TfrmSXJGDZList.YFHZData(FDZID:string):Boolean;
|
||
var
|
||
CRID,OrdMainId,FYFID,MaxNo,FComTaiTou,FCRID,FFactoryName,CWFactoryNo,CWFactoryName:String;
|
||
begin
|
||
Result:=False;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(FDZID)+'''');
|
||
Open;
|
||
end;
|
||
CWFactoryNo:=Trim(ADOQueryTemp.fieldbyname('FactoryNo').AsString);
|
||
CWFactoryName:=Trim(ADOQueryTemp.fieldbyname('FactoryName').AsString);
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from YF_Money_KC where FactoryNo='''+Trim(CWFactoryNo)+'''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty=False then
|
||
begin
|
||
CRID:=ADOQueryTemp.fieldbyname('CRID').AsString;
|
||
end else
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update YF_Money_CRID set CRID=CRID+1');
|
||
sql.Add('select * from YF_Money_CRID ');
|
||
Open;
|
||
end;
|
||
CRID:=ADOQueryCmd.fieldbyname('CRID').AsString;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from YF_Money_KC where 1<>1');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Append;
|
||
FieldByName('CRID').Value:=StrToInt(CRID);
|
||
FieldByName('FactoryName').Value:=Trim(CWFactoryName);
|
||
FieldByName('FactoryNo').Value:=Trim(CWFactoryNo);
|
||
FieldByName('ZdyStr1').Value:='Ӧ<><D3A6><EFBFBD><EFBFBD>';
|
||
Post;
|
||
end;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_CR where FactoryNo='''+Trim(CWFactoryNo)+'''');
|
||
sql.Add(' and MHID='''+Trim(CDS_Main.fieldbyname('DZID').AsString)+'''');
|
||
Open;
|
||
end;
|
||
FYFID:=Trim(ADOQueryTemp.fieldbyname('YFID').AsString);
|
||
if Trim(FYFID)='' then
|
||
begin
|
||
if GetLSNo(ADOQueryCmd,MaxNo,'SJ','YF_Money_CR',3,1)=False then
|
||
begin
|
||
Application.MessageBox('ȡɴ<C8A1><C9B4>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end else
|
||
begin
|
||
MaxNo:=Trim(FYFID);
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_CR where YFID='''+Trim(MaxNo)+'''');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
if Trim(FYFID)='' then
|
||
Append
|
||
else
|
||
Edit;
|
||
FieldByName('YFID').Value:=Trim(MaxNo);
|
||
FieldByName('CRID').Value:=StrToInt(CRID);
|
||
FieldByName('Filler').Value:=Trim(DName);
|
||
FieldByName('CRType').Value:='Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>';
|
||
FieldByName('CRFlag').Value:='Ӧ<><D3A6><EFBFBD><EFBFBD>';
|
||
FieldByName('QtyFlag').Value:=1;
|
||
FieldByName('FactoryNo').Value:=Trim(CWFactoryNo);
|
||
FieldByName('FactoryName').Value:=Trim(CWFactoryName);
|
||
FieldByName('HZFactoryNo').Value:=Trim(CWFactoryNo);
|
||
FieldByName('HZFactoryName').Value:=Trim(CWFactoryName);
|
||
|
||
{if Trim(CDS_Main.fieldbyname('PS').AsString)<>'' then
|
||
begin
|
||
FieldByName('PS').Value:=CDS_Main.fieldbyname('PS').Value;
|
||
end else
|
||
begin
|
||
FieldByName('PS').Value:=0;
|
||
end;}
|
||
//FieldByName('CRTime').Value:=CDS_Main.fieldbyname('DZDate').Value;
|
||
//FieldByName('Qty').Value:=CDS_Main.fieldbyname('Qty').Value;
|
||
//FieldByName('Price').Value:=CDS_Main.fieldbyname('Price').Value;
|
||
//FieldByName('Money').Value:=CDS_Main.fieldbyname('Money').Value;
|
||
//FieldByName('BBMoney').Value:=CDS_Main.fieldbyname('Money').Value;
|
||
//FieldByName('CPName').Value:=Trim(CDS_Main.fieldbyname('MPRTCodeName').AsString);
|
||
FieldByName('QtyUnit').Value:='Kg';
|
||
FieldByName('YFType').Value:='<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>';
|
||
FieldByName('HuiLv').Value:=1;
|
||
FieldByName('BZType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
FieldByName('YFName').Value:='ɴ<>ӹ<DFBC>';
|
||
//FieldByName('PSName').Value:='ɴ<><C9B4>';
|
||
FieldByName('MHID').Value:=Trim(CDS_Main.fieldbyname('DZID').AsString);
|
||
Post;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('UPdate YF_Money_CR Set PS=(select PS from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(FDZID)+''')');
|
||
sql.Add(', Qty=(select Qty from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(FDZID)+''')');
|
||
sql.Add(', Price=(select Price from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(FDZID)+''')');
|
||
sql.Add(',Money=(select Money from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(FDZID)+''')');
|
||
sql.Add(',BBMoney=(select Money from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(FDZID)+''')');
|
||
sql.Add(',CPName=(select MPRTCodeName from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(FDZID)+''')');
|
||
sql.Add(',CRTime=(select DZDate from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(FDZID)+''')');
|
||
sql.Add(',OrderNo=(select OrderNo from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(FDZID)+''')');
|
||
sql.Add(',Note=(select Note from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(FDZID)+''')');
|
||
sql.Add(' where YFID='''+Trim(MaxNo)+'''');
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update JYOrder_Main_MD_DuiZhang Set YFID='''+Trim(MaxNo)+'''');
|
||
sql.Add(' where DZID='''+Trim(CDS_Main.fieldbyname('DZID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update YF_Money_KC Set ');
|
||
sql.Add(' KCMoney=(select isnull(Sum(Money*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID and A.Valid=''Y'')');
|
||
sql.Add(',KCBBMoney=(select isnull(Sum(BBMoney*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID and A.Valid=''Y'' )');
|
||
sql.Add(' where CRID='+CRID);
|
||
ExecSQL;
|
||
end;
|
||
|
||
Result:=True;
|
||
end;
|
||
function TfrmSXJGDZList.DelYFHZData():Boolean;
|
||
var
|
||
CRID:String;
|
||
begin
|
||
Result:=False;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_CR where MHID='''+Trim(CDS_Main.fieldbyname('DZID').AsString)+'''');
|
||
Open;
|
||
end;
|
||
CRID:=Trim(ADOQueryTemp.fieldbyname('CRID').AsString);
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' delete YF_Money_CR where ');
|
||
sql.Add(' MHID='''+Trim(CDS_Main.fieldbyname('DZID').AsString)+'''');
|
||
sql.Add(' Update JYOrder_Main_MD_DuiZhang Set YFID=Null where ');
|
||
sql.Add(' DZID='''+Trim(CDS_Main.fieldbyname('DZID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
if Trim(CRID)<>'' then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update YF_Money_KC Set ');
|
||
sql.Add(' KCMoney=(select isnull(Sum(Money*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID and A.Valid=''Y'')');
|
||
sql.Add(',KCBBMoney=(select isnull(Sum(BBMoney*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID and A.Valid=''Y'' )');
|
||
sql.Add(' where CRID='+CRID);
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_CR where CRID='+CRID);
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' delete YF_Money_KC where CRID='+CRID);
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
Result:=True;
|
||
end;
|
||
procedure TfrmSXJGDZList.ToolButton4Click(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then exit;
|
||
if cxTabControl1.TabIndex<>1 then Exit;
|
||
if CDS_Main.Locate('SSel',True,[])=False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫִ<D2AA>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
CDS_Main.DisableControls;
|
||
with CDS_Main do
|
||
begin
|
||
First;
|
||
while Locate('SSel',True,[]) do
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(CDS_Main.fieldbyname('DZID').AsString)+'''');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Edit;
|
||
FieldByName('DuiZhangPerson').Value:=Null;
|
||
FieldByName('DuiZhangTime').Value:=Null;
|
||
FieldByName('Status').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
Post;
|
||
end;
|
||
DelYFHZData();
|
||
CDS_Main.Delete;
|
||
end;
|
||
end;
|
||
CDS_Main.EnableControls;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
CDS_Main.EnableControls;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.SPNameChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain10.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain10,SGetFilters(Panel3,1,2));
|
||
SCreateCDS20(ADOQueryMain10,ClientDataSet0);
|
||
SInitCDSData20(ADOQueryMain10,ClientDataSet0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.MPRTCodeNameChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel5,1,2));
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.SXFactoryNameChange(Sender: TObject);
|
||
begin
|
||
FactoryName.Text:=Trim(SXFactoryName.Text);
|
||
if ADOQueryMain10.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain10,SGetFilters(Panel3,1,2));
|
||
SCreateCDS20(ADOQueryMain10,ClientDataSet0);
|
||
SInitCDSData20(ADOQueryMain10,ClientDataSet0);
|
||
end;
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel5,1,2));
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSXJGDZList.ToolButton5Click(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain10.IsEmpty then exit;
|
||
TcxGridToExcel('ɴ<>߷<EFBFBD><DFB7><EFBFBD><EFBFBD>б<EFBFBD>',cxGrid0);
|
||
end;
|
||
|
||
end.
|