375 lines
9.5 KiB
ObjectPascal
375 lines
9.5 KiB
ObjectPascal
|
|
unit U_YGYPInPut_BGYPSH;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
|||
|
|
cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView,
|
|||
|
|
cxGridTableView, cxGridDBTableView, cxClasses, cxControls,
|
|||
|
|
cxGridCustomView, cxGrid, cxMemo, cxRichEdit, ComCtrls, cxContainer,
|
|||
|
|
cxTextEdit, cxMaskEdit, cxButtonEdit, StdCtrls, ToolWin, DBClient, ADODB,
|
|||
|
|
ExtCtrls, BtnEdit, cxCalendar,StrUtils, cxDropDownEdit,jpeg,
|
|||
|
|
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdFTP, cxPC,
|
|||
|
|
cxGridCustomPopupMenu, cxGridPopupMenu, Menus, ExtDlgs;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfrmYGYPInPut_BGYPSH = class(TForm)
|
|||
|
|
ToolBar1: TToolBar;
|
|||
|
|
TBClose: TToolButton;
|
|||
|
|
ADOTemp: TADOQuery;
|
|||
|
|
ADOCmd: TADOQuery;
|
|||
|
|
TBSave: TToolButton;
|
|||
|
|
PopupMenu1: TPopupMenu;
|
|||
|
|
N1: TMenuItem;
|
|||
|
|
N2: TMenuItem;
|
|||
|
|
DataSource1: TDataSource;
|
|||
|
|
Order_Sub: TClientDataSet;
|
|||
|
|
cxGrid1: TcxGrid;
|
|||
|
|
Tv1: TcxGridDBTableView;
|
|||
|
|
v1BGName: TcxGridDBColumn;
|
|||
|
|
v1BGQty: TcxGridDBColumn;
|
|||
|
|
v1BGUnit: TcxGridDBColumn;
|
|||
|
|
v1BGNote: TcxGridDBColumn;
|
|||
|
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
|
cxStyleRepository1: TcxStyleRepository;
|
|||
|
|
cxStyle1: TcxStyle;
|
|||
|
|
Panel1: TPanel;
|
|||
|
|
ToolBar2: TToolBar;
|
|||
|
|
TAdd: TToolButton;
|
|||
|
|
TDel: TToolButton;
|
|||
|
|
Label4: TLabel;
|
|||
|
|
SQName: TEdit;
|
|||
|
|
Label7: TLabel;
|
|||
|
|
GangWei: TEdit;
|
|||
|
|
Dept: TEdit;
|
|||
|
|
Label6: TLabel;
|
|||
|
|
Label5: TLabel;
|
|||
|
|
SQDate: TDateTimePicker;
|
|||
|
|
SQType: TComboBox;
|
|||
|
|
Label1: TLabel;
|
|||
|
|
Label2: TLabel;
|
|||
|
|
SQNote: TEdit;
|
|||
|
|
Label3: TLabel;
|
|||
|
|
ZDept: TEdit;
|
|||
|
|
ADOQuery2: TADOQuery;
|
|||
|
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure TBSaveClick(Sender: TObject);
|
|||
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
|
procedure FormDestroy(Sender: TObject);
|
|||
|
|
procedure v1BGUnitPropertiesButtonClick(Sender: TObject;
|
|||
|
|
AButtonIndex: Integer);
|
|||
|
|
procedure v1BGNamePropertiesButtonClick(Sender: TObject;
|
|||
|
|
AButtonIndex: Integer);
|
|||
|
|
procedure TaddClick(Sender: TObject);
|
|||
|
|
procedure TDelClick(Sender: TObject);
|
|||
|
|
private
|
|||
|
|
TPInt:Integer;
|
|||
|
|
procedure InitData();
|
|||
|
|
function SaveData():Boolean;
|
|||
|
|
{ Private declarations }
|
|||
|
|
public
|
|||
|
|
PState,CopyInt:Integer;
|
|||
|
|
FKC:double;
|
|||
|
|
FBGMainID,FYGID:String;
|
|||
|
|
{ Public declarations }
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
frmYGYPInPut_BGYPSH: TfrmYGYPInPut_BGYPSH;
|
|||
|
|
implementation
|
|||
|
|
uses
|
|||
|
|
U_DataLink,U_ZDYHelp,U_RTFun,U_ZDYHelpSel,U_YGYPZZChkList_BGYPKC;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
procedure TfrmYGYPInPut_BGYPSH.TBCloseClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYGYPInPut_BGYPSH.InitData();
|
|||
|
|
Var FDEPT:String;
|
|||
|
|
Fint: Integer;
|
|||
|
|
begin
|
|||
|
|
with ADOQuery2 do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select A.*,B.* from OA_YG_DangAn A ');
|
|||
|
|
sql.Add('inner join SY_Dept B on A.DPID=B.DPID');
|
|||
|
|
SQL.Add('where isnull(A.YGEName,YGName)='''+trim(DName)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
FDEPT:=ADOQuery2.fieldbyname('DPParent').AsString;
|
|||
|
|
for Fint:=2 to ADOQuery2.fieldbyname('DPlevel').AsInteger-1 do
|
|||
|
|
begin
|
|||
|
|
with ADOCmd do
|
|||
|
|
begin
|
|||
|
|
close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from SY_Dept where DPID='''+trim(FDEPT)+'''');
|
|||
|
|
open;
|
|||
|
|
end;
|
|||
|
|
FDEPT:=Trim(ADOCmd.fieldbyname('DPParent').AsString);
|
|||
|
|
end;
|
|||
|
|
if ADOCmd.IsEmpty=False then
|
|||
|
|
ZDept.Text:=trim(ADOCmd.fieldbyname('DPName').asstring);
|
|||
|
|
with ADOCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select A.* from OA_YG_DangAN A ');
|
|||
|
|
sql.add('where isnull(A.YGEName,A.YGName)='''+trim(DName)+''' ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCSHDataNew(ADOCmd,Panel1,2);
|
|||
|
|
SQName.Text:=trim(DName);
|
|||
|
|
FYGID:=trim(ADOCmd.fieldbyname('YGID').asstring);
|
|||
|
|
SQDate.DateTime:=SGetServerDate(ADOTemp);
|
|||
|
|
with ADOCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select A.* from OA_YG_DangAN_BGYP A ');
|
|||
|
|
sql.add('where A.BGMainID='''+trim(FBGMainID)+''' ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCSHDataNew(ADOCmd,Panel1,1);
|
|||
|
|
with ADOCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select A.* from OA_YG_DangAN_BGYP_Sub A ');
|
|||
|
|
sql.add('where A.BGMainID='''+trim(FBGMainID)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCreateCDS20(ADOCmd,Order_Sub);
|
|||
|
|
SInitCDSData20(ADOCmd,Order_Sub);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYGYPInPut_BGYPSH.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
InitData();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrmYGYPInPut_BGYPSH.SaveData():Boolean;
|
|||
|
|
var
|
|||
|
|
maxno:String;
|
|||
|
|
begin
|
|||
|
|
Result:=False;
|
|||
|
|
try
|
|||
|
|
ADOCmd.Connection.BeginTrans;
|
|||
|
|
if trim(FBGMainID)='' then
|
|||
|
|
begin
|
|||
|
|
if GetLSNo(ADOCmd,FBGMainid,'BY','OA_YG_DangAN_BGYP',4,1)=False then
|
|||
|
|
begin
|
|||
|
|
ADOCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
with ADOCmd do
|
|||
|
|
begin
|
|||
|
|
close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from OA_YG_DangAN_BGYP ');
|
|||
|
|
sql.add('where BGMainid='''+trim(FBGMainid)+'''');
|
|||
|
|
open;
|
|||
|
|
if ADOCmd.IsEmpty then append
|
|||
|
|
else edit;
|
|||
|
|
fieldbyname('BGMainid').value:=trim(FBGMainid);
|
|||
|
|
RTSetsavedata(ADOCmd,'OA_YG_DangAN_BGYP',Panel1,1);
|
|||
|
|
fieldbyname('YGID').AsString:=trim(FYGID);
|
|||
|
|
post;
|
|||
|
|
end;
|
|||
|
|
with Order_Sub do
|
|||
|
|
begin
|
|||
|
|
first;
|
|||
|
|
while not eof do
|
|||
|
|
begin
|
|||
|
|
if fieldbyname('BGSubid').AsString='' then
|
|||
|
|
begin
|
|||
|
|
if GetLSNo(ADOCmd,maxno,'BG','OA_YG_DangAN_BGYP_Sub',4,1)=False then
|
|||
|
|
begin
|
|||
|
|
ADOCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
maxno:=trim(Order_Sub.fieldbyname('BGSubid').AsString);
|
|||
|
|
end;
|
|||
|
|
with ADOCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
SQL.Add('select * from OA_YG_DangAN_BGYP_Sub where BGSubid='''+Trim(maxno)+'''');
|
|||
|
|
Open;
|
|||
|
|
if isempty then
|
|||
|
|
begin
|
|||
|
|
append;
|
|||
|
|
fieldbyname('SQStatus').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
edit;
|
|||
|
|
fieldbyname('BGSubid').Value:=trim(Maxno);
|
|||
|
|
fieldbyname('BGMainid').value:=trim(FBGMainid);
|
|||
|
|
fieldbyname('BGLYSubid').Value:=trim(Order_Sub.fieldbyname('BGLYSubid').asstring);
|
|||
|
|
RTSetSaveDataCDS(ADOCmd,Tv1,Order_Sub,'OA_YG_DangAN_BGYP_Sub',0);
|
|||
|
|
post;
|
|||
|
|
end;
|
|||
|
|
next;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
ADOCmd.Connection.CommitTrans;
|
|||
|
|
Result:=True;
|
|||
|
|
except
|
|||
|
|
Result:=False;
|
|||
|
|
ADOCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYGYPInPut_BGYPSH.TBSaveClick(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
FSFNO:String;
|
|||
|
|
begin
|
|||
|
|
ToolBar1.SetFocus;
|
|||
|
|
if order_Sub.isempty then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
if SQType.Text='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
|
|||
|
|
begin
|
|||
|
|
with Order_Sub do
|
|||
|
|
begin
|
|||
|
|
first;
|
|||
|
|
while not eof do
|
|||
|
|
begin
|
|||
|
|
if fieldbyname('CGQty').AsFloat<fieldbyname('BGQty').AsFloat then
|
|||
|
|
begin
|
|||
|
|
application.MessageBox(PChar(Order_Sub.fieldbyname('BGName').asstring+'<27><><EFBFBD>治<EFBFBD><E6B2BB>'),'<27><>ʾ');
|
|||
|
|
exit;
|
|||
|
|
end;
|
|||
|
|
next;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
if SaveData() then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ',0);
|
|||
|
|
Modalresult:=1;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYGYPInPut_BGYPSH.FormClose(Sender: TObject;
|
|||
|
|
var Action: TCloseAction);
|
|||
|
|
begin
|
|||
|
|
Action:=caFree;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYGYPInPut_BGYPSH.FormDestroy(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
frmYGYPInPut_BGYPSH:=nil;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYGYPInPut_BGYPSH.v1BGUnitPropertiesButtonClick(
|
|||
|
|
Sender: TObject; AButtonIndex: Integer);
|
|||
|
|
begin
|
|||
|
|
frmZDYHelp:=TfrmZDYHelp.Create(self);
|
|||
|
|
with frmZDYHelp do
|
|||
|
|
begin
|
|||
|
|
flag:='BGUnit';
|
|||
|
|
flagname:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ';
|
|||
|
|
if showModal=1 then
|
|||
|
|
begin
|
|||
|
|
with Order_Sub do
|
|||
|
|
begin
|
|||
|
|
edit;
|
|||
|
|
fieldbyname('BGUnit').Value:=trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYGYPInPut_BGYPSH.v1BGNamePropertiesButtonClick(
|
|||
|
|
Sender: TObject; AButtonIndex: Integer);
|
|||
|
|
begin
|
|||
|
|
frmZDYHelp:=TfrmZDYHelp.Create(self);
|
|||
|
|
with frmZDYHelp do
|
|||
|
|
begin
|
|||
|
|
flag:='BGName';
|
|||
|
|
flagname:='<27>칫<EFBFBD><ECB9AB>Ʒ';
|
|||
|
|
//FNote:=True;
|
|||
|
|
//v1Note.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ';
|
|||
|
|
if showModal=1 then
|
|||
|
|
begin
|
|||
|
|
with Order_Sub do
|
|||
|
|
begin
|
|||
|
|
edit;
|
|||
|
|
fieldbyname('BGName').Value:=trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
|
|||
|
|
//fieldbyname('BGUnit').Value:=trim(ClientDataSet1.fieldbyname('Note').AsString);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYGYPInPut_BGYPSH.TaddClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if trim(SQType.Text)='' then
|
|||
|
|
begin
|
|||
|
|
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD><CEAA>','<27><>ʾ');
|
|||
|
|
exit;
|
|||
|
|
end;
|
|||
|
|
frmYGYPZZChkList_BGYPKC:=TfrmYGYPZZChkList_BGYPKC.Create(self);
|
|||
|
|
with frmYGYPZZChkList_BGYPKC do
|
|||
|
|
begin
|
|||
|
|
Fformid:='1';
|
|||
|
|
if showmodal=1 then
|
|||
|
|
begin
|
|||
|
|
with Order_Main do
|
|||
|
|
begin
|
|||
|
|
first;
|
|||
|
|
while not eof do
|
|||
|
|
begin
|
|||
|
|
if fieldbyname('Ssel').AsBoolean=true then
|
|||
|
|
begin
|
|||
|
|
with Order_Sub do
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
fieldbyname('BGName').Value:=order_Main.fieldbyname('KCName').AsString;
|
|||
|
|
fieldbyname('CGQty').Value:=order_Main.fieldbyname('SumKCQty').AsFloat;
|
|||
|
|
fieldbyname('BGUnit').value:=Order_Main.fieldbyname('KCUnit').AsString;
|
|||
|
|
post;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
next;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYGYPInPut_BGYPSH.TDelClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if Order_Sub.IsEmpty then exit;
|
|||
|
|
with ADOCmd do
|
|||
|
|
begin
|
|||
|
|
close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('delete from OA_YG_DangAN_BGYP_Sub ');
|
|||
|
|
sql.add('where BGSubid='''+trim(Order_Sub.fieldbyname('BGSubid').AsString)+'''');
|
|||
|
|
execsql;
|
|||
|
|
end;
|
|||
|
|
Order_Sub.Delete;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|