771 lines
21 KiB
ObjectPascal
771 lines
21 KiB
ObjectPascal
![]() |
unit U_PBOUTSQList;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
|
|||
|
cxEdit, DB, cxDBData, cxGridCustomTableView, cxGridTableView,
|
|||
|
cxGridBandedTableView, cxGridDBBandedTableView, cxGridLevel, cxClasses,
|
|||
|
cxControls, cxGridCustomView, cxGridDBTableView, cxGrid, StdCtrls, ComCtrls,
|
|||
|
ExtCtrls, ToolWin, cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient,
|
|||
|
cxDropDownEdit, cxCheckBox, RM_Common, RM_Class, RM_e_Xls, RM_Dataset,
|
|||
|
RM_System, RM_GridReport, Menus, cxCalendar, cxButtonEdit, cxTextEdit,
|
|||
|
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, cxCalc, dxBarBuiltInMenu,
|
|||
|
cxPC, cxSplitter;
|
|||
|
|
|||
|
type
|
|||
|
TfrmPBOUTSQList = class(TForm)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBRafresh: TToolButton;
|
|||
|
TBFind: TToolButton;
|
|||
|
TBExport: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
Panel1: TPanel;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
DataSource1: TDataSource;
|
|||
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|||
|
Label2: TLabel;
|
|||
|
BegDate: TDateTimePicker;
|
|||
|
EndDate: TDateTimePicker;
|
|||
|
CDS_Main: TClientDataSet;
|
|||
|
RM1: TRMGridReport;
|
|||
|
RMDBMain: TRMDBDataSet;
|
|||
|
RMXLSExport1: TRMXLSExport;
|
|||
|
RMDBHZ: TRMDBDataSet;
|
|||
|
CDS_HZ: TClientDataSet;
|
|||
|
CDS_PRT: TClientDataSet;
|
|||
|
TBDel: TToolButton;
|
|||
|
PopupMenu1: TPopupMenu;
|
|||
|
N1: TMenuItem;
|
|||
|
N2: TMenuItem;
|
|||
|
TBAdd: TToolButton;
|
|||
|
TBEdit: TToolButton;
|
|||
|
Label5: TLabel;
|
|||
|
pbid: TEdit;
|
|||
|
Label13: TLabel;
|
|||
|
ToFactoryName: TEdit;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
ADOQueryPrint: TADOQuery;
|
|||
|
CheckBox1: TCheckBox;
|
|||
|
Panel4: TPanel;
|
|||
|
Label1: TLabel;
|
|||
|
Button1: TButton;
|
|||
|
Button2: TButton;
|
|||
|
YWNOTE: TEdit;
|
|||
|
cxTabControl1: TcxTabControl;
|
|||
|
ToolButton4: TToolButton;
|
|||
|
ToolButton5: TToolButton;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
v1Column4: TcxGridDBColumn;
|
|||
|
v1Column8: TcxGridDBColumn;
|
|||
|
v1Column10: TcxGridDBColumn;
|
|||
|
v1OrdDate: TcxGridDBColumn;
|
|||
|
v1Column1: TcxGridDBColumn;
|
|||
|
v1Column13: TcxGridDBColumn;
|
|||
|
v1Column17: TcxGridDBColumn;
|
|||
|
v1Column7: TcxGridDBColumn;
|
|||
|
Tv1Column3: TcxGridDBColumn;
|
|||
|
Tv1Column4: TcxGridDBColumn;
|
|||
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
cxSplitter1: TcxSplitter;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
TV2: TcxGridDBTableView;
|
|||
|
v1Column14: TcxGridDBColumn;
|
|||
|
Tv1Column1: TcxGridDBColumn;
|
|||
|
v1Column20: TcxGridDBColumn;
|
|||
|
cxGridDBColumn3: TcxGridDBColumn;
|
|||
|
cxGridDBColumn4: TcxGridDBColumn;
|
|||
|
cxGridDBColumn5: TcxGridDBColumn;
|
|||
|
v1Column16: TcxGridDBColumn;
|
|||
|
v1Column9: TcxGridDBColumn;
|
|||
|
v2Column6: TcxGridDBColumn;
|
|||
|
v1Column3: TcxGridDBColumn;
|
|||
|
v1Column12: TcxGridDBColumn;
|
|||
|
cxGrid2Level1: TcxGridLevel;
|
|||
|
DataSource2: TDataSource;
|
|||
|
TV2Column1: TcxGridDBColumn;
|
|||
|
TV2Column2: TcxGridDBColumn;
|
|||
|
Tv1Column2: TcxGridDBColumn;
|
|||
|
Label3: TLabel;
|
|||
|
carxx: TEdit;
|
|||
|
ToolButton2: TToolButton;
|
|||
|
ToolButton3: TToolButton;
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure TBRafreshClick(Sender: TObject);
|
|||
|
procedure ConNoMChange(Sender: TObject);
|
|||
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure TBExportClick(Sender: TObject);
|
|||
|
procedure TBFindClick(Sender: TObject);
|
|||
|
procedure SPNameChange(Sender: TObject);
|
|||
|
procedure pbidKeyPress(Sender: TObject; var Key: Char);
|
|||
|
procedure N1Click(Sender: TObject);
|
|||
|
procedure N2Click(Sender: TObject);
|
|||
|
procedure TBDelClick(Sender: TObject);
|
|||
|
procedure TBAddClick(Sender: TObject);
|
|||
|
procedure TBEditClick(Sender: TObject);
|
|||
|
procedure SPSpecChange(Sender: TObject);
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
procedure CheckBox1Click(Sender: TObject);
|
|||
|
procedure CRTypeChange(Sender: TObject);
|
|||
|
procedure ToolButton2Click(Sender: TObject);
|
|||
|
procedure Button2Click(Sender: TObject);
|
|||
|
procedure Button1Click(Sender: TObject);
|
|||
|
procedure ToolButton3Click(Sender: TObject);
|
|||
|
procedure cxTabControl1Change(Sender: TObject);
|
|||
|
procedure ToolButton4Click(Sender: TObject);
|
|||
|
procedure ToolButton5Click(Sender: TObject);
|
|||
|
procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
|||
|
private
|
|||
|
canshu2: string;
|
|||
|
procedure InitGrid();
|
|||
|
procedure InitSUB();
|
|||
|
procedure SetStatus();
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
canshu1: string;
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmPBOUTSQList: TfrmPBOUTSQList;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_RTFun, U_SXCKOutPut2, U_SXCKTHPut, U_FUN, U_ZdyAttachGYS;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
procedure TfrmPBOUTSQList.SetStatus();
|
|||
|
begin
|
|||
|
TBAdd.Visible := false;
|
|||
|
TBEdit.Visible := false;
|
|||
|
TBDel.Visible := false;
|
|||
|
|
|||
|
ToolButton4.Visible := false;
|
|||
|
ToolButton5.Visible := false;
|
|||
|
ToolButton1.Visible := false;
|
|||
|
ToolButton2.Visible := false;
|
|||
|
ToolButton3.Visible := false;
|
|||
|
case cxTabControl1.TabIndex of
|
|||
|
0:
|
|||
|
begin
|
|||
|
TBAdd.Visible := true;
|
|||
|
TBEdit.Visible := true;
|
|||
|
TBDel.Visible := true;
|
|||
|
|
|||
|
// if canshu1 = '<27><><EFBFBD><EFBFBD>' then
|
|||
|
// begin
|
|||
|
// ToolButton4.Visible := true;
|
|||
|
// end;
|
|||
|
if canshu1 = '<27>ֿ<EFBFBD>' then
|
|||
|
begin
|
|||
|
// ToolButton5.Visible := true;
|
|||
|
ToolButton2.Visible := true;
|
|||
|
end;
|
|||
|
end;
|
|||
|
1:
|
|||
|
begin
|
|||
|
|
|||
|
// if canshu1 = '<27><><EFBFBD><EFBFBD>' then
|
|||
|
// begin
|
|||
|
// ToolButton5.Visible := true;
|
|||
|
// end;
|
|||
|
if canshu1 = '<27>ֿ<EFBFBD>' then
|
|||
|
begin
|
|||
|
// ToolButton5.Visible := true;
|
|||
|
ToolButton3.Visible := true;
|
|||
|
ToolButton1.Visible := True;
|
|||
|
end;
|
|||
|
end;
|
|||
|
2:
|
|||
|
begin
|
|||
|
// ToolButton1.Visible := True;
|
|||
|
// if canshu1 = '<27>ֿ<EFBFBD>' then
|
|||
|
// begin
|
|||
|
//
|
|||
|
// ToolButton3.Visible := true;
|
|||
|
// end;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
frmPBOUTSQList := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
Action := caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
//cxGrid1.Align:=alClient;
|
|||
|
// canshu1 := Trim(DParameters1);
|
|||
|
canshu2 := Trim(DParameters2);
|
|||
|
EndDate.DateTime := SGetServerDate10(ADOQueryTemp);
|
|||
|
BegDate.DateTime := EndDate.DateTime - 30;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.InitGrid();
|
|||
|
var
|
|||
|
pwhere: string;
|
|||
|
begin
|
|||
|
if SGetFilters(Panel1, 1, 2) <> '' then
|
|||
|
pwhere := ' and ' + SGetFilters(Panel1, 1, 2);
|
|||
|
try
|
|||
|
ADOQueryMain.DisableControls;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Filtered := False;
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' select * from (select isnull(A.ChkStatus,''0'')ChkStatus,PBID,ToFactoryName,YWY,YWZB,ZBZNOTE,carxx, ');
|
|||
|
SQL.Add('convert(varchar(10),ChkTime,120)ChkTime,Chker,convert(varchar(10),CRTIME,120)CRTIME,FILLER');
|
|||
|
|
|||
|
sql.Add(' from CK_SXPB_CR A');
|
|||
|
|
|||
|
sql.Add(' where 1=1');
|
|||
|
if CheckBox1.Checked = true then
|
|||
|
begin
|
|||
|
sql.add(' and A.CRTime>=''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)) + '''');
|
|||
|
sql.Add(' and A.CRTime<''' + Trim(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1)) + '''');
|
|||
|
end;
|
|||
|
case cxTabControl1.TabIndex of
|
|||
|
0:
|
|||
|
begin
|
|||
|
SQL.Add('and isnull(A.ChkStatus,''0'')=''0'' ');
|
|||
|
|
|||
|
end;
|
|||
|
1:
|
|||
|
begin
|
|||
|
SQL.Add('and isnull(A.ChkStatus,''0'')=''1'' ');
|
|||
|
end;
|
|||
|
// 2:
|
|||
|
// begin
|
|||
|
// SQL.Add('and isnull(A.ChkStatus,''0'')=''2'' ');
|
|||
|
// end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
SQL.Add(' and CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
|
|||
|
SQL.Add(' and isnull(CKName,'''')=''<27><><EFBFBD><EFBFBD>'' AND CKTYPE=''<27><><EFBFBD><EFBFBD>'' ');
|
|||
|
sql.Add('group by isnull(A.ChkStatus,''0''),carxx,PBID,ToFactoryName,YWY,YWZB,ZBZNOTE,convert(varchar(10),ChkTime,120),Chker,convert(varchar(10),CRTIME,120),FILLER)aa where 1=1');
|
|||
|
sql.Add(pwhere);
|
|||
|
Open;
|
|||
|
//ShowMessage(SQL.Text);
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOQueryMain, CDS_Main);
|
|||
|
SInitCDSData20(ADOQueryMain, CDS_Main);
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.InitSUB();
|
|||
|
begin
|
|||
|
|
|||
|
try
|
|||
|
ADOQueryCmd.DisableControls;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Filtered := False;
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' select A.* ,B.PRTColor,B.PRTHX');
|
|||
|
SQL.Add(',GYSJC=(SELECT COHRNAME FROM COMPANY WHERE COTYPE=''<27><>Ӧ<EFBFBD><D3A6>'' and valid=''Y'' and coname=a.FactoryName )');
|
|||
|
|
|||
|
sql.Add(' from CK_SXPB_CR A');
|
|||
|
sql.Add(' left join JYOrder_Sub B on A.ORDSubIdCK=B.SubId');
|
|||
|
sql.Add(' where 1=1');
|
|||
|
SQL.ADD('AND PBID=' + QuotedStr(Trim(CDS_MAIN.FIELDBYNAME('PBID').ASSTRING)));
|
|||
|
|
|||
|
Open;
|
|||
|
//ShowMessage(SQL.Text);
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOQueryCmd, CDS_HZ);
|
|||
|
SInitCDSData20(ADOQueryCmd, CDS_HZ);
|
|||
|
finally
|
|||
|
CDS_HZ.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
BegDate.SetFocus;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.ConNoMChange(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active then
|
|||
|
begin
|
|||
|
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
writeCxGrid(Self.Caption + 'TV1', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>4');
|
|||
|
writeCxGrid(Self.Caption + 'TV2', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>4');
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
if Trim(canshu2) = '<27>鿴' then
|
|||
|
begin
|
|||
|
TBAdd.Visible := False;
|
|||
|
TBDel.Visible := False;
|
|||
|
TBEdit.Visible := False;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
TBAdd.Visible := True;
|
|||
|
TBDel.Visible := True;
|
|||
|
TBEdit.Visible := True;
|
|||
|
end;
|
|||
|
ReadCxGrid(Self.Caption + 'TV1', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>4');
|
|||
|
ReadCxGrid(Self.Caption + 'TV2', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>4');
|
|||
|
SetStatus();
|
|||
|
//InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.TBExportClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.IsEmpty then
|
|||
|
exit;
|
|||
|
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>', cxGrid2);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.TBFindClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active then
|
|||
|
begin
|
|||
|
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
|||
|
SCreateCDS20(ADOQueryMain, CDS_Main);
|
|||
|
SInitCDSData20(ADOQueryMain, CDS_Main);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.SPNameChange(Sender: TObject);
|
|||
|
begin
|
|||
|
TBFind.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.pbidKeyPress(Sender: TObject; var Key: Char);
|
|||
|
begin
|
|||
|
if Key = #13 then
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.N1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
SelOKNo(CDS_Main, True);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.N2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
SelOKNo(CDS_Main, False);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.TBDelClick(Sender: TObject);
|
|||
|
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
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
|
|||
|
with CDS_HZ do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while not Eof do
|
|||
|
begin
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' delete CK_SXPB_CR where SPID=''' + Trim(CDS_HZ.fieldbyname('SPID').AsString) + '''');
|
|||
|
sql.Add(' Update CK_SXPB_CR Set MXKCQty=(select sum(isnull(Qty,0)*CRQtyFlag) from CK_SXPB_CR A where A.FZSPID=CK_SXPB_CR.SPID)');
|
|||
|
sql.Add(',MXKCPiQty=(select sum(isnull(PiQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.FZSPID=CK_SXPB_CR.SPID)');
|
|||
|
sql.Add(',MXKCKgQty=(select sum(isnull(KgQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.FZSPID=CK_SXPB_CR.SPID)');
|
|||
|
sql.Add(' where SPID=''' + Trim(CDS_HZ.fieldbyname('FZSPID').AsString) + '''');
|
|||
|
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
Next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
InitGrid();
|
|||
|
Application.MessageBox('ɾ<><C9BE><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
except
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('ɾ<><C9BE><EFBFBD>쳣!', '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.TBAddClick(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmSXCKOutPut2 := TfrmSXCKOutPut2.Create(Application);
|
|||
|
with frmSXCKOutPut2 do
|
|||
|
begin
|
|||
|
FBCId := '';
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
Self.InitGrid();
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmSXCKOutPut2.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.TBEditClick(Sender: TObject);
|
|||
|
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;
|
|||
|
|
|||
|
try
|
|||
|
frmSXCKOutPut2 := TfrmSXCKOutPut2.Create(Application);
|
|||
|
with frmSXCKOutPut2 do
|
|||
|
begin
|
|||
|
FBCId := Trim(CDS_Main.fieldbyname('pbid').AsString);
|
|||
|
// TBDel.Visible := False;
|
|||
|
// TBAdd.Visible := False;
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
Self.InitGrid();
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmSXCKOutPut2.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.SPSpecChange(Sender: TObject);
|
|||
|
begin
|
|||
|
TBFind.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.ToolButton1Click(Sender: TObject);
|
|||
|
var
|
|||
|
fPrintFile: string;
|
|||
|
Txt, fImagePath: string;
|
|||
|
Moudle: THandle;
|
|||
|
Makebar: TMakebar;
|
|||
|
Mixtext: TMixtext;
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
// if cxTabControl1.TabIndex <> 1 then
|
|||
|
// Exit;
|
|||
|
ExportFtErpFile('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>۵<EFBFBD>.rmf', ADOQueryTemp);
|
|||
|
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>۵<EFBFBD>.rmf';
|
|||
|
|
|||
|
with ADOQueryPrint do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
SQL.ADD('EXEC P_Print_PBXSB @PBID=' + QuotedStr(Trim(CDS_Main.fieldbyname('PBID').AsString)));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if FileExists(fPrintFile) then
|
|||
|
begin
|
|||
|
try
|
|||
|
Moudle := LoadLibrary('MakeQRBarcode.dll');
|
|||
|
@Makebar := GetProcAddress(Moudle, 'Make');
|
|||
|
@Mixtext := GetProcAddress(Moudle, 'MixText');
|
|||
|
Txt := Trim(CDS_Main.fieldbyname('PBID').AsString);
|
|||
|
fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
|
|||
|
if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
|
|||
|
CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
|
|||
|
if FileExists(fImagePath) then
|
|||
|
DeleteFile(fImagePath);
|
|||
|
Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
|
|||
|
except
|
|||
|
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
RMVariables['QRBARCODE'] := fImagePath;
|
|||
|
RM1.LoadFromFile(fPrintFile);
|
|||
|
RM1.ShowReport;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.CheckBox1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.CRTypeChange(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.ToolButton2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
|
|||
|
if Application.MessageBox('ȷ<><C8B7>Ҫִ<D2AA><D6B4><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
Exit;
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
CDS_Main.DisableControls;
|
|||
|
with CDS_Main do
|
|||
|
begin
|
|||
|
with CDS_HZ do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while not Eof do
|
|||
|
begin
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('Update CK_SXPB_CR Set MXKCQty=(select sum(isnull(Qty,0)*CRQtyFlag) from CK_SXPB_CR A where A.FZSPID=CK_SXPB_CR.SPID)');
|
|||
|
sql.Add(',MXKCPiQty=(select sum(isnull(PiQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.FZSPID=CK_SXPB_CR.SPID)');
|
|||
|
sql.Add(',MXKCKgQty=(select sum(isnull(KgQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.FZSPID=CK_SXPB_CR.SPID)');
|
|||
|
sql.Add(' where SPID=''' + Trim(CDS_HZ.fieldbyname('FZSPID').AsString) + '''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from CK_SXPB_CR where SPID=''' + Trim(CDS_HZ.fieldbyname('FZSPID').AsString) + '''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOQueryTemp.FieldByName('MXKCQty').Value < 0 then
|
|||
|
begin
|
|||
|
CDS_Main.EnableControls;
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
Next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('UPdate CK_SXPB_CR Set ChkStatus=''1'',ChkTime=GETDATE(),Chker=' + QuotedStr(Trim(DName)));
|
|||
|
sql.Add(' where pbid=''' + Trim(CDS_Main.fieldbyname('pbid').AsString) + '''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
end;
|
|||
|
CDS_Main.EnableControls;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
InitGrid();
|
|||
|
except
|
|||
|
CDS_Main.EnableControls;
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!', '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.Button2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
Panel4.Visible := False;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.Button1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if Application.MessageBox('<27>ı<DEB8><C4B1>Ż<EFBFBD>ͬʱ<CDAC><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
Exit;
|
|||
|
if trim(YWNOTE.Text) = '' then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
try
|
|||
|
CDS_Main.DisableControls;
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
with CDS_Main do
|
|||
|
begin
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('Update CK_SXPB_CR Set spcode=''' + trim(YWNOTE.Text) + ''' ');
|
|||
|
sql.Add('where FZSPID=''' + Trim(CDS_Main.fieldbyname('fzspid').AsString) + '''');
|
|||
|
ExecSQL;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
CDS_Main.EnableControls;
|
|||
|
application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
|
|||
|
Panel4.Visible := false;
|
|||
|
TBRafresh.Click;
|
|||
|
exit;
|
|||
|
except
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
CDS_Main.EnableControls;
|
|||
|
application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.ToolButton3Click(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
CDS_Main.DisableControls;
|
|||
|
with CDS_Main do
|
|||
|
begin
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('UPdate CK_SXPB_CR Set ChkStatus=''0'',ChkTime=NULL,Chker=NULL');
|
|||
|
sql.Add(' where pbid=''' + Trim(CDS_Main.fieldbyname('pbid').AsString) + '''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
with CDS_HZ do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while not Eof do
|
|||
|
begin
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
// sql.Add(' delete CK_SXPB_CR where SPID=''' + Trim(CDS_HZ.fieldbyname('SPID').AsString) + '''');
|
|||
|
sql.Add(' Update CK_SXPB_CR Set MXKCQty=(select sum(isnull(Qty,0)*CRQtyFlag) from CK_SXPB_CR A where A.FZSPID=CK_SXPB_CR.SPID)');
|
|||
|
sql.Add(',MXKCPiQty=(select sum(isnull(PiQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.FZSPID=CK_SXPB_CR.SPID)');
|
|||
|
sql.Add(',MXKCKgQty=(select sum(isnull(KgQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.FZSPID=CK_SXPB_CR.SPID)');
|
|||
|
sql.Add(' where SPID=''' + Trim(CDS_HZ.fieldbyname('FZSPID').AsString) + '''');
|
|||
|
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
Next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
CDS_Main.EnableControls;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
InitGrid();
|
|||
|
except
|
|||
|
CDS_Main.EnableControls;
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!', '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.cxTabControl1Change(Sender: TObject);
|
|||
|
begin
|
|||
|
SetStatus();
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.ToolButton4Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
|
|||
|
if Application.MessageBox('ȷ<><C8B7>Ҫִ<D2AA><D6B4><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
Exit;
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
CDS_Main.DisableControls;
|
|||
|
with CDS_Main do
|
|||
|
begin
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('UPdate CK_SXPB_CR Set ChkStatus=''1'',ChkTime=GETDATE(),Chker=' + QuotedStr(Trim(DName)));
|
|||
|
sql.Add(' where pbid=''' + Trim(CDS_Main.fieldbyname('pbid').AsString) + '''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
end;
|
|||
|
CDS_Main.EnableControls;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
InitGrid();
|
|||
|
except
|
|||
|
CDS_Main.EnableControls;
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!', '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.ToolButton5Click(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
|
|||
|
if Application.MessageBox('ȷ<><C8B7>Ҫִ<D2AA>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
Exit;
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
CDS_Main.DisableControls;
|
|||
|
with CDS_Main do
|
|||
|
begin
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('UPdate CK_SXPB_CR SET ChkStatus=NULL,ChkTime=Null,Chker=Null');
|
|||
|
sql.Add(' where pbid=''' + Trim(CDS_Main.fieldbyname('pbid').AsString) + '''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
end;
|
|||
|
CDS_Main.EnableControls;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
InitGrid();
|
|||
|
except
|
|||
|
CDS_Main.EnableControls;
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!', '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmPBOUTSQList.Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty = FALSE then
|
|||
|
begin
|
|||
|
INITSUB();
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|