D7wmguihua/样品/U_CPAddWJE.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

678 lines
19 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_CPAddWJE;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
cxEdit, DB, cxDBData, ADODB, DBClient, cxGridLevel, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView,
cxGrid, ComCtrls, ToolWin, cxGridCustomPopupMenu, cxGridPopupMenu, cxTextEdit,
cxButtonEdit, StdCtrls, ExtCtrls, cxCurrencyEdit, cxLookAndFeels,
cxLookAndFeelPainters, 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, cxNavigator;
type
TfrmCPAddWJE = class(TForm)
ToolBar1: TToolBar;
ToolButton1: TToolButton;
TBClose: TToolButton;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column1: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
v1Column11: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
CDS_Sub: TClientDataSet;
ADOQueryMain: TADOQuery;
DataSource2: TDataSource;
ADOQueryCmd: TADOQuery;
ADOQueryTemp: TADOQuery;
cxGridPopupMenu1: TcxGridPopupMenu;
v1Column13: TcxGridDBColumn;
v1Column14: TcxGridDBColumn;
v1Column20: TcxGridDBColumn;
v1Column41: TcxGridDBColumn;
Panel1: TPanel;
CheckBox1: TCheckBox;
v1Column12: TcxGridDBColumn;
v1Column15: TcxGridDBColumn;
v1Column16: TcxGridDBColumn;
v1Column17: TcxGridDBColumn;
v1Column18: TcxGridDBColumn;
v1Column19: TcxGridDBColumn;
v1Column21: TcxGridDBColumn;
v1Column22: TcxGridDBColumn;
v1Column23: TcxGridDBColumn;
v1Column29: TcxGridDBColumn;
Tv1Column1: TcxGridDBColumn;
Tv1Column2: TcxGridDBColumn;
procedure FormShow(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure v1Column7PropertiesEditValueChanged(Sender: TObject);
procedure v1Column8PropertiesEditValueChanged(Sender: TObject);
procedure v1Column2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure v1Column26PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure v1Column27PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure v1Column20PropertiesEditValueChanged(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure v1Column23PropertiesEditValueChanged(Sender: TObject);
private
canshu1: string;
Fint: Integer;
procedure InitSubGrid();
function SaveData(): Boolean;
{ Private declarations }
public
FCYID, FCYCode, FCPID, FCPNO: string;
CopyInt: Integer;
{ Public declarations }
end;
var
frmCPAddWJE: TfrmCPAddWJE;
implementation
uses
U_DataLink, U_Fun, U_iniParam, U_ZDYHelp;
{$R *.dfm}
procedure TfrmCPAddWJE.InitSubGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Close;
SQL.Clear;
SQL.Add('select * from CP_YDang where CYID=''' + Trim(FCYID) + '''');
Open;
end;
SCreateCDS20(ADOQueryMain, CDS_Sub);
SInitCDSData20(ADOQueryMain, CDS_Sub);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmCPAddWJE.FormShow(Sender: TObject);
var
fsj, FFSj, FFQZSj, FFFSj, FFType: string;
FFInt, i, j: Integer;
ii: LongInt;
begin
//canshu1:=Trim(DParameters1);
ReadCxGrid('<27><>Ʒ<EFBFBD>༭YT', Tv1, '<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>1');
// if DParameters2 = '<27>޼۸<DEBC>' then
// begin
// Tv1Column3.Visible := False;
// Tv1Column4.Visible := False;
// Tv1Column5.Visible := False;
// Tv1Column6.Visible := False;
// Tv1Column7.Visible := False;
//
// Tv1Column3.Options.Editing := False;
// Tv1Column4.Options.Editing := False;
// Tv1Column5.Options.Editing := False;
// Tv1Column6.Options.Editing := False;
// Tv1Column7.Options.Editing := False;
// end;
InitSubGrid();
if CopyInt = 1 then
begin
FCYID := '';
end;
{ if Trim(YPCodeType)<>'' then
begin
if Trim(FCYID)='' then
begin
//ȡǰ׺
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select CYNO AA from CP_YDang ');
SQL.Add('where Cast(CYID as int)=(select isnull(Max(Cast(CYID as int)),0) from CP_YDang where CYType='''+Trim(FCPID)+''')');
Open;
end;
if Trim(ADOQueryTemp.fieldbyname('AA').asstring)='' then
begin
FFQZSj:=Trim(FCPNO);
end else
begin
fsj:=Trim(ADOQueryTemp.fieldbyname('AA').asstring);
FFInt:=0;
i:=0;
FFFSj:=Trim(Copy(fsj,Length(FCPNO)+1,Length(fsj)));
while FFInt<=0 do
begin
FFSj:=Trim(Copy(fsj,Length(FCPNO)+1+i,Length(fsj)));
if TryStrToInt(FFSj,ii) then
begin
if StrToInt(FFSj)>=0 then
begin
i:=i+1;
end else
begin
FFInt:=1;
FFQZSj:=Trim(Copy(fsj,1,Length(FCPNO)+i+1));//ǰ׺<C7B0>ַ<EFBFBD><D6B7><EFBFBD>
end;
if i=Length(FFFSj) then
begin
FFInt:=1;
FFQZSj:=Trim(FCPNO);
end;
end else
begin
FFInt:=1;
FFQZSj:=Trim(Copy(fsj,1,Length(FCPNO)+i+1));//ǰ׺<C7B0>ַ<EFBFBD><D6B7><EFBFBD>
end;
end;
end;
//ȡǰ׺
//ȡ<><C8A1>׺
if Trim(YPCodeType)='<27><><EFBFBD><EFBFBD>' then
begin
i:=99;
while i>=1 do
begin
if i=99 then
begin
FFType:=Trim(FCPID);
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from CP_Type where CPID='''+Trim(FFType)+'''');
Open;
i:=fieldbyname('CPLevel').AsInteger;
if i>1 then
FFType:=Trim(fieldbyname('CPParent').AsString)
else
if i=1 then
begin
FFType:=Trim(fieldbyname('CPID').AsString);
i:=0;
end;
end;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('exec P_Select_CP_YDang_MaxNo :CPType');
Parameters.ParamByName('CPType').Value:=Trim(FFType);
Open;
end;
end else
if Trim(YPCodeType)='С<><D0A1>' then
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select CYNO AA from CP_YDang ');
SQL.Add('where Cast(CYID as int)=(select isnull(Max(Cast(CYID as int)),0) from CP_YDang where CYType='''+Trim(FCPID)+''')');
Open;
end;
end;
if Trim(ADOQueryTemp.fieldbyname('AA').asstring)='' then
begin
FFFSj:='0001';
end else
begin
fsj:=Trim(ADOQueryTemp.fieldbyname('AA').asstring);
FFInt:=0;
i:=0;
FFFSj:='';
fsj:=Trim( Copy( fsj,Length(FFQZSj)+1,Length(fsj) ) );
while FFInt<=0 do
begin
FFSj:=Trim(Copy(fsj,(Length(fsj)-i),(Length(fsj))));
if TryStrToInt(FFSj,ii) then
begin
if StrToInt(FFSj)>=0 then
begin
FFFSj:=Trim(FFSj);//<2F><>׺<EFBFBD><D7BA><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
end else
begin
FFInt:=1;
end;
i:=i+1;
if i=Length(fsj) then
begin
FFInt:=1;
end;
end else
begin
FFInt:=1;
end;
end;
i:=Length(FFFSj); //<2F><><EFBFBD>ֱ<EFBFBD><D6B1>ų<EFBFBD><C5B3><EFBFBD> 3
FFInt:=StrToInt(FFFSj)+1;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
j:=Length(Trim(IntToStr(FFInt))); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> 1
FFFSj:=Trim(IntToStr(FFInt));//<2F><>׺<EFBFBD><D7BA><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
while j<i do
begin
FFFSj:='0'+Trim(FFFsj);
j:=j+1
end;
end;
//ȡ<><C8A1>׺
fsj:=Trim(FFQZSj)+Trim(FFFSj);
if CopyInt=0 then
CDS_Sub.Append
else
if CopyInt=1 then
CDS_Sub.Edit;
CDS_Sub.FieldByName('CYNo').Value:=Trim(fsj);
CDS_Sub.Post;
end;
end else }
begin
if CDS_Sub.IsEmpty then
begin
CDS_Sub.Append;
CDS_Sub.Post;
end;
end;
end;
procedure TfrmCPAddWJE.TBCloseClick(Sender: TObject);
begin
WriteCxGrid('<27><>Ʒ<EFBFBD>༭YT', Tv1, '<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>1');
Close;
end;
function TfrmCPAddWJE.SaveData(): Boolean;
var
maxId: string;
begin
try
ADOQueryCmd.Connection.BeginTrans;
if Trim(FCYID) = '' then
begin
if GetLSNo(ADOQueryCmd, maxId, '', 'CP_YDang', 4, 1) = False then
begin
Result := False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
end
else
begin
maxId := Trim(FCYID);
end;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from CP_YDang where CYID=''' + Trim(FCYID) + '''');
Open;
end;
with ADOQueryCmd do
begin
if Trim(FCYID) = '' then
begin
Append;
end
else
begin
Edit;
end;
FieldByName('CYID').Value := Trim(maxId);
FieldByName('CYType').Value := Trim(FCPID);
SSetSaveDataCDSNew(ADOQueryCmd, Tv1, CDS_Sub, 'CP_YDang', 3);
if Trim(CDS_Sub.fieldbyname('CYPriceKg').AsString) = '' then
FieldByName('CYPriceKg').Value := 0
else
FieldByName('CYPriceKg').Value := CDS_Sub.fieldbyname('CYPriceKg').AsString;
if Trim(CDS_Sub.fieldbyname('CYPriceM').AsString) = '' then
FieldByName('CYPriceM').Value := 0
else
FieldByName('CYPriceM').Value := CDS_Sub.fieldbyname('CYPriceM').AsString;
FieldByName('Price1').Value := CDS_Sub.fieldbyname('Price1').AsFloat;
FieldByName('Price2').Value := CDS_Sub.fieldbyname('Price2').AsFloat;
FieldByName('Price3').Value := CDS_Sub.fieldbyname('Price3').AsFloat;
FieldByName('Price4').Value := CDS_Sub.fieldbyname('Price4').AsFloat;
FieldByName('Price5').Value := CDS_Sub.fieldbyname('Price5').AsFloat;
FieldByName('Price6').Value := CDS_Sub.fieldbyname('Price6').AsFloat;
FieldByName('Price7').Value := CDS_Sub.fieldbyname('Price7').AsFloat;
Post;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select count(*) as AA from CP_YDang where CYNo=''' + Trim(CDS_Sub.fieldbyname('CYNo').AsString) + '''');
Open;
if FieldByName('AA').AsInteger > 1 then
begin
ADOQueryCmd.Connection.RollbackTrans;
Result := False;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
with CDS_Sub do
begin
Edit;
FieldByName('CYID').Value := Trim(maxId);
FieldByName('CYType').Value := Trim(FCPID);
Post;
end;
Result := True;
except
Result := True;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
end;
end;
procedure TfrmCPAddWJE.ToolButton1Click(Sender: TObject);
begin
if CDS_Sub.Locate('CYNo', null, []) = True then
begin
Application.MessageBox('<27><>Ʒ<EFBFBD><C6B7><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
{if CDS_Sub.Locate('CYName',null,[])=True then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
Exit;
end; }
ToolBar1.SetFocus;
if SaveData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ', 0);
ModalResult := 1;
end;
end;
procedure TfrmCPAddWJE.v1Column7PropertiesEditValueChanged(Sender: TObject);
var
mvalue, FieldName, PriceKg, MF, KZ: string;
FReal: Double;
begin
mvalue := Trim(TcxTextEdit(Sender).EditingText);
with CDS_Sub do
begin
Edit;
if TryStrToFloat(mvalue, FReal) = False then
FieldByName('CYMF').Value := mvalue
else
begin
if Trim(canshu1) = <><D3A2>' then
FieldByName('CYMF').Value := mvalue + '"'
else
FieldByName('CYMF').Value := mvalue + 'CM';
end;
Post;
end;
FieldName := Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
PriceKg := Trim(CDS_Sub.fieldbyname('CYPriceKg').AsString);
if Trim(PriceKg) = '' then
begin
PriceKg := '0';
end;
MF := Trim(CDS_Sub.fieldbyname('CYMF').AsString);
KZ := Trim(CDS_Sub.fieldbyname('CYKZ').AsString);
if Trim(canshu1) <> <><D3A2>' then
MF := Copy(MF, 1, Pos('C', MF) - 1)
else
MF := Copy(MF, 1, Pos('"', MF) - 1);
KZ := Copy(KZ, 1, Pos('g', KZ) - 1);
if TryStrToFloat(MF, FReal) = False then
begin
MF := '0';
end;
if TryStrToFloat(KZ, FReal) = False then
begin
KZ := '0';
end;
with CDS_Sub do
begin
Edit;
if Trim(canshu1) <> <><D3A2>' then
FieldByName('CYPriceM').Value := StrToFloat(PriceKg) * StrToFloat(MF) * StrToFloat(KZ) * 1.00 / 100000
else
FieldByName('CYPriceM').Value := StrToFloat(PriceKg) * StrToFloat(MF) * 2.54 * StrToFloat(KZ) * 1.00 / 100000;
Post;
end;
end;
procedure TfrmCPAddWJE.v1Column8PropertiesEditValueChanged(Sender: TObject);
var
mvalue, FieldName, PriceKg, MF, KZ: string;
FReal: Double;
begin
mvalue := Trim(TcxTextEdit(Sender).EditingText);
with CDS_Sub do
begin
Edit;
if TryStrToFloat(mvalue, FReal) = False then
FieldByName('CYKZ').Value := mvalue
else
FieldByName('CYKZ').Value := mvalue + 'g/<2F>O';
Post;
end;
FieldName := Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
PriceKg := Trim(CDS_Sub.fieldbyname('CYPriceKg').AsString);
if Trim(PriceKg) = '' then
begin
PriceKg := '0';
end;
MF := Trim(CDS_Sub.fieldbyname('CYMF').AsString);
KZ := Trim(CDS_Sub.fieldbyname('CYKZ').AsString);
if Trim(canshu1) <> <><D3A2>' then
MF := Copy(MF, 1, Pos('C', MF) - 1)
else
MF := Copy(MF, 1, Pos('"', MF) - 1);
KZ := Copy(KZ, 1, Pos('g', KZ) - 1);
if TryStrToFloat(MF, FReal) = False then
begin
MF := '0';
end;
if TryStrToFloat(KZ, FReal) = False then
begin
KZ := '0';
end;
with CDS_Sub do
begin
Edit;
if Trim(canshu1) <> <><D3A2>' then
FieldByName('CYPriceM').Value := StrToFloat(PriceKg) * StrToFloat(MF) * StrToFloat(KZ) * 1.00 / 100000
else
FieldByName('CYPriceM').Value := StrToFloat(PriceKg) * StrToFloat(MF) * 2.54 * StrToFloat(KZ) * 1.00 / 100000;
Post;
end;
end;
procedure TfrmCPAddWJE.v1Column2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := 'YPName';
flagname := '<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>';
if ShowModal = 1 then
begin
with CDS_Sub do
begin
Edit;
FieldByName('CYName').Value := Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmCPAddWJE.v1Column26PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
var
fsj: string;
begin
fsj := Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := 'GYStr';
flagname := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
if ShowModal = 1 then
begin
with CDS_Sub do
begin
Edit;
FieldByName(fsj).Value := Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmCPAddWJE.v1Column27PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
var
fsj: string;
begin
fsj := Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := 'YPJGFactory';
flagname := '<27>ӹ<EFBFBD><D3B9><EFBFBD>';
if ShowModal = 1 then
begin
with CDS_Sub do
begin
Edit;
FieldByName(fsj).Value := Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmCPAddWJE.v1Column20PropertiesEditValueChanged(Sender: TObject);
var
FieldName, mvalue, MF, KZ, PriceKg: string;
FReal: Double;
begin
mvalue := TcxTextEdit(Sender).EditingText;
FieldName := Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
with CDS_Sub do
begin
Edit;
FieldByName(FieldName).Value := mvalue;
Post;
end;
PriceKg := Trim(CDS_Sub.fieldbyname('CYPriceKg').AsString);
if Trim(PriceKg) = '' then
begin
PriceKg := '0';
end;
MF := Trim(CDS_Sub.fieldbyname('CYMF').AsString);
KZ := Trim(CDS_Sub.fieldbyname('CYKZ').AsString);
if Trim(canshu1) <> <><D3A2>' then
MF := Copy(MF, 1, Pos('C', MF) - 1)
else
MF := Copy(MF, 1, Pos('"', MF) - 1);
KZ := Copy(KZ, 1, Pos('g', KZ) - 1);
if TryStrToFloat(MF, FReal) = False then
begin
MF := '0';
end;
if TryStrToFloat(KZ, FReal) = False then
begin
KZ := '0';
end;
with CDS_Sub do
begin
Edit;
if Trim(canshu1) <> <><D3A2>' then
FieldByName('CYPriceM').Value := StrToFloat(PriceKg) * StrToFloat(MF) * StrToFloat(KZ) * 1.00 / 100000
else
FieldByName('CYPriceM').Value := StrToFloat(PriceKg) * StrToFloat(MF) * 2.54 * StrToFloat(KZ) * 1.00 / 100000;
Post;
end;
end;
procedure TfrmCPAddWJE.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked = True then
begin
canshu1 := <><D3A2>';
end
else
begin
canshu1 := '';
end;
end;
procedure TfrmCPAddWJE.v1Column23PropertiesEditValueChanged(Sender: TObject);
var
Fieldname: string;
fPrice6: double;
begin
Fieldname := Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
with CDS_Sub do
begin
edit;
fieldbyname(Fieldname).Value := TcxTextEdit(Sender).EditingText;
fPrice6 := 0;
if 1 - fieldbyname('Price1').AsFloat > 0 then
begin
fPrice6 := fieldbyname('Price2').AsFloat / (1 - fieldbyname('Price1').AsFloat);
fPrice6 := fPrice6 + fieldbyname('Price3').AsFloat + fieldbyname('Price4').AsFloat + fieldbyname('Price5').AsFloat;
end;
FieldByName('Price6').Value := strtofloat(format('%.1f', [fPrice6]));
FieldByName('Price7').Value := strtofloat(format('%.1f', [fieldbyname('Price6').AsFloat / 0.8]));
post;
end;
Tv1.Controller.EditingController.ShowEdit();
end;
end.