348 lines
9.1 KiB
ObjectPascal
348 lines
9.1 KiB
ObjectPascal
unit U_SXDZInPut;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
||
cxDataStorage, cxEdit, DB, cxDBData, cxCalendar, cxDropDownEdit,
|
||
ComCtrls, ToolWin, cxGridLevel, cxGridCustomTableView, cxGridTableView,
|
||
cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient, cxButtonEdit,
|
||
cxTextEdit;
|
||
|
||
type
|
||
TfrmSXDZInPut = class(TForm)
|
||
cxGrid2: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1Column2: TcxGridDBColumn;
|
||
v2Column1: TcxGridDBColumn;
|
||
v1Column9: TcxGridDBColumn;
|
||
v2Column6: TcxGridDBColumn;
|
||
cxGrid2Level1: TcxGridLevel;
|
||
ToolBar1: TToolBar;
|
||
TBAdd: TToolButton;
|
||
TBDel: TToolButton;
|
||
TBSave: TToolButton;
|
||
TBClose: TToolButton;
|
||
DataSource3: TDataSource;
|
||
CDS_Sub: TClientDataSet;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
cxGridPopupMenu2: TcxGridPopupMenu;
|
||
v1Column12: TcxGridDBColumn;
|
||
v1Column14: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
v1Column1: TcxGridDBColumn;
|
||
ToolButton1: TToolButton;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBAddClick(Sender: TObject);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBDelClick(Sender: TObject);
|
||
procedure TBSaveClick(Sender: TObject);
|
||
procedure v1Column14PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure v2Column1PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure v2Column6PropertiesEditValueChanged(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
function SaveCKData():Boolean;
|
||
public
|
||
{ Public declarations }
|
||
FBCId:String;
|
||
end;
|
||
|
||
var
|
||
frmSXDZInPut: TfrmSXDZInPut;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_RTFun,U_ClothContractListHZCX,U_ZDYHelp, U_GYSSelList,U_ContractCGJGSXSelList,U_SXDZViewSCList;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmSXDZInPut.FormClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmSXDZInPut.TBAddClick(Sender: TObject);
|
||
begin
|
||
with CDS_Sub do
|
||
begin
|
||
Append;
|
||
FieldByName('DZDate').Value:=Trim(FormatDateTime('yyyy-MM-dd',Now));
|
||
Post;
|
||
end;
|
||
end;
|
||
function TfrmSXDZInPut.SaveCKData():Boolean;
|
||
var
|
||
FCRID,Maxno,FDZID:string;
|
||
begin
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
CDS_Sub.DisableControls;
|
||
with CDS_Sub do
|
||
begin
|
||
First;
|
||
while not eof do
|
||
begin
|
||
if Trim(CDS_Sub.fieldbyname('DZID').AsString)='' then
|
||
begin
|
||
if GetLSNo(ADOQueryCmd,Maxno,'SX','JYOrder_Main_MD_DuiZhang',3,1)=False then
|
||
begin
|
||
Result:=False;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡɴ<C8A1>߶<EFBFBD><DFB6>˱<EFBFBD><CBB1><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end else
|
||
begin
|
||
Maxno:=Trim(CDS_Sub.fieldbyname('DZID').AsString);
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(Maxno)+'''');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from JYOrder_Main_MD_DuiZhang');
|
||
sql.Add(' where DZID='''+Trim(CDS_Sub.fieldbyname('DZID').AsString)+'''');
|
||
Open;
|
||
end;
|
||
FDZID:=Trim(ADOQueryTemp.fieldbyname('DZID').AsString);
|
||
if Trim(FDZID)='' then
|
||
begin
|
||
Append;
|
||
FieldByName('Filler').Value:=Trim(DName);
|
||
end else
|
||
begin
|
||
Edit;
|
||
FieldByName('Editer').Value:=Trim(DName);
|
||
FieldByName('EditTime').Value:=SGetServerDate(ADOQueryTemp);
|
||
end;
|
||
FieldByName('DZID').Value:=Trim(Maxno);
|
||
FieldByName('DZType').Value:='ɴ<><C9B4>';
|
||
FieldByName('Status').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
FieldByName('FactoryNo').Value:=Trim(CDS_Sub.fieldbyname('FactoryNo').AsString);
|
||
RTSetSaveDataCDS(ADOQueryCmd,Tv1,CDS_Sub,'JYOrder_Main_MD_DuiZhang',2);
|
||
Post;
|
||
end;
|
||
Edit;
|
||
FieldByName('DZID').Value:=Trim(Maxno);
|
||
Post;
|
||
Next;
|
||
end;
|
||
end;
|
||
CDS_Sub.EnableControls;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
Result:=True;
|
||
except
|
||
Result:=False;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
|
||
end;
|
||
|
||
end;
|
||
procedure TfrmSXDZInPut.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid('ɴ<>߶<EFBFBD><DFB6><EFBFBD>¼<EFBFBD><C2BC>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmSXDZInPut.FormShow(Sender: TObject);
|
||
begin
|
||
ReadCxGrid('ɴ<>߶<EFBFBD><DFB6><EFBFBD>¼<EFBFBD><C2BC>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select A.* ');
|
||
sql.Add(' from JYOrder_Main_MD_DuiZhang A');
|
||
sql.Add(' where DZID='''+Trim(FBCId)+'''');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp,CDS_Sub);
|
||
SInitCDSData20(ADOQueryTemp,CDS_Sub);
|
||
end;
|
||
|
||
procedure TfrmSXDZInPut.TBDelClick(Sender: TObject);
|
||
begin
|
||
if CDS_Sub.IsEmpty then Exit;
|
||
if Trim(CDS_Sub.fieldbyname('DZID').AsString)<>'' then
|
||
begin
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from JYOrder_Main_MD_DuiZhang where DZID='''+Trim(CDS_Sub.fieldbyname('DZID').AsString)+'''');
|
||
sql.Add(' and isnull(Status,'''')=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty=False then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' delete JYOrder_Main_MD_DuiZhang where DZID='''+Trim(CDS_Sub.fieldbyname('DZID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
CDS_Sub.Delete;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ɾ<><C9BE><EFBFBD>쳣!','<27><>ʾ',0);
|
||
end;
|
||
end else
|
||
begin
|
||
CDS_Sub.Delete;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmSXDZInPut.TBSaveClick(Sender: TObject);
|
||
begin
|
||
if CDS_Sub.IsEmpty then Exit;
|
||
if CDS_Sub.Locate('DZDate',null,[])=True then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if CDS_Sub.Locate('MPRTCodeName',null,[])=True then
|
||
begin
|
||
Application.MessageBox('Ʒ<><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if CDS_Sub.Locate('FactoryName',null,[])=True then
|
||
begin
|
||
Application.MessageBox('<27><>Ӧ<EFBFBD>̲<EFBFBD><CCB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if CDS_Sub.Locate('Qty',null,[])=True then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if CDS_Sub.Locate('Price',null,[])=True then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
ToolBar1.SetFocus;
|
||
if SaveCKData() then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!','<27><>ʾ',0);
|
||
//ModalResult:=1;
|
||
Exit;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSXDZInPut.v1Column14PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmGYSSelList:=TfrmGYSSelList.Create(Application);
|
||
with frmGYSSelList do
|
||
begin
|
||
if ShowModal=1 then
|
||
begin
|
||
with Self.CDS_Sub do
|
||
begin
|
||
edit;
|
||
FieldByName('FactoryNo').Value:=Trim(frmGYSSelList.Order_Main.fieldbyname('ZKID').AsString) ;
|
||
FieldByName('FactoryName').Value:=Trim(frmGYSSelList.Order_Main.fieldbyname('KHName').AsString);
|
||
//Post;
|
||
end;
|
||
end;
|
||
end;
|
||
finally
|
||
frmGYSSelList.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSXDZInPut.v2Column1PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='SXPBName';
|
||
flagname:='ɴ<><C9B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
if ShowModal=1 then
|
||
begin
|
||
with Self.CDS_Sub do
|
||
begin
|
||
Edit;
|
||
FieldByName('MPRTCodeName').Value:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
|
||
end;
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSXDZInPut.v2Column6PropertiesEditValueChanged(
|
||
Sender: TObject);
|
||
var
|
||
mvalue,FName,FQty,FPrice:String;
|
||
begin
|
||
FName:=Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
|
||
mvalue:=TcxTextEdit(Sender).EditingText;
|
||
if Trim(mvalue)='' then mvalue:='0';
|
||
with CDS_Sub do
|
||
begin
|
||
edit;
|
||
FieldByName(FName).Value:=mvalue;
|
||
//Post;
|
||
end;
|
||
FQty:=CDS_Sub.fieldbyname('Qty').AsString;
|
||
FPrice:=CDS_Sub.fieldbyname('Price').AsString;
|
||
if Trim(FQty)='' then FQty:='0';
|
||
if Trim(FPrice)='' then FPrice:='0';
|
||
with CDS_Sub do
|
||
begin
|
||
Edit;
|
||
FieldByName('Money').Value:=StrToFloat(FQty)*StrToFloat(FPrice);
|
||
//Post;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmSXDZInPut.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
try
|
||
frmSXDZViewSCList:=TfrmSXDZViewSCList.Create(Application);
|
||
with frmSXDZViewSCList do
|
||
begin
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmSXDZViewSCList.Free;
|
||
end;
|
||
end;
|
||
|
||
end.
|