836 lines
23 KiB
ObjectPascal
836 lines
23 KiB
ObjectPascal
![]() |
unit U_ZdyAttachmentBJ_Edit;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, ExtCtrls, cxPC, cxControls, ComCtrls, ToolWin, StdCtrls, Menus,
|
|||
|
cxTextEdit, cxCurrencyEdit, BtnEdit, cxContainer, cxEdit, cxImage, DB, ADODB,
|
|||
|
cxDBEdit, cxLookAndFeelPainters, cxButtons, IdBaseComponent, IdComponent,
|
|||
|
IdTCPConnection, IdTCPClient, IdFTP, ShellAPI, cxStyles, cxCustomData,
|
|||
|
cxGraphics, cxFilter, cxData, cxDataStorage, cxDBData, cxGridLevel, cxClasses,
|
|||
|
cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
|||
|
cxGrid, DBClient, cxButtonEdit, cxGridCustomPopupMenu, cxGridPopupMenu,
|
|||
|
cxDropDownEdit, cxMaskEdit;
|
|||
|
|
|||
|
type
|
|||
|
TfrmZdyAttachmentBJ_Edit = class(TForm)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
Tsave: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
Panel1: TPanel;
|
|||
|
GroupBox1: TGroupBox;
|
|||
|
Label1: TLabel;
|
|||
|
Label6: TLabel;
|
|||
|
custName: TEdit;
|
|||
|
Label17: TLabel;
|
|||
|
PopupMenu1: TPopupMenu;
|
|||
|
N1: TMenuItem;
|
|||
|
N2: TMenuItem;
|
|||
|
N3: TMenuItem;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryTmp: TADOQuery;
|
|||
|
ADOQuerymain: TADOQuery;
|
|||
|
Label4: TLabel;
|
|||
|
Label7: TLabel;
|
|||
|
Panel2: TPanel;
|
|||
|
Panel3: TPanel;
|
|||
|
CDS1: TClientDataSet;
|
|||
|
Label9: TLabel;
|
|||
|
DS1: TDataSource;
|
|||
|
CRTime: TDateTimePicker;
|
|||
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|||
|
note: TMemo;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
TV1: TcxGridDBTableView;
|
|||
|
V1Column1: TcxGridDBColumn;
|
|||
|
V1Column3: TcxGridDBColumn;
|
|||
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
Panel4: TPanel;
|
|||
|
Panel5: TPanel;
|
|||
|
ToolBar2: TToolBar;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
ToolButton2: TToolButton;
|
|||
|
CYNO: TEdit;
|
|||
|
Label15: TLabel;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
TV2: TcxGridDBTableView;
|
|||
|
cxGridLevel1: TcxGridLevel;
|
|||
|
V2Column1: TcxGridDBColumn;
|
|||
|
V2Column2: TcxGridDBColumn;
|
|||
|
V2Column3: TcxGridDBColumn;
|
|||
|
V2Column4: TcxGridDBColumn;
|
|||
|
V2Column5: TcxGridDBColumn;
|
|||
|
CDS_HP: TClientDataSet;
|
|||
|
DS_HP: TDataSource;
|
|||
|
V2Column6: TcxGridDBColumn;
|
|||
|
cxGridPopupMenu2: TcxGridPopupMenu;
|
|||
|
cV1Column5: TcxGridDBColumn;
|
|||
|
cV1Column6: TcxGridDBColumn;
|
|||
|
cV1Column7: TcxGridDBColumn;
|
|||
|
cV1Column8: TcxGridDBColumn;
|
|||
|
lbl1: TLabel;
|
|||
|
yxdate: TDateTimePicker;
|
|||
|
lbl3: TLabel;
|
|||
|
lbl4: TLabel;
|
|||
|
lbl5: TLabel;
|
|||
|
lbl6: TLabel;
|
|||
|
lbl7: TLabel;
|
|||
|
khxz: TEdit;
|
|||
|
lbl8: TLabel;
|
|||
|
lbl9: TLabel;
|
|||
|
lianxiren: TEdit;
|
|||
|
lbl10: TLabel;
|
|||
|
lbl11: TLabel;
|
|||
|
cypp: TEdit;
|
|||
|
lbl12: TLabel;
|
|||
|
lbl13: TLabel;
|
|||
|
yjsl: TEdit;
|
|||
|
lbl14: TLabel;
|
|||
|
lbl15: TLabel;
|
|||
|
swfp: TEdit;
|
|||
|
lbl16: TLabel;
|
|||
|
lbl17: TLabel;
|
|||
|
xddate: TDateTimePicker;
|
|||
|
lbl18: TLabel;
|
|||
|
lbl19: TLabel;
|
|||
|
glsj: TEdit;
|
|||
|
lbl20: TLabel;
|
|||
|
toplace: TEdit;
|
|||
|
lbl21: TLabel;
|
|||
|
custNo: TBtnEditA;
|
|||
|
cV1Column2: TcxGridDBColumn;
|
|||
|
cV1Column4: TcxGridDBColumn;
|
|||
|
cV1Column9: TcxGridDBColumn;
|
|||
|
cV1Column10: TcxGridDBColumn;
|
|||
|
cV1Column11: TcxGridDBColumn;
|
|||
|
ywy: TEdit;
|
|||
|
V1Column2: TcxGridDBColumn;
|
|||
|
V1Column4: TcxGridDBColumn;
|
|||
|
bjtype: TBtnEditA;
|
|||
|
Priceunit: TBtnEditA;
|
|||
|
bjjttype: TBtnEditA;
|
|||
|
jyxz: TBtnEditA;
|
|||
|
zlbz: TBtnEditA;
|
|||
|
ysfs: TBtnEditA;
|
|||
|
payment: TBtnEditA;
|
|||
|
ToolButton3: TToolButton;
|
|||
|
cxGrid4: TcxGrid;
|
|||
|
TV4: TcxGridDBTableView;
|
|||
|
V4Column3: TcxGridDBColumn;
|
|||
|
V4Column2: TcxGridDBColumn;
|
|||
|
V4Column4: TcxGridDBColumn;
|
|||
|
cxGrid4Level1: TcxGridLevel;
|
|||
|
DS_YPXZ: TDataSource;
|
|||
|
CDS_YPXZ: TClientDataSet;
|
|||
|
V4Column1: TcxGridDBColumn;
|
|||
|
V4Column5: TcxGridDBColumn;
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure TsaveClick(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure MTypeBtnDnClick(Sender: TObject);
|
|||
|
procedure ToolButton2Click(Sender: TObject);
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
procedure custNoBtnClick(Sender: TObject);
|
|||
|
procedure PriceunitChange(Sender: TObject);
|
|||
|
procedure V1Column8PropertiesEditValueChanged(Sender: TObject);
|
|||
|
procedure huilvPropertiesEditValueChanged(Sender: TObject);
|
|||
|
procedure custCountryBtnClick(Sender: TObject);
|
|||
|
procedure CYNOKeyPress(Sender: TObject; var Key: Char);
|
|||
|
procedure TV1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
|||
|
procedure bjtypeBtnClick(Sender: TObject);
|
|||
|
procedure PriceunitBtnClick(Sender: TObject);
|
|||
|
procedure bjjttypeBtnClick(Sender: TObject);
|
|||
|
procedure jyxzBtnClick(Sender: TObject);
|
|||
|
procedure zlbzBtnClick(Sender: TObject);
|
|||
|
procedure ysfsBtnClick(Sender: TObject);
|
|||
|
procedure paymentBtnClick(Sender: TObject);
|
|||
|
procedure ToolButton3Click(Sender: TObject);
|
|||
|
procedure custNameKeyPress(Sender: TObject; var Key: Char);
|
|||
|
procedure TV4KeyPress(Sender: TObject; var Key: Char);
|
|||
|
procedure TV4DblClick(Sender: TObject);
|
|||
|
private
|
|||
|
function savedata(): Boolean;
|
|||
|
procedure GetYP();
|
|||
|
procedure InitGrid();
|
|||
|
procedure InitImage();
|
|||
|
procedure InitHistoryPrice(FCode: string);
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
fkeyNo: string;
|
|||
|
FType: integer;
|
|||
|
canshu1: string;
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmZdyAttachmentBJ_Edit: TfrmZdyAttachmentBJ_Edit;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_Fun10, U_ZDYHelp, U_CPManageFMSel, U_ZdyAttachment, U_CPManage;
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.GetYP();
|
|||
|
begin
|
|||
|
if cds1.Locate('P_Code;P_COLOR', VarArrayOf([trim(CDS_YPXZ.fieldbyname('CYNo').AsString), trim(CDS_YPXZ.fieldbyname('CYColor').AsString)]), []) then
|
|||
|
begin
|
|||
|
if Application.MessageBox('<27>Ѵ<EFBFBD><D1B4>ڸ<EFBFBD><DAB8><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
|
|||
|
cds1.append;
|
|||
|
cds1.FieldByName('P_Code').Value := trim(CDS_YPXZ.fieldbyname('CYNo').AsString);
|
|||
|
cds1.FieldByName('P_CodeName').Value := trim(CDS_YPXZ.fieldbyname('CYName').AsString);
|
|||
|
cds1.FieldByName('P_CodeNameE').Value := trim(CDS_YPXZ.fieldbyname('CYEName').AsString);
|
|||
|
cds1.FieldByName('P_spec').Value := trim(CDS_YPXZ.fieldbyname('CYSpec').AsString);
|
|||
|
cds1.FieldByName('P_cf').Value := trim(CDS_YPXZ.fieldbyname('CYCF').AsString);
|
|||
|
cds1.FieldByName('P_MF').Value := trim(CDS_YPXZ.fieldbyname('CYMF').AsString);
|
|||
|
cds1.FieldByName('P_KZ').Value := trim(CDS_YPXZ.fieldbyname('CYKZ').AsString);
|
|||
|
cds1.FieldByName('MiDu').Value := trim(CDS_YPXZ.fieldbyname('MiDu').AsString);
|
|||
|
cds1.FieldByName('P_color').Value := trim(CDS_YPXZ.fieldbyname('CYColor').AsString);
|
|||
|
cds1.FieldByName('DLYDATE').Value := now;
|
|||
|
cds1.Post;
|
|||
|
|
|||
|
cxGrid4.Visible := False;
|
|||
|
|
|||
|
InitHistoryPrice(trim(CDS_YPXZ.fieldbyname('CYNo').AsString));
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.InitHistoryPrice(FCode: string);
|
|||
|
begin
|
|||
|
with ADOQueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select top 5 A.* from KH_CP_BJ A');
|
|||
|
sql.Add('where P_Code=' + quotedstr(trim(FCode)));
|
|||
|
if canshu1 <> '<27><><EFBFBD><EFBFBD>' then
|
|||
|
begin
|
|||
|
sql.Add(' and custName in (select Y.CoName from TbForBatch X inner join Company Y on X.Value1=Y.Dept');
|
|||
|
sql.Add('where X.MainType=''<27><><EFBFBD>Ų<EFBFBD>ѯ'' and X.DName=' + quotedstr(trim(DName)) + ') ');
|
|||
|
end;
|
|||
|
sql.Add('order by CRTime desc ');
|
|||
|
open;
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOQueryTmp, CDS_HP);
|
|||
|
SInitCDSData20(ADOQueryTmp, CDS_HP);
|
|||
|
end;
|
|||
|
|
|||
|
function TfrmZdyAttachmentBJ_Edit.savedata(): Boolean;
|
|||
|
var
|
|||
|
Filler: string;
|
|||
|
FillTime: TdateTime;
|
|||
|
begin
|
|||
|
result := false;
|
|||
|
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
try
|
|||
|
if FType = 0 then
|
|||
|
begin
|
|||
|
if GetLSNo(ADOQueryTmp, fkeyNo, '', 'KH_CP_BJ', 4, 1) = False then
|
|||
|
begin
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
Filler := DName;
|
|||
|
FillTime := SGetServerDateTime(adoqueryTmp);
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
with ADOQueryTmp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('select * from KH_CP_BJ where BJNO=''' + Trim(fkeyNo) + '''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
Filler := adoqueryTmp.fieldbyname('Filler').AsString;
|
|||
|
FillTime := adoqueryTmp.fieldbyname('FillTime').AsDateTime;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('delete from KH_CP_BJ where BJNO=''' + Trim(fkeyNo) + '''');
|
|||
|
execsql;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('select * from KH_CP_BJ where BJNO=''' + Trim(fkeyNo) + '''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
with cds1 do
|
|||
|
begin
|
|||
|
DisableControls;
|
|||
|
First;
|
|||
|
while not eof do
|
|||
|
begin
|
|||
|
ADOQueryCmd.Append;
|
|||
|
SSetsaveSqlNew(ADOQueryCmd, 'KH_CP_BJ', GroupBox1, 2);
|
|||
|
RTSetSaveDataCDS(ADOQueryCmd, Tv1, cds1, 'KH_CP_BJ', 0);
|
|||
|
ADOQueryCmd.FieldByName('BJNO').Value := trim(fkeyNO);
|
|||
|
ADOQueryCmd.FieldByName('BJID').Value := recNo;
|
|||
|
ADOQueryCmd.FieldByName('Filler').Value := Trim(Filler);
|
|||
|
ADOQueryCmd.FieldByName('FillTime').Value := FillTime;
|
|||
|
ADOQueryCmd.FieldByName('CRTime').Value := formatdateTime('yyyy-MM-dd', CRTime.DateTime);
|
|||
|
// ADOQueryCmd.FieldByName('DlyDate').Value := formatdateTime('yyyy-MM-dd', DlyDate.DateTime);
|
|||
|
ADOQueryCmd.FieldByName('FillTime').Value := FillTime;
|
|||
|
ADOQueryCmd.FieldByName('FillTime').Value := FillTime;
|
|||
|
ADOQueryCmd.FieldByName('price').Value := cds1.fieldbyname('price').AsFloat;
|
|||
|
ADOQueryCmd.FieldByName('price1').Value := cds1.fieldbyname('price1').AsFloat;
|
|||
|
ADOQueryCmd.FieldByName('BJQty1').Value := cds1.fieldbyname('BJQty1').AsFloat;
|
|||
|
if FType = 1 then
|
|||
|
begin
|
|||
|
ADOQueryCmd.FieldByName('editer').Value := trim(dName);
|
|||
|
ADOQueryCmd.FieldByName('editTime').Value := SGetServerDateTime(adoqueryTmp);
|
|||
|
end;
|
|||
|
ADOQueryCmd.Post;
|
|||
|
next;
|
|||
|
end;
|
|||
|
EnableControls;
|
|||
|
end;
|
|||
|
|
|||
|
result := true;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
except
|
|||
|
result := False;
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.InitGrid();
|
|||
|
begin
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select A.* from KH_CP_BJ A');
|
|||
|
sql.Add('where BJNO=' + quotedstr(trim(fkeyNo)));
|
|||
|
open;
|
|||
|
end;
|
|||
|
if not ADOQueryMain.IsEmpty then
|
|||
|
begin
|
|||
|
SCSHDataNew(ADOQueryMain, GroupBox1, 2);
|
|||
|
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOQueryMain, CDS1);
|
|||
|
SInitCDSData20(ADOQueryMain, CDS1);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.InitImage();
|
|||
|
begin
|
|||
|
{ with ADOQueryImage do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from TP_File A');
|
|||
|
sql.Add('where TFid='+quotedstr(trim(zdyCode.Text)));
|
|||
|
open;
|
|||
|
end; }
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
frmZdyAttachmentBJ_Edit := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid(self.Caption + '1', Tv1);
|
|||
|
WriteCxGrid(self.Caption + '2', Tv2);
|
|||
|
close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
Panel1.Align := alclient;
|
|||
|
clearControl(GroupBox1, 2);
|
|||
|
// huilv.Text := '1';
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.TsaveClick(Sender: TObject);
|
|||
|
begin
|
|||
|
// zdyName.SetFocus;
|
|||
|
cxgrid1.SetFocus;
|
|||
|
if cds1.IsEmpty then
|
|||
|
exit;
|
|||
|
if trim(custNo.Text) = '' then
|
|||
|
begin
|
|||
|
application.MessageBox('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
if trim(custNo.Text) = '' then
|
|||
|
begin
|
|||
|
application.MessageBox('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
|
|||
|
try
|
|||
|
if not savedata() then
|
|||
|
begin
|
|||
|
application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
|||
|
self.ModalResult := 1;
|
|||
|
end;
|
|||
|
|
|||
|
except
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
readCxGrid(self.Caption + '1', Tv1);
|
|||
|
readCxGrid(self.Caption + '2', Tv2);
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.MTypeBtnDnClick(Sender: TObject);
|
|||
|
begin
|
|||
|
TBtnEditC(Sender).Text := '';
|
|||
|
TBtnEditC(Sender).TxtCode := '';
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.ToolButton2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS1.IsEmpty then
|
|||
|
exit;
|
|||
|
CDS1.Delete;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.ToolButton1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
frmCPManage := TfrmCPManage.create(self);
|
|||
|
with frmCPManage do
|
|||
|
begin
|
|||
|
if showmodal = 1 then
|
|||
|
begin
|
|||
|
cds_main.DisableControls;
|
|||
|
cds_main.first;
|
|||
|
while not cds_main.Eof do
|
|||
|
begin
|
|||
|
if cds_main.FieldByName('ssel').AsBoolean then
|
|||
|
begin
|
|||
|
cds1.append;
|
|||
|
|
|||
|
cds1.FieldByName('P_Code').Value := trim(cds_main.fieldbyname('CYNo').AsString);
|
|||
|
cds1.FieldByName('P_CodeName').Value := trim(cds_main.fieldbyname('CYName').AsString);
|
|||
|
cds1.FieldByName('P_CodeNameE').Value := trim(cds_main.fieldbyname('CYEName').AsString);
|
|||
|
cds1.FieldByName('P_spec').Value := trim(cds_main.fieldbyname('CYSpec').AsString);
|
|||
|
cds1.FieldByName('P_cf').Value := trim(cds_main.fieldbyname('CYCF').AsString);
|
|||
|
cds1.FieldByName('P_MF').Value := trim(cds_main.fieldbyname('CYMF').AsString);
|
|||
|
cds1.FieldByName('P_KZ').Value := trim(cds_main.fieldbyname('CYKZ').AsString);
|
|||
|
cds1.FieldByName('P_color').Value := trim(cds_main.fieldbyname('CYColor').AsString);
|
|||
|
cds1.FieldByName('MiDu').Value := trim(cds_main.fieldbyname('MiDu').AsString);
|
|||
|
cds1.FieldByName('Price').Value := 0;
|
|||
|
cds1.FieldByName('DLYDATE').Value := now;
|
|||
|
cds1.Post;
|
|||
|
end;
|
|||
|
cds_main.next;
|
|||
|
end;
|
|||
|
cds_main.EnableControls;
|
|||
|
end;
|
|||
|
free;
|
|||
|
end;
|
|||
|
tv1.Controller.EditingController.ShowEdit();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.custNoBtnClick(Sender: TObject);
|
|||
|
begin
|
|||
|
frmZdyAttachment := TfrmZdyAttachment.create(self);
|
|||
|
with frmZdyAttachment do
|
|||
|
begin
|
|||
|
if Self.canshu1 = '¼<><C2BC>' then
|
|||
|
canshu1 := 'ҵ<><D2B5>Ա';
|
|||
|
|
|||
|
if showmodal = 1 then
|
|||
|
begin
|
|||
|
custNo.Text := trim(cds_hz.fieldbyname('COCode').AsString);
|
|||
|
custName.Text := trim(cds_hz.fieldbyname('COName').AsString);
|
|||
|
lianxiren.Text := trim(cds_hz.fieldbyname('Contacts').AsString);
|
|||
|
ywy.Text := trim(cds_hz.fieldbyname('Salesman').AsString);
|
|||
|
end;
|
|||
|
free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.PriceunitChange(Sender: TObject);
|
|||
|
begin
|
|||
|
// if trim(huilv.Text) = '' then
|
|||
|
// begin
|
|||
|
// huilv.Text := '1';
|
|||
|
// end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.V1Column8PropertiesEditValueChanged(Sender: TObject);
|
|||
|
var
|
|||
|
mvalue, FFieldName: string;
|
|||
|
begin
|
|||
|
{ mvalue:=TcxTextEdit(Sender).EditingText;
|
|||
|
if Trim(mvalue)='' then
|
|||
|
begin
|
|||
|
mvalue:='0';
|
|||
|
end;
|
|||
|
FFieldName:=Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
|
|||
|
with CDS1 do
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
FieldByName(FFieldName).Value:=Trim(mvalue);
|
|||
|
FieldByName('Price').Value:=format('%.2f',[fieldbyname('Price1').AsFloat * strtofloatdef(trim(huilv.Text),1)]);
|
|||
|
Post;
|
|||
|
end;
|
|||
|
tv1.Controller.EditingController.ShowEdit();}
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.huilvPropertiesEditValueChanged(Sender: TObject);
|
|||
|
var
|
|||
|
mvalue, FFieldName: string;
|
|||
|
begin
|
|||
|
mvalue := TcxCurrencyEdit(Sender).EditingText;
|
|||
|
if Trim(mvalue) = '' then
|
|||
|
begin
|
|||
|
mvalue := '1';
|
|||
|
end;
|
|||
|
// huilv.Text := mvalue;
|
|||
|
if not cds1.Active then
|
|||
|
exit;
|
|||
|
if cds1.IsEmpty then
|
|||
|
exit;
|
|||
|
with cds1 do
|
|||
|
begin
|
|||
|
DisableControls;
|
|||
|
first;
|
|||
|
while not eof do
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
// FieldByName('Price').Value := format('%.2f', [fieldbyname('Price1').AsFloat * strtofloatdef(trim(huilv.Text), 1)]);
|
|||
|
Post;
|
|||
|
next;
|
|||
|
end;
|
|||
|
EnableControls;
|
|||
|
end;
|
|||
|
tv1.Controller.EditingController.ShowEdit();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.custCountryBtnClick(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
|||
|
with frmZDYHelp do
|
|||
|
begin
|
|||
|
flag := 'custCountry';
|
|||
|
flagname := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
// custCountry.Text := Trim(ClientDataSet1.fieldbyname('zdyName').AsString);
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmZDYHelp.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.CYNOKeyPress(Sender: TObject; var Key: Char);
|
|||
|
begin
|
|||
|
if Key = #13 then
|
|||
|
begin
|
|||
|
if Length(Trim(CYNO.Text)) < 4 then
|
|||
|
Exit;
|
|||
|
with ADOQueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from CP_YDang where CYID=' + quotedstr(trim(CYNO.Text)));
|
|||
|
sql.Add('or CYNO like' + quotedstr('%' + trim(CYNO.Text) + '%'));
|
|||
|
open;
|
|||
|
end;
|
|||
|
if ADOQueryTmp.IsEmpty then
|
|||
|
begin
|
|||
|
application.MessageBox('<27>˱<EFBFBD><CBB1>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
|||
|
CYNO.Text := '';
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
if ADOQueryTmp.RecordCount = 1 then
|
|||
|
begin
|
|||
|
|
|||
|
if cds1.Locate('P_Code;P_COLOR', VarArrayOf([trim(ADOQueryTmp.fieldbyname('CYNo').AsString), trim(ADOQueryTmp.fieldbyname('CYColor').AsString)]), []) then
|
|||
|
begin
|
|||
|
if Application.MessageBox('<27>Ѵ<EFBFBD><D1B4>ڸ<EFBFBD><DAB8><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
|
|||
|
cds1.append;
|
|||
|
cds1.FieldByName('P_Code').Value := trim(ADOQueryTmp.fieldbyname('CYNo').AsString);
|
|||
|
cds1.FieldByName('P_CodeName').Value := trim(ADOQueryTmp.fieldbyname('CYName').AsString);
|
|||
|
cds1.FieldByName('P_CodeNameE').Value := trim(ADOQueryTmp.fieldbyname('CYEName').AsString);
|
|||
|
cds1.FieldByName('P_spec').Value := trim(ADOQueryTmp.fieldbyname('CYSpec').AsString);
|
|||
|
cds1.FieldByName('P_cf').Value := trim(ADOQueryTmp.fieldbyname('CYCF').AsString);
|
|||
|
cds1.FieldByName('P_MF').Value := trim(ADOQueryTmp.fieldbyname('CYMF').AsString);
|
|||
|
cds1.FieldByName('P_KZ').Value := trim(ADOQueryTmp.fieldbyname('CYKZ').AsString);
|
|||
|
cds1.FieldByName('MiDu').Value := trim(ADOQueryTmp.fieldbyname('MiDu').AsString);
|
|||
|
cds1.FieldByName('P_color').Value := trim(ADOQueryTmp.fieldbyname('CYColor').AsString);
|
|||
|
cds1.FieldByName('DLYDATE').Value := now;
|
|||
|
cds1.Post;
|
|||
|
InitHistoryPrice(trim(ADOQueryTmp.fieldbyname('CYNo').AsString));
|
|||
|
CYNO.Text := '';
|
|||
|
end;
|
|||
|
if ADOQueryTmp.RecordCount > 1 then
|
|||
|
begin
|
|||
|
SCreateCDS20(ADOQueryTmp, CDS_YPXZ);
|
|||
|
SInitCDSData20(ADOQueryTmp, CDS_YPXZ);
|
|||
|
cxGrid4.Visible := True;
|
|||
|
cxGrid4.SetFocus;
|
|||
|
CYNO.Text := '';
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.TV1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
|||
|
begin
|
|||
|
InitHistoryPrice(trim(cds1.fieldbyname('P_Code').AsString));
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.bjtypeBtnClick(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
|||
|
with frmZDYHelp do
|
|||
|
begin
|
|||
|
flag := 'bjtype';
|
|||
|
flagname := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
bjtype.Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmZDYHelp.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.PriceunitBtnClick(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
|||
|
with frmZDYHelp do
|
|||
|
begin
|
|||
|
flag := 'Priceunit';
|
|||
|
flagname := '<27><><EFBFBD><EFBFBD>';
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
Priceunit.Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmZDYHelp.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.bjjttypeBtnClick(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
|||
|
with frmZDYHelp do
|
|||
|
begin
|
|||
|
flag := 'bjjttype';
|
|||
|
flagname := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
bjjttype.Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmZDYHelp.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.jyxzBtnClick(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
|||
|
with frmZDYHelp do
|
|||
|
begin
|
|||
|
flag := 'jyxz';
|
|||
|
flagname := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
jyxz.Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmZDYHelp.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.zlbzBtnClick(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
|||
|
with frmZDYHelp do
|
|||
|
begin
|
|||
|
flag := 'zlbz';
|
|||
|
flagname := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
zlbz.Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmZDYHelp.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.ysfsBtnClick(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
|||
|
with frmZDYHelp do
|
|||
|
begin
|
|||
|
flag := 'ysfs';
|
|||
|
flagname := '<27><><EFBFBD>ͷ<EFBFBD>ʽ';
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
ysfs.Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmZDYHelp.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.paymentBtnClick(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
|||
|
with frmZDYHelp do
|
|||
|
begin
|
|||
|
flag := 'payment';
|
|||
|
flagname := '<27><><EFBFBD>ʽ';
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
payment.Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmZDYHelp.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.ToolButton3Click(Sender: TObject);
|
|||
|
var
|
|||
|
FValue, FFValue, FColumn, FFColumn: string;
|
|||
|
begin
|
|||
|
ToolBar1.SetFocus;
|
|||
|
if CDS1.IsEmpty then
|
|||
|
Exit;
|
|||
|
if Application.MessageBox('ȷ<><C8B7>Ҫһ<D2AA><D2BB><EFBFBD>滻<EFBFBD><E6BBBB>', '<27><>ʾ', 1) = 2 then
|
|||
|
exit;
|
|||
|
FColumn := Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
|
|||
|
FFColumn := Tv1.Controller.FocusedColumn.Summary.GroupFormat;
|
|||
|
FValue := Trim(CDS1.fieldbyname(FColumn).AsString);
|
|||
|
if Trim(FFColumn) <> '' then
|
|||
|
begin
|
|||
|
FFValue := Trim(CDS1.fieldbyname(FFColumn).AsString);
|
|||
|
end;
|
|||
|
with CDS1 do
|
|||
|
begin
|
|||
|
DisableControls;
|
|||
|
First;
|
|||
|
while not Eof do
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
if FValue = '' then
|
|||
|
begin
|
|||
|
CDS1.FieldByName(FColumn).Value := null;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
CDS1.FieldByName(FColumn).Value := FValue;
|
|||
|
end;
|
|||
|
if Trim(FFColumn) <> '' then
|
|||
|
begin
|
|||
|
if FFValue = '' then
|
|||
|
begin
|
|||
|
CDS1.FieldByName(FFColumn).Value := null;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
CDS1.FieldByName(FFColumn).Value := FFValue;
|
|||
|
end;
|
|||
|
end;
|
|||
|
Post;
|
|||
|
Next;
|
|||
|
end;
|
|||
|
EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.custNameKeyPress(Sender: TObject; var Key: Char);
|
|||
|
begin
|
|||
|
if Key = #13 then
|
|||
|
begin
|
|||
|
with ADOQueryTmp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add(' exec P_Select_Dept ' + quotedstr(trim(DName)));
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
with ADOQueryTmp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add(' select * from Company A left join Company_contact B ');
|
|||
|
sql.Add(' on A.CoID=B.CoID and B.IsDefault=1 where A.CoType=''<27>ͻ<EFBFBD>'' and A.Valid=''Y'' ');
|
|||
|
if trim(canshu1) = '¼<><C2BC>' then
|
|||
|
sql.Add(' and isnull(Dept,''<27><><EFBFBD><EFBFBD>'') in (select X.Value1 from TbForBatch X where X.MainType=''<27><><EFBFBD>Ų<EFBFBD>ѯ'' and X.DName=' + quotedstr(trim(DName)) + ') ');
|
|||
|
sql.Add(' and A.COName like' + quotedstr('%' + Trim(custName.Text) + '%'));
|
|||
|
|
|||
|
// ShowMessage(SQL.Text);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
|
|||
|
if not ADOQueryTmp.IsEmpty then
|
|||
|
begin
|
|||
|
custNo.Text := trim(ADOQueryTmp.fieldbyname('COCode').AsString);
|
|||
|
custName.Text := trim(ADOQueryTmp.fieldbyname('COName').AsString);
|
|||
|
lianxiren.Text := trim(ADOQueryTmp.fieldbyname('Contacts').AsString);
|
|||
|
ywy.Text := trim(ADOQueryTmp.fieldbyname('Salesman').AsString);
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
application.MessageBox('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
|||
|
custName.Text := '';
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.TV4KeyPress(Sender: TObject; var Key: Char);
|
|||
|
begin
|
|||
|
if Key = #13 then
|
|||
|
begin
|
|||
|
GetYP();
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmZdyAttachmentBJ_Edit.TV4DblClick(Sender: TObject);
|
|||
|
begin
|
|||
|
GetYP();
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|