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

380 lines
9.7 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_DyeCardGlideEdit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, BtnEdit, ComCtrls, cxStyles, cxCustomData,
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ToolWin,
cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGrid, ADODB, DBClient,
cxCalendar, cxContainer, cxTextEdit, cxCurrencyEdit, cxDropDownEdit,
cxCheckBox, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore,
dxSkinsDefaultPainters, dxDateRanges, U_BaseInput, System.ImageList,
Vcl.ImgList, dxBarBuiltInMenu, cxGridCustomPopupMenu, cxGridPopupMenu,
cxButtonEdit, Vcl.Menus;
type
TfrmDyeCardGlideEdit = class(TfrmBaseInput)
CDS_Glide: TClientDataSet;
DS_Glide: TDataSource;
CDS_1: TClientDataSet;
DS_1: TDataSource;
ADO_Car: TADOQuery;
ADO_Glide: TADOQuery;
ADOQueryCmd: TADOQuery;
ADOQueryTmp: TADOQuery;
GPM_1: TcxGridPopupMenu;
Panel1: TPanel;
Panel2: TPanel;
cxGrid2: TcxGrid;
TV2: TcxGridDBTableView;
TV2Column1: TcxGridDBColumn;
TV2Column2: TcxGridDBColumn;
TV2Column3: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
ToolBar1: TToolBar;
TBGX: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
cxGrid1: TcxGrid;
TV1: TcxGridDBTableView;
v2PSName: TcxGridDBColumn;
v2PSNote: TcxGridDBColumn;
v2SYRName: TcxGridDBColumn;
vLDPrice: TcxGridDBColumn;
v2Column1: TcxGridDBColumn;
cxGridLevel2: TcxGridLevel;
CDS_Card: TClientDataSet;
ToolButton1: TToolButton;
ToolButton6: TToolButton;
Panel4: TPanel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
DTMName: TEdit;
DTMNo: TEdit;
DTMPrice: TEdit;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ToolButton2Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure TBGXClick(Sender: TObject);
procedure TV1DblClick(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
private
fOrdType: string;
procedure InitGrid1();
procedure InitCard();
procedure InitGlide();
{ Private declarations }
public
FWorkshop, FPCIDS: string;
{ Public declarations }
end;
var
frmDyeCardGlideEdit: TfrmDyeCardGlideEdit;
implementation
uses
U_DataLink, U_RTFun, U_DyeTechnicsSel;
{$R *.dfm}
procedure TfrmDyeCardGlideEdit.InitGrid1();
begin
with ADOQueryTmp do
begin
Close;
SQL.Clear;
sql.Add(' select * from Dye_Process ');
Open;
end;
SCreateCDS(ADOQueryTmp, CDS_1);
SInitCDSData(ADOQueryTmp, CDS_1);
end;
procedure TfrmDyeCardGlideEdit.InitGlide();
begin
try
with Ado_Glide do
begin
close;
sql.Clear;
sql.Add('select A.*');
sql.Add('from Dye_Plan_Glide A ');
sql.Add('where A.PCID=''' + trim(CDS_Card.fieldbyname('RTValue').AsString) + ''' ');
open;
end;
SCreateCDS(Ado_Glide, CDS_Glide);
SInitCDSData(Ado_Glide, CDS_Glide);
finally
end;
end;
procedure TfrmDyeCardGlideEdit.InitCard();
begin
try
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add('select * from [dbo].[F_Tool_SplitString](' + quotedstr(FPCIDS) + ','';'') A ');
open;
end;
SCreateCDS(ADOQueryTmp, CDS_Card);
SInitCDSData(ADOQueryTmp, CDS_Card);
finally
end;
end;
procedure TfrmDyeCardGlideEdit.FormDestroy(Sender: TObject);
begin
inherited;
frmDyeCardGlideEdit := nil;
end;
procedure TfrmDyeCardGlideEdit.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := cahide;
end;
procedure TfrmDyeCardGlideEdit.ToolButton1Click(Sender: TObject);
begin
WriteCxGrid(self.Caption + 'TV1', Tv1, '<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
WriteCxGrid(self.Caption + 'TV2', Tv2, '<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure TfrmDyeCardGlideEdit.ToolButton2Click(Sender: TObject);
begin
with CDS_Glide do
begin
if IsEmpty then
Exit;
if RecNo >= 1 then
begin
//Prior;
Edit;
fieldByName('GlideNo').Value := fieldByName('GlideNo').Value - 1;
Post;
Prior;
Edit;
fieldByName('GlideNo').Value := fieldByName('GlideNo').Value + 1;
Post;
end;
Prior;
end;
end;
procedure TfrmDyeCardGlideEdit.ToolButton3Click(Sender: TObject);
begin
CDS_Glide.IndexFieldNames := 'GlideNo';
with CDS_Glide do
begin
if IsEmpty then
Exit;
Next;
if not Eof then
Prior
else
begin
exit;
end;
if not Eof then
begin
Edit;
fieldByName('GlideNo').Value := fieldByName('GlideNo').Value + 1;
Post;
Prior;
Edit;
fieldByName('GlideNo').Value := fieldByName('GlideNo').Value - 1;
Post;
end;
Next;
end;
end;
procedure TfrmDyeCardGlideEdit.ToolButton4Click(Sender: TObject);
var
k: integer;
begin
if cds_Glide.IsEmpty then
exit;
cds_Glide.Delete;
cds_Glide.IndexFieldNames := 'GlideNo';
cds_Glide.DisableControls;
cds_Glide.First;
k := 1;
while not cds_Glide.Eof do
begin
cds_Glide.Edit;
cds_Glide.FieldByName('GlideNo').Value := k;
cds_Glide.Post;
inc(k);
cds_Glide.Next;
end;
cds_Glide.First;
cds_Glide.EnableControls;
end;
procedure TfrmDyeCardGlideEdit.FormShow(Sender: TObject);
begin
inherited;
ReadCxGrid(self.Caption + 'TV1', Tv1, '<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
ReadCxGrid(self.Caption + 'TV2', Tv2, '<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
InitGrid1();
InitCard();
InitGlide();
end;
procedure TfrmDyeCardGlideEdit.ToolButton5Click(Sender: TObject);
var
maxID: string;
begin
if CDS_Glide.IsEmpty then
exit;
if CDS_Card.IsEmpty then
exit;
try
CDS_Glide.DisableControls;
with CDS_Card do
begin
CDS_Card.First;
while not eof do
begin
try
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update Dye_Plan_Card ');
sql.Add('set DTMNo=' + QuotedStr(DTMNo.Text));
sql.Add(', DTMName=' + QuotedStr(DTMName.Text));
sql.Add(', DTMPrice=' + (DTMPrice.Text));
sql.Add('where PCID=''' + trim(CDS_Card.fieldbyname('RTValue').asstring) + '''');
execsql;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('delete Dye_Plan_Glide ');
sql.Add('where PCID=''' + trim(CDS_Card.fieldbyname('RTValue').asstring) + '''');
execsql;
end;
CDS_Glide.First;
while not CDS_Glide.Eof do
begin
// if trim(CDS_Glide.FieldByName('GlideID').asstring) = '' then
begin
if GetLSNo(ADOQueryCmd, maxID, 'CG', 'Dye_Plan_Glide', 4, 1) = False then
raise Exception.Create(PChar(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!'));
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from Dye_Plan_Glide A where 1=2');
open;
append;
fieldbyname('Filler').Value := trim(DName);
FieldByName('GlideID').Value := trim(maxID);
FieldByName('PCID').Value := trim(CDS_Card.fieldbyname('RTValue').AsString);
FieldByName('GlideNo').Value := trim(CDS_Glide.fieldbyname('GlideNo').AsString);
FieldByName('GlideName').Value := trim(CDS_Glide.fieldbyname('GlideName').AsString);
FieldByName('Note').Value := trim(CDS_Glide.fieldbyname('Note').AsString);
post;
end;
CDS_Glide.Next;
end;
ADOQueryCmd.Connection.CommitTrans;
except
ADOQueryCmd.Connection.RollbackTrans;
raise Exception.Create(PChar(Exception(ExceptObject).Message));
end;
CDS_Card.Next;
end;
end;
CDS_Glide.EnableControls;
ModalResult := 1;
except
CDS_Glide.EnableControls;
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
end;
end;
procedure TfrmDyeCardGlideEdit.ToolButton6Click(Sender: TObject);
begin
close;
end;
procedure TfrmDyeCardGlideEdit.TV1DblClick(Sender: TObject);
begin
with CDS_1 do
begin
CDS_Glide.Append;
CDS_Glide.FieldByName('GlideNo').Value := CDS_Glide.RecordCount + 1;
CDS_Glide.FieldByName('GlideName').Value := CDS_1.fieldbyname('PSName').AsString;
CDS_Glide.FieldByName('Note').Value := CDS_1.fieldbyname('Note').AsString;
CDS_Glide.Post;
end;
end;
procedure TfrmDyeCardGlideEdit.TBGXClick(Sender: TObject);
begin
frmDyeTechnicsSel := TfrmDyeTechnicsSel.create(self);
with frmDyeTechnicsSel do
begin
if showmodal = 1 then
begin
with frmDyeTechnicsSel.CDS_2 do
begin
self.DTMNo.Text := frmDyeTechnicsSel.CDS_2.fieldbyname('DTMNo').AsString;
self.DTMName.Text := frmDyeTechnicsSel.CDS_2.fieldbyname('DTMName').AsString;
self.DTMPrice.Text := frmDyeTechnicsSel.CDS_2.fieldbyname('DTMPrice').AsString;
end;
with frmDyeTechnicsSel.CDS_1 do
begin
First;
CDS_Glide.EmptyDataSet;
while not Eof do
begin
CDS_Glide.Append;
CDS_Glide.FieldByName('GlideNo').Value := CDS_Glide.RecordCount + 1;
CDS_Glide.FieldByName('GlideName').Value := frmDyeTechnicsSel.CDS_1.fieldbyname('PSName').AsString;
CDS_Glide.FieldByName('Note').Value := frmDyeTechnicsSel.CDS_1.fieldbyname('Note').AsString;
CDS_Glide.Post;
Next;
end;
end;
end;
free;
end;
end;
end.