RTFormwork/项目代码/RTBasicsV1/F03染色配方管理/U_DyeFormulaSampleInput.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

428 lines
11 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_DyeFormulaSampleInput;
interface
uses
Windows, Messages, strUtils, SysUtils, Variants, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, CheckLst, Spin, ComCtrls, Buttons, ExtCtrls, ToolWin,
cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit,
DB, cxDBData, cxGridLevel, cxGridCustomTableView, cxGridTableView,
cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxMaskEdit,
cxButtonEdit, cxContainer, cxTextEdit, cxMemo, cxLookAndFeels,
cxLookAndFeelPainters, cxNavigator, ADODB, DBClient, BtnEdit, dxSkinsCore,
dxSkinsDefaultPainters, dxDateRanges, cxCalendar;
type
TfrmDyeFormulaSampleInput = class(TForm)
ToolBar1: TToolBar;
TBSave: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
Label15: TLabel;
Label4: TLabel;
Label3: TLabel;
Label6: TLabel;
Label17: TLabel;
Label14: TLabel;
Label10: TLabel;
Label7: TLabel;
Label2: TLabel;
Label23: TLabel;
DlyDate: TDateTimePicker;
comeDate: TDateTimePicker;
Request: TEdit;
C_Code: TEdit;
Panel3: TPanel;
ToolBar2: TToolBar;
TBAddDtl: TToolButton;
TBDelDtl: TToolButton;
cxgrid1: TcxGrid;
TV1: TcxGridDBTableView;
TV1ColPos: TcxGridDBColumn;
TV1chnName: TcxGridDBColumn;
TV1ColType: TcxGridDBColumn;
TV1ClrMethod: TcxGridDBColumn;
TV1CraftType: TcxGridDBColumn;
TV1Firm: TcxGridDBColumn;
TV1Handle: TcxGridDBColumn;
TV1Note: TcxGridDBColumn;
cxgrid1L1: TcxGridLevel;
custName: TBtnEditA;
Saleser: TEdit;
C_Composition: TEdit;
Lights: TBtnEditA;
Note: TMemo;
CDS_1: TClientDataSet;
DS_1: TDataSource;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
DFSType: TBtnEditA;
TV1Column1: TcxGridDBColumn;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBAddDtlClick(Sender: TObject);
procedure TBDelDtlClick(Sender: TObject);
procedure TBSaveClick(Sender: TObject);
procedure custNameBtnClick(Sender: TObject);
procedure DFSTypeBtnClick(Sender: TObject);
procedure LightsBtnClick(Sender: TObject);
procedure TV1ColTypePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure TV1ClrMethodPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure TV1CraftTypePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure SCTypeDropDown(Sender: TObject);
private
procedure InitGrid();
function Savedata(): boolean;
{ Private declarations }
public
FDFSMID: string;
{ Public declarations }
end;
var
frmDyeFormulaSampleInput: TfrmDyeFormulaSampleInput;
implementation
uses
U_DataLink, U_RTFun, U_CompanySel, U_ZDYHelp;
{$R *.dfm}
function TfrmDyeFormulaSampleInput.Savedata(): boolean;
var
MaxMid, MaxSid: string;
begin
result := false;
ADOQueryCmd.Connection.BeginTrans;
try
if trim(FDFSMID) = '' then
begin
if GetLSNo(ADOQueryTemp, MaxMid, 'FX', 'Dye_Formula_Sample_Main', 4, 1) = False then
raise Exception.Create(С<C8A1><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end
else
MaxMid := FDFSMID;
with AdoqueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from Dye_Formula_Sample_Main where DFSMID=''' + trim(MaxMid) + '''');
open;
if Trim(FDFSMID) = '' then
begin
append;
Fieldbyname('DFSMID').Value := trim(MaxMid);
Fieldbyname('Fillid').Value := Trim(dcode);
Fieldbyname('Filler').Value := Trim(DName);
end
else
begin
Edit;
Fieldbyname('Editid').Value := Trim(dcode);
Fieldbyname('Editer').Value := Trim(DName);
Fieldbyname('EditTime').Value := SGetServerDateTime(ADOQueryTemp);
end;
RTSetsavedata(ADOQueryCmd, 'Dye_Formula_Sample_Main', panel1, 0);
Fieldbyname('CustNo').Value := CustName.TxtCode;
post;
end;
with CDS_1 do
begin
DisableControls;
first;
while not eof do
begin
if Fieldbyname('DFSSID').AsString = '' then
begin
if GetLSNo(ADOQueryTemp, MaxSid, 'FS', 'Dye_Formula_Sample_Sub', 4, 1) = False then
raise Exception.Create(С<C8A1><D0A1><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end
else
MaxSid := Fieldbyname('DFSSID').AsString;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.add('select * from Dye_Formula_Sample_Sub where DFSMID=''' + trim(MaxMid) + ''' ');
sql.add('and DFSSID=''' + trim(MaxSid) + '''');
open;
if IsEmpty then
begin
append;
end
else
begin
edit;
end;
RTSetSaveDataCDS(ADOQueryCmd, Tv1, CDS_1, 'Dye_Formula_Sample_Sub', 0);
Fieldbyname('DFSMID').Value := trim(MaxMid);
Fieldbyname('DFSSID').Value := trim(MaxSid);
Post;
end;
with ADOQueryTemp do
begin
close;
sql.Clear;
sql.Add('select * from Dye_Formula_Sample_Sub A ');
sql.Add('inner join Dye_Formula_Sample_Main B on B.DFSMID=A.DFSMID ');
sql.Add('where A.C_ColorNo=''' + trim(CDS_1.Fieldbyname('C_ColorNo').AsString) + ''' ');
open;
end;
if ADOQueryTemp.RecordCount > 1 then
raise Exception.Create(<><C9AB><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>');
next;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
CDS_1.EnableControls;
FDFSMID := MaxMid;
result := true;
except
CDS_1.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmDyeFormulaSampleInput.SCTypeDropDown(Sender: TObject);
begin
if not CDS_1.IsEmpty then
begin
Application.MessageBox('<27><>ϸΪ<CFB8>ղ<EFBFBD><D5B2>ܸ<EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
end;
procedure TfrmDyeFormulaSampleInput.InitGrid();
begin
with ADOQueryTemp do
begin
close;
sql.Clear;
sql.Add('select * from Dye_Formula_Sample_Main where DFSMID=''' + trim(FDFSMID) + '''');
open;
end;
SCSHData(ADOQueryTemp, Panel1, 0);
CustName.TxtCode := ADOQueryTemp.Fieldbyname('CustNo').AsString;
with ADOQueryTemp do
begin
close;
sql.Clear;
sql.Add('select * from Dye_Formula_Sample_Sub where DFSMID=''' + trim(FDFSMID) + '''');
open;
end;
SCreateCDS(ADOQueryTemp, CDS_1);
SInitCDSData(ADOQueryTemp, CDS_1);
end;
procedure TfrmDyeFormulaSampleInput.FormDestroy(Sender: TObject);
begin
frmDyeFormulaSampleInput := nil;
end;
procedure TfrmDyeFormulaSampleInput.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := cahide;
end;
procedure TfrmDyeFormulaSampleInput.TBCloseClick(Sender: TObject);
begin
close;
end;
procedure TfrmDyeFormulaSampleInput.FormCreate(Sender: TObject);
begin
comeDate.DateTime := now();
Dlydate.DateTime := now();
SClearData(Panel1, 0);
end;
procedure TfrmDyeFormulaSampleInput.FormShow(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmDyeFormulaSampleInput.TBAddDtlClick(Sender: TObject);
begin
CDS_1.Append;
// CDS_1.Fieldbyname('P_ColorNo').Value := trim(fmaxNo);
CDS_1.Post;
end;
procedure TfrmDyeFormulaSampleInput.TBDelDtlClick(Sender: TObject);
begin
if CDS_1.IsEmpty then
Exit;
if Trim(CDS_1.fieldbyname('DFSSID').AsString) <> '' then
begin
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
Exit;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update Dye_Formula_Large_Sub set DelId=' + quotedstr(DCode) + ',Deler=' + quotedstr(DName) + ',Deltime=getdate() where DFSSID=' + quotedstr(trim(CDS_1.fieldByName('DFSSID').AsString)));
sql.Add('insert into Dye_Formula_Large_Sub_Del select * from Dye_Formula_Large_Sub where DFSSID=' + quotedstr(trim(CDS_1.fieldByName('DFSSID').AsString)));
sql.Add('delete Dye_Formula_Large_Sub where DFSSID=' + quotedstr(trim(CDS_1.fieldByName('DFSSID').AsString)));
execsql;
end;
end;
CDS_1.Delete;
end;
procedure TfrmDyeFormulaSampleInput.TBSaveClick(Sender: TObject);
begin
if CDS_1.IsEmpty then
exit;
if trim(DFSType.Text) = '' then
begin
application.MessageBox('С<><D0A1><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
exit;
end;
DFSType.SetFocus;
if savedata() then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
end
else
begin
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmDyeFormulaSampleInput.TV1ClrMethodPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := 'ClrMethod';
flagname := 'Ⱦɫ<C8BE><C9AB>ʽ';
if ShowModal = 1 then
begin
Self.CDS_1.Edit;
Self.CDS_1.Fieldbyname('ClrMethod').Value := Trim(ClientDataSet1.Fieldbyname('ZDYName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmDyeFormulaSampleInput.TV1ColTypePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := 'ColType';
flagname := '<27><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>';
if ShowModal = 1 then
begin
Self.CDS_1.Edit;
Self.CDS_1.Fieldbyname('ColType').Value := Trim(ClientDataSet1.Fieldbyname('ZDYName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmDyeFormulaSampleInput.TV1CraftTypePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := 'CraftType';
flagname := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
if ShowModal = 1 then
begin
Self.CDS_1.Edit;
Self.CDS_1.Fieldbyname('CraftType').Value := Trim(ClientDataSet1.Fieldbyname('ZDYName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmDyeFormulaSampleInput.custNameBtnClick(Sender: TObject);
begin
try
frmCompanySel := TfrmCompanySel.Create(Application);
with frmCompanySel do
begin
FCoType := '<27>ͻ<EFBFBD>';
if ShowModal = 1 then
begin
CustName.Text := Trim(CDS_1.fieldbyname('CoName').AsString);
CustName.TxtCode := Trim(CDS_1.fieldbyname('CoCode').AsString);
Self.Saleser.Text := Trim(CDS_1.fieldbyname('Saleser').AsString);
end;
end;
finally
frmCompanySel.Free;
end;
end;
procedure TfrmDyeFormulaSampleInput.DFSTypeBtnClick(Sender: TObject);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := 'DFSType';
flagname := 'С<><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
if ShowModal = 1 then
begin
DFSType.Text := Trim(ClientDataSet1.Fieldbyname('ZDYName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmDyeFormulaSampleInput.LightsBtnClick(Sender: TObject);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := 'LightsType';
flagname := '<27><>ɫ<EFBFBD>ƹ<EFBFBD>';
if ShowModal = 1 then
begin
Lights.Text := Trim(ClientDataSet1.Fieldbyname('ZDYName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
end.