RTFormwork/项目代码/RTBasicsV1/T02贸易汇总仓库/U_TradeClothOutInspList.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

496 lines
14 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_TradeClothOutInspList;
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, BtnEdit,
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore,
dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, U_BaseList,
Vcl.CheckLst, cxContainer, Vcl.Clipbrd, cxPC;
type
TfrmTradeClothOutInspList = class(TfrmBaseList)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBFind: TToolButton;
TBExport: TToolButton;
TBClose: TToolButton;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DataSource1: TDataSource;
cxGridPopupMenu1: TcxGridPopupMenu;
CDS_Main: TClientDataSet;
RMDBMain: TRMDBDataSet;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column2: TcxGridDBColumn;
v1Column26: TcxGridDBColumn;
v1Column13: TcxGridDBColumn;
v2Column1: TcxGridDBColumn;
v1Column22: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
v2Column6: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
v1Column1: TcxGridDBColumn;
v1Column14: TcxGridDBColumn;
v1Column15: TcxGridDBColumn;
v1Column17: TcxGridDBColumn;
v1Column18: TcxGridDBColumn;
v1Column20: TcxGridDBColumn;
v1Column23: TcxGridDBColumn;
v1Column27: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
Panel1: TPanel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label7: TLabel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
C_Name: TEdit;
FromCoName: TEdit;
ToOrdNo: TEdit;
Tv1Column4: TcxGridDBColumn;
Label6: TLabel;
Label8: TLabel;
BCIOID: TEdit;
C_ColorNo: TEdit;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
Tv1Column11: TcxGridDBColumn;
Label10: TLabel;
C_Color: TEdit;
Tv1Column17: TcxGridDBColumn;
ToolButton5: TToolButton;
N3: TMenuItem;
Tv1Column19: TcxGridDBColumn;
Tv1Column20: TcxGridDBColumn;
Panel2: TPanel;
cxTabControl1: TcxTabControl;
cxchckbx1: TcxCheckBox;
cxchckbx2: TcxCheckBox;
cxchckbx3: TcxCheckBox;
Tv1Column1: TcxGridDBColumn;
Label1: TLabel;
Tv1Column2: TcxGridDBColumn;
Label5: TLabel;
C_Pattern: TEdit;
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 N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure SPIDKeyPress(Sender: TObject; var Key: Char);
procedure SPSpecChange(Sender: TObject);
procedure FromCoNameChange(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure Tv1Column16PropertiesEditValueChanged(Sender: TObject);
procedure cxchckbx1Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
procedure cxTabControl1Change(Sender: TObject);
private
procedure SetStatus();
procedure InitGrid();
{ Private declarations }
public
FSTKName, canshu1: string;
{ Public declarations }
end;
var
frmTradeClothOutInspList: TfrmTradeClothOutInspList;
implementation
uses
U_DataLink, U_RTFun, U_ZDYHelp;
{$R *.dfm}
procedure TfrmTradeClothOutInspList.SetStatus();
begin
end;
procedure TfrmTradeClothOutInspList.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
end;
procedure TfrmTradeClothOutInspList.FormCreate(Sender: TObject);
begin
inherited;
EndDate.DateTime := SGetServerDate(ADOQueryTemp);
BegDate.DateTime := EndDate.DateTime;
end;
procedure TfrmTradeClothOutInspList.InitGrid();
var
MInsp_WastageFlag: string;
begin
MInsp_WastageFlag := '';
if cxchckbx1.Checked then
begin
if MInsp_WastageFlag = '' then
MInsp_WastageFlag := QUOTEDSTR(Trim('1'))
else
MInsp_WastageFlag := MInsp_WastageFlag + ',' + QUOTEDSTR(Trim('1'));
end;
if cxchckbx2.Checked then
begin
if MInsp_WastageFlag = '' then
MInsp_WastageFlag := QUOTEDSTR(Trim('2'))
else
MInsp_WastageFlag := MInsp_WastageFlag + ',' + QUOTEDSTR(Trim('2'));
end;
if cxchckbx3.Checked then
begin
if MInsp_WastageFlag = '' then
MInsp_WastageFlag := QUOTEDSTR(Trim('3'))
else
MInsp_WastageFlag := MInsp_WastageFlag + ',' + QUOTEDSTR(Trim('3'));
end;
with ADOQueryCMD do
begin
Close;
sql.Clear;
sql.Add(' EXEC P_Trade_ClothOutInsp_PSC ');
ExecSQL;
end;
with ADOQueryMain do
begin
Close;
sql.Clear;
sql.Add(' select A.* ');
sql.Add(' from BS_Cloth_IO A');
SQL.Add(' where ioFlag=''<27><><EFBFBD><EFBFBD>'' and IOtype=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' and isnull(stkName,'''')=''' + Trim(FstkName) + '''');
if MInsp_WastageFlag <> '' then
sql.Add('and Insp_WastageFlag in (' + MInsp_WastageFlag + ') ');
case cxTabControl1.TabIndex of
0:
begin
sql.Add('and isnull(Insp_Piece,0) =0 ');
end;
1:
begin
sql.Add('and isnull(Insp_Piece,0)>0 ');
sql.add(' and A.IOTime>=''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)) + '''');
sql.Add(' and A.IOTime<''' + Trim(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1)) + '''');
end;
2:
begin
end;
end;
Open;
end;
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
SCreateCDS(ADOQueryMain, CDS_Main);
SInitCDSData(ADOQueryMain, CDS_Main);
TV1.DataController.Filter.Clear;
end;
procedure TfrmTradeClothOutInspList.TBRafreshClick(Sender: TObject);
begin
BegDate.SetFocus;
InitGrid();
end;
procedure TfrmTradeClothOutInspList.ToolButton1Click(Sender: TObject);
begin
if not CDS_Main.Locate('SSel', TRUE, []) then
begin
application.MessageBox('<27><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 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
with CDS_Main do
begin
DisableControls;
First;
while not eof do
begin
if fieldbyname('SSel').AsBoolean then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('update CK_SXPB_CR set DJWCFlag=1,DJWCTime=getdate(),DJWCer=' + quotedstr(DName));
sql.Add(' where SPID=' + quotedstr(trim(CDS_Main.FieldByName('SPID').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(CDS_Main.FieldByName('SPID').AsString)));
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
sql.Add(')');
execsql;
end;
end;
next;
end;
First;
EnableControls;
end;
InitGrid();
except
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmTradeClothOutInspList.ToolButton2Click(Sender: TObject);
begin
if not CDS_Main.Locate('SSel', TRUE, []) then
begin
application.MessageBox('<27><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
exit;
end;
if Application.MessageBox(<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
Exit;
try
with CDS_Main do
begin
DisableControls;
First;
while not eof do
begin
if fieldbyname('SSel').AsBoolean then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('update CK_SXPB_CR set DJWCFlag=0,DJWCTime=null,DJWCer=null');
sql.Add(' where SPID=' + quotedstr(trim(CDS_Main.FieldByName('SPID').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(CDS_Main.FieldByName('SPID').AsString)));
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
sql.Add(')');
execsql;
end;
end;
next;
end;
First;
EnableControls;
end;
InitGrid();
except
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmTradeClothOutInspList.ToolButton5Click(Sender: TObject);
begin
WriteCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure TfrmTradeClothOutInspList.CheckBox1Click(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmTradeClothOutInspList.CheckBox2Click(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmTradeClothOutInspList.ConNoMChange(Sender: TObject);
begin
if ADOQueryMain.Active then
begin
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
end;
end;
procedure TfrmTradeClothOutInspList.cxchckbx1Click(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmTradeClothOutInspList.cxTabControl1Change(Sender: TObject);
begin
BegDate.SetFocus;
InitGrid();
end;
procedure TfrmTradeClothOutInspList.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmTradeClothOutInspList.FormShow(Sender: TObject);
begin
inherited;
SetStatus();
ReadCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
InitGrid();
end;
procedure TfrmTradeClothOutInspList.TBExportClick(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then
exit;
TcxGridToExcel('<27><><EFBFBD><EFBFBD><ECB2BC><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>', cxGrid1);
end;
procedure TfrmTradeClothOutInspList.TBFindClick(Sender: TObject);
begin
if ADOQueryMain.Active then
begin
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
SCreateCDS(ADOQueryMain, CDS_Main);
SInitCDSData(ADOQueryMain, CDS_Main);
end;
end;
procedure TfrmTradeClothOutInspList.N1Click(Sender: TObject);
begin
SelOKNoFiler(TV1, True);
end;
procedure TfrmTradeClothOutInspList.N2Click(Sender: TObject);
begin
SelOKNoFiler(TV1, False);
end;
procedure TfrmTradeClothOutInspList.N3Click(Sender: TObject);
begin
Clipboard.SetTextBuf(PChar(Trim(CDS_Main.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
end;
procedure TfrmTradeClothOutInspList.SPIDKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
{if Length(Trim(SPID.Text))<4 then Exit;
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add(' select A.* ');
sql.Add(',ConNo=(select ConNo from Contract_Main CM where CM.MainId=A.CGMainId)');
//sql.Add(' ,ConNo=(select ConNo from Contract_Main CM where CM.MainId=A.CGMainId )');
sql.Add(' from CK_SXPB_CR A');
sql.add(' where SPID like :SXID');
Parameters.ParamByName('SXID').Value:='%'+Trim(SXID.Text)+'%';
Open;
//ShowMessage(SQL.Text);
end;
SCreateCDS(ADOQueryMain,CDS_Main);
SInitCDSData(ADOQueryMain,CDS_Main);
finally
ADOQueryMain.EnableControls;
end; }
end;
end;
procedure TfrmTradeClothOutInspList.SPSpecChange(Sender: TObject);
begin
TBFind.Click;
end;
procedure TfrmTradeClothOutInspList.FromCoNameChange(Sender: TObject);
begin
TBFind.Click;
end;
procedure TfrmTradeClothOutInspList.FormDestroy(Sender: TObject);
begin
inherited;
frmTradeClothOutInspList := nil;
end;
procedure TfrmTradeClothOutInspList.Tv1Column16PropertiesEditValueChanged(Sender: TObject);
var
mvalue, FFieldName: string;
begin
mvalue := TcxTextEdit(Sender).EditingText;
FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_Main do
begin
Edit;
FieldByName(FFieldName).Value := mvalue;
Post;
end;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('update CK_SXPB_CR set ' + FFieldName + '=' + quotedstr(Trim(mvalue)));
sql.Add('where SPID=' + quotedstr(Trim(CDS_Main.fieldbyname('SPID').AsString)));
ExecSQL;
end;
tv1.Controller.EditingController.ShowEdit();
end;
procedure TfrmTradeClothOutInspList.Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
if AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('Insp_WastageFlag').Index] = null then
Exit;
if (AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('Insp_WastageFlag').Index]) = 1 then
ACanvas.Brush.Color := $00FF00;
if (AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('Insp_WastageFlag').Index]) = 2 then
ACanvas.Brush.Color := $00FFFF;
if (AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('Insp_WastageFlag').Index]) = 3 then
ACanvas.Brush.Color := $4763FF;
end;
end.