363 lines
8.9 KiB
ObjectPascal
363 lines
8.9 KiB
ObjectPascal
unit U_YarnRackWeighing;
|
||
|
||
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, cxPC, cxCheckComboBox, cxDropDownEdit, Menus, RM_e_Xls,
|
||
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, Buttons, dxSkinsCore,
|
||
dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, U_BaseList;
|
||
|
||
type
|
||
TfrmYarnRackWeighing = class(TFrmBaseList)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBClose: TToolButton;
|
||
ADOQueryTemp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
RM1: TRMGridReport;
|
||
RMDB_Main: TRMDBDataSet;
|
||
cxGrid2: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
cxGridLevel1: TcxGridLevel;
|
||
cxGridPopupMenu2: TcxGridPopupMenu;
|
||
DS_HZ: TDataSource;
|
||
CDS_HZ: TClientDataSet;
|
||
RMXLSExport2: TRMXLSExport;
|
||
v2Column8: TcxGridDBColumn;
|
||
v2Column12: TcxGridDBColumn;
|
||
ADOQueryPrt: TADOQuery;
|
||
Panel10: TPanel;
|
||
Panel7: TPanel;
|
||
SpeedButton1: TSpeedButton;
|
||
SpeedButton2: TSpeedButton;
|
||
SpeedButton3: TSpeedButton;
|
||
SpeedButton4: TSpeedButton;
|
||
SpeedButton5: TSpeedButton;
|
||
SpeedButton6: TSpeedButton;
|
||
SpeedButton7: TSpeedButton;
|
||
SpeedButton8: TSpeedButton;
|
||
SpeedButton9: TSpeedButton;
|
||
SpeedButton10: TSpeedButton;
|
||
SpeedButton11: TSpeedButton;
|
||
SpeedButton12: TSpeedButton;
|
||
Label5: TLabel;
|
||
Label6: TLabel;
|
||
YRNo: TEdit;
|
||
YRWeight: TEdit;
|
||
Button3: TButton;
|
||
ToolButton1: TToolButton;
|
||
Tv2Column1: TcxGridDBColumn;
|
||
Label1: TLabel;
|
||
YRType: TComboBox;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure Tv2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||
procedure SpeedButton1Click(Sender: TObject);
|
||
procedure SpeedButton12Click(Sender: TObject);
|
||
procedure YRNoClick(Sender: TObject);
|
||
procedure Button3Click(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
procedure PrintReport(FZDYNo: string);
|
||
procedure InitGrid();
|
||
public
|
||
fFlag: integer;
|
||
{ Public declarations }
|
||
RKFlag, FCYID, fmanage: string;
|
||
end;
|
||
|
||
var
|
||
frmYarnRackWeighing: TfrmYarnRackWeighing;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmYarnRackWeighing.PrintReport(FZDYNo: string);
|
||
var
|
||
fPrintFile: string;
|
||
begin
|
||
if CDS_HZ.IsEmpty then
|
||
Exit;
|
||
ExportFtErpFile('ɴ<>ܱ<EFBFBD>ǩ.rmf', ADOQueryTemp);
|
||
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\ɴ<>ܱ<EFBFBD>ǩ.rmf';
|
||
with ADOQueryPrt do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add(' select * from YE_YarnRack where YRNo=''' + Trim(FZDYNo) + '''');
|
||
open;
|
||
end;
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
RM1.LoadFromFile(fPrintFile);
|
||
RM1.PrintReport;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + fPrintFile + '!'), '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select A.* from YE_YarnRack A order by YRNO ');
|
||
Open;
|
||
end;
|
||
SCreateCDS(ADOQueryMain, CDS_HZ);
|
||
SInitCDSData(ADOQueryMain, CDS_HZ);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.FormDestroy(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
frmYarnRackWeighing := nil;
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(Trim(Self.Caption), Tv2, '<27><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>');
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
ReadCxGrid(Trim(Self.Caption), Tv2, '<27><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>');
|
||
// Enddate.DateTime:=SGetServerDate(ADOQueryTemp);
|
||
// begdate.DateTime:=Enddate.DateTime-30;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
InitGrid;
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.N1Click(Sender: TObject);
|
||
begin
|
||
if CDS_HZ.IsEmpty then
|
||
exit;
|
||
with CDS_HZ do
|
||
begin
|
||
DisableControls;
|
||
first;
|
||
while not eof do
|
||
begin
|
||
edit;
|
||
fieldbyname('ssel').Value := true;
|
||
post;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.N2Click(Sender: TObject);
|
||
begin
|
||
if CDS_HZ.IsEmpty then
|
||
exit;
|
||
with CDS_HZ do
|
||
begin
|
||
DisableControls;
|
||
first;
|
||
while not eof do
|
||
begin
|
||
edit;
|
||
fieldbyname('ssel').Value := false;
|
||
post;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.FormCreate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
fmanage := Trim(DParameters1);
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.Tv2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||
var
|
||
i: Integer;
|
||
begin
|
||
if not CDS_HZ.fieldbyname('EditFlag').AsBoolean then
|
||
begin
|
||
for i := 0 to tv2.ColumnCount - 1 do
|
||
begin
|
||
if uppercase(tv2.Columns[i].DataBinding.FieldName) <> 'SSEL' then
|
||
tv2.Columns[i].Options.Editing := false;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
for i := 0 to tv2.ColumnCount - 1 do
|
||
begin
|
||
if uppercase(tv2.Columns[i].DataBinding.FieldName) <> 'SSEL' then
|
||
tv2.Columns[i].Options.Editing := True;
|
||
end
|
||
end;
|
||
|
||
v2Column8.Options.Editing := True;
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.SpeedButton1Click(Sender: TObject);
|
||
var
|
||
fsj: string;
|
||
begin
|
||
fsj := Trim(TSpeedButton(Sender).Hint);
|
||
if Trim(fsj) = '' then
|
||
Exit;
|
||
fsj := Trim(TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text);
|
||
TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text := fsj + Trim(TSpeedButton(Sender).Caption);
|
||
TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).SelectAll;
|
||
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.SpeedButton12Click(Sender: TObject);
|
||
var
|
||
fsj: string;
|
||
begin
|
||
fsj := Trim(TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text);
|
||
if Trim(fsj) = '' then
|
||
Exit;
|
||
TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text := Copy(fsj, 1, Length(fsj) - 1);
|
||
TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).SelectAll;
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.YRNoClick(Sender: TObject);
|
||
var
|
||
i: Integer;
|
||
begin
|
||
with Panel7 do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TSpeedButton then
|
||
begin
|
||
TSpeedButton(Controls[i]).Hint := Trim(TEdit(Sender).Name);
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.Button3Click(Sender: TObject);
|
||
var
|
||
FReal: Double;
|
||
maxId: string;
|
||
begin
|
||
|
||
if Trim(YRNo.Text) = '' then
|
||
begin
|
||
Application.MessageBox('˿<>ܺŲ<DCBA><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ', 0);
|
||
exit;
|
||
end;
|
||
if Length(YRNo.Text) <> 3 then
|
||
begin
|
||
Application.MessageBox('˿<>ܺ<EFBFBD>Ϊ<EFBFBD><CEAA>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>', '<27><>ʾ', 0);
|
||
exit;
|
||
end;
|
||
if Trim(YRType.Text) = '' then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ', 0);
|
||
exit;
|
||
end;
|
||
|
||
if Trim(YRWeight.Text) = '' then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
if TryStrToFloat(YRWeight.Text, FReal) = False then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>֣<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YE_YarnRack ');
|
||
sql.Add(' where YRNo=' + QuotedStr(YRNo.Text));
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
if ADOQueryCmd.IsEmpty then
|
||
begin
|
||
if GetLSNo(ADOQueryTemp, maxId, 'M', 'YE_YarnRack', 4, 1) = False then
|
||
begin
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
Append;
|
||
FieldByName('YRId').Value := maxId;
|
||
FieldByName('Filler').Value := dname;
|
||
FieldByName('YRNo').Value := YRNo.Text;
|
||
FieldByName('YRType').Value := YRType.Text;
|
||
end
|
||
else
|
||
begin
|
||
Edit
|
||
end;
|
||
FieldByName('YRWeight').Value := YRWeight.Text;
|
||
Post;
|
||
end;
|
||
|
||
PrintReport(Trim(YRNo.Text));
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmYarnRackWeighing.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
PrintReport(Trim(CDS_HZ.FieldByName('YRNo').AsString));
|
||
end;
|
||
|
||
end.
|
||
|