318 lines
8.7 KiB
ObjectPascal
318 lines
8.7 KiB
ObjectPascal
unit U_WarpRollerCklist;
|
||
|
||
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, RM_Common,
|
||
RM_Class, RM_e_Xls, RM_GridReport, RM_System, RM_Dataset, cxTextEdit, cxPC,
|
||
cxCheckBox, Menus, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator;
|
||
|
||
type
|
||
TfrmWarpRollerCklist = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBAdd: TToolButton;
|
||
TBEdit: TToolButton;
|
||
TBDel: TToolButton;
|
||
TBExport: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
Label1: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1Note: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
v1CRType: TcxGridDBColumn;
|
||
v1CRTime: TcxGridDBColumn;
|
||
v1CRNO: TcxGridDBColumn;
|
||
v1Filler: TcxGridDBColumn;
|
||
v1FillTime: TcxGridDBColumn;
|
||
Label2: TLabel;
|
||
CRType: TComboBox;
|
||
Label5: TLabel;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryTmp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
CDS_Main: TClientDataSet;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
ADOPrint: TADOQuery;
|
||
RMXLSExport1: TRMXLSExport;
|
||
v1P_Code: TcxGridDBColumn;
|
||
JZRKNo: TEdit;
|
||
Label7: TLabel;
|
||
v1custName: TcxGridDBColumn;
|
||
RMDB_Main: TRMDBDataSet;
|
||
cxStyleRepository1: TcxStyleRepository;
|
||
cxStyle1: TcxStyle;
|
||
cxStyle2: TcxStyle;
|
||
cxStyle_gridRow: TcxStyle;
|
||
cxStyle_gridFoot: TcxStyle;
|
||
cxStyle_gridHead: TcxStyle;
|
||
cxStyle_gridGroupBox: TcxStyle;
|
||
cxStyle_yellow: TcxStyle;
|
||
cxStyle_Red: TcxStyle;
|
||
cxStyle_fontBlack: TcxStyle;
|
||
cxStyle_fontclFuchsia: TcxStyle;
|
||
cxStyle_fontclPurple: TcxStyle;
|
||
cxStyle_fontclGreen: TcxStyle;
|
||
cxStyle_fontclBlue: TcxStyle;
|
||
cxStyle_fontclTeal: TcxStyle;
|
||
cxStyle_fontclOlive: TcxStyle;
|
||
Label8: TLabel;
|
||
ToFactoryName: TEdit;
|
||
ADOQueryMain: TADOQuery;
|
||
RM1: TRMGridReport;
|
||
v1Column5: TcxGridDBColumn;
|
||
WBCode: TEdit;
|
||
Label14: TLabel;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
N2: TMenuItem;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure TBAddClick(Sender: TObject);
|
||
procedure OrderNoChange(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 v1Column6CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
private
|
||
procedure InitGrid();
|
||
procedure InitForm();
|
||
{ Private declarations }
|
||
public
|
||
canshu1, canshu2: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmWarpRollerCklist: TfrmWarpRollerCklist;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_Fun10, U_ZDYHelp, U_WarpRollerCk;
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmWarpRollerCklist.InitForm();
|
||
var
|
||
fsj: string;
|
||
begin
|
||
readCxGrid(self.Caption, Tv1, '<27>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD>');
|
||
fsj := 'select distinct(CRType) name from CK_WarpBeam_CR where CRFlag=''<27><><EFBFBD><EFBFBD>'' ';
|
||
SInitComBoxBySql(ADOQueryCmd, CRType, False, fsj);
|
||
end;
|
||
|
||
|
||
procedure TfrmWarpRollerCklist.InitGrid();
|
||
begin
|
||
try
|
||
with adoqueryMain do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add(' select A.* from CK_WarpBeam_CR A ');
|
||
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''');
|
||
|
||
open;
|
||
end;
|
||
SCreateCDS20(adoqueryMain, CDS_Main);
|
||
SInitCDSData20(adoqueryMain, CDS_Main);
|
||
finally
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmWarpRollerCklist.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action := cafree;
|
||
end;
|
||
|
||
procedure TfrmWarpRollerCklist.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmWarpRollerCklist := nil;
|
||
end;
|
||
|
||
procedure TfrmWarpRollerCklist.TBAddClick(Sender: TObject);
|
||
begin
|
||
frmWarpRollerCk := TfrmWarpRollerCk.create(self);
|
||
with frmWarpRollerCk do
|
||
begin
|
||
fkeyNo := '';
|
||
fType := 0;
|
||
if showmodal = 1 then
|
||
begin
|
||
TBRafresh.Click;
|
||
self.CDS_Main.Locate('crNo', trim(fkeyNo), []);
|
||
end;
|
||
free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmWarpRollerCklist.OrderNoChange(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 TfrmWarpRollerCklist.FormShow(Sender: TObject);
|
||
begin
|
||
InitForm();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmWarpRollerCklist.FormCreate(Sender: TObject);
|
||
begin
|
||
EndDate.Date := SGetServerDate10(ADOQueryTmp);
|
||
BegDate.Date := EndDate.Date;
|
||
cxGrid1.Align := alclient;
|
||
canshu1 := trim(DParameters1);
|
||
end;
|
||
|
||
procedure TfrmWarpRollerCklist.TBCloseClick(Sender: TObject);
|
||
begin
|
||
writeCxGrid(self.Caption, Tv1, '<27>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD>');
|
||
close;
|
||
end;
|
||
|
||
procedure TfrmWarpRollerCklist.TBEditClick(Sender: TObject);
|
||
var WSql : string;
|
||
begin
|
||
if cds_main.IsEmpty then
|
||
exit;
|
||
|
||
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+')';
|
||
|
||
frmWarpRollerCk := TfrmWarpRollerCk.create(self);
|
||
with frmWarpRollerCk do
|
||
begin
|
||
fkeyNo := WSql;
|
||
fType := 1;
|
||
JZRKNo.Enabled := false;
|
||
if showmodal = 1 then
|
||
begin
|
||
TBRafresh.Click;
|
||
self.CDS_Main.Locate('JZRKID', trim(fkeyNo), []);
|
||
end;
|
||
free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmWarpRollerCklist.TBDelClick(Sender: TObject);
|
||
var
|
||
YFID, CRID, note: string;
|
||
begin
|
||
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 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;
|
||
// 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
|
||
// CDS_Main.EnableControls;
|
||
// 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;
|
||
end;
|
||
except
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmWarpRollerCklist.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
initGrid();
|
||
end;
|
||
|
||
procedure TfrmWarpRollerCklist.TBExportClick(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then
|
||
Exit;
|
||
TcxGridToExcel(self.Caption, cxgrid1);
|
||
end;
|
||
|
||
procedure TfrmWarpRollerCklist.v1Column6CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
|
||
var
|
||
colIdx0, colIdx1: integer;
|
||
begin
|
||
colIdx0 := tv1.GetColumnByFieldName('CRNO').Index;
|
||
if (ARow1.Values[colIdx0] = ARow2.Values[colIdx0]) then
|
||
AAreEqual := True
|
||
else
|
||
AAreEqual := False;
|
||
|
||
end;
|
||
|
||
procedure TfrmWarpRollerCklist.N1Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main, True);
|
||
end;
|
||
|
||
procedure TfrmWarpRollerCklist.N2Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main, False);
|
||
end;
|
||
|
||
end.
|
||
|