410 lines
11 KiB
ObjectPascal
410 lines
11 KiB
ObjectPascal
unit U_KnitPlanCard;
|
||
|
||
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, Vcl.Clipbrd, 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, cxContainer, FrameDateSel;
|
||
|
||
type
|
||
TfrmKnitPlanCard = class(TfrmBaseList)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
GPM_1: TcxGridPopupMenu;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
Label3: TLabel;
|
||
ConNo: TcxTextEdit;
|
||
ADOQueryPrint: TADOQuery;
|
||
Loom: TcxTextEdit;
|
||
Label1: TLabel;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
cxGridLevel2: TcxGridLevel;
|
||
v3Column1: TcxGridDBColumn;
|
||
v3Column2: TcxGridDBColumn;
|
||
Label2: TLabel;
|
||
C_Name: TcxTextEdit;
|
||
DS_1: TDataSource;
|
||
CDS_1: TClientDataSet;
|
||
Label4: TLabel;
|
||
C_Code: TcxTextEdit;
|
||
v3Column6: TcxGridDBColumn;
|
||
v3Column8: TcxGridDBColumn;
|
||
v3Column14: TcxGridDBColumn;
|
||
v3Column15: TcxGridDBColumn;
|
||
v3Column16: TcxGridDBColumn;
|
||
cxTabControl1: TcxTabControl;
|
||
Tv1Column1: TcxGridDBColumn;
|
||
Tv1Column2: TcxGridDBColumn;
|
||
Tv1Column3: TcxGridDBColumn;
|
||
ToolButton1: TToolButton;
|
||
ToolButton2: TToolButton;
|
||
Tv1Column4: TcxGridDBColumn;
|
||
Tv1Column5: TcxGridDBColumn;
|
||
Tv1Column6: TcxGridDBColumn;
|
||
Tv1Column7: TcxGridDBColumn;
|
||
Tv1Column8: TcxGridDBColumn;
|
||
Label5: TLabel;
|
||
OrderNo: TcxTextEdit;
|
||
Tv1Column9: TcxGridDBColumn;
|
||
Label6: TLabel;
|
||
BatchNo: TcxTextEdit;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
N2: TMenuItem;
|
||
ToolButton3: TToolButton;
|
||
ToolButton4: TToolButton;
|
||
N3: TMenuItem;
|
||
ToolButton5: TToolButton;
|
||
Label9: TLabel;
|
||
PCID: TcxTextEdit;
|
||
frmFrameDateSel: TfrmFrameDateSel;
|
||
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 N3Click(Sender: TObject);
|
||
procedure ToolButton5Click(Sender: TObject);
|
||
private
|
||
FInt, PFInt: Integer;
|
||
FFMainID, BPFlag: string;
|
||
procedure InitGrid();
|
||
{ Private declarations }
|
||
public
|
||
canshu1: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun, U_ZDYHelp, U_LabelPrint, U_KnitCardInPut,
|
||
U_KnitPlanCardDel;
|
||
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmKnitPlanCard.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
Action := caFree;
|
||
WriteCxGrid('DCG13', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
|
||
end;
|
||
|
||
procedure TfrmKnitPlanCard.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
|
||
end;
|
||
|
||
procedure TfrmKnitPlanCard.InitGrid();
|
||
begin
|
||
FFMainID := '';
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.*,C.*,D.* ');
|
||
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 ');
|
||
|
||
// sql.Add(' where not exists(select X.PCID from Knit_Cloth_Inspect X where X.PCID=A.PCID ) ');
|
||
|
||
case cxTabControl1.TabIndex of
|
||
0:
|
||
begin
|
||
sql.Add(' and PRTCount=0');
|
||
end;
|
||
1:
|
||
begin
|
||
sql.Add(' and PRTCount>0');
|
||
sql.Add(' and A.FillTIme>=''' + Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel.BegDate.Date)) + '''');
|
||
sql.Add(' and A.FillTIme<''' + Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel.EndDate.Date + 1)) + '''');
|
||
end;
|
||
2:
|
||
begin
|
||
sql.Add(' and A.FillTIme>=''' + Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel.BegDate.Date)) + '''');
|
||
sql.Add(' and A.FillTIme<''' + Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel.EndDate.Date + 1)) + '''');
|
||
end;
|
||
end;
|
||
|
||
Open;
|
||
end;
|
||
SCreateCDS(ADOQueryMain, CDS_1);
|
||
SInitCDSData(ADOQueryMain, CDS_1);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmKnitPlanCard.N1Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(cds_1, true)
|
||
end;
|
||
|
||
procedure TfrmKnitPlanCard.N2Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(cds_1, false);
|
||
end;
|
||
|
||
procedure TfrmKnitPlanCard.N3Click(Sender: TObject);
|
||
begin
|
||
Clipboard.SetTextBuf(PChar(Trim(CDS_1.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
|
||
end;
|
||
|
||
procedure TfrmKnitPlanCard.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmKnitPlanCard.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 TfrmKnitPlanCard.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
|
||
end;
|
||
|
||
procedure TfrmKnitPlanCard.ToolButton3Click(Sender: TObject);
|
||
var
|
||
FMainId, FSubId: string;
|
||
begin
|
||
|
||
try
|
||
frmKnitCardInPut := TfrmKnitCardInPut.Create(Application);
|
||
with frmKnitCardInPut do
|
||
begin
|
||
FMainId := Trim(Self.CDS_1.fieldbyname('MainId').AsString);
|
||
FSubId := Trim(Self.CDS_1.fieldbyname('SubId').AsString);
|
||
if ShowModal = 1 then
|
||
begin
|
||
// InitGrid();
|
||
end;
|
||
end;
|
||
finally
|
||
frmKnitCardInPut.Free;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmKnitPlanCard.ToolButton4Click(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 + ',' + (Trim(CDS_1.fieldbyname('PCID').AsString));
|
||
end
|
||
else
|
||
begin
|
||
WSql := (Trim(CDS_1.fieldbyname('PCID').AsString));
|
||
end;
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
|
||
CDS_1.Locate('SSel', True, []);
|
||
CDS_1.EnableControls;
|
||
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
// with ADOQueryCmd do
|
||
// begin
|
||
// Close;
|
||
// sql.Clear;
|
||
// sql.Add('insert into Knit_Need_Up(UOperation,UType,UDataId) values(''<27><><EFBFBD><EFBFBD>'',''<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>'',' + quotedstr(MCIIDS) + ') ');
|
||
// ExecSQL;
|
||
// end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
Sql.Clear;
|
||
Sql.Add('exec P_Knit_Card_Del ');
|
||
Sql.Add('@PCIDS=' + quotedstr(Trim(WSql)));
|
||
Sql.Add(',@DCode=' + Quotedstr(DCode));
|
||
Sql.Add(',@DName=' + Quotedstr(DName));
|
||
Open;
|
||
end;
|
||
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
|
||
begin
|
||
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
InitGrid();
|
||
application.MessageBox('ɾ<><C9BE><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmKnitPlanCard.ToolButton5Click(Sender: TObject);
|
||
begin
|
||
|
||
try
|
||
frmKnitPlanCardDel := TfrmKnitPlanCardDel.Create(Application);
|
||
with frmKnitPlanCardDel do
|
||
begin
|
||
if ShowModal = 1 then
|
||
begin
|
||
end;
|
||
end;
|
||
finally
|
||
frmKnitPlanCardDel.Free;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmKnitPlanCard.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 TfrmKnitPlanCard.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
frmFrameDateSel.EndDate.Date := SGetServerDate(ADOQueryTemp);
|
||
frmFrameDateSel.BegDate.Date := frmFrameDateSel.EndDate.Date - 1;
|
||
ReadCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmKnitPlanCard.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
end.
|
||
|