RTFormwork/项目代码/RTBasicsV1/C01纱线加弹计划/U_YarnRack.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

446 lines
12 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_YarnRack;
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, dxSkinsCore,
dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, U_BaseList;
type
TfrmYarnRack = class(TFrmBaseList)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBClose: TToolButton;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
ToolButton2: TToolButton;
ADOQueryMain: TADOQuery;
ToolButton1: TToolButton;
RM1: TRMGridReport;
RMDB_Main: TRMDBDataSet;
cxGrid2: TcxGrid;
Tv2: TcxGridDBTableView;
cxGridLevel1: TcxGridLevel;
cxGridPopupMenu2: TcxGridPopupMenu;
DS_HZ: TDataSource;
CDS_HZ: TClientDataSet;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
Panel1: TPanel;
MachNo: TEdit;
RMXLSExport2: TRMXLSExport;
v2Column8: TcxGridDBColumn;
Label1: TLabel;
v2Column12: TcxGridDBColumn;
ToolButton3: TToolButton;
ADOQueryPrt: TADOQuery;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
Tv2Column1: TcxGridDBColumn;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure cxTabControl1Change(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure CustomerChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure v2Column8PropertiesEditValueChanged(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure Tv2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure v2Column12PropertiesEditValueChanged(Sender: TObject);
procedure Tv2Column1PropertiesEditValueChanged(Sender: TObject);
private
{ Private declarations }
procedure PrintReport(FZDYNo: string);
procedure InitGrid();
public
fFlag: integer;
{ Public declarations }
RKFlag, FCYID, fmanage: string;
end;
var
frmYarnRack: TfrmYarnRack;
implementation
uses
U_DataLink, U_RTFun, U_ZDYHelp;
{$R *.dfm}
procedure TfrmYarnRack.PrintReport(FZDYNo: string);
var
fPrintFile, FFCYID: string;
i, j: Integer;
Txt, fImagePath: string;
Moudle: THandle;
Makebar: TMakebar;
Mixtext: TMixtext;
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 YRId=''' + Trim(FZDYNo) + '''');
open;
end;
try
Moudle := LoadLibrary('MakeQRBarcode.dll');
@Makebar := GetProcAddress(Moudle, 'Make');
@Mixtext := GetProcAddress(Moudle, 'MixText');
// Txt := Trim(FZDYNo);
Txt := Trim(ADOQueryPrt.fieldbyname('YRNO').AsString);
fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
if FileExists(fImagePath) then
DeleteFile(fImagePath);
Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
except
CDS_HZ.EnableControls;
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
exit;
end;
RMVariables['QRBARCODE'] := fImagePath;
if FileExists(fPrintFile) then
begin
RM1.LoadFromFile(fPrintFile);
RM1.PrintReport;
// RM1.ShowReport;
end
else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>' + fPrintFile + '!'), '<27><>ʾ', 0);
Exit;
end;
end;
procedure TfrmYarnRack.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;
ToolButton2.Click;
end;
end;
procedure TfrmYarnRack.FormDestroy(Sender: TObject);
begin
inherited;
frmYarnRack := nil;
end;
procedure TfrmYarnRack.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
end;
procedure TfrmYarnRack.TBCloseClick(Sender: TObject);
begin
WriteCxGrid(Trim(Self.Caption), Tv2, '<27><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>');
Close;
end;
procedure TfrmYarnRack.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 TfrmYarnRack.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmYarnRack.ToolButton2Click(Sender: TObject);
var
sql: string;
begin
if ADOQueryMain.Active then
begin
sql := SGetFilters(Panel1, 1, 2);
SDofilter(ADOQueryMain, sql);
SCreateCDS(ADOQueryMain, CDS_HZ);
SInitCDSData(ADOQueryMain, CDS_HZ);
end;
end;
procedure TfrmYarnRack.ToolButton1Click(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then
Exit;
TcxGridToExcel(self.Caption, cxgrid2);
end;
procedure TfrmYarnRack.cxTabControl1Change(Sender: TObject);
begin
InitGrid;
end;
procedure TfrmYarnRack.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 TfrmYarnRack.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 TfrmYarnRack.CustomerChange(Sender: TObject);
begin
ToolButton2.Click;
end;
procedure TfrmYarnRack.FormCreate(Sender: TObject);
begin
inherited;
fmanage := Trim(DParameters1);
end;
procedure TfrmYarnRack.v2Column8PropertiesEditValueChanged(Sender: TObject);
var
mvalue, FFieldName: string;
begin
mvalue := TcxTextEdit(Sender).EditingText;
FFieldName := Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
try
ADOQueryCmd.Connection.BeginTrans;
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value := Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YE_YarnRack ');
sql.Add(' Set ' + FFieldName + '=' + Trim(mvalue));
sql.Add(' , Editer=''' + Trim(DName) + '''');
sql.Add(' , Edittime=getdate()');
sql.Add(' where YRId=' + quotedstr(CDS_HZ.fieldbyname('YRId').AsString));
ExecSQL;
end;
ADOQueryCmd.Connection.CommitTrans;
tv2.Controller.EditingController.ShowEdit();
except
tv2.Controller.EditingController.ShowEdit();
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
end
end;
procedure TfrmYarnRack.ToolButton3Click(Sender: TObject);
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('update YE_YarnRack set EditFlag=0 where YRId=' + QuotedStr(CDS_HZ.FieldByName('YRId').AsString));
ExecSQL;
end;
PrintReport(Trim(CDS_HZ.fieldbyname('YRId').AsString));
end;
procedure TfrmYarnRack.ToolButton4Click(Sender: TObject);
var
maxId: string;
begin
MachNo.SetFocus;
if GetLSNo(ADOQueryCmd, maxId, 'M', 'YE_YarnRack', 4, 1) = False then
begin
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('insert into YE_YarnRack(YRId,Filler) values(' + quotedstr(Trim(maxId)) + ',' + quotedstr(Trim(dname)) + ')');
ExecSQL;
end;
InitGrid();
end;
procedure TfrmYarnRack.ToolButton5Click(Sender: TObject);
begin
if CDS_HZ.IsEmpty then
Exit;
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('delete YE_YarnRack where YRId=' + QuotedStr(CDS_HZ.FieldByName('YRId').AsString));
ExecSQL;
end;
CDS_HZ.Delete;
end;
procedure TfrmYarnRack.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 TfrmYarnRack.v2Column12PropertiesEditValueChanged(Sender: TObject);
var
mvalue, FFieldName: string;
begin
mvalue := TcxTextEdit(Sender).EditingText;
FFieldName := Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
try
ADOQueryCmd.Connection.BeginTrans;
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value := Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YE_YarnRack ');
sql.Add(' Set ' + FFieldName + '=''' + Trim(mvalue) + '''');
sql.Add(' , Editer=''' + Trim(DName) + '''');
sql.Add(' , Edittime=getdate()');
sql.Add(' where YRId=' + quotedstr(CDS_HZ.fieldbyname('YRId').AsString));
ExecSQL;
end;
ADOQueryCmd.Connection.CommitTrans;
tv2.Controller.EditingController.ShowEdit();
except
tv2.Controller.EditingController.ShowEdit();
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
end
end;
procedure TfrmYarnRack.Tv2Column1PropertiesEditValueChanged(Sender: TObject);
var
mvalue, FFieldName: string;
begin
mvalue := TcxTextEdit(Sender).EditingText;
FFieldName := Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
try
ADOQueryCmd.Connection.BeginTrans;
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value := Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YE_YarnRack ');
sql.Add(' Set ' + FFieldName + '=''' + Trim(mvalue) + '''');
sql.Add(' , Editer=''' + Trim(DName) + '''');
sql.Add(' , Edittime=getdate()');
sql.Add(' where YRId=' + quotedstr(CDS_HZ.fieldbyname('YRId').AsString));
// ShowMessage(sql.Text);
ExecSQL;
end;
ADOQueryCmd.Connection.CommitTrans;
tv2.Controller.EditingController.ShowEdit();
except
tv2.Controller.EditingController.ShowEdit();
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
end
end;
end.