D7wmguihua/应收应付/U_YFCRLZView.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

1012 lines
29 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_YFCRLZView;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin,
StdCtrls, cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdFTP,ShellAPI,IniFiles, cxCheckBox, cxCalendar,
cxButtonEdit, cxTextEdit, cxDropDownEdit;
type
TfrmYFCRLZView = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBDel: TToolButton;
TBClose: TToolButton;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
Panel1: TPanel;
ToolButton2: TToolButton;
Label1: TLabel;
YFName: TEdit;
ADOQueryMain: TADOQuery;
ToolButton1: TToolButton;
RM1: TRMGridReport;
RMDB_Main: TRMDBDataSet;
Label3: TLabel;
FactoryName: TEdit;
cxGrid2: TcxGrid;
Tv2: TcxGridDBTableView;
cxGridDBColumn1: TcxGridDBColumn;
cxGridDBColumn3: TcxGridDBColumn;
cxGridDBColumn5: TcxGridDBColumn;
cxGridDBColumn6: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
Label2: TLabel;
Label6: TLabel;
begdate: TDateTimePicker;
Enddate: TDateTimePicker;
cxGridPopupMenu2: TcxGridPopupMenu;
DS_HZ: TDataSource;
CDS_HZ: TClientDataSet;
ToolButton3: TToolButton;
v2Column1: TcxGridDBColumn;
VHL: TcxGridDBColumn;
VBZ: TcxGridDBColumn;
VYB: TcxGridDBColumn;
VBB: TcxGridDBColumn;
v2Column6: TcxGridDBColumn;
VOrderNo: TcxGridDBColumn;
v2KP: TcxGridDBColumn;
v2BatchNo: TcxGridDBColumn;
v2PS: TcxGridDBColumn;
v2PayMent: TcxGridDBColumn;
v2Note: TcxGridDBColumn;
v2Column2: TcxGridDBColumn;
Label4: TLabel;
OrderNo: TEdit;
Label5: TLabel;
Price: TEdit;
v2Column3: TcxGridDBColumn;
Label7: TLabel;
ComTaiTou: TEdit;
ToolButton4: TToolButton;
v2Column4: TcxGridDBColumn;
v2Column5: TcxGridDBColumn;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure TBDelClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure FactoryNameChange(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure cxGridDBColumn8PropertiesEditValueChanged(Sender: TObject);
procedure cxGridDBColumn5PropertiesEditValueChanged(Sender: TObject);
procedure cxGridDBColumn1PropertiesEditValueChanged(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure cxGridDBColumn3PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure cxGridDBColumn6PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure v2Column3PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure ToolButton1Click(Sender: TObject);
procedure v2Column7PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure v2Column2PropertiesEditValueChanged(Sender: TObject);
procedure v2PSPropertiesEditValueChanged(Sender: TObject);
procedure v2BatchNoPropertiesEditValueChanged(Sender: TObject);
procedure v2PayMentPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure OrderNoChange(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure OrderNoKeyPress(Sender: TObject; var Key: Char);
procedure Tv2StylesGetContentStyle(Sender: TcxCustomGridTableView;
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
out AStyle: TcxStyle);
private
{ Private declarations }
procedure InitGridHZ();
procedure InitGrid();
function SaveData():Boolean;
public
{ Public declarations }
RKFlag,FCYID:String;
end;
var
frmYFCRLZView: TfrmYFCRLZView;
implementation
uses
U_DataLink,U_Fun,U_ZDYHelp, U_ProductOrderList, U_ProductOrderNewList;
{$R *.dfm}
procedure TfrmYFCRLZView.InitGrid();
begin
begdate.SetFocus;
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add(' exec P_View_YFK :begdate,:Enddate,1,'''' ');
Parameters.ParamByName('begdate').Value:=Trim(FormatDateTime('yyyy-MM-dd',begdate.DateTime));
Parameters.ParamByName('Enddate').Value:=Trim(FormatDateTime('yyyy-MM-dd',Enddate.DateTime+1));
Open;
end;
SCreateCDS20(ADOQueryMain,CDS_HZ);
SInitCDSData20(ADOQueryMain,CDS_HZ);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmYFCRLZView.InitGridHZ();
begin
end;
procedure TfrmYFCRLZView.FormDestroy(Sender: TObject);
begin
frmYFCRLZView:=nil;
end;
procedure TfrmYFCRLZView.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmYFCRLZView.TBCloseClick(Sender: TObject);
begin
WriteCxGrid(<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>',Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
{with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('delete CK_YP_CR where isnull(CRTime,'''')='''' and CYID='''+Trim(FCYID)+''' and CRType='''+Trim(RKFlag)+'''');
ExecSQL;
end;}
Close;
end;
procedure TfrmYFCRLZView.TBDelClick(Sender: TObject);
var
FBBMoney,CRID:string;
begin
if CDS_HZ.IsEmpty then Exit;
if Trim(CDS_HZ.FieldByName('YFType').AsString)='<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>' then
begin
if Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ɣ<EFBFBD>ȷ<EFBFBD><C8B7>Ҫִ<D2AA>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select isnull(BBMoney,0) BBMoney from YF_Money_CR where YFID='''+Trim(cds_hz.fieldbyname('YFID').AsString)+'''');
Open;
end;
FBBMoney:=ADOQueryTemp.fieldbyname('BBMoney').AsString;
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
if Trim(CDS_HZ.fieldbyname('YFID').AsString)<>'' then
begin
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('delete YF_Money_CR where YFID='''+Trim(CDS_HZ.fieldbyname('YFID').AsString)+'''');
SQL.Add('Update YF_Money_KC Set KCBBMoney=KCBBMoney-'+FBBMoney);
sql.Add(' where CRID='''+Trim(CDS_HZ.fieldbyname('CRID').AsString)+'''');
ExecSQL;
end;
CRID:=Trim(CDS_HZ.fieldbyname('CRID').AsString);
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;
CDS_HZ.Delete;
end;
procedure TfrmYFCRLZView.FormShow(Sender: TObject);
var
fsj:String;
begin
ReadCxGrid(<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>',Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Enddate.DateTime:=SGetServerDate(ADOQueryTemp);
begdate.DateTime:=Enddate.DateTime-50;
fsj:='select Name=ZdyName,code='''' from KH_Zdy where Type=''OrdDefStr2'' ';
SInitCxGridComboBoxBySql(ADOQueryTemp,v2Column3,fsj,0,False,'');
if Trim(DParameters1)='<27>޶<EFBFBD><DEB6><EFBFBD><EFBFBD><EFBFBD>' then
begin
VOrderNo.Hidden:=True;
VOrderNo.Visible:=False;
label4.Visible:=False;
OrderNo.Visible:=False;
end;
if Trim(DParameters2)='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
begin
VHL.Hidden:=True;
VHL.Visible:=False;
VBZ.Hidden:=True;
VBZ.Visible:=False;
VYB.Hidden:=True;
VYB.Visible:=False;
VBB.Caption:='<27><><EFBFBD><EFBFBD>';
end;
if Trim(DParameters5)<>'<27><>Ʊ' then
begin
v2KP.Hidden:=True;
v2KP.Visible:=False;
end else
begin
v2KP.Hidden:=False;
v2KP.Visible:=True;
end;
if Trim(DParameters6)='<27><><EFBFBD><EFBFBD>' then
begin
v2PS.Hidden:=False;
v2PS.Visible:=True;
v2BatchNo.Hidden:=False;
v2BatchNo.Visible:=True;
v2PayMent.Hidden:=False;
v2PayMent.Visible:=True;
end else
begin
v2PS.Hidden:=True;
v2PS.Visible:=False;
v2BatchNo.Hidden:=True;
v2BatchNo.Visible:=False;
v2PayMent.Hidden:=True;
v2PayMent.Visible:=False;
end;
InitGrid();
end;
procedure TfrmYFCRLZView.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmYFCRLZView.ToolButton2Click(Sender: TObject);
begin
if ADOQueryMain.Active then
begin
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
SCreateCDS20(ADOQueryMain,CDS_HZ);
SInitCDSData20(ADOQueryMain,CDS_HZ);
end;
end;
procedure TfrmYFCRLZView.FactoryNameChange(Sender: TObject);
begin
ToolButton2.Click;
end;
procedure TfrmYFCRLZView.Button2Click(Sender: TObject);
begin
if CDS_HZ.IsEmpty then Exit;
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
if Trim(CDS_HZ.fieldbyname('SubID').AsString)<>'' then
begin
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('delete YCL_SG_HZ where SubID='''+Trim(CDS_HZ.fieldbyname('SubID').AsString)+'''');
ExecSQL;
end;
end;
CDS_HZ.Delete;
end;
function TfrmYFCRLZView.SaveData():Boolean;
var
maxId,CRID:String;
begin
try
ADOQueryCmd.Connection.BeginTrans;
if GetLSNo(ADOQueryCmd,maxId,'YF','YF_Money_CR',4,1)=False then
begin
Result:=False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from YF_Money_KC where FactoryName='''+Trim(CDS_HZ.fieldbyname('FactoryName').AsString)+'''');
Open;
end;
if ADOQueryCmd.IsEmpty=False then
begin
CRID:=ADOQueryCmd.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('FactoryNo').Value:=Trim(CDS_HZ.fieldbyname('FactoryNo').AsString);
FieldByName('FactoryName').Value:=Trim(CDS_HZ.fieldbyname('FactoryName').AsString);
FieldByName('ZdyStr1').Value:=<><D3A6><EFBFBD><EFBFBD>';
Post;
end;
end;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from YF_Money_CR where 1<>1');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('YFID').Value:=Trim(maxId);
FieldByName('CRID').Value:=StrToInt(CRID);
//SSetSaveDataCDSNew(ADOQueryCmd,Tv2,CDS_HZ,'YF_Money_CR',3);
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(CDS_HZ.fieldbyname('FactoryNo').AsString);
FieldByName('FactoryName').Value:=Trim(CDS_HZ.fieldbyname('FactoryName').AsString);
FieldByName('CRTime').Value:=SGetServerDate(ADOQueryTemp);
Post;
end;
with CDS_HZ do
begin
Edit;
FieldByName('YFId').Value:=Trim(maxId);
FieldByName('CRID').Value:=StrToInt(CRID);
end;
ADOQueryCmd.Connection.CommitTrans;
Result:=True;
except
Result:=True;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
end;
end;
procedure TfrmYFCRLZView.cxGridDBColumn8PropertiesEditValueChanged(
Sender: TObject);
var
mvalue,FFieldName:String;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value:=Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YCL_SG_HZ ');
if Trim(mvalue)<>'' then
begin
sql.Add(' Set '+FFieldName+'='''+Trim(mvalue)+'''');
end else
begin
sql.Add(' Set '+FFieldName+'=NULL');
end;
SQL.Add(',Editer='''+Trim(DName)+'''');
SQL.Add(',Edittime=getdate() ');
SQL.Add(' where SubId='''+Trim(CDS_HZ.fieldbyname('SubId').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmYFCRLZView.cxGridDBColumn5PropertiesEditValueChanged(
Sender: TObject);
var
mvalue,FQty,FPrice,FMoney,FHuiLv,FBBMoney,FKCBB,FFieldName:String;
begin
{ if Trim(CDS_HZ.FieldByName('YFType').AsString)='<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>' then
begin
Application.MessageBox('<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD>޸<EFBFBD>!','<27><>ʾ',0);
Exit;
end;}
mvalue:=TcxTextEdit(Sender).EditingText;
if Trim(mvalue)='' then
begin
mvalue:='0';
end;
FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value:=Trim(mvalue);
if Trim(DParameters2)='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
begin
FieldByName('HuiLv').Value:=1;
end;
Post;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select isnull(BBMoney,0) BBMoney from YF_Money_CR where YFID='''+cds_hz.fieldbyname('YFID').AsString+'''');
Open;
end;
FKCBB:=ADOQueryTemp.fieldbyname('BBMoney').AsString;
FQty:=Trim(CDS_HZ.fieldbyname('Qty').AsString);
if Trim(FQty)='' then FQty:='0';
FPrice:=Trim(CDS_HZ.fieldbyname('Price').AsString);
if Trim(FPrice)='' then FPrice:='0';
FQty:=Trim(CDS_HZ.fieldbyname('Qty').AsString);
if Trim(FQty)='' then FQty:='0';
FMoney:=Trim(CDS_HZ.fieldbyname('Money').AsString);
if Trim(FMoney)='' then FMoney:='0';
FHuiLv:=Trim(CDS_HZ.fieldbyname('HuiLv').AsString);
if Trim(FHuiLv)='' then FHuiLv:='0';
{FBBMoney:=Trim(CDS_HZ.fieldbyname('BBMoney').AsString);
if Trim(FBBMoney)='' then FBBMoney:='0'; }
if Trim(FFieldName)<>'Money' then
begin
if Trim(FFieldName)<>'HuiLv' then
begin
FBBMoney:=FloatToStr(StrToFloat(FQty)*StrToFloat(FPrice)*StrToFloat(FHuiLv));
FMoney:=FloatToStr(StrToFloat(FQty)*StrToFloat(FPrice));
end else
begin
FBBMoney:=FloatToStr(StrToFloat(FMoney)*StrToFloat(FHuiLv));
end;
end else
begin
FBBMoney:=FloatToStr(StrToFloat(FMoney)*StrToFloat(FHuiLv));
end;
with CDS_HZ do
begin
Edit;
FieldByName('Money').Value:=StrToFloat(FMoney);
FieldByName('BBMoney').Value:=StrToFloat(FBBMoney);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_CR ');
sql.Add(' Set '+FFieldName+'='+Trim(mvalue));
if Trim(FFieldName)<>'Money' then
begin
sql.Add(',Money='+FMoney);
end;
sql.Add(',BBMoney='+FBBMoney);
SQL.Add(',Editer='''+Trim(DName)+'''');
SQL.Add(',Edittime=getdate() ');
SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
SQL.Add('Update YF_Money_KC Set KCBBMoney=KCBBMoney-'+FKCBB+'+'+FBBMoney);
sql.Add(' where CRID='''+Trim(CDS_HZ.fieldbyname('CRID').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmYFCRLZView.cxGridDBColumn1PropertiesEditValueChanged(
Sender: TObject);
var
mvalue,FFieldName:String;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value:=Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_CR ');
if Trim(mvalue)<>'' then
begin
sql.Add(' Set '+FFieldName+'='''+Trim(mvalue)+'''');
end else
begin
sql.Add(' Set '+FFieldName+'=NULL');
end;
SQL.Add(',Editer='''+Trim(DName)+'''');
SQL.Add(',Edittime=getdate() ');
SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmYFCRLZView.ToolButton3Click(Sender: TObject);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='YFFactory';
flagname:='<27>Է<EFBFBD><D4B7><EFBFBD>λ';
if Trim(DParameters8)='' then
begin
flag:='YFFactory';
end else
begin
flag:=Trim(DParameters8);
end;
if Trim(DParameters4)='<27>Է<EFBFBD><D4B7><EFBFBD>λ<EFBFBD>ֿ<EFBFBD>' then
MainType:='<27><><EFBFBD><EFBFBD>';
if ShowModal=1 then
begin
with Self.CDS_HZ do
begin
Append;
FieldByName('FactoryNo').Value:=Trim(ClientDataSet1.fieldbyname('ZdyNo').AsString);
FieldByName('FactoryName').Value:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
FieldByName('CRTime').Value:=SGetServerDate(ADOQueryTemp);
Post;
end;
Self.SaveData();
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmYFCRLZView.cxGridDBColumn3PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
if Trim(CDS_HZ.FieldByName('YFType').AsString)='<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>' then
begin
Application.MessageBox('<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD>޸<EFBFBD>!','<27><>ʾ',0);
Exit;
end;
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='YFName';
flagname:='<27><>Ŀ<EFBFBD><C4BF>ժҪ';
if Trim(DParameters3)='<27><>Ŀ<EFBFBD>ֿ<EFBFBD>' then
MainType:='<27><><EFBFBD><EFBFBD>';
if ShowModal=1 then
begin
with Self.CDS_HZ do
begin
Edit;
FieldByName('YFCode').Value:=Trim(ClientDataSet1.fieldbyname('ZdyNo').AsString);
FieldByName('YFName').Value:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_CR ');
sql.Add(' Set YFCode='''+Trim(ClientDataSet1.fieldbyname('ZdyNo').AsString)+'''');
sql.Add(' ,YFName='''+Trim(ClientDataSet1.fieldbyname('ZdyName').AsString)+'''');
SQL.Add(',Editer='''+Trim(DName)+'''');
SQL.Add(',Edittime=getdate() ');
SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
ExecSQL;
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmYFCRLZView.cxGridDBColumn6PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='OrderUnit';
flagname:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ';
if ShowModal=1 then
begin
Self.CDS_HZ.Edit;
Self.CDS_HZ.FieldByName('QtyUnit').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_CR ');
sql.Add(' Set QtyUnit='''+Trim(ClientDataSet1.fieldbyname('ZdyName').AsString)+'''');
SQL.Add(',Editer='''+Trim(DName)+'''');
SQL.Add(',Edittime=getdate() ');
SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
ExecSQL;
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmYFCRLZView.v2Column3PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='BZType';
flagname:='<27><><EFBFBD><EFBFBD>';
if ShowModal=1 then
begin
Self.CDS_HZ.Edit;
Self.CDS_HZ.FieldByName('BZType').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_CR ');
sql.Add(' Set BZType='''+Trim(ClientDataSet1.fieldbyname('ZdyName').AsString)+'''');
SQL.Add(',Editer='''+Trim(DName)+'''');
SQL.Add(',Edittime=getdate() ');
SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
ExecSQL;
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmYFCRLZView.ToolButton1Click(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then Exit;
SelExportData(Tv2,ADOQueryMain,<><D3A6><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>');
end;
procedure TfrmYFCRLZView.v2Column7PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
if Trim(CDS_HZ.FieldByName('YFType').AsString)='<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>' then
begin
Application.MessageBox('<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD>޸<EFBFBD>!','<27><>ʾ',0);
Exit;
end;
try
frmProductOrderNewList:=TfrmProductOrderNewList.Create(Application);
with frmProductOrderNewList do
begin
DParameters1:='<27><>Ȩ<EFBFBD><C8A8>';
//frmProductOrderList.v1Column4.Visible:=True;
if ShowModal=1 then
begin
with Self.CDS_HZ do
begin
Edit;
FieldByName('MainId').Value:=Trim(frmProductOrderNewList.Order_Main.fieldbyname('MainId').AsString);
FieldByName('OrderNo').Value:=Trim(frmProductOrderNewList.Order_Main.fieldbyname('OrderNo').AsString);
FieldByName('ComTaiTou').Value:=Trim(frmProductOrderNewList.Order_Main.fieldbyname('OrdDefStr2').AsString);
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_CR ');
sql.Add(' Set MainId='''+Trim(frmProductOrderNewList.Order_Main.fieldbyname('MainId').AsString)+'''');
SQL.Add(',ComTaiTou='''+Trim(frmProductOrderNewList.Order_Main.fieldbyname('OrdDefStr2').AsString)+'''');
//sql.Add(' ,SubId='''+Trim(frmProductOrderList.Order_Main.fieldbyname('SubId').AsString)+'''');
SQL.Add(',Editer='''+Trim(DName)+'''');
SQL.Add(',Edittime=getdate() ');
SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
ExecSQL;
end;
end;
end;
end;
finally
frmProductOrderNewList.Free;
end;
end;
procedure TfrmYFCRLZView.v2Column2PropertiesEditValueChanged(Sender: TObject);
var
mvalue,FBBMoney,FKCBB,FFieldName:String;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
if Trim(mvalue)='' then
begin
mvalue:='0';
end;
FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value:=Trim(mvalue);
Post;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select isnull(KPMoney,0) KPMoney from YF_Money_CR where YFID='''+cds_hz.fieldbyname('YFID').AsString+'''');
Open;
end;
FKCBB:=ADOQueryTemp.fieldbyname('KPMoney').AsString;
FBBMoney:=CDS_HZ.fieldbyname('KPMoney').AsString;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_CR ');
sql.Add(' Set '+FFieldName+'='+Trim(mvalue));
SQL.Add(',Editer='''+Trim(DName)+'''');
SQL.Add(',Edittime=getdate() ');
SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
SQL.Add('Update YF_Money_KC Set KCKPMoney=KCKPMoney-'+FKCBB+'+'+FBBMoney);
sql.Add(' where CRID='''+Trim(CDS_HZ.fieldbyname('CRID').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmYFCRLZView.v2PSPropertiesEditValueChanged(Sender: TObject);
var
mvalue,FFieldName:String;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
if Trim(mvalue)='' then
begin
mvalue:='0';
end;
FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value:=Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_CR ');
sql.Add(' Set '+FFieldName+'='+Trim(mvalue));
SQL.Add(',Editer='''+Trim(DName)+'''');
SQL.Add(',Edittime=getdate() ');
SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmYFCRLZView.v2BatchNoPropertiesEditValueChanged(Sender: TObject);
var
mvalue,FFieldName:String;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value:=Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_CR ');
sql.Add(' Set '+FFieldName+'='''+Trim(mvalue)+'''');
SQL.Add(',Editer='''+Trim(DName)+'''');
SQL.Add(',Edittime=getdate() ');
SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmYFCRLZView.v2PayMentPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='PayMent';
flagname:=<><D6A7><EFBFBD><EFBFBD>ʽ';
if ShowModal=1 then
begin
with Self.CDS_HZ do
begin
Edit;
FieldByName('PayMent').Value:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_CR ');
sql.Add(' Set PayMent='''+Trim(ClientDataSet1.fieldbyname('ZdyName').AsString)+'''');
SQL.Add(',Editer='''+Trim(DName)+'''');
SQL.Add(',Edittime=getdate() ');
SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
ExecSQL;
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmYFCRLZView.OrderNoChange(Sender: TObject);
begin
if Length(Trim(OrderNo.Text))<3 then Exit;
ToolButton2.Click;
end;
procedure TfrmYFCRLZView.ToolButton4Click(Sender: TObject);
var
FColumn:String;
begin
begdate.SetFocus;
FColumn:=Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName;
if ((Trim(FColumn)='Note') or (Trim(FColumn)='YFName') or (Trim(FColumn)='ComTaiTou') or (Trim(FColumn)='Price')) then
begin
end else
begin
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫִ<D2AA>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
OneKeyPost(Tv2,CDS_HZ);
CDS_HZ.DisableControls;
with CDS_HZ do
begin
First;
while not Eof do
begin
if Trim(FColumn)<>'Price' then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update YF_Money_CR Set '+Trim(FColumn)+'='''+Trim(CDS_HZ.fieldbyname(FColumn).Value)+'''');
sql.Add(' where YFID='''+Trim(CDS_HZ.fieldbyname('YFID').AsString)+'''');
ExecSQL;
end;
end else
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
if Trim(CDS_HZ.fieldbyname(FColumn).AsString)<>'' then
sql.Add('Update YF_Money_CR Set Price='+Trim(CDS_HZ.fieldbyname(FColumn).AsString))
else
sql.Add('Update YF_Money_CR Set Price=0 ');
sql.Add(' where YFID='''+Trim(CDS_HZ.fieldbyname('YFID').AsString)+'''');
ExecSQL;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_CR Set Money=Price*Qty,BBMoney=Price*Qty');
sql.Add(' where YFID='''+Trim(CDS_HZ.fieldbyname('YFID').AsString)+'''');
ExecSQL;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_KC Set KCMoney=(select sum(QtyFlag*Money) from YF_Money_CR where CRId=YF_Money_KC.CRID)');
sql.Add(',KCBBMoney=(select sum(QtyFlag*BBMoney) from YF_Money_CR where CRId=YF_Money_KC.CRID)');
sql.Add(' where CRID=(select CRID from YF_Money_CR B where B.YFID='''+Trim(CDS_HZ.fieldbyname('YFID').AsString)+''')');
ExecSQL;
end;
end;
Next;
end;
end;
CDS_HZ.EnableControls;
end;
procedure TfrmYFCRLZView.OrderNoKeyPress(Sender: TObject; var Key: Char);
begin
if Key=#13 then
begin
if Length(OrderNo.Text)<3 then Exit;
begdate.SetFocus;
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add(' exec P_View_YFK :begdate,:Enddate,2,:orderno ');
Parameters.ParamByName('begdate').Value:=Trim(FormatDateTime('yyyy-MM-dd',begdate.DateTime));
Parameters.ParamByName('Enddate').Value:=Trim(FormatDateTime('yyyy-MM-dd',Enddate.DateTime+1));
Parameters.ParamByName('orderno').Value:='%'+Trim(OrderNo.Text)+'%';
Open;
end;
SCreateCDS20(ADOQueryMain,CDS_HZ);
SInitCDSData20(ADOQueryMain,CDS_HZ);
finally
ADOQueryMain.EnableControls;
end;
end;
end;
procedure TfrmYFCRLZView.Tv2StylesGetContentStyle(
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
var
Id,Id10:Integer;
begin
try
if Tv2.GroupedItemCount=0 then
begin
Id:=TV2.GetColumnByFieldName('Qty').Index;//;-TV1.GroupedItemCount;
Id10:=TV2.GetColumnByFieldName('CanKaoQty').Index;
if ARecord.Values[Id]<>ARecord.Values[Id10] then
begin
if ARecord.Values[Id10]<>null then
AStyle:=DataLink_YSYF.Green;
end;
end else
begin
end;
except
end;
end;
end.