552 lines
13 KiB
ObjectPascal
552 lines
13 KiB
ObjectPascal
unit U_SKInput;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, ComCtrls, ToolWin, cxStyles, cxCustomData, cxGraphics, cxFilter,
|
||
cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxClasses,
|
||
cxControls, cxGridCustomView, cxGridCustomTableView, cxGridTableView,
|
||
cxGridDBTableView, cxGrid, cxGridCustomPopupMenu, cxGridPopupMenu, ADODB,
|
||
DBClient, ExtCtrls, StdCtrls, BtnEdit, cxButtonEdit, cxTextEdit,
|
||
cxDropDownEdit;
|
||
|
||
type
|
||
TfrmSKInput = class(TForm)
|
||
DataSource1: TDataSource;
|
||
YFSub: TClientDataSet;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
ToolBar1: TToolBar;
|
||
TSave: TToolButton;
|
||
TBClose: TToolButton;
|
||
ToolBar2: TToolBar;
|
||
TADD: TToolButton;
|
||
TDEl: TToolButton;
|
||
Panel1: TPanel;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1P_Spec: TcxGridDBColumn;
|
||
v1Qty: TcxGridDBColumn;
|
||
v1Price: TcxGridDBColumn;
|
||
v1QtyUnit: TcxGridDBColumn;
|
||
v1Money: TcxGridDBColumn;
|
||
v1note: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
Label1: TLabel;
|
||
YFID: TEdit;
|
||
Label2: TLabel;
|
||
Label3: TLabel;
|
||
CRTime: TDateTimePicker;
|
||
Note: TMemo;
|
||
PayMent: TBtnEditA;
|
||
FactoryName: TBtnEditA;
|
||
Label4: TLabel;
|
||
Label6: TLabel;
|
||
ADOQueryTmp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
Label8: TLabel;
|
||
SYRName: TBtnEditA;
|
||
Label9: TLabel;
|
||
Money: TEdit;
|
||
Label10: TLabel;
|
||
HuiLv: TEdit;
|
||
BZType: TComboBox;
|
||
Label11: TLabel;
|
||
Label12: TLabel;
|
||
BBMoney: TEdit;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
Label7: TLabel;
|
||
v1Column4: TcxGridDBColumn;
|
||
Label5: TLabel;
|
||
ishs: TComboBox;
|
||
YFName: TBtnEditA;
|
||
Label14: TLabel;
|
||
YFGSType: TComboBox;
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TSaveClick(Sender: TObject);
|
||
procedure FactoryNameBtnClick(Sender: TObject);
|
||
procedure PayMentBtnClick(Sender: TObject);
|
||
procedure v1P_SpecPropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure v1QtyUnitPropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure TADDClick(Sender: TObject);
|
||
procedure TDElClick(Sender: TObject);
|
||
procedure v1QtyPropertiesEditValueChanged(Sender: TObject);
|
||
procedure SYRNameBtnClick(Sender: TObject);
|
||
procedure v1Column3PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure HuiLvKeyPress(Sender: TObject; var Key: Char);
|
||
procedure Panel1Click(Sender: TObject);
|
||
procedure HuiLvExit(Sender: TObject);
|
||
procedure v1MoneyPropertiesEditValueChanged(Sender: TObject);
|
||
procedure YFNameBtnClick(Sender: TObject);
|
||
private
|
||
procedure initGrid();
|
||
procedure SaveDate();
|
||
procedure HJJE();
|
||
{ Private declarations }
|
||
public
|
||
FYFID: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmSKInput: TfrmSKInput;
|
||
|
||
implementation
|
||
|
||
uses U_Fun10,U_ZDYHelp, U_ZdyAttachment,U_dataLink, U_ZdyAttachGYS,
|
||
U_CPManageSel;
|
||
{$R *.dfm}
|
||
procedure TfrmSKInput.HJJE();
|
||
var
|
||
FMoney,FHuiLv,FBBMoney:double;
|
||
begin
|
||
if TV1.DataController.Summary.FooterSummaryValues[1]<>NULL then
|
||
FMoney:=TV1.DataController.Summary.FooterSummaryValues[1]
|
||
else
|
||
FMoney:=0;
|
||
|
||
FHuiLv:=strtofloat(HuiLv.Text);
|
||
if FHuiLv=0 then FHuiLv:=1;
|
||
FBBMoney:= FHuiLv*FMoney;
|
||
Money.Text:=floattostr(FMoney);
|
||
HuiLv.Text:=floattostr(FHuiLv);
|
||
BBMoney.Text:=floattostr(FBBMoney);
|
||
end;
|
||
|
||
procedure TfrmSKInput.SaveDate();
|
||
var
|
||
MaxYFSID,MaxYFID:string;
|
||
begin
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
try
|
||
if trim(FYFID)='' then
|
||
begin
|
||
if GetLSNo(ADOQueryTmp,MaxYFID,'SK','YF_Money_CR_Sub',4,1)=False then
|
||
begin
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
YFID.Text:=MaxYFID;
|
||
end
|
||
else
|
||
begin
|
||
MaxYFID:=trim(FYFID);
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.add('select * from YF_Money_CR where YFID='+quotedstr(FYFID));
|
||
open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
if trim(FYFID)='' then
|
||
begin
|
||
append;
|
||
Fieldbyname('YFID').value:=trim(MaxYFID);
|
||
FieldByName('CRType').Value:='<27>տ<EFBFBD><D5BF>Ǽ<EFBFBD>';
|
||
FieldByName('CRFlag').Value:='Ӧ<><D3A6><EFBFBD><EFBFBD>';
|
||
FieldByName('QtyFlag').Value:=-1;
|
||
FieldByName('status').Value:='0';
|
||
FieldByName('Filler').Value:=Trim(DName);
|
||
end
|
||
else
|
||
begin
|
||
edit;
|
||
FieldByName('Editer').Value:=Trim(DName);
|
||
FieldByName('EditTime').Value:=SGetServerDateTime(ADOQueryTmp);
|
||
end;
|
||
|
||
SSetsaveSqlnew(ADOQueryCmd,'YF_Money_CR',panel1,0);
|
||
post;
|
||
end;
|
||
|
||
|
||
with YFSub do
|
||
begin
|
||
first;
|
||
while not eof do
|
||
begin
|
||
if fieldbyname('YFSID').AsString='' then
|
||
begin
|
||
if GetLSNo(ADOQueryTmp,MaxYFSID,'SKS','YF_Money_CR_Sub',4,1)=False then
|
||
begin
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
MaxYFSID:=YFSub.fieldbyname('YFSID').AsString;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.add('select * from YF_Money_CR_Sub where YFSID='+Quotedstr(trim(MaxYFSID)));
|
||
open;
|
||
end;
|
||
if ADOQueryCmd.IsEmpty then
|
||
begin
|
||
ADOQueryCmd.append;
|
||
ADOQueryCmd.Fieldbyname('YFSID').value:=trim(MaxYFSID);
|
||
ADOQueryCmd.Fieldbyname('YFID').value:=trim(MaxYFID);
|
||
end
|
||
else
|
||
begin
|
||
ADOQueryCmd.edit;
|
||
end;
|
||
|
||
SSetSaveDataCDSNew(ADOQueryCmd,Tv1,YFSub,'YF_Money_CR_Sub',0);
|
||
ADOQueryCmd.Post;
|
||
next;
|
||
end;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ');
|
||
Modalresult:=1;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',MB_ICONERROR);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSKInput.initGrid();
|
||
begin
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_CR where YFID='+quotedstr(trim(FYFID)));
|
||
open;
|
||
end;
|
||
if ADOQueryTmp.isempty=False then
|
||
begin
|
||
SCSHDataNew(ADOQueryTmp,Panel1,0);
|
||
end
|
||
else
|
||
begin
|
||
HuiLv.Text:='1';
|
||
CRTime.DateTime:=SGetServerDate(ADOQueryTmp);
|
||
end;
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_CR_Sub where YFID='''+trim(FYFID)+'''');
|
||
open;
|
||
end;
|
||
SCreateCDS20(ADOQueryTmp,YFSub);
|
||
SInitCDSData20(ADOQueryTmp,YFSub);
|
||
end;
|
||
|
||
procedure TfrmSKInput.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(trim(self.Caption),Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmSKInput.FormShow(Sender: TObject);
|
||
begin
|
||
ReadCxGrid(trim(self.Caption),Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
initGrid();
|
||
end;
|
||
|
||
procedure TfrmSKInput.TSaveClick(Sender: TObject);
|
||
begin
|
||
yfname.SetFocus;
|
||
if trim(YFGSType.Text)='' then
|
||
begin
|
||
application.MessageBox('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>','<27><>ʾ');
|
||
exit;
|
||
end;
|
||
if YFSub.Locate('KXType',null,[]) then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD><CEAA>','<27><>ʾ');
|
||
exit;
|
||
end;
|
||
if YFSub.Locate('KXType','',[]) then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD><CEAA>','<27><>ʾ');
|
||
exit;
|
||
end;
|
||
if trim(FactoryName.Text)='' then
|
||
begin
|
||
application.MessageBox('<27>Է<EFBFBD><D4B7><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>','<27><>ʾ');
|
||
exit;
|
||
end;
|
||
SaveDate();
|
||
end;
|
||
|
||
procedure TfrmSKInput.FactoryNameBtnClick(Sender: TObject);
|
||
begin
|
||
|
||
|
||
try
|
||
frmZdyAttachment:=TfrmZdyAttachment.Create(Application);
|
||
with frmZdyAttachment do
|
||
begin
|
||
if ShowModal=1 then
|
||
begin
|
||
FactoryName.Text:=Trim(CDS_HZ.fieldbyname('CoName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZdyAttachment.Free;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmSKInput.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 TfrmSKInput.v1P_SpecPropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='KXType4';
|
||
flagname:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
if ShowModal=1 then
|
||
begin
|
||
Self.YFSub.Edit;
|
||
Self.YFSub.FieldByName('KXType').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSKInput.v1QtyUnitPropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='QtyUnit';
|
||
flagname:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ';
|
||
if ShowModal=1 then
|
||
begin
|
||
Self.YFSub.Edit;
|
||
Self.YFSub.FieldByName('QtyUnit').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSKInput.TADDClick(Sender: TObject);
|
||
begin
|
||
with YFSub do
|
||
begin
|
||
Append;
|
||
FieldByName('Qty').Value:=0;
|
||
FieldByName('Price').Value:=0;
|
||
FieldByName('MxMoney').Value:=0;
|
||
Post;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmSKInput.TDElClick(Sender: TObject);
|
||
begin
|
||
if YFSub.IsEmpty then exit;
|
||
if application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD>','<27><>ʾ',1)=2 then exit;
|
||
if trim(YFSub.fieldbyname('YFSID').asstring)='' then
|
||
begin
|
||
YFSub.delete;
|
||
HJJE();
|
||
end
|
||
else
|
||
begin
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
sql.clear;
|
||
sql.add('delete from YF_Money_CR_Sub where YFSID='''+trim(YFSub.fieldbyname('YFSID').asstring)+''' ');
|
||
execsql;
|
||
end;
|
||
YFSub.delete;
|
||
HJJE();
|
||
TSave.Click;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSKInput.v1QtyPropertiesEditValueChanged(Sender: TObject);
|
||
var
|
||
mvalue,FFieldName:string;
|
||
FQty,FPrice,FMxMoney:double;
|
||
begin
|
||
mvalue:=TcxTextEdit(Sender).EditingText;
|
||
FFieldName:=Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
|
||
if Trim(mvalue)='' then
|
||
begin
|
||
mvalue:='0';
|
||
end;
|
||
with YFSub do
|
||
begin
|
||
Edit;
|
||
FieldByName(FFieldName).Value:=Trim(mvalue);
|
||
Post;
|
||
end;
|
||
with YFSub do
|
||
begin
|
||
Edit;
|
||
FQty:=FieldByName('Qty').AsFloat;
|
||
FPrice:=FieldByName('Price').AsFloat;
|
||
Post;
|
||
end;
|
||
FMxMoney:=strtofloat(format('%.2f',[FQty * FPrice]));
|
||
with YFSub do
|
||
begin
|
||
Edit;
|
||
FieldByName(FFieldName).Value:=Trim(mvalue);
|
||
FieldbyName('MxMoney').Value:=FMxMoney;
|
||
Post;
|
||
end;
|
||
tv1.Controller.EditingController.ShowEdit();
|
||
HJJE();
|
||
end;
|
||
|
||
procedure TfrmSKInput.SYRNameBtnClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='SYRName';
|
||
flagname:='<27><>˾̧ͷ';
|
||
if Trim(flag)='SYRName' then
|
||
begin
|
||
flag:='OrdDefStr2';
|
||
V1Name.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
V1Note.Caption:='Ӣ<><D3A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
fnote:=True;
|
||
end;
|
||
if ShowModal=1 then
|
||
begin
|
||
SYRName.Text:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSKInput.v1Column3PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='MPRTCodeName';
|
||
flagname:='<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>';
|
||
if ShowModal=1 then
|
||
begin
|
||
with YFSub do
|
||
begin
|
||
Edit;
|
||
FieldByName('CPName').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
FieldByName('CPCode').Value:=Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString);
|
||
end;
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
//self.tv1.Controller.EditingController.ShowEdit();
|
||
end;
|
||
|
||
procedure TfrmSKInput.HuiLvKeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
if not (((key>='0') and (key<='9')) or (key='.') or (key=#8)) then
|
||
begin
|
||
key:=#0;
|
||
end
|
||
else if (pos('.', TEdit(Sender).text)<>0) then
|
||
begin
|
||
if key='.' then
|
||
begin
|
||
key:=#0;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSKInput.Panel1Click(Sender: TObject);
|
||
begin
|
||
yfname.SetFocus;
|
||
end;
|
||
|
||
procedure TfrmSKInput.HuiLvExit(Sender: TObject);
|
||
begin
|
||
HJJE();
|
||
end;
|
||
|
||
procedure TfrmSKInput.v1MoneyPropertiesEditValueChanged(Sender: TObject);
|
||
var
|
||
mvalue,FFieldName:string;
|
||
begin
|
||
mvalue:=TcxTextEdit(Sender).EditingText;
|
||
FFieldName:=Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
|
||
if Trim(mvalue)='' then
|
||
begin
|
||
mvalue:='0';
|
||
end;
|
||
with YFSub do
|
||
begin
|
||
Edit;
|
||
FieldByName(FFieldName).Value:=Trim(mvalue);
|
||
Post;
|
||
end;
|
||
tv1.Controller.EditingController.ShowEdit();
|
||
HJJE();
|
||
end;
|
||
|
||
procedure TfrmSKInput.YFNameBtnClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='YFName4';
|
||
flagname:='<27><>Ŀ<EFBFBD><C4BF>ժҪ';
|
||
if ShowModal=1 then
|
||
begin
|
||
YFName.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
end.
|