257 lines
6.4 KiB
ObjectPascal
257 lines
6.4 KiB
ObjectPascal
unit U_TatPlanMachInput;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
|
||
cxEdit, DB, cxDBData, ADODB, DBClient, cxGridLevel, cxGridCustomTableView,
|
||
cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView,
|
||
cxGrid, ComCtrls, ToolWin, cxGridCustomPopupMenu, cxGridPopupMenu, cxTextEdit,
|
||
cxButtonEdit, StdCtrls, ExtCtrls, cxCurrencyEdit, BtnEdit, cxLookAndFeels,
|
||
cxLookAndFeelPainters, cxNavigator, cxContainer, cxMaskEdit, dxSkinsCore,
|
||
dxSkinsDefaultPainters, dxDateRanges;
|
||
|
||
type
|
||
TfrmTatPlanMachInput = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
ToolButton1: TToolButton;
|
||
TBClose: TToolButton;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
ScrollBox1: TScrollBox;
|
||
Label1: TLabel;
|
||
PMID: TEdit;
|
||
Label3: TLabel;
|
||
Label5: TLabel;
|
||
MCNO: TEdit;
|
||
Label8: TLabel;
|
||
PMType: TComboBox;
|
||
Label4: TLabel;
|
||
OrderNo: TcxButtonEdit;
|
||
Label9: TLabel;
|
||
MainID: TEdit;
|
||
Label10: TLabel;
|
||
SubID: TEdit;
|
||
Label11: TLabel;
|
||
C_Name: TEdit;
|
||
C_Code: TEdit;
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure PMTypePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||
procedure OrderNoPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||
private
|
||
canshu1, YCP, XCP: string;
|
||
Fint, CXS: Integer;
|
||
procedure InitData();
|
||
function SaveData(): Boolean;
|
||
function CheckData(): Boolean;
|
||
{ Private declarations }
|
||
public
|
||
FPMID, FCYCode, FCPID, FCPNO, FCPName, FMCNo: string;
|
||
CopyInt, PState: Integer;
|
||
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmTatPlanMachInput: TfrmTatPlanMachInput;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun, U_iniParam, U_ZDYHelp, U_TatPlanSel;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmTatPlanMachInput.InitData();
|
||
var
|
||
FXHInt: Integer;
|
||
begin
|
||
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
SQL.Add('select * from Tat_Plan_Mach where PMID=''' + Trim(FPMID) + '''');
|
||
|
||
Open;
|
||
end;
|
||
if ADOQueryMain.IsEmpty then
|
||
begin
|
||
PMType.Text := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
MCNo.text := FMCNo;
|
||
end
|
||
else
|
||
begin
|
||
SCSHData(ADOQueryMain, ScrollBox1, 2);
|
||
end;
|
||
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmTatPlanMachInput.FormShow(Sender: TObject);
|
||
begin
|
||
InitData();
|
||
end;
|
||
|
||
procedure TfrmTatPlanMachInput.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
end;
|
||
|
||
function TfrmTatPlanMachInput.SaveData(): Boolean;
|
||
var
|
||
maxId, FCYNo, maxpbno: string;
|
||
begin
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
|
||
if GetLSNo(ADOQueryCmd, maxId, 'RW', 'Tat_Plan_Mach', 4, 1) = False then
|
||
begin
|
||
Result := False;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
PMID.Text := trim(maxId);
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from Tat_Plan_Mach where PMID=''' + Trim(FPMID) + '''');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
|
||
Append;
|
||
FieldByName('Filler').Value := Trim(DName);
|
||
FieldByName('Filltime').Value := SGetServerDateTime(ADOQueryTemp);
|
||
FieldByName('PMID').Value := Trim(maxId);
|
||
FieldByName('PMType').Value := Trim(PMType.text);
|
||
FieldByName('MCNo').Value := Trim(MCNo.text);
|
||
RTSetsavedata(ADOQueryCmd, 'Tat_Plan_Mach', ScrollBox1, 2);
|
||
Post;
|
||
end;
|
||
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('EXEC P_Tat_Plan_Mach_SetSequence @PMID=''' + Trim(PMID.Text) + '''');
|
||
sql.Add(',@Operate=''<27><><EFBFBD><EFBFBD>'' ');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.FieldByName('intReturn').AsInteger = -1 then
|
||
begin
|
||
raise Exception.Create(pchar(trim(ADOQueryTemp.FieldByName('ShowMsg').AsString)));
|
||
end;
|
||
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
FPMID := maxId;
|
||
Result := True;
|
||
except
|
||
Result := False;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatPlanMachInput.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
|
||
if CheckData() = False then
|
||
begin
|
||
exit;
|
||
end;
|
||
if SaveData() then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ', 0);
|
||
ModalResult := 1;
|
||
end;
|
||
end;
|
||
|
||
function TfrmTatPlanMachInput.CheckData(): Boolean;
|
||
var
|
||
mvalue, FReal: Double;
|
||
maxConNo: string;
|
||
begin
|
||
try
|
||
if Trim(orderno.Text) = '' then
|
||
raise Exception.Create('<27><>֯<EFBFBD><D6AF><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>!');
|
||
// if Trim(CYNo.Text) = '' then
|
||
// raise Exception.Create('<27><>Ʒ<EFBFBD><C6B7><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>!');
|
||
// if Trim(JZPM.Text) = '' then
|
||
// raise Exception.Create('<27><><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!');
|
||
// if Trim(weimi.Text) = '' then
|
||
// raise Exception.Create('γ<>ܲ<EFBFBD><DCB2><EFBFBD>Ϊ<EFBFBD><CEAA>!');
|
||
// if Trim(wsspec.Text) = '' then
|
||
// raise Exception.Create('γɴ<CEB3><C9B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!');
|
||
// if Trim(pici.Text) = '' then
|
||
// raise Exception.Create('<27><><EFBFBD>β<EFBFBD><CEB2><EFBFBD>Ϊ<EFBFBD><CEAA>!');
|
||
|
||
Result := True;
|
||
except
|
||
Result := false;
|
||
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatPlanMachInput.PMTypePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||
var
|
||
fsj: string;
|
||
FWZ: Integer;
|
||
begin
|
||
fsj := Trim(TcxButtonEdit(Sender).Hint);
|
||
FWZ := Pos('/', fsj);
|
||
try
|
||
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag := Copy(fsj, 1, FWZ - 1);
|
||
flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ);
|
||
|
||
if ShowModal = 1 then
|
||
begin
|
||
TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmTatPlanMachInput.OrderNoPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmTatPlanSel := TfrmTatPlanSel.Create(Application);
|
||
with frmTatPlanSel do
|
||
begin
|
||
if ShowModal = 1 then
|
||
begin
|
||
Self.OrderNo.Text := frmTatPlanSel.CDS_1.fieldbyname('OrderNo').AsString;
|
||
Self.MainID.Text := frmTatPlanSel.CDS_1.fieldbyname('MainID').AsString;
|
||
Self.SubID.Text := frmTatPlanSel.CDS_1.fieldbyname('SubID').AsString;
|
||
Self.C_Code.Text := frmTatPlanSel.CDS_1.fieldbyname('C_Code').AsString;
|
||
Self.C_Name.Text := frmTatPlanSel.CDS_1.fieldbyname('C_Name').AsString;
|
||
end;
|
||
end;
|
||
|
||
finally
|
||
frmTatPlanSel.Free;
|
||
end;
|
||
end;
|
||
|
||
end.
|
||
|