RTFormwork/项目代码/RTBasicsV1/D01针织生产计划/U_KnitPlanCardDel.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

315 lines
8.8 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_KnitPlanCardDel;
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_Basehelp, Vcl.Menus, Vcl.Clipbrd, U_BaseList, System.ImageList, Vcl.ImgList;
type
TfrmKnitPlanCardDel = class(TfrmBasehelp)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
GPM_1: TcxGridPopupMenu;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
ADOQueryPrint: TADOQuery;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
cxGridLevel2: TcxGridLevel;
v3Column1: TcxGridDBColumn;
v3Column2: TcxGridDBColumn;
DS_1: TDataSource;
CDS_1: TClientDataSet;
v3Column6: TcxGridDBColumn;
v3Column8: TcxGridDBColumn;
v3Column14: TcxGridDBColumn;
v3Column15: TcxGridDBColumn;
v3Column16: TcxGridDBColumn;
Tv1Column1: TcxGridDBColumn;
Tv1Column2: TcxGridDBColumn;
Tv1Column3: TcxGridDBColumn;
ToolButton2: TToolButton;
Tv1Column4: TcxGridDBColumn;
Tv1Column5: TcxGridDBColumn;
Tv1Column6: TcxGridDBColumn;
Tv1Column7: TcxGridDBColumn;
Tv1Column8: TcxGridDBColumn;
Tv1Column9: TcxGridDBColumn;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
Tv1Column10: TcxGridDBColumn;
Tv1Column12: TcxGridDBColumn;
Label3: TLabel;
Label1: TLabel;
Label2: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
ConNo: TEdit;
Loom: TEdit;
C_Name: TEdit;
C_Code: TEdit;
OrderNo: TEdit;
BatchNo: TEdit;
Label7: TLabel;
Label8: TLabel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
Label9: TLabel;
PCID: TEdit;
ToolButton1: 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 Button1Click(Sender: TObject);
procedure cxTabControl1Change(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
private
FInt, PFInt: Integer;
FFMainID, BPFlag: string;
procedure InitGrid();
{ Private declarations }
public
canshu1: string;
{ Public declarations }
end;
var
frmKnitPlanCardDel: TfrmKnitPlanCardDel;
implementation
uses
U_DataLink, U_RTFun, U_ZDYHelp, U_LabelPrint;
{$R *.dfm}
procedure TfrmKnitPlanCardDel.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
WriteCxGrid('DCG13', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
end;
procedure TfrmKnitPlanCardDel.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmKnitPlanCardDel.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_Del A ');
sql.Add(' left join knit_Plan_Sub C on A.SubId=C.SubId');
sql.Add(' left join knit_Plan_Main D on A.MainId=D.MainId');
sql.Add(' where A.FillTIme>=''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)) + '''');
sql.Add(' and A.FillTIme<''' + Trim(FormatDateTime('yyyy-MM-dd', EndDate.DateTime + 1)) + '''');
Open;
end;
SCreateCDS(ADOQueryMain, CDS_1);
SInitCDSData(ADOQueryMain, CDS_1);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmKnitPlanCardDel.N1Click(Sender: TObject);
begin
SelOKNo(cds_1, true)
end;
procedure TfrmKnitPlanCardDel.N2Click(Sender: TObject);
begin
SelOKNo(cds_1, false);
end;
procedure TfrmKnitPlanCardDel.N3Click(Sender: TObject);
begin
Clipboard.SetTextBuf(PChar(Trim(CDS_1.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
end;
procedure TfrmKnitPlanCardDel.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmKnitPlanCardDel.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 + ',' + (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('exec P_Knit_Card_ReDel ');
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('<27><>ԭ<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
except
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmKnitPlanCardDel.ToolButton2Click(Sender: TObject);
begin
WriteCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
end;
procedure TfrmKnitPlanCardDel.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 TfrmKnitPlanCardDel.FormShow(Sender: TObject);
begin
inherited;
ReadCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2');
EndDate.DateTime := SGetServerDate(ADOQueryTemp);
BegDate.DateTime := EndDate.DateTime - 10;
InitGrid();
end;
procedure TfrmKnitPlanCardDel.Button1Click(Sender: TObject);
begin
// if CDS_AnPai.IsEmpty then
// Exit;
// if CDS_AnPai.Locate('SSel', True, []) = False then
// begin
// Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
// Exit;
// end;
// if CDS_AnPai.Locate('SSel;JYFlag', VarArrayOf([True, True]), []) then
// begin
// Application.MessageBox('<27>Ѽ<EFBFBD><D1BC><EFBFBD><E9B2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
// Exit;
// end;
// if Application.MessageBox('ȷ<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
// Exit;
// try
// ADOQueryCmd.Connection.BeginTrans;
// CDS_AnPai.DisableControls;
// with CDS_AnPai do
// begin
// while CDS_AnPai.FieldByName('SSel').AsBoolean = True do
// begin
// with ADOQueryCmd do
// begin
// Close;
// sql.Clear;
// sql.Add('delete knit_Plan_Card ');
// sql.Add(' where APId=''' + Trim(CDS_AnPai.fieldbyname('APID').AsString) + '''');
// sql.Add(' and not exists(select * from knit_Cloth_Inspect A where A.MJID=knit_Plan_Card.APID)');
//
// sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( ');
// sql.Add(' ' + quotedstr(trim(DName)));
// sql.Add(',getdate() ');
// sql.Add(',' + quotedstr(trim(self.Caption)));
// sql.Add(',' + quotedstr(trim('<27><><EFBFBD>ϲ<EFBFBD>Ʊ')));
// sql.Add(',' + quotedstr(trim('<27><><EFBFBD><EFBFBD>:' + trim(CDS_AnPai.FieldByName('apid').AsString) + ' <20><><EFBFBD><EFBFBD>:' + trim(CDS_AnPai.FieldByName('carno').AsString) + ' <20><><EFBFBD><EFBFBD>:' + trim(CDS_AnPai.FieldByName('APBatchNo').AsString) + ' MAINID:' + trim(CDS_AnPai.FieldByName('mainid').AsString))));
// sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
// sql.Add(')');
// ExecSQL;
// end;
// CDS_AnPai.Delete;
// end;
// end;
// CDS_AnPai.EnableControls;
//
// ADOQueryCmd.Connection.CommitTrans;
// except
// ADOQueryCmd.Connection.RollbackTrans;
// CDS_AnPai.EnableControls;
// Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
// Exit;
// end;
end;
procedure TfrmKnitPlanCardDel.cxTabControl1Change(Sender: TObject);
begin
InitGrid();
end;
end.