RTFormwork/项目代码/RTBasicsV1/F02染色计划单/U_DyeProcessInput.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

269 lines
6.9 KiB
ObjectPascal
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_DyeProcessInput;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin, StdCtrls,
cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdFTP, ShellAPI, IniFiles, cxCheckBox, cxCalendar, cxButtonEdit,
cxTextEdit, cxDropDownEdit, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator,
dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu;
type
TfrmDyeProcessInput = class(TForm)
ToolBar1: TToolBar;
TBClose: TToolButton;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
GPM_2: TcxGridPopupMenu;
DS_HZ: TDataSource;
CDS_HZ: TClientDataSet;
ToolButton3: TToolButton;
cxGrid2: TcxGrid;
Tv2: TcxGridDBTableView;
v2PSName: TcxGridDBColumn;
v2PSNote: TcxGridDBColumn;
v2Column1: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
v2SYRName: TcxGridDBColumn;
vLDPrice: TcxGridDBColumn;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton4: TToolButton;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure v2SYRNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
private
{ Private declarations }
procedure InitGrid();
function SaveData(): Boolean;
public
{ Public declarations }
RKFlag, FCYID: string;
fDEFstr5: string;
end;
var
frmDyeProcessInput: TfrmDyeProcessInput;
implementation
uses
U_DataLink, U_RTFun, U_ZDYHelp;
{$R *.dfm}
procedure TfrmDyeProcessInput.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered := False;
Close;
SQL.Clear;
sql.Add(' select * from Dye_Process where PSID=''' + Trim(FCYID) + '''');
Open;
end;
SCreateCDS(ADOQueryMain, CDS_HZ);
SInitCDSData(ADOQueryMain, CDS_HZ);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmDyeProcessInput.FormDestroy(Sender: TObject);
begin
frmDyeProcessInput := nil;
end;
procedure TfrmDyeProcessInput.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TfrmDyeProcessInput.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmDyeProcessInput.FormShow(Sender: TObject);
begin
ReadCxGrid(trim(Self.Caption), Tv2, 'Ⱦɫ<C8BE>ƻ<EFBFBD>');
InitGrid();
end;
procedure TfrmDyeProcessInput.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
function TfrmDyeProcessInput.SaveData(): Boolean;
var
maxId, CRID, fzdyCode, FFFlag, FStr: string;
begin
try
ADOQueryCmd.Connection.BeginTrans;
with CDS_HZ do
begin
first;
while not Eof do
begin
if Trim(fieldbyname('PSID').AsString) = '' then
begin
if GetLSNo(ADOQueryCmd, maxId, 'JP', 'Dye_Process', 4, 1) = False then
begin
Result := False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
end
else
begin
maxId := Trim(FCYID);
end;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from Dye_Process where PSID=''' + Trim(FCYID) + '''');
Open;
end;
with ADOQueryCmd do
begin
if Trim(FCYID) = '' then
begin
Append;
FieldByName('Filler').Value := Trim(DName);
end
else
begin
Edit;
FieldByName('Editer').Value := Trim(DName);
FieldByName('Edittime').Value := SGetServerDateTime(ADOQueryTemp);
end;
FieldByName('PSID').Value := Trim(maxId);
RTSetSaveDataCDS(ADOQueryCmd, Tv2, CDS_HZ, 'Dye_Process', 0);
Post;
end;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from Dye_Process where PSName=''' + Trim(CDS_HZ.fieldbyname('PSName').AsString) + '''');
Open;
end;
if ADOQueryCmd.RecordCount > 1 then
begin
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox(PChar('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' + trim(ADOQueryCmd.fieldbyname('PSName').AsString) + '<27>Ѵ<EFBFBD><D1B4><EFBFBD>'), '<27><>ʾ');
Exit;
end;
with CDS_HZ do
begin
Edit;
FieldByName('PSID').Value := Trim(maxId);
end;
next;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
Result := True;
except
;
Result := True;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!', '<27><>ʾ', 0);
end;
end;
procedure TfrmDyeProcessInput.ToolButton3Click(Sender: TObject);
begin
cxGrid2.SetFocus;
if Trim(CDS_HZ.FieldByName('PSName').AsString) = '' then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
Exit;
if SaveData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
ModalResult := 1;
end;
end;
procedure TfrmDyeProcessInput.ToolButton4Click(Sender: TObject);
begin
WriteCxGrid(trim(Self.Caption), Tv2, 'Ⱦɫ<C8BE>ƻ<EFBFBD>');
end;
procedure TfrmDyeProcessInput.v2SYRNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := 'CJName';
flagname := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
if ShowModal = 1 then
begin
with CDS_HZ do
begin
Edit;
FieldByName('Workshop').Value := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
end;
finally
;
frmZDYHelp.Free;
end;
end;
procedure TfrmDyeProcessInput.ToolButton1Click(Sender: TObject);
begin
with CDS_HZ do
begin
Append;
post;
end;
end;
procedure TfrmDyeProcessInput.ToolButton2Click(Sender: TObject);
begin
if CDS_HZ.IsEmpty then
exit;
if application.MessageBox(<><C8B7>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>', '<27><>ʾ', 1) = 2 then
exit;
with ADOQueryCmd do
begin
close;
SQL.Clear;
sql.Add('delete from Dye_Process where PSId=''' + trim(CDS_HZ.fieldbyname('PSID').AsString) + '''');
ExecSQL;
end;
CDS_HZ.Delete;
end;
end.