852 lines
23 KiB
ObjectPascal
852 lines
23 KiB
ObjectPascal
unit U_TatWBPlan;
|
||
|
||
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, cxLookAndFeels,
|
||
cxLookAndFeelPainters, cxNavigator, dxDateRanges, dxBarBuiltInMenu, U_BaseList,
|
||
cxPC, cxCheckBox, dxScrollbarAnnotations, Vcl.Menus, cxContainer,
|
||
cxProgressBar, dxSkinsCore, dxSkinsDefaultPainters, 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;
|
||
|
||
type
|
||
TfrmTatWBPlan = class(TfrmBaseList)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBFind: TToolButton;
|
||
TBAdd: TToolButton;
|
||
TBEdit: TToolButton;
|
||
TBDel: TToolButton;
|
||
TBPrint: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
Label1: TLabel;
|
||
Label2: TLabel;
|
||
GPM_1: TcxGridPopupMenu;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
DS_1: TDataSource;
|
||
TBExport: TToolButton;
|
||
CDS_1: TClientDataSet;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1Column5: TcxGridDBColumn;
|
||
v1PRTOrderQty: TcxGridDBColumn;
|
||
v1Column4: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
v1Column6: TcxGridDBColumn;
|
||
v1Column7: TcxGridDBColumn;
|
||
TBView: TToolButton;
|
||
v1Column19: TcxGridDBColumn;
|
||
v1Column21: TcxGridDBColumn;
|
||
v1Column31: TcxGridDBColumn;
|
||
CustName: TEdit;
|
||
Label7: TLabel;
|
||
cxTabControl1: TcxTabControl;
|
||
Tv1Column1: TcxGridDBColumn;
|
||
Tv1Column2: TcxGridDBColumn;
|
||
TBEnd: TToolButton;
|
||
TBNoEnd: TToolButton;
|
||
ToolButton1: TToolButton;
|
||
btnChk: TToolButton;
|
||
btnReChk: TToolButton;
|
||
Panel2: TPanel;
|
||
cxGrid2: TcxGrid;
|
||
TV2: TcxGridDBTableView;
|
||
cxGridDBColumn1: TcxGridDBColumn;
|
||
V2Column4: TcxGridDBColumn;
|
||
TV1Column5: TcxGridDBColumn;
|
||
V2Column3: TcxGridDBColumn;
|
||
cxGridDBColumn15: TcxGridDBColumn;
|
||
TV1Column3: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
ToolBar2: TToolBar;
|
||
ToolButton2: TToolButton;
|
||
ToolButton3: TToolButton;
|
||
DS_2: TDataSource;
|
||
CDS_2: TClientDataSet;
|
||
GPM_2: TcxGridPopupMenu;
|
||
Label3: TLabel;
|
||
WB_Spec: TEdit;
|
||
ToolButton4: TToolButton;
|
||
cxTabControl2: TcxTabControl;
|
||
cxGrid3: TcxGrid;
|
||
TV3: TcxGridDBTableView;
|
||
v2Column10: TcxGridDBColumn;
|
||
cxGridDBColumn2: TcxGridDBColumn;
|
||
v2Column2: TcxGridDBColumn;
|
||
v2Column6: TcxGridDBColumn;
|
||
cxGridDBColumn3: TcxGridDBColumn;
|
||
cxGridLevel2: TcxGridLevel;
|
||
DS_3: TDataSource;
|
||
CDS_3: TClientDataSet;
|
||
GPM_3: TcxGridPopupMenu;
|
||
ADO_2: TADOQuery;
|
||
ADO_3: TADOQuery;
|
||
PM_1: TPopupMenu;
|
||
N5: TMenuItem;
|
||
N6: TMenuItem;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBFindClick(Sender: TObject);
|
||
procedure TBEditClick(Sender: TObject);
|
||
procedure TBDelClick(Sender: TObject);
|
||
procedure TBExportClick(Sender: TObject);
|
||
procedure TBPrintClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure TBAddClick(Sender: TObject);
|
||
procedure ConNoChange(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBViewClick(Sender: TObject);
|
||
procedure OrdTypeChange(Sender: TObject);
|
||
procedure C_CodeKeyPress(Sender: TObject; var Key: Char);
|
||
procedure BatchNoHZKeyPress(Sender: TObject; var Key: Char);
|
||
procedure CustNameKeyPress(Sender: TObject; var Key: Char);
|
||
procedure C_NameKeyPress(Sender: TObject; var Key: Char);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure TBEndClick(Sender: TObject);
|
||
procedure TBNoEndClick(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure btnChkClick(Sender: TObject);
|
||
procedure btnReChkClick(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
procedure cxTabControl2Change(Sender: TObject);
|
||
procedure TV2FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure N5Click(Sender: TObject);
|
||
procedure N6Click(Sender: TObject);
|
||
|
||
private
|
||
FInt, PFInt: Integer;
|
||
procedure InitGrid();
|
||
procedure InitCard();
|
||
procedure InitCardYarn();
|
||
procedure InitForm();
|
||
function DelData(): Boolean;
|
||
procedure InitButton();
|
||
{ Private declarations }
|
||
public
|
||
canshu1, FCheJian: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun, U_ZDYHelp, U_LabelPrint, U_TatWBPlanInPut,
|
||
U_TatWBPlanCardInPut;
|
||
|
||
{$R *.dfm}
|
||
procedure TfrmTatWBPlan.InitCard();
|
||
begin
|
||
with ADO_2 do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.* ');
|
||
sql.Add(' from Tat_WB_Card A ');
|
||
sql.Add('where TWPId=' + quotedstr(trim(CDS_1.fieldbyname('TWPId').AsString)));
|
||
case cxTabControl2.TabIndex of
|
||
0:
|
||
begin
|
||
sql.Add('and WB_Type =''<27><><EFBFBD><EFBFBD>'' ');
|
||
end;
|
||
1:
|
||
begin
|
||
sql.Add('and WB_Type =''<27><><EFBFBD><EFBFBD>'' ');
|
||
end;
|
||
|
||
end;
|
||
|
||
Open;
|
||
end;
|
||
SCreateCDS(ADO_2, CDS_2);
|
||
SInitCDSData(ADO_2, CDS_2);
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.InitCardYarn();
|
||
begin
|
||
|
||
with ADO_3 do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.* ');
|
||
sql.Add(' from Tat_WB_Card_Yarn A ');
|
||
sql.Add('where WBCID=' + quotedstr(trim(CDS_2.fieldbyname('WBCID').AsString)));
|
||
|
||
Open;
|
||
end;
|
||
SCreateCDS(ADO_3, CDS_3);
|
||
SInitCDSData(ADO_3, CDS_3);
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.InitButton();
|
||
begin
|
||
|
||
TBAdd.Enabled := False;
|
||
TBEdit.Enabled := False;
|
||
TBDel.Enabled := False;
|
||
TBEnd.Enabled := False;
|
||
TBNoEnd.Enabled := False;
|
||
btnChk.Enabled := False;
|
||
btnReChk.Enabled := False;
|
||
if Trim(canshu1) = '¼<><C2BC>' then
|
||
begin
|
||
case cxTabControl1.TabIndex of
|
||
0:
|
||
begin
|
||
TBAdd.Enabled := true;
|
||
TBDel.Enabled := true;
|
||
TBEdit.Enabled := true;
|
||
btnChk.Enabled := true;
|
||
|
||
end;
|
||
1:
|
||
begin
|
||
TBAdd.Enabled := true;
|
||
TBEnd.Enabled := true;
|
||
TBEdit.Enabled := true;
|
||
btnReChk.Enabled := true;
|
||
end;
|
||
2:
|
||
begin
|
||
TBNoEnd.Enabled := true;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
if Trim(canshu1) = '<27><><EFBFBD><EFBFBD>' then
|
||
begin
|
||
case cxTabControl1.TabIndex of
|
||
0:
|
||
begin
|
||
TBAdd.Enabled := true;
|
||
TBDel.Enabled := true;
|
||
TBEdit.Enabled := true;
|
||
btnChk.Enabled := true;
|
||
end;
|
||
1:
|
||
begin
|
||
TBAdd.Enabled := true;
|
||
TBEnd.Enabled := true;
|
||
TBEdit.Enabled := true;
|
||
btnReChk.Enabled := true;
|
||
end;
|
||
2:
|
||
begin
|
||
TBNoEnd.Enabled := true;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered := False;
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.* ');
|
||
sql.Add(' from Tat_WB_Plan A ');
|
||
sql.Add('where 1=1 ');
|
||
case cxTabControl1.TabIndex of
|
||
0:
|
||
begin
|
||
sql.Add('and isnull(Status,''0'') =''0'' ');
|
||
end;
|
||
1:
|
||
begin
|
||
sql.Add('and isnull(Status,''0'') =''9'' ');
|
||
end;
|
||
2:
|
||
begin
|
||
sql.Add('and isnull(Status,''0'') =''10'' ');
|
||
sql.Add(' and A.FillTIme>=''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)) + '''');
|
||
sql.Add(' and A.FillTIme<''' + Trim(FormatDateTime('yyyy-MM-dd', EndDate.DateTime + 1)) + '''');
|
||
end;
|
||
end;
|
||
|
||
sql.add('order by A.FILLTIME DESC');
|
||
Open;
|
||
end;
|
||
SCreateCDS(ADOQueryMain, CDS_1);
|
||
SInitCDSData(ADOQueryMain, CDS_1);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.N5Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_2, True);
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.N6Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_2, False);
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.InitForm();
|
||
begin
|
||
|
||
ReadCxGrid(trim(self.Caption) + 'Tv1', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
ReadCxGrid(trim(self.Caption) + 'Tv2', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
ReadCxGrid(trim(self.Caption) + 'Tv3', Tv3, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
BegDate.DateTime := SGetServerDate(ADOQueryTemp) - 30;
|
||
EndDate.DateTime := SGetServerDate(ADOQueryTemp);
|
||
InitButton();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.TBFindClick(Sender: TObject);
|
||
begin
|
||
TBRafresh.Click;
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS(ADOQueryMain, CDS_1);
|
||
SInitCDSData(ADOQueryMain, CDS_1);
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.TBNoEndClick(Sender: TObject);
|
||
begin
|
||
if CDS_1.IsEmpty then
|
||
exit;
|
||
try
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update Tat_WB_Plan SET status=''0'',Comper=null,Comptime=null ');
|
||
sql.Add('where TWPId=' + quotedstr(trim(CDS_1.fieldbyname('TWPId').AsString)));
|
||
|
||
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><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')));
|
||
sql.Add(',' + quotedstr(trim('<27>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD>ţ<EFBFBD>' + trim(CDS_1.FieldByName('TWPId').AsString))));
|
||
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
|
||
sql.Add(')');
|
||
execsql;
|
||
end;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
TBRafresh.Click;
|
||
except
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.TBEditClick(Sender: TObject);
|
||
begin
|
||
if CDS_1.IsEmpty then
|
||
Exit;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
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><C6BB><EFBFBD><EFBFBD><EFBFBD>')));
|
||
sql.Add(',' + quotedstr(trim('<27>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD>ţ<EFBFBD>' + trim(CDS_1.FieldByName('TWPId').AsString))));
|
||
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
|
||
sql.Add(')');
|
||
ExecSQL;
|
||
end;
|
||
|
||
try
|
||
frmTatWBPlanInPut := TfrmTatWBPlanInPut.Create(Application);
|
||
with frmTatWBPlanInPut do
|
||
begin
|
||
PState := 1;
|
||
FTWPId := Trim(Self.CDS_1.fieldbyname('TWPId').AsString);
|
||
if ShowModal = 1 then
|
||
begin
|
||
InitGrid();
|
||
Self.CDS_1.Locate('TWPId', frmTatWBPlanInPut.FTWPId, []);
|
||
end;
|
||
end;
|
||
finally
|
||
frmTatWBPlanInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.TBEndClick(Sender: TObject);
|
||
begin
|
||
if CDS_1.IsEmpty then
|
||
exit;
|
||
try
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update Tat_WB_Plan SET status=''10'' ,Comper=''' + trim(DName) + ''',Comptime=getdate() ');
|
||
sql.Add('where TWPId=' + quotedstr(trim(CDS_1.fieldbyname('TWPId').AsString)));
|
||
|
||
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><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')));
|
||
sql.Add(',' + quotedstr(trim('<27>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD>ţ<EFBFBD>' + trim(CDS_1.FieldByName('TWPId').AsString))));
|
||
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
|
||
sql.Add(')');
|
||
execsql;
|
||
end;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
TBRafresh.Click;
|
||
except
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.TBDelClick(Sender: TObject);
|
||
begin
|
||
if CDS_1.IsEmpty then
|
||
Exit;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select A.*');
|
||
sql.Add('from Tat_WB_Plan A');
|
||
sql.Add(' where A.TWPId=''' + Trim(CDS_1.fieldbyname('TWPId').AsString) + '''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty = False then
|
||
begin
|
||
Application.MessageBox('<27>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>ɾ<EFBFBD><C9BE>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
||
Exit;
|
||
if DelData() then
|
||
begin
|
||
CDS_1.Delete;
|
||
end;
|
||
end;
|
||
|
||
function TfrmTatWBPlan.DelData(): Boolean;
|
||
begin
|
||
try
|
||
Result := false;
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete Tat_WB_Plan where TWPId=''' + Trim(CDS_1.fieldbyname('TWPId').AsString) + '''');
|
||
|
||
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><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>')));
|
||
sql.Add(',' + quotedstr(trim('<27><><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD>ţ<EFBFBD>' + trim(CDS_1.FieldByName('TWPId').AsString))));
|
||
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
|
||
sql.Add(')');
|
||
ExecSQL;
|
||
end;
|
||
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
Result := True;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Result := False;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>쳣<EFBFBD><ECB3A3>', '<27><>ʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.TBExportClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then
|
||
Exit;
|
||
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', cxGrid1);
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.TBPrintClick(Sender: TObject);
|
||
var
|
||
WSql: string;
|
||
begin
|
||
if CDS_1.IsEmpty then
|
||
Exit;
|
||
WSql := Trim(CDS_1.fieldbyname('TWPId').AsString);
|
||
|
||
try
|
||
frmLabelPrint := TfrmLabelPrint.Create(Application);
|
||
with frmLabelPrint do
|
||
begin
|
||
FLMType := 'TatWBPlan';
|
||
FFiltration1 := WSql;
|
||
FFiltration2 := WSql;
|
||
FFiltration3 := WSql;
|
||
if ShowModal = 1 then
|
||
begin
|
||
// Self.InitGrid();
|
||
end;
|
||
end;
|
||
finally
|
||
frmLabelPrint.Free;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.TBAddClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmTatWBPlanInPut := TfrmTatWBPlanInPut.Create(Application);
|
||
with frmTatWBPlanInPut do
|
||
begin
|
||
PState := 0;
|
||
FTWPId := '';
|
||
FSubId := '';
|
||
if ShowModal = 1 then
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
end;
|
||
finally
|
||
frmTatWBPlanInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.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 TfrmTatWBPlan.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
canshu1 := Self.fParameters1;
|
||
InitForm();
|
||
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.TBViewClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmTatWBPlanInPut := TfrmTatWBPlanInPut.Create(Application);
|
||
with frmTatWBPlanInPut do
|
||
begin
|
||
PState := 1;
|
||
FTWPId := Trim(Self.CDS_1.fieldbyname('TWPId').AsString);
|
||
TBSave.Visible := False;
|
||
ToolBar3.Visible := False;
|
||
ScrollBox1.Enabled := False;
|
||
if ShowModal = 1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmTatWBPlanInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(trim(self.Caption) + 'Tv1', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
WriteCxGrid(trim(self.Caption) + 'Tv2', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
WriteCxGrid(trim(self.Caption) + 'Tv3', Tv3, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
try
|
||
frmTatWBPlanCardInPut := TfrmTatWBPlanCardInPut.Create(Application);
|
||
with frmTatWBPlanCardInPut do
|
||
begin
|
||
FTWPId := Trim(self.CDS_1.fieldbyname('TWPId').AsString);
|
||
case cxTabControl2.TabIndex of
|
||
0:
|
||
begin
|
||
FWB_Type := '<27><><EFBFBD><EFBFBD>';
|
||
end;
|
||
1:
|
||
begin
|
||
FWB_Type := '<27><><EFBFBD><EFBFBD>';
|
||
end;
|
||
|
||
end;
|
||
if ShowModal = 1 then
|
||
begin
|
||
InitCard();
|
||
end;
|
||
end;
|
||
finally
|
||
frmTatWBPlanCardInPut.Free;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.ToolButton3Click(Sender: TObject);
|
||
var
|
||
rtvalues: TArray<string>;
|
||
begin
|
||
if CDS_2.IsEmpty then
|
||
Exit;
|
||
Tv2.OnFocusedRecordChanged := nil;
|
||
if CDS_2.Locate('SSel', True, []) = False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
rtvalues := SelCDSKey(CDS_2, ['WBCID']);
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
Sql.Clear;
|
||
Sql.Add('exec P_TatWB_Card_Del ');
|
||
Sql.Add('@WBCIDS=' + quotedstr(Trim(rtvalues[0])));
|
||
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;
|
||
InitCard();
|
||
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 TfrmTatWBPlan.ToolButton4Click(Sender: TObject);
|
||
var
|
||
RTValues: TArray<string>;
|
||
begin
|
||
if CDS_2.IsEmpty then
|
||
Exit;
|
||
|
||
RTValues := SelCDSKey(CDS_2, ['WBCID']);
|
||
|
||
try
|
||
frmLabelPrint := TfrmLabelPrint.Create(Application);
|
||
with frmLabelPrint do
|
||
begin
|
||
FPreviewPrint := False;
|
||
case cxTabControl2.TabIndex of
|
||
0:
|
||
begin
|
||
FLMType := 'TatWBCard1';
|
||
end;
|
||
1:
|
||
begin
|
||
FLMType := 'TatWBCard2';
|
||
end;
|
||
end;
|
||
FFiltration1 := RTValues[0];
|
||
if ShowModal = 1 then
|
||
begin
|
||
// Self.InitGrid();
|
||
// with ADOQueryCmd do
|
||
// begin
|
||
// Close;
|
||
// sql.Clear;
|
||
// sql.Add('update Tat_WB_Card ');
|
||
// sql.Add(' set PRTer=' + quotedstr(DName));
|
||
// sql.Add(', PRTCount=PRTCount+1');
|
||
// sql.Add(', PRTDate=getdate()');
|
||
// sql.Add(' where WBCID in (' + WSql + ')');
|
||
// ExecSQL;
|
||
// end;
|
||
end;
|
||
end;
|
||
finally
|
||
frmLabelPrint.Free;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
begin
|
||
InitCard();
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.TV2FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
||
begin
|
||
InitCardYarn();
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.btnChkClick(Sender: TObject);
|
||
begin
|
||
if CDS_1.IsEmpty then
|
||
exit;
|
||
try
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update Tat_WB_Plan SET status=''9'',chker=''' + trim(DName) + ''',Chktime=getdate() ');
|
||
sql.Add('where TWPId=' + quotedstr(trim(CDS_1.fieldbyname('TWPId').AsString)));
|
||
|
||
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><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ')));
|
||
sql.Add(',' + quotedstr(trim('<27>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD>ţ<EFBFBD>' + trim(CDS_1.FieldByName('TWPId').AsString))));
|
||
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
|
||
sql.Add(')');
|
||
execsql;
|
||
end;
|
||
application.MessageBox('<27><>ʼ<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
TBRafresh.Click;
|
||
except
|
||
application.MessageBox('<27><>ʼʧ<CABC>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.btnReChkClick(Sender: TObject);
|
||
begin
|
||
if CDS_1.IsEmpty then
|
||
exit;
|
||
|
||
try
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update Tat_WB_Plan SET status=''0'',chker=null,Chktime=null ');
|
||
sql.Add('where TWPId=' + quotedstr(trim(CDS_1.fieldbyname('TWPId').AsString)));
|
||
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><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ')));
|
||
sql.Add(',' + quotedstr(trim('<27>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD>ţ<EFBFBD>' + trim(CDS_1.FieldByName('TWPId').AsString))));
|
||
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
|
||
sql.Add(')');
|
||
execsql;
|
||
end;
|
||
TBRafresh.Click;
|
||
except
|
||
application.MessageBox('<27>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼʧ<CABC>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.OrdTypeChange(Sender: TObject);
|
||
begin
|
||
TBRafresh.Click;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.C_CodeKeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
if Key = #13 then
|
||
TBRafresh.Click();
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS(ADOQueryMain, CDS_1);
|
||
SInitCDSData(ADOQueryMain, CDS_1);
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.BatchNoHZKeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
if Key = #13 then
|
||
TBRafresh.Click();
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS(ADOQueryMain, CDS_1);
|
||
SInitCDSData(ADOQueryMain, CDS_1);
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.CustNameKeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
if Key = #13 then
|
||
TBRafresh.Click();
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS(ADOQueryMain, CDS_1);
|
||
SInitCDSData(ADOQueryMain, CDS_1);
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
InitButton();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.cxTabControl2Change(Sender: TObject);
|
||
begin
|
||
InitCard();
|
||
end;
|
||
|
||
procedure TfrmTatWBPlan.C_NameKeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
if Key = #13 then
|
||
TBRafresh.Click();
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS(ADOQueryMain, CDS_1);
|
||
SInitCDSData(ADOQueryMain, CDS_1);
|
||
end;
|
||
|
||
end.
|
||
|