394 lines
11 KiB
ObjectPascal
394 lines
11 KiB
ObjectPascal
![]() |
unit U_KnitPlanCardOFF;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
|
|||
|
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
|
|||
|
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses, cxControls,
|
|||
|
cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
|||
|
cxGrid, DBClient, cxCalendar, cxButtonEdit, cxSplitter, RM_Common, RM_Class,
|
|||
|
RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, cxTextEdit, cxCheckBox,
|
|||
|
BtnEdit, RM_BarCode, cxPC, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator,
|
|||
|
dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu,
|
|||
|
U_BaseList, Vcl.Menus, dxSkinBasic, 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, dxSkinOffice2016Colorful, dxSkinOffice2016Dark,
|
|||
|
dxSkinOffice2019Black, dxSkinOffice2019Colorful, dxSkinOffice2019DarkGray,
|
|||
|
dxSkinOffice2019White, dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic,
|
|||
|
dxSkinSharp, dxSkinSharpPlus, dxSkinSilver, dxSkinSpringtime, dxSkinStardust,
|
|||
|
dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinTheBezier, dxSkinValentine,
|
|||
|
dxSkinVisualStudio2013Blue, dxSkinVisualStudio2013Dark,
|
|||
|
dxSkinVisualStudio2013Light, dxSkinVS2010, dxSkinWhiteprint, dxSkinWXI,
|
|||
|
dxSkinXmas2008Blue, dxScrollbarAnnotations;
|
|||
|
|
|||
|
type
|
|||
|
TfrmKnitPlanCardOFF = class(TfrmBaseList)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBRafresh: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
Panel1: TPanel;
|
|||
|
GPM_1: TcxGridPopupMenu;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
Label3: TLabel;
|
|||
|
ConNo: TEdit;
|
|||
|
ADOQueryPrint: TADOQuery;
|
|||
|
CarNo: TEdit;
|
|||
|
Label1: TLabel;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
cxGridLevel2: TcxGridLevel;
|
|||
|
v3Column1: TcxGridDBColumn;
|
|||
|
v3Column2: TcxGridDBColumn;
|
|||
|
Label2: TLabel;
|
|||
|
C_Name: TEdit;
|
|||
|
DS_1: TDataSource;
|
|||
|
CDS_1: TClientDataSet;
|
|||
|
Label4: TLabel;
|
|||
|
C_Code: TEdit;
|
|||
|
v3Column6: TcxGridDBColumn;
|
|||
|
v3Column8: TcxGridDBColumn;
|
|||
|
v3Column14: TcxGridDBColumn;
|
|||
|
v3Column15: TcxGridDBColumn;
|
|||
|
v3Column16: TcxGridDBColumn;
|
|||
|
cxTabControl1: TcxTabControl;
|
|||
|
Tv1Column1: TcxGridDBColumn;
|
|||
|
Tv1Column2: TcxGridDBColumn;
|
|||
|
Tv1Column3: TcxGridDBColumn;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
ToolButton2: TToolButton;
|
|||
|
Tv1Column7: TcxGridDBColumn;
|
|||
|
Tv1Column8: TcxGridDBColumn;
|
|||
|
Label5: TLabel;
|
|||
|
OrderNo: TEdit;
|
|||
|
Tv1Column9: TcxGridDBColumn;
|
|||
|
Label6: TLabel;
|
|||
|
BatchNo: TEdit;
|
|||
|
PopupMenu1: TPopupMenu;
|
|||
|
N1: TMenuItem;
|
|||
|
N2: TMenuItem;
|
|||
|
Tv1Column10: TcxGridDBColumn;
|
|||
|
Tv1Column11: TcxGridDBColumn;
|
|||
|
Tv1Column12: TcxGridDBColumn;
|
|||
|
Tv1Column13: TcxGridDBColumn;
|
|||
|
Tv1Column14: TcxGridDBColumn;
|
|||
|
Tv1Column15: TcxGridDBColumn;
|
|||
|
Tv1Column16: TcxGridDBColumn;
|
|||
|
Tv1Column17: TcxGridDBColumn;
|
|||
|
Tv1Column18: TcxGridDBColumn;
|
|||
|
Tv1Column19: TcxGridDBColumn;
|
|||
|
Tv1Column20: TcxGridDBColumn;
|
|||
|
Tv1Column21: TcxGridDBColumn;
|
|||
|
Label7: TLabel;
|
|||
|
Label8: TLabel;
|
|||
|
BegDate: TDateTimePicker;
|
|||
|
EndDate: TDateTimePicker;
|
|||
|
ToolButton3: TToolButton;
|
|||
|
Tv1Column4: TcxGridDBColumn;
|
|||
|
Tv1Column5: TcxGridDBColumn;
|
|||
|
ToolButton4: TToolButton;
|
|||
|
ToolButton5: TToolButton;
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
procedure TBRafreshClick(Sender: TObject);
|
|||
|
procedure ConNoChange(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure cxTabControl1Change(Sender: TObject);
|
|||
|
procedure ToolButton2Click(Sender: TObject);
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
procedure N1Click(Sender: TObject);
|
|||
|
procedure N2Click(Sender: TObject);
|
|||
|
procedure ToolButton3Click(Sender: TObject);
|
|||
|
procedure ToolButton4Click(Sender: TObject);
|
|||
|
procedure ToolButton5Click(Sender: TObject);
|
|||
|
|
|||
|
private
|
|||
|
FInt, PFInt: Integer;
|
|||
|
FFMainID, BPFlag, FFPCID: string;
|
|||
|
procedure InitGrid();
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
canshu1: string;
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_RTFun, U_ZDYHelp, U_LabelPrint;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmKnitPlanCardOFF.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
Action := caFree;
|
|||
|
WriteCxGrid('DCG13', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmKnitPlanCardOFF.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
Close;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmKnitPlanCardOFF.InitGrid();
|
|||
|
begin
|
|||
|
FFMainID := '';
|
|||
|
try
|
|||
|
ADOQueryMain.DisableControls;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select isnull(IsOffMachine,''<27><>'') AS IsOffMachine ');
|
|||
|
sql.Add(' ,A.*,C.*,D.*,ISJY=cast(A.Status AS bit)');
|
|||
|
sql.Add(' from Knit_Plan_Card A ');
|
|||
|
sql.Add(' inner join knit_Plan_Sub C on A.SubId=C.SubId');
|
|||
|
sql.Add(' inner join knit_Plan_Main D on A.MainId=D.MainId');
|
|||
|
sql.Add(' where 1=1 AND ISNULL(IsOffMachine,''<27><>'')=''<27><>'' '); //A.Status = ''0''
|
|||
|
sql.Add(' and A.offTIme>=''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)) + '''');
|
|||
|
sql.Add(' and A.offTIme<''' + Trim(FormatDateTime('yyyy-MM-dd', EndDate.DateTime + 1)) + '''');
|
|||
|
|
|||
|
// case cxTabControl1.TabIndex of
|
|||
|
// 0:
|
|||
|
// begin
|
|||
|
// sql.Add(' and PRTCount=0');
|
|||
|
// sql.Add(' Order by A.Filltime Desc');
|
|||
|
// end;
|
|||
|
// 1:
|
|||
|
// begin
|
|||
|
// sql.Add(' and PRTCount>0');
|
|||
|
// sql.Add(' Order by A.PRTDate Desc');
|
|||
|
// end;
|
|||
|
// 2:
|
|||
|
// begin
|
|||
|
// sql.Add(' Order by A.PRTDate Desc,A.Filltime Desc');
|
|||
|
// end;
|
|||
|
// end;
|
|||
|
// ShowMessage(sql.text);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryMain, CDS_1);
|
|||
|
SInitCDSData(ADOQueryMain, CDS_1);
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmKnitPlanCardOFF.N1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
SelOKNo(cds_1, true)
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmKnitPlanCardOFF.N2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
SelOKNo(cds_1, false);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmKnitPlanCardOFF.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmKnitPlanCardOFF.ToolButton1Click(Sender: TObject);
|
|||
|
var
|
|||
|
WSql: string;
|
|||
|
begin
|
|||
|
if CDS_1.IsEmpty then
|
|||
|
Exit;
|
|||
|
Tv1.OnFocusedRecordChanged := nil;
|
|||
|
if CDS_1.Locate('SSel', True, []) = False then
|
|||
|
begin
|
|||
|
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
|
|||
|
WSql := '';
|
|||
|
CDS_1.DisableControls;
|
|||
|
|
|||
|
with CDS_1 do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while not Eof do
|
|||
|
begin
|
|||
|
if CDS_1.fieldbyname('SSel').AsBoolean then
|
|||
|
begin
|
|||
|
if WSql <> '' then
|
|||
|
begin
|
|||
|
WSql := WSql + ',' + QuotedStr(Trim(CDS_1.fieldbyname('PCID').AsString));
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
WSql := QuotedStr(Trim(CDS_1.fieldbyname('PCID').AsString));
|
|||
|
end;
|
|||
|
end;
|
|||
|
Next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
CDS_1.Locate('SSel', True, []);
|
|||
|
CDS_1.EnableControls;
|
|||
|
|
|||
|
try
|
|||
|
frmLabelPrint := TfrmLabelPrint.Create(Application);
|
|||
|
with frmLabelPrint do
|
|||
|
begin
|
|||
|
FPreviewPrint := False;
|
|||
|
FLMType := 'KnitPlanCard';
|
|||
|
FFiltration1 := WSql;
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
// Self.InitGrid();
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('update Knit_Plan_Card ');
|
|||
|
sql.Add('set PRTer=' + quotedstr(DName));
|
|||
|
sql.Add(', PRTCount=PRTCount+1');
|
|||
|
sql.Add(', PRTDate=getdate()');
|
|||
|
sql.Add(' where PCID in (' + WSql + ')');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmLabelPrint.Free;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmKnitPlanCardOFF.ToolButton2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmKnitPlanCardOFF.ToolButton3Click(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
if CDS_1.IsEmpty then
|
|||
|
Exit;
|
|||
|
TcxGridToExcel('<27><>Ʊ<EFBFBD>»<EFBFBD><C2BB><EFBFBD>', cxGrid1);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmKnitPlanCardOFF.ToolButton4Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_1.IsEmpty then
|
|||
|
exit;
|
|||
|
if not CDS_1.Locate('SSel', True, []) then
|
|||
|
begin
|
|||
|
application.MessageBox('<27><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ');
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
// if CDS_3.IsEmpty then
|
|||
|
// Exit;
|
|||
|
if Application.MessageBox('ȷ<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
Exit;
|
|||
|
with CDS_1 do
|
|||
|
begin
|
|||
|
DisableControls;
|
|||
|
First;
|
|||
|
while not eof do
|
|||
|
begin
|
|||
|
if fieldbyname('SSel').AsBoolean then
|
|||
|
begin
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
SQL.Add(' update Knit_Plan_Card SET ZHUANQTY=0,IsOffMachine=NULL,Offer=NULL,OffTime=NULL');
|
|||
|
sql.Add(' where PCID=''' + Trim(CDS_1.fieldbyname('PCID').AsString) + '''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
end;
|
|||
|
next;
|
|||
|
end;
|
|||
|
EnableControls;
|
|||
|
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmKnitPlanCardOFF.ToolButton5Click(Sender: TObject);
|
|||
|
var
|
|||
|
sInput: string;
|
|||
|
iLoopCount: double;
|
|||
|
begin
|
|||
|
if not InputQuery('<27><><EFBFBD>뵥<EFBFBD><EBB5A5>', '<27><><EFBFBD><EFBFBD><EFBFBD>뵥<EFBFBD>ۣ<EFBFBD>', sInput) then
|
|||
|
Exit; // <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>
|
|||
|
if not TryStrToFloat(sInput, iLoopCount) then
|
|||
|
begin
|
|||
|
ShowMessage('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>');
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
try
|
|||
|
with CDS_1 do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while not Eof do
|
|||
|
begin
|
|||
|
if CDS_1.fieldbyname('SSel').AsBoolean then
|
|||
|
begin
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
SQL.Add('update Knit_Plan_Card set price=' + trim(sInput));
|
|||
|
sql.Add(',money=zhuanqty*' + trim(sInput));
|
|||
|
sql.Add(' where pcid=' + quotedstr(trim(CDS_1.fieldbyname('pcid').AsString)));
|
|||
|
|
|||
|
execsql;
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
Next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
|||
|
|
|||
|
InitGrid();
|
|||
|
// TBRafresh.Click;
|
|||
|
except
|
|||
|
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmKnitPlanCardOFF.ConNoChange(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active = False then
|
|||
|
Exit;
|
|||
|
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
|||
|
SCreateCDS(ADOQueryMain, CDS_1);
|
|||
|
SInitCDSData(ADOQueryMain, CDS_1);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmKnitPlanCardOFF.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
ReadCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
|
|||
|
// fsj := 'select distinct Code=Null,Name=MCCJ from Machine Group by MCCJ ';
|
|||
|
// SInitComBoxBySql(ADOQueryTemp, CheJian, False, fsj);
|
|||
|
BegDate.DateTime := SGetServerDate(ADOQueryTemp) - 30;
|
|||
|
EndDate.DateTime := SGetServerDate(ADOQueryTemp);
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmKnitPlanCardOFF.cxTabControl1Change(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|