531 lines
14 KiB
ObjectPascal
531 lines
14 KiB
ObjectPascal
unit U_FinishedClothOutList;
|
||
|
||
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, RM_Common, RM_Class, RM_e_Xls, RM_Dataset, RM_System,
|
||
RM_GridReport, cxCheckBox, Menus, MovePanel, BtnEdit, cxPC, cxLookAndFeels,
|
||
cxLookAndFeelPainters, dxBarBuiltInMenu, cxNavigator;
|
||
|
||
type
|
||
TfrmFinishedClothOutList = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBExport: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
Label1: TLabel;
|
||
Label2: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
CDS_Main: TClientDataSet;
|
||
RM1: TRMGridReport;
|
||
RMDBMain: TRMDBDataSet;
|
||
RMXLSExport1: TRMXLSExport;
|
||
Label10: TLabel;
|
||
CKNo: TEdit;
|
||
TBCKCX: TToolButton;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
N2: TMenuItem;
|
||
MovePanel2: TMovePanel;
|
||
Label3: TLabel;
|
||
Label4: TLabel;
|
||
Label5: TLabel;
|
||
Label6: TLabel;
|
||
P_CodeName: TEdit;
|
||
toconno: TEdit;
|
||
OrderNo: TEdit;
|
||
JYID: TEdit;
|
||
Label8: TLabel;
|
||
ADOQueryPrint: TADOQuery;
|
||
Label12: TLabel;
|
||
P_Code: TEdit;
|
||
Label14: TLabel;
|
||
KHName: TEdit;
|
||
Label9: TLabel;
|
||
JTH: TEdit;
|
||
ComboBox1: TComboBox;
|
||
ToolButton2: TToolButton;
|
||
Label13: TLabel;
|
||
BatchNo: TEdit;
|
||
Panel2: TPanel;
|
||
Panel3: TPanel;
|
||
cxTabControl1: TcxTabControl;
|
||
Panel6: TPanel;
|
||
Label7: TLabel;
|
||
LBCPAP: TLabel;
|
||
BTLP: TButton;
|
||
BTNP: TButton;
|
||
TCBNOR: TComboBox;
|
||
cxGrid2: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1Sel: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1Column8: TcxGridDBColumn;
|
||
v1Column9: TcxGridDBColumn;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
v1Column4: TcxGridDBColumn;
|
||
v2Column1: TcxGridDBColumn;
|
||
v2Column3: TcxGridDBColumn;
|
||
cxgrdPS: TcxGridDBColumn;
|
||
v1Column10: TcxGridDBColumn;
|
||
v1Column6: TcxGridDBColumn;
|
||
v1Column5: TcxGridDBColumn;
|
||
cxgrdMJLen: TcxGridDBColumn;
|
||
cxGrid2Level1: TcxGridLevel;
|
||
Label11: TLabel;
|
||
JYType: TComboBox;
|
||
v1Column7: TcxGridDBColumn;
|
||
Tv1Column1: TcxGridDBColumn;
|
||
Tv1Column2: TcxGridDBColumn;
|
||
Tv1Column3: TcxGridDBColumn;
|
||
Tv1Column4: TcxGridDBColumn;
|
||
Tv1Column5: TcxGridDBColumn;
|
||
Tv1Column6: TcxGridDBColumn;
|
||
Tv1Column7: TcxGridDBColumn;
|
||
Tv1Column8: TcxGridDBColumn;
|
||
Tv1Column9: TcxGridDBColumn;
|
||
Label15: TLabel;
|
||
SHDWName: TEdit;
|
||
Tv1Column10: TcxGridDBColumn;
|
||
conno: TEdit;
|
||
ToolButton1: TToolButton;
|
||
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 N1Click(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
procedure TBCKCXClick(Sender: TObject);
|
||
procedure OrderNoKeyPress(Sender: TObject; var Key: Char);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure Tv1DblClick(Sender: TObject);
|
||
procedure BTLPClick(Sender: TObject);
|
||
procedure BTNPClick(Sender: TObject);
|
||
procedure TCBNORChange(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
private
|
||
CurrentPage, RecordsNumber: Integer;
|
||
procedure InitGrid();
|
||
procedure SetStatus();
|
||
{ Private declarations }
|
||
public
|
||
canshu1: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_Fun, U_ZDYHelp;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmFinishedClothOutList.SetStatus();
|
||
var
|
||
i: Integer;
|
||
begin
|
||
TBCKCX.Visible := False;
|
||
ToolButton1.Visible := False;
|
||
case cxTabControl1.TabIndex of
|
||
0:
|
||
begin
|
||
ClearOrHideControls(Panel1, '0', True, True);
|
||
ClearOrHideControls(Panel1, '1', True, False);
|
||
|
||
for i := 0 to tv1.ColumnCount - 1 do
|
||
begin
|
||
tv1.Columns[i].Visible := false;
|
||
end;
|
||
IsVisibleTV(Panel1, TV1, '0', True);
|
||
cxgrdPS.Visible := True;
|
||
cxgrdMJLen.Visible := True;
|
||
Tv1Column8.Visible := True;
|
||
Tv1Column9.Visible := True;
|
||
Tv1Column3.Visible := True;
|
||
ToolButton1.Visible := True;
|
||
end;
|
||
|
||
1:
|
||
begin
|
||
for i := 0 to tv1.ColumnCount - 1 do
|
||
begin
|
||
tv1.Columns[i].Visible := True;
|
||
end;
|
||
cxgrdPS.Visible := false;
|
||
|
||
ClearOrHideControls(Panel1, '0', False, True);
|
||
ClearOrHideControls(Panel1, '1', False, True);
|
||
if canshu1 = '<27><><EFBFBD><EFBFBD>' then
|
||
TBCKCX.Visible := true;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.FormCreate(Sender: TObject);
|
||
begin
|
||
//cxGrid1.Align:=alClient;
|
||
BegDate.DateTime := SGetServerDateTime(ADOQueryTemp);
|
||
EndDate.DateTime := SGetServerDateTime(ADOQueryTemp)
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.InitGrid();
|
||
var
|
||
fwhere, Pwhere: string;
|
||
begin
|
||
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered := False;
|
||
Close;
|
||
sql.Clear;
|
||
|
||
case cxTabControl1.TabIndex of
|
||
0: /////////////////////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>//////////////////////////////
|
||
begin
|
||
Pwhere := SGetFilters(Panel1, 1, 2);
|
||
if trim(Pwhere) <> '' then
|
||
fwhere := fwhere + ' where ' + Trim(Pwhere);
|
||
|
||
sql.Add('exec P_CPCK_Get_CKHZ ');
|
||
sql.add('''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)) + ''' ');
|
||
sql.Add(',''' + Trim(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1)) + '''');
|
||
sql.Add(',' + QuotedStr(fwhere) + ' ');
|
||
end;
|
||
1: /////////////////////////<2F><>ϸ//////////////////////////////
|
||
begin
|
||
fwhere := ' where CRTime>' + quotedstr(FormatDateTime('yyyy-MM-dd', BegDate.DateTime));
|
||
fwhere := fwhere + ' and CRTime<=' + quotedstr(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1));
|
||
|
||
Pwhere := SGetFilters(Panel1, 1, 2);
|
||
if trim(Pwhere) <> '' then
|
||
fwhere := fwhere + ' and ' + trim(Pwhere);
|
||
sql.Add('exec P_CPCK_Get_CK ');
|
||
sql.Add('@pageIndex=' + inttostr(CurrentPage));
|
||
sql.Add(',@pageSize=' + inttostr(RecordsNumber));
|
||
sql.Add(',@criteria= ' + quotedstr(fwhere));
|
||
end;
|
||
end;
|
||
//ShowMessage(SQL.Text);
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain, CDS_Main);
|
||
SInitCDSData20(ADOQueryMain, CDS_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
BegDate.SetFocus;
|
||
SetStatus();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.ConNoMChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(Self.Caption, Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.FormShow(Sender: TObject);
|
||
var
|
||
fsj: string;
|
||
begin
|
||
CurrentPage := 1;
|
||
RecordsNumber := 500;
|
||
// fsj := 'select distinct Code=Null,Name=CRType from FinishedCloth_CR where CRFlag=''<27><><EFBFBD><EFBFBD>'' order by CRType ';
|
||
// SInitComBoxBySql(ADOQueryTemp, CRType, False, fsj);
|
||
ReadCxGrid(Self.Caption, Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
||
SetStatus();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.TBExportClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then
|
||
exit;
|
||
SelExportData(Tv1, ADOQueryMain, '');
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.N1Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main, True);
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.N2Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main, False);
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.TBCKCXClick(Sender: TObject);
|
||
var
|
||
FFMainId, FPrice, FHZ, FCKOrderNo: string;
|
||
begin
|
||
if CDS_Main.IsEmpty then
|
||
Exit;
|
||
if CDS_Main.Locate('SSel', True, []) = False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
// CDS_Main.DisableControls;
|
||
// with CDS_Main do
|
||
// begin
|
||
// First;
|
||
// while not Eof do
|
||
// begin
|
||
// if CDS_Main.FieldByName('SSel').AsBoolean = True then
|
||
// begin
|
||
// if FCKOrderNo = '' then
|
||
// begin
|
||
// FCKOrderNo := Trim(CDS_Main.fieldbyname('CKOrdNo').AsString);
|
||
// with ADOQueryTemp do
|
||
// begin
|
||
// Close;
|
||
// sql.Clear;
|
||
// sql.Add('select * from YF_Money_CR_Sub where yfpzno=''' + Trim(CDS_Main.fieldbyname('CKOrdNo').AsString) + '''');
|
||
// Open;
|
||
// end;
|
||
// if ADOQueryTemp.IsEmpty = False then
|
||
// begin
|
||
// CDS_Main.EnableControls;
|
||
// Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>տ<D5BF><EEA3AC><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
// Exit;
|
||
// end;
|
||
// end;
|
||
// end;
|
||
// Next;
|
||
// end;
|
||
// end;
|
||
// CDS_Main.EnableControls;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
||
Exit;
|
||
|
||
MovePanel2.Visible := True;
|
||
MovePanel2.Refresh;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
CDS_Main.DisableControls;
|
||
with CDS_Main do
|
||
begin
|
||
First;
|
||
while CDS_Main.Locate('SSel', True, []) = True do
|
||
begin
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('EXEC P_CPCK_UP_CKRE @JYID=' + quotedstr(trim(CDS_Main.fieldbyname('JYID').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><E2B3B7>')));
|
||
sql.Add(',' + quotedstr(trim('<27><><EFBFBD>ⵥ<EFBFBD>ţ<EFBFBD>' + trim(CDS_Main.FieldByName('CKNo').AsString) + ' <20><><EFBFBD>룺' + trim(CDS_Main.FieldByName('JYID').AsString))));
|
||
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
|
||
sql.Add(')');
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('exec P_FHSQ_UP_QTY1 ' + quotedstr(trim(CDS_Main.fieldbyname('CKNo').asstring)));
|
||
ExecSQL;
|
||
end;
|
||
CDS_Main.Delete;
|
||
end;
|
||
end;
|
||
end;
|
||
CDS_Main.EnableControls;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
MovePanel2.Visible := False;
|
||
Exit;
|
||
except
|
||
MovePanel2.Visible := False;
|
||
CDS_Main.EnableControls;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD><ECB3A3>', '<27><>ʾ', 0);
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.OrderNoKeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
if Key = #13 then
|
||
begin
|
||
// SetStatus();
|
||
InitGrid();
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.ToolButton2Click(Sender: TObject);
|
||
var
|
||
fPrintFile: string;
|
||
begin
|
||
if CDS_Main.IsEmpty then
|
||
EXIT;
|
||
ExportFtErpFile(trim(ComboBox1.Text) + '.rmf', ADOQueryTemp);
|
||
if ComboBox1.Text = '<27><>ͨ<EFBFBD>뵥' then
|
||
begin
|
||
with ADOQueryPrint do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.add('exec P_Print_CKMDZZ1 ' + quotedstr(Trim(CDS_Main.fieldbyname('CKOrdNo').AsString)));
|
||
Open;
|
||
end;
|
||
end;
|
||
|
||
if trim(ComboBox1.Text) = '<27><>ͨ<EFBFBD><CDA8>̨<EFBFBD>뵥' then
|
||
begin
|
||
with ADOQueryPrint do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.add('exec P_Print_CKMDZZ2 ' + quotedstr(Trim(CDS_Main.fieldbyname('CKOrdNo').AsString)));
|
||
Open;
|
||
end;
|
||
end;
|
||
if ComboBox1.Text = '<27><>ҳ<EFBFBD><D2B3>̨<EFBFBD>뵥' then
|
||
begin
|
||
with ADOQueryPrint do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.add('exec P_Print_CKMDZZ3 ' + quotedstr(Trim(CDS_Main.fieldbyname('CKOrdNo').AsString)));
|
||
Open;
|
||
end;
|
||
end;
|
||
|
||
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + Trim(ComboBox1.Text) + '.rmf';
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
RM1.DefaultCopies := 2;
|
||
RM1.LoadFromFile(fPrintFile);
|
||
RM1.ShowReport;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
SetStatus();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.Tv1DblClick(Sender: TObject);
|
||
var
|
||
Tabint: integer;
|
||
str: string;
|
||
begin
|
||
Tabint := cxTabControl1.TabIndex;
|
||
case Tabint of
|
||
0:
|
||
begin
|
||
AssignmentControls(Panel1, CDS_Main, '0');
|
||
cxTabControl1.TabIndex := 1;
|
||
end;
|
||
end;
|
||
// str:=cds_Main.fieldbyname('orderno').Value;
|
||
// ShowMessage(str);
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.BTLPClick(Sender: TObject);
|
||
begin
|
||
if CurrentPage > 1 then
|
||
CurrentPage := CurrentPage - 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.BTNPClick(Sender: TObject);
|
||
begin
|
||
if CurrentPage < CDS_Main.FieldByName('TotalCount').AsInteger / RecordsNumber then
|
||
CurrentPage := CurrentPage + 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.TCBNORChange(Sender: TObject);
|
||
begin
|
||
RecordsNumber := StrToInt(TCBNOR.Text);
|
||
CurrentPage := 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmFinishedClothOutList.ToolButton1Click(Sender: TObject);
|
||
var
|
||
fPrintFile: string;
|
||
fwhere, Pwhere: string;
|
||
begin
|
||
|
||
if CDS_Main.IsEmpty then
|
||
EXIT;
|
||
Pwhere := SGetFilters(Panel1, 1, 2);
|
||
if trim(Pwhere) <> '' then
|
||
fwhere := fwhere + ' where ' + Trim(Pwhere);
|
||
with ADOQueryPrint do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('exec P_CPCK_PRINT_RBB ');
|
||
sql.add('''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)) + ''' ');
|
||
sql.Add(',''' + Trim(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1)) + '''');
|
||
sql.Add(',' + QuotedStr(fwhere) + ' ');
|
||
Open;
|
||
end;
|
||
ExportFtErpFile('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ձ<EFBFBD><D5B1><EFBFBD>.rmf', ADOQueryTemp);
|
||
|
||
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ձ<EFBFBD><D5B1><EFBFBD>.rmf';
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
RM1.DefaultCopies := 1;
|
||
RM1.LoadFromFile(fPrintFile);
|
||
RM1.ShowReport;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
end.
|
||
|