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

1350 lines
38 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_YFCR;
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, cxPC, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator,
dxBarBuiltInMenu, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinBlueprint,
dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide,
dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis,
dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black,
dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue,
dxSkinOffice2010Silver, dxSkinOffice2013DarkGray, dxSkinOffice2013LightGray,
dxSkinOffice2013White, dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic,
dxSkinSharp, dxSkinSharpPlus, dxSkinSilver, dxSkinSpringTime, dxSkinStardust,
dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinsDefaultPainters,
dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue,
dxSkinscxPCPainter;
type
TfrmYFCR = 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;
TBADD: 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;
v2C_CodeName: TcxGridDBColumn;
v2T_qty: TcxGridDBColumn;
v2Column3: TcxGridDBColumn;
v2Column2: TcxGridDBColumn;
v2Column4: TcxGridDBColumn;
v2Column5: TcxGridDBColumn;
P_CodeName: TEdit;
Label4: TLabel;
Label5: TLabel;
P_Color: TEdit;
Edit1: TEdit;
Label7: TLabel;
Button1: TButton;
CheckBox1: TCheckBox;
v2T_Price: TcxGridDBColumn;
v2T_ps: TcxGridDBColumn;
v2Column7: TcxGridDBColumn;
v2Column8: TcxGridDBColumn;
cxTabControl1: TcxTabControl;
tchk: TToolButton;
Tnochk: TToolButton;
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 TBADDClick(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 v2T_qtyPropertiesEditValueChanged(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure v2T_PricePropertiesEditValueChanged(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure tchkClick(Sender: TObject);
procedure TnochkClick(Sender: TObject);
procedure cxTabControl1Change(Sender: TObject);
procedure VBBPropertiesEditValueChanged(Sender: TObject);
procedure FactoryNameKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
procedure InitGridHZ();
procedure InitGrid();
procedure InitGridHC();
function SaveData(): Boolean;
procedure SetStatus();
public
fFlag: integer;
{ Public declarations }
RKFlag, FCYID: string;
FZD, FCZSJ: string;
end;
var
frmYFCR: TfrmYFCR;
implementation
uses
U_DataLink, U_Fun, U_ZDYHelp, U_ProductOrderList, U_ProductOrderNewList,
U_PbProductList, U_ZdyAttachGYS;
{$R *.dfm}
procedure TfrmYFCR.SetStatus();
var
i: integer;
begin
Tchk.Enabled := false;
TNochk.Enabled := false;
TBDel.Enabled := false;
for i := 0 to tv2.ColumnCount - 1 do
begin
if uppercase(tv2.Columns[i].DataBinding.FieldName) <> 'SSEL' then
tv2.Columns[i].Options.Editing := false;
end;
if cxTabControl1.TabIndex = 0 then
begin
Tchk.Enabled := true;
TBDel.Enabled := true;
for i := 0 to tv2.ColumnCount - 1 do
begin
tv2.Columns[i].Options.Editing := true;
end;
end;
if cxTabControl1.TabIndex = 1 then
begin
TNochk.Enabled := true;
end;
initgrid();
end;
procedure TfrmYFCR.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Close;
SQL.Clear;
Filtered := False;
sql.Add(' select A.*,C.ConNo ');
sql.Add(',scPrice=isnull((select Top 1 cast(cast(Price as float) as varchar) from YF_Money_CR X where CRType='<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>'' and X.FillTime<A.FillTime and X.P_CodeName=A.P_CodeName and X.P_cOlor=A.P_Color order by FillTime desc),0)');
sql.Add(' from YF_Money_CR A');
// sql.Add(' inner join YF_Money_KC B on A.CRID=B.CRID');
SQL.Add(' left join ConTract_sub C on A.MainId=C.MainId AND C.SUBID=A.SUBID');
sql.Add(' where A.CRTime>=''' + FormatDateTime('yyyy-MM-dd', begdate.DateTime) + ''' ');
sql.Add(' and CRTime<''' + FormatDateTime('yyyy-MM-dd', Enddate.DateTime + 1) + ''' ');
sql.Add(' and A.CRType='<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>'' ');
if cxTabControl1.TabIndex < 2 then
sql.Add(' and status=''' + inttostr(cxTabControl1.TabIndex) + ''' ');
Open;
end;
SCreateCDS20(ADOQueryMain, CDS_HZ);
SInitCDSData20(ADOQueryMain, CDS_HZ);
finally
ADOQueryMain.EnableControls;
ToolButton2.Click;
end;
end;
procedure TfrmYFCR.InitGridHC();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Close;
SQL.Clear;
Filtered := False;
sql.Add(' select A.*,C.ConNo ');
sql.Add(',scPrice=isnull((select Top 1 cast(cast(Price as float) as varchar) from YF_Money_CR X where CRType='<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>'' and X.FillTime<A.FillTime and X.P_CodeName=A.P_CodeName and X.P_cOlor=A.P_Color order by FillTime desc),0)');
sql.Add(' from YF_Money_CR A');
// sql.Add(' inner join YF_Money_KC B on A.CRID=B.CRID');
SQL.Add(' left join ConTract_sub C on A.MainId=C.MainId AND C.SUBID=A.SUBID');
sql.Add(' where A.CRTime>=''' + FormatDateTime('yyyy-MM-dd', begdate.DateTime) + ''' ');
sql.Add(' and CRTime<''' + FormatDateTime('yyyy-MM-dd', Enddate.DateTime + 1) + ''' ');
sql.Add(' and A.CRType='<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>'' ');
sql.Add(' and ' + FZD + '=''' + Trim(FCZSJ) + '''');
if cxTabControl1.TabIndex < 2 then
sql.Add(' and status=''' + inttostr(cxTabControl1.TabIndex) + ''' ');
// ShowMessage(SQL.text);
Open;
end;
SCreateCDS20(ADOQueryMain, CDS_HZ);
SInitCDSData20(ADOQueryMain, CDS_HZ);
finally
ADOQueryMain.EnableControls;
// ToolButton2.Click;
end;
end;
procedure TfrmYFCR.InitGridHZ();
begin
end;
procedure TfrmYFCR.FormDestroy(Sender: TObject);
begin
frmYFCR := nil;
end;
procedure TfrmYFCR.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TfrmYFCR.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 TfrmYFCR.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;
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('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( ');
sql.Add(' ' + quotedstr(trim(DName)));
sql.Add(',getdate() ');
sql.Add(',' + quotedstr(trim(self.Caption)));
sql.Add(',' + quotedstr(trim(<><D3A6><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>')));
sql.Add(',' + quotedstr(trim('<27><>Ӧ<EFBFBD><D3A6>:' + trim(CDS_HZ.FieldByName('factoryName').AsString) + ' <20><><EFBFBD><EFBFBD>:' + trim(CDS_HZ.FieldByName('money').AsString))));
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
sql.Add(')');
ExecSQL;
end;
end;
CDS_HZ.Delete;
end;
procedure TfrmYFCR.FormShow(Sender: TObject);
begin
ReadCxGrid(<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Enddate.DateTime := SGetServerDate(ADOQueryTemp);
begdate.DateTime := Enddate.DateTime;
if Trim(DParameters1) = '<27>޶<EFBFBD><DEB6><EFBFBD><EFBFBD><EFBFBD>' then
begin
VOrderNo.Hidden := True;
VOrderNo.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;
SetStatus();
InitGrid();
end;
procedure TfrmYFCR.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmYFCR.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 TfrmYFCR.FactoryNameChange(Sender: TObject);
begin
ToolButton2.Click;
end;
procedure TfrmYFCR.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 TfrmYFCR.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) + ''' and YFDefFlag1=''' + inttostr(fFlag) + '''');
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>';
FieldByName('YFDefFlag1').Value := fFlag;
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 := formatdateTIme('yyyy-MM-dd', CDS_HZ.fieldbyname('CRTime').AsDateTime);
FieldByName('YFDefFlag1').Value := fFlag;
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 TfrmYFCR.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 TfrmYFCR.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;
tv2.Controller.EditingController.ShowEdit();
end;
procedure TfrmYFCR.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;
tv2.Controller.EditingController.ShowEdit();
end;
procedure TfrmYFCR.TBADDClick(Sender: TObject);
begin
try
frmZdyAttachGYS := TfrmZdyAttachGYS.Create(Application);
with frmZdyAttachGYS do
begin
if ShowModal = 1 then
begin
with Self.CDS_HZ do
begin
Append;
FieldByName('FactoryNo').Value := Trim(CDS_HZ.fieldbyname('ZdyCode').AsString);
FieldByName('FactoryName').Value := Trim(CDS_HZ.fieldbyname('ZdyName').AsString);
FieldByName('CRTime').Value := SGetServerDate(ADOQueryTemp);
Post;
end;
Self.SaveData();
end;
end;
finally
frmZdyAttachGYS.Free;
end;
{ try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='FactoryNo1Name';
flagname:='<27><><EFBFBD><EFBFBD>';
MainType:='<27><><EFBFBD><EFBFBD><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 TfrmYFCR.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 TfrmYFCR.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 TfrmYFCR.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 TfrmYFCR.ToolButton1Click(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then
Exit;
SelExportData(Tv2, ADOQueryMain, <><D3A6><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>');
end;
procedure TfrmYFCR.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
frmPbProductList := TfrmPbProductList.Create(Application);
with frmPbProductList 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(frmPbProductList.Order_Main.fieldbyname('MainId').AsString);
FieldByName('subID').Value := Trim(frmPbProductList.Order_Main.fieldbyname('subID').AsString);
FieldByName('ConNO').Value := Trim(frmPbProductList.Order_Main.fieldbyname('ConNO').AsString);
FieldByName('C_CodeName').Value := Trim(frmPbProductList.Order_Main.fieldbyname('C_CodeName').AsString);
post;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_CR ');
sql.Add(' Set MainId=''' + Trim(frmPbProductList.Order_Main.fieldbyname('MainId').AsString) + '''');
sql.Add(' ,SubId=''' + Trim(frmPbProductList.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
frmPbProductList.Release;
self.Tv2.Controller.EditingController.ShowEdit();
end;
end;
procedure TfrmYFCR.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 TfrmYFCR.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 TfrmYFCR.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 TfrmYFCR.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 TfrmYFCR.v2T_qtyPropertiesEditValueChanged(Sender: TObject);
var
mvalue, FQty, FPrice, FMoney, FHuiLv, FBBMoney, FKCBB, FFieldName, TMoney: string;
begin
mvalue := TcxTextEdit(Sender).EditingText;
if Trim(mvalue) = '' then
begin
mvalue := '0';
end;
FFieldName := Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
TMoney := format('%.2f', [CDS_HZ.Fieldbyname('T_Price').AsFloat * strtofloat(mvalue)]);
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value := Trim(mvalue);
FieldByName('T_Money').Value := trim(TMoney);
if Trim(DParameters2) = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
begin
FieldByName('HuiLv').Value := 1;
end;
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_CR ');
sql.Add(' Set ' + FFieldName + '=' + Trim(mvalue));
sql.Add(',T_Money=' + TMoney);
SQL.Add(' where YFId=''' + Trim(CDS_HZ.fieldbyname('YFId').AsString) + '''');
ExecSQL;
end;
end;
procedure TfrmYFCR.Button1Click(Sender: TObject);
begin
if CDS_HZ.IsEmpty then
exit;
if CDS_HZ.Locate('ssel', true, []) = false then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
ADOQueryCmd.Connection.BeginTrans;
try
with CDS_HZ do
begin
DisableControls;
First;
while not eof do
begin
if fieldbyname('ssel').AsBoolean then
begin
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from YF_Money_CR ');
sql.Add('where YFID=' + quotedstr(trim(CDS_HZ.fieldbyname('YFID').AsString)));
open;
edit;
Fieldbyname('Price').Value := strtofloatdef(edit1.Text, 0);
Fieldbyname('Money').Value := format('%.2f', [Fieldbyname('Qty').AsFloat * strtofloatdef(edit1.Text, 0)]);
Fieldbyname('BBMoney').Value := format('%.2f', [Fieldbyname('Qty').AsFloat * strtofloatdef(edit1.Text, 0)]);
post;
end;
end;
next;
end;
First;
EnableControls;
end;
ADOQueryCmd.Connection.CommitTrans;
InitGrid();
except
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmYFCR.CheckBox1Click(Sender: TObject);
begin
if CDS_HZ.IsEmpty then
exit;
with CDS_HZ do
begin
DisableControls;
first;
while not eof do
begin
edit;
fieldbyname('ssel').Value := checkbox1.Checked;
post;
next;
end;
First;
EnableControls;
end;
end;
procedure TfrmYFCR.v2T_PricePropertiesEditValueChanged(Sender: TObject);
var
mvalue, FQty, FPrice, FMoney, FHuiLv, FBBMoney, FKCBB, FFieldName, TMoney: string;
begin
mvalue := TcxTextEdit(Sender).EditingText;
if Trim(mvalue) = '' then
begin
mvalue := '0';
end;
FFieldName := Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
TMoney := format('%.2f', [CDS_HZ.Fieldbyname('T_Qty').AsFloat * strtofloat(mvalue)]);
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value := Trim(mvalue);
FieldByName('T_Money').Value := trim(TMoney);
if Trim(DParameters2) = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
begin
FieldByName('HuiLv').Value := 1;
end;
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_CR ');
sql.Add(' Set ' + FFieldName + '=' + Trim(mvalue));
sql.Add(',T_Money=' + TMoney);
SQL.Add(' where YFId=''' + Trim(CDS_HZ.fieldbyname('YFId').AsString) + '''');
ExecSQL;
end;
end;
procedure TfrmYFCR.FormCreate(Sender: TObject);
begin
cxgrid2.Align := alclient;
end;
procedure TfrmYFCR.tchkClick(Sender: TObject);
begin
if CDS_HZ.IsEmpty then
exit;
if CDS_HZ.Locate('ssel', true, []) = false then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
try
ADOQueryCmd.Connection.BeginTrans;
with CDS_HZ do
begin
DisableControls;
First;
while not eof do
begin
if Fieldbyname('ssel').AsBoolean then
begin
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update YF_Money_CR SET status=''1'' ');
sql.Add('where YFID =' + quotedstr(trim(CDS_HZ.fieldbyname('YFID').AsString)));
execsql;
end;
end;
next;
end;
First;
EnableControls;
end;
InitGrid();
ADOQueryCmd.Connection.CommitTrans;
except
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmYFCR.TnochkClick(Sender: TObject);
begin
if CDS_HZ.IsEmpty then
exit;
if CDS_HZ.Locate('ssel', true, []) = false then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
try
ADOQueryCmd.Connection.BeginTrans;
with CDS_HZ do
begin
DisableControls;
First;
while not eof do
begin
if Fieldbyname('ssel').AsBoolean then
begin
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update YF_Money_CR SET status=''0'' ');
sql.Add('where YFID =' + quotedstr(trim(CDS_HZ.fieldbyname('YFID').AsString)));
execsql;
end;
end;
next;
end;
First;
EnableControls;
end;
InitGrid();
ADOQueryCmd.Connection.CommitTrans;
except
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmYFCR.cxTabControl1Change(Sender: TObject);
begin
SetStatus();
InitGrid();
end;
procedure TfrmYFCR.VBBPropertiesEditValueChanged(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(',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;
InitGrid();
tv2.Controller.EditingController.ShowEdit();
end;
procedure TfrmYFCR.FactoryNameKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
if Length(TcxTextEdit(Sender).Name) < 2 then
Exit;
FZD := TcxTextEdit(Sender).Name;
// <20><>ȡ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>
FCZSJ := TcxTextEdit(Sender).Text;
InitGridHC();
end;
end;
end.