314 lines
8.9 KiB
ObjectPascal
314 lines
8.9 KiB
ObjectPascal
unit U_FHJJInPut;
|
||
|
||
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, cxDropDownEdit, cxCalendar, cxGridCustomPopupMenu,
|
||
cxGridPopupMenu;
|
||
|
||
type
|
||
TfrmFHJJInPut = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBSave: TToolButton;
|
||
TBClose: TToolButton;
|
||
ADOTemp: TADOQuery;
|
||
ADOCmd: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
Order_Sub: TClientDataSet;
|
||
DataSource2: TDataSource;
|
||
ADOZDY: TADOQuery;
|
||
CDS_ZDY: TClientDataSet;
|
||
ADOQuery1: TADOQuery;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
ToolButton3: TToolButton;
|
||
ToolButton4: TToolButton;
|
||
ClientDataSet1: TClientDataSet;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1Column6: TcxGridDBColumn;
|
||
v1Column18: TcxGridDBColumn;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column9: TcxGridDBColumn;
|
||
v1Column20: TcxGridDBColumn;
|
||
v1Column10: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
v1Column12: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBSaveClick(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
procedure v1Column6PropertiesEditValueChanged(Sender: TObject);
|
||
private
|
||
FXS:Integer;
|
||
procedure InitData();
|
||
procedure ZDYHelp(FButn:TcxButtonEdit;LType:string);
|
||
function SaveData():Boolean;
|
||
procedure GetMaxConNO();
|
||
{ Private declarations }
|
||
public
|
||
PState,PCopyInt:Integer;
|
||
FMainId,FConNo,FConType,FYLType:String;
|
||
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmFHJJInPut: TfrmFHJJInPut;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_ZDYHelp,U_RTFun,U_ZDYHelpSel,U_OrderSunSelList;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmFHJJInPut.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
WriteCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmFHJJInPut.InitData();
|
||
begin
|
||
with ADOQuery1 do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select A.*,C.OrderNo,D.PRTHX,PRTCode=isnull(C.MPRTCode,'''')+isnull(C.MPRTGY,'''') ');
|
||
sql.Add(',PRTColor=isnull(D.PRTColorNo,'''')+'' ''+isnull(D.PRTColor,'''')+'' ''+isnull(D.PRTColorEng,'''')');
|
||
SQL.Add(' from JYOrder_FH A');
|
||
sql.Add(' inner join JYOrder_Main C on A.MainId=C.MainId');
|
||
sql.Add(' left join JYOrder_Sub D on A.SubId=D.SubId');
|
||
sql.Add(' where A.FHId='''+Trim(FMainId)+'''');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQuery1,Order_Sub);
|
||
SInitCDSData20(ADOQuery1,Order_Sub);
|
||
|
||
|
||
end;
|
||
|
||
procedure TfrmFHJJInPut.ZDYHelp(FButn:TcxButtonEdit;LType:string);
|
||
begin
|
||
end;
|
||
|
||
procedure TfrmFHJJInPut.FormShow(Sender: TObject);
|
||
begin
|
||
ReadCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
InitData();
|
||
end;
|
||
procedure TfrmFHJJInPut.GetMaxConNO();
|
||
begin
|
||
|
||
end;
|
||
function TfrmFHJJInPut.SaveData():Boolean;
|
||
var
|
||
maxno:String;
|
||
begin
|
||
try
|
||
Result:=False;
|
||
ADOCmd.Connection.BeginTrans;
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
Order_Sub.DisableControls;
|
||
with Order_Sub do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if Trim(Order_Sub.fieldbyname('FHID').AsString)='' then
|
||
begin
|
||
if GetLSNo(ADOCmd,maxno,'FH','JYOrder_FH',4,1)=False then
|
||
begin
|
||
Order_Sub.EnableControls;
|
||
ADOCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end else
|
||
begin
|
||
maxno:=Trim(Order_Sub.fieldbyname('FHID').AsString);
|
||
end;
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select * from JYOrder_FH where FHID='''+Trim(Order_Sub.fieldbyname('FHID').AsString)+'''');
|
||
Open;
|
||
end;
|
||
with ADOCmd do
|
||
begin
|
||
if Trim(Order_Sub.fieldbyname('FHID').AsString)='' then
|
||
begin
|
||
Append;
|
||
end
|
||
else begin
|
||
Edit;
|
||
end;
|
||
FieldByName('FHID').Value:=Trim(maxno);
|
||
FieldByName('MainId').Value:=Order_Sub.fieldbyname('MainId').Value;
|
||
FieldByName('SubId').Value:=Order_Sub.fieldbyname('SubId').Value;
|
||
RTSetSaveDataCDS(ADOCmd,Tv1,Order_Sub,'JYOrder_FH',0) ;
|
||
FieldByName('FHType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
FieldByName('FHPerson').Value:=Trim(DName);
|
||
FieldByName('FHStatus').Value:='<27>ѷ<EFBFBD><D1B7><EFBFBD>';
|
||
if Trim(FMainId)='' then
|
||
begin
|
||
FieldByName('Filler').Value:=Trim(DName);
|
||
end else
|
||
begin
|
||
FieldByName('Editer').Value:=Trim(DName);
|
||
FieldByName('EditTime').Value:=SGetServerDateTime(ADOTemp);
|
||
end;
|
||
Post;
|
||
end;
|
||
Edit;
|
||
FieldByName('FHID').Value:=Trim(maxno);
|
||
Next;
|
||
end;
|
||
end;
|
||
Order_Sub.EnableControls;
|
||
ADOCmd.Connection.CommitTrans;
|
||
Result:=True;
|
||
except
|
||
Result:=False;
|
||
ADOCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmFHJJInPut.TBSaveClick(Sender: TObject);
|
||
var
|
||
FPPrice,PRTPrice,BCMoney,FPQty,ChaMoney:string;
|
||
begin
|
||
ToolBar1.SetFocus;
|
||
|
||
if Order_Sub.IsEmpty then
|
||
begin
|
||
Application.MessageBox('<27><>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
|
||
exit;
|
||
end;
|
||
if Order_Sub.Locate('FHDate',null,[]) then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if Order_Sub.Locate('FHQty',null,[]) then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if SaveData() then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ',0);
|
||
ModalResult:=1;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmFHJJInPut.ToolButton3Click(Sender: TObject);
|
||
var
|
||
FSQDate:string;
|
||
begin
|
||
FSQDate:=Trim(FormatDateTime('yyyy-MM-dd',SGetServerDate(ADOTemp)));
|
||
try
|
||
frmOrderSunSelList:=TfrmOrderSunSelList.Create(Application);
|
||
with frmOrderSunSelList do
|
||
begin
|
||
if ShowModal=1 then
|
||
begin
|
||
with frmOrderSunSelList.Order_Main do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if frmOrderSunSelList.Order_Main.FieldByName('SSel').AsBoolean=True then
|
||
begin
|
||
with Self.Order_Sub do
|
||
begin
|
||
Append;
|
||
FieldByName('MainId').Value:=frmOrderSunSelList.Order_Main.FieldByName('MainId').Value;
|
||
FieldByName('SubId').Value:=frmOrderSunSelList.Order_Main.FieldByName('SubId').Value;
|
||
FieldByName('OrderNo').Value:=frmOrderSunSelList.Order_Main.FieldByName('OrderNo').Value;
|
||
FieldByName('PRTCode').Value:=Trim(frmOrderSunSelList.Order_Main.FieldByName('MPRTCode').AsString)+
|
||
Trim(frmOrderSunSelList.Order_Main.FieldByName('MPRTGY').AsString);
|
||
FieldByName('PRTColor').Value:=frmOrderSunSelList.Order_Main.FieldByName('PRTColor').Value;
|
||
FieldByName('PRTHX').Value:=frmOrderSunSelList.Order_Main.FieldByName('PRTHX').Value;
|
||
FieldByName('QtyUnit').Value:=frmOrderSunSelList.Order_Main.FieldByName('OrderUnit').Value;
|
||
FieldByName('FHPS').Value:=frmOrderSunSelList.Order_Main.FieldByName('KCPS').Value;
|
||
FieldByName('FHQty').Value:=frmOrderSunSelList.Order_Main.FieldByName('KCQty').Value;
|
||
FieldByName('FHDate').Value:=FSQDate;
|
||
//Post;
|
||
end;
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
finally
|
||
frmOrderSunSelList.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmFHJJInPut.ToolButton4Click(Sender: TObject);
|
||
begin
|
||
if Order_Sub.IsEmpty then Exit;
|
||
if Trim(Order_Sub.fieldbyname('FHId').AsString)<>'' then
|
||
begin
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete JYOrder_FH where FHId='''+Trim(Order_Sub.fieldbyname('FHId').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
Order_Sub.Delete;
|
||
end;
|
||
|
||
procedure TfrmFHJJInPut.v1Column6PropertiesEditValueChanged(
|
||
Sender: TObject);
|
||
var
|
||
mvalue:string;
|
||
begin
|
||
mvalue:=TcxTextEdit(Sender).EditingText;
|
||
with Order_Sub do
|
||
begin
|
||
Edit;
|
||
FieldByName('MDID').Value:=Trim(mvalue);
|
||
Post;
|
||
end;
|
||
with ADOTemp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select B.OrderNo,A.PS,A.MDDate from JYOrder_Main_MD A');
|
||
sql.Add(' inner join JYorder_Main B on A.ORDMainId=B.MainId');
|
||
sql.Add(' and A.MDID='''+Trim(mvalue)+'''');
|
||
Open;
|
||
end;
|
||
if ADOTemp.IsEmpty then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
with Order_Sub do
|
||
begin
|
||
Edit;
|
||
FieldByName('OrderNo').Value:=ADOTemp.fieldbyname('OrderNo').Value;
|
||
FieldByName('PS').Value:=ADOTemp.fieldbyname('PS').Value;
|
||
Post;
|
||
end;
|
||
end;
|
||
|
||
end.
|