442 lines
12 KiB
ObjectPascal
442 lines
12 KiB
ObjectPascal
unit U_WarpRollerRklist;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, ComCtrls, ToolWin, StdCtrls, ExtCtrls, cxStyles, cxCustomData,
|
||
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData,
|
||
cxButtonEdit, cxDropDownEdit, cxGridLevel, cxGridCustomTableView,
|
||
cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView,
|
||
cxGrid, DBClient, ADODB, cxGridCustomPopupMenu, cxGridPopupMenu, cxContainer,
|
||
cxTextEdit, cxCurrencyEdit, cxCheckBox, RM_System, RM_Dataset, RM_Common,
|
||
RM_Class, RM_GridReport, cxPC, Menus, RM_e_Xls, cxLookAndFeels,
|
||
cxLookAndFeelPainters, cxNavigator, dxSkinsCore, dxSkinsDefaultPainters,
|
||
dxSkinscxPCPainter, dxSkinBlack, dxSkinBlue, dxSkinBlueprint,
|
||
dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide,
|
||
dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
|
||
dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
|
||
dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis,
|
||
dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black,
|
||
dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
|
||
dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue,
|
||
dxSkinOffice2010Silver, dxSkinOffice2013DarkGray,
|
||
dxSkinOffice2013LightGray, dxSkinOffice2013White, dxSkinPumpkin,
|
||
dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus,
|
||
dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
|
||
dxSkinTheAsphaltWorld, dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint,
|
||
dxSkinXmas2008Blue;
|
||
|
||
type
|
||
TfrmWarpRollerRklist = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBFind: TToolButton;
|
||
TBAdd: TToolButton;
|
||
TBEdit: TToolButton;
|
||
TBDel: TToolButton;
|
||
TBExport: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
Label1: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
Label2: TLabel;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryTmp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
CDS_Main: TClientDataSet;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
ckName: TComboBox;
|
||
Label6: TLabel;
|
||
Label7: TLabel;
|
||
JZRKNo: TEdit;
|
||
gangNo: TEdit;
|
||
Label10: TLabel;
|
||
RMDB_Main: TRMDBDataSet;
|
||
ADOQueryPrint: TADOQuery;
|
||
RM1: TRMGridReport;
|
||
P_CODE: TEdit;
|
||
Label15: TLabel;
|
||
Label17: TLabel;
|
||
PCID: TEdit;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
N2: TMenuItem;
|
||
ToolButton1: TToolButton;
|
||
RMXLSExport1: TRMXLSExport;
|
||
ADOQueryMain: TADOQuery;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1Ssel: TcxGridDBColumn;
|
||
v1Column9: TcxGridDBColumn;
|
||
v1CRTime: TcxGridDBColumn;
|
||
v1Column8: TcxGridDBColumn;
|
||
v1Note: TcxGridDBColumn;
|
||
v1Column5: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
Tv1Column1: TcxGridDBColumn;
|
||
Tv1Column2: TcxGridDBColumn;
|
||
Tv1Column3: TcxGridDBColumn;
|
||
Tv1Column4: TcxGridDBColumn;
|
||
Tv1Column5: TcxGridDBColumn;
|
||
Tv1Column6: TcxGridDBColumn;
|
||
Tv1Column7: TcxGridDBColumn;
|
||
Tv1Column8: TcxGridDBColumn;
|
||
Tv1Column9: TcxGridDBColumn;
|
||
Tv1Column10: TcxGridDBColumn;
|
||
Label3: TLabel;
|
||
edtKaNo: TEdit;
|
||
Label4: TLabel;
|
||
APMachineNo: TEdit;
|
||
Tv1Column11: TcxGridDBColumn;
|
||
Label5: TLabel;
|
||
jcfactoryname: TEdit;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure TBAddClick(Sender: TObject);
|
||
procedure P_CodeNameChange(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBEditClick(Sender: TObject);
|
||
procedure TBDelClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure TBExportClick(Sender: TObject);
|
||
procedure TBFindClick(Sender: TObject);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
private
|
||
procedure InitGrid();
|
||
procedure SetStatus();
|
||
procedure InitForm();
|
||
{ Private declarations }
|
||
public
|
||
fCKName, canshu1: string;
|
||
fCRType: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmWarpRollerRklist: TfrmWarpRollerRklist;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_Fun10, U_Fun, U_ZDYHelp, U_WarpRollerRk, U_SXYLGS;
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmWarpRollerRklist.InitForm();
|
||
var
|
||
fsj: string;
|
||
begin
|
||
readCxGrid(self.Caption, Tv1, '<27>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD>');
|
||
SetStatus();
|
||
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.SetStatus();
|
||
begin
|
||
// TBEdit.Visible := False;
|
||
// TBDel.Visible := False;
|
||
// TBAdd.Visible := False;
|
||
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.InitGrid();
|
||
begin
|
||
|
||
try
|
||
with adoqueryMain do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add(' select A.* ,edtKaNo,C_TouWen,ZJPiLen,C_ShangPai,C_PiE,C_Len,APMachineNo,jcfactoryname ');
|
||
|
||
SQL.Add(',P_CODE=(select TOP 1 P_CODE from PD_Plan_SUB e where e.SUBID=(select TOP 1 SUBID from PD_Plan_Card_MS f where f.pcid=A.pcid))');
|
||
SQL.Add(',P_codeNAME=(select TOP 1 P_codeNAME from PD_Plan_SUB e where e.SUBID=(select TOP 1 SUBID from PD_Plan_Card_MS f where f.pcid=A.pcid))');
|
||
SQL.Add('from CK_WarpBeam_CR A LEFT JOIN PD_PLAN_cARD B ON A.PCID=B.PCID ');
|
||
sql.Add(' where A.CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
|
||
SQL.Add(' and A.CRTime>=' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime))));
|
||
SQL.Add(' and A.CRTime<' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', EndDate.DateTime + 1))));
|
||
SQL.Add(' and A.Valid =''Y'' ');
|
||
// ShowMessage(SQL.Text);
|
||
open;
|
||
end;
|
||
SCreateCDS20(adoqueryMain, CDS_Main);
|
||
SInitCDSData20(adoqueryMain, CDS_Main);
|
||
finally
|
||
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action := cafree;
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmWarpRollerRklist := nil;
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.TBAddClick(Sender: TObject);
|
||
begin
|
||
frmWarpRollerRk := TfrmWarpRollerRk.create(self);
|
||
with frmWarpRollerRk do
|
||
begin
|
||
fkeyNo := '';
|
||
fType := 0;
|
||
if showmodal = 1 then
|
||
begin
|
||
TBRafresh.Click;
|
||
self.CDS_Main.Locate('JZRKID', trim(fkeyNo), []);
|
||
end;
|
||
free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.P_CodeNameChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS20(ADOQueryMain, CDS_Main);
|
||
SInitCDSData20(ADOQueryMain, CDS_Main);
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.FormShow(Sender: TObject);
|
||
begin
|
||
InitForm();
|
||
// InitGrid();
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.FormCreate(Sender: TObject);
|
||
begin
|
||
EndDate.Date := SGetServerDate10(ADOQueryTmp);
|
||
BegDate.Date := EndDate.Date;
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.TBCloseClick(Sender: TObject);
|
||
begin
|
||
writeCxGrid(self.Caption, Tv1, '<27>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD>');
|
||
close;
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.TBEditClick(Sender: TObject);
|
||
var
|
||
WSql: string;
|
||
begin
|
||
if cds_main.IsEmpty then
|
||
exit;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.* from CK_WarpBeam_CR A');
|
||
SQL.Add('where A.KCID=''' + trim(cds_main.fieldbyname('KCID').AsString) + ''' ');
|
||
SQL.Add('and A.CRFLAG=''<27><><EFBFBD><EFBFBD>'' and A.valid=''Y'' ');
|
||
Open;
|
||
end;
|
||
if not ADOQueryCmd.IsEmpty then
|
||
begin
|
||
Application.MessageBox('<27>˵<EFBFBD><CBB5>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⣬<EFBFBD><E2A3AC><EFBFBD><EFBFBD><EFBFBD>ģ<DEB8>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
|
||
WSql := '';
|
||
CDS_Main.DisableControls;
|
||
with CDS_Main do
|
||
begin
|
||
First;
|
||
while CDS_Main.Locate('SSel', True, []) do
|
||
begin
|
||
if WSql <> '' then
|
||
WSql := WSql + '' + ',' + QuotedStr(Trim(CDS_Main.fieldbyname('JZRKID').AsString))
|
||
else
|
||
WSql := ' in (' + QuotedStr(Trim(CDS_Main.fieldbyname('JZRKID').AsString));
|
||
Edit;
|
||
FieldByName('SSel').Value := False;
|
||
Post;
|
||
end;
|
||
end;
|
||
CDS_Main.EnableControls;
|
||
WSql := WSql + ')';
|
||
|
||
frmWarpRollerRk := TfrmWarpRollerRk.create(self);
|
||
with frmWarpRollerRk do
|
||
begin
|
||
fkeyNo := WSql;
|
||
fType := 1;
|
||
if showmodal = 1 then
|
||
begin
|
||
TBRafresh.Click;
|
||
self.CDS_Main.Locate('JZRKID', trim(fkeyNo), []);
|
||
end;
|
||
free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.TBDelClick(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then
|
||
Exit;
|
||
if CDS_Main.IsEmpty then
|
||
Exit;
|
||
// if Trim(CDS_Main.fieldbyname('Filler').AsString) <> Trim(DName) then
|
||
// begin
|
||
// Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
// Exit;
|
||
// end;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
||
Exit;
|
||
try
|
||
if Trim(CDS_Main.FieldByName('JZRKID').AsString) <> '' then
|
||
begin
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with CDS_Main do
|
||
begin
|
||
while CDS_Main.Locate('SSel', True, []) = True do
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('update CK_WarpBeam_CR set Valid=''N'' where JZRKID=' + quotedstr(Trim(CDS_Main.FieldByName('JZRKID').AsString)));
|
||
ExecSQL;
|
||
end;
|
||
|
||
CDS_Main.Edit;
|
||
CDS_Main.FieldByName('SSel').Value := False;
|
||
CDS_Main.Post;
|
||
Next;
|
||
end;
|
||
end;
|
||
|
||
|
||
// with ADOQueryCmd do
|
||
// begin
|
||
// Close;
|
||
// SQL.Clear;
|
||
// SQL.Add('exec P_Up_WarpRoller ' + quotedstr(Trim(CDS_Main.FieldByName('KCID').AsString)));
|
||
// Open;
|
||
// end;
|
||
// if Trim(ADOQueryCmd.FieldByName('Msg').AsString) = '<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>' then
|
||
// begin
|
||
// ADOQueryCmd.Connection.RollbackTrans;
|
||
// Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
// Exit;
|
||
// end;
|
||
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
CDS_Main.Delete;
|
||
TBRafresh.Click;
|
||
end;
|
||
except
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
initGrid();
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.TBExportClick(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then
|
||
Exit;
|
||
TcxGridToExcel(self.Caption, cxgrid1);
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.TBFindClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS20(ADOQueryMain, CDS_Main);
|
||
SInitCDSData20(ADOQueryMain, CDS_Main);
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.N1Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main, True);
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.N2Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main, False);
|
||
end;
|
||
|
||
procedure TfrmWarpRollerRklist.ToolButton1Click(Sender: TObject);
|
||
var
|
||
fPrintFile, FFCYID, FKCID: string;
|
||
DPS, i, j: Integer;
|
||
Txt, fImagePath: string;
|
||
Moudle: THandle;
|
||
Makebar: TMakebar;
|
||
Mixtext: TMixtext;
|
||
begin
|
||
if CDS_Main.IsEmpty then
|
||
Exit;
|
||
|
||
ExportFtErpFile('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩ.rmf', ADOQueryTmp);
|
||
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩ.rmf';
|
||
CDS_Main.DisableControls;
|
||
|
||
while CDS_Main.locate('ssel', True, []) do
|
||
begin
|
||
FKCID := Trim(CDS_Main.fieldbyname('KCID').AsString);
|
||
try
|
||
Moudle := LoadLibrary('MakeQRBarcode.dll');
|
||
@Makebar := GetProcAddress(Moudle, 'Make');
|
||
@Mixtext := GetProcAddress(Moudle, 'MixText');
|
||
Txt := FKCID;
|
||
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
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
CDS_Main.EnableControls;
|
||
exit;
|
||
end;
|
||
with ADOQueryPrint do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select A.* from CK_WarpRoller_CR A');
|
||
sql.Add(' where A.CRFlag=''<27><><EFBFBD><EFBFBD>'' and A.Valid=''Y'' ');
|
||
sql.Add(' and A.KCID= ' + quotedstr(Trim(FKCID)));
|
||
open;
|
||
end;
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
RMVariables['QRBARCODE'] := fImagePath;
|
||
RM1.ShowPrintDialog := False;
|
||
RM1.LoadFromFile(fPrintFile);
|
||
RM1.PrintReport;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
|
||
CDS_Main.EnableControls;
|
||
Exit;
|
||
end;
|
||
with CDS_Main do
|
||
begin
|
||
edit;
|
||
fieldbyname('SSEL').value := False;
|
||
post;
|
||
end;
|
||
end;
|
||
CDS_Main.EnableControls;
|
||
end;
|
||
|
||
end.
|
||
|