RTFormwork/项目代码/RTBasicsV1/T04贸易明细仓库/U_TradeClothStkList.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

513 lines
17 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_TradeClothStkList;
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, MovePanel, Math, Clipbrd,
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, cxTextEdit, dxSkinsCore,
dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, U_BaseList, cxPC,
System.StrUtils, cxContainer, dxCore, cxDateUtils, cxMaskEdit, dxSkinWXI,
dxScrollbarAnnotations, 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,
dxSkinXmas2008Blue, FramePagingSel;
type
TfrmTradeClothStkList = class(TfrmBaseList)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBExport: TToolButton;
TBClose: TToolButton;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DS_1: TDataSource;
GPM_1: TcxGridPopupMenu;
CDS_1: TClientDataSet;
ToolButton2: TToolButton;
ToolButton4: TToolButton;
PM_1: TPopupMenu;
PM11: TMenuItem;
N1: TMenuItem;
cxPageControl1: TcxPageControl;
cxTabSheet1: TcxTabSheet;
cxTabSheet2: TcxTabSheet;
Pnl_F1: TPanel;
Label3: TLabel;
Label7: TLabel;
Label10: TLabel;
Label5: TLabel;
lbl1: TLabel;
Label20: TLabel;
Label23: TLabel;
begtime: TDateTimePicker;
endTime: TDateTimePicker;
OrderNo: TcxTextEdit;
conNO: TcxTextEdit;
STKID: TcxTextEdit;
C_Name: TcxTextEdit;
C_Color: TcxTextEdit;
BCIOID: TcxTextEdit;
C_Pattern: TcxTextEdit;
C_Code: TcxTextEdit;
Pnl_F2: TPanel;
Label4: TLabel;
Label6: TLabel;
Label9: TLabel;
Label12: TLabel;
Label13: TLabel;
DateTimePicker3: TDateTimePicker;
DateTimePicker4: TDateTimePicker;
Edit1: TcxTextEdit;
Edit2: TcxTextEdit;
Edit4: TcxTextEdit;
Edit5: TcxTextEdit;
Edit7: TcxTextEdit;
Edit8: TcxTextEdit;
GPM_2: TcxGridPopupMenu;
CDS_2: TClientDataSet;
DS_2: TDataSource;
cxGrid2: TcxGrid;
TV2: TcxGridDBTableView;
cxGridDBColumn2: TcxGridDBColumn;
cxGridDBColumn3: TcxGridDBColumn;
cxGridDBColumn4: TcxGridDBColumn;
cxGridDBColumn5: TcxGridDBColumn;
cxGridDBColumn7: TcxGridDBColumn;
cxGridDBColumn8: TcxGridDBColumn;
cxGridDBColumn9: TcxGridDBColumn;
cxGridDBColumn10: TcxGridDBColumn;
cxGridDBColumn11: TcxGridDBColumn;
cxGridDBColumn12: TcxGridDBColumn;
cxGridDBColumn13: TcxGridDBColumn;
cxGridDBColumn14: TcxGridDBColumn;
cxGridDBColumn15: TcxGridDBColumn;
cxGridDBColumn16: TcxGridDBColumn;
cxGridDBColumn17: TcxGridDBColumn;
cxGridDBColumn18: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
TV2Column1: TcxGridDBColumn;
TV2Column3: TcxGridDBColumn;
Label18: TLabel;
Label19: TLabel;
Edit9: TcxTextEdit;
Edit10: TcxTextEdit;
Label8: TLabel;
Label14: TLabel;
Edit3: TcxTextEdit;
Edit11: TcxTextEdit;
PM_2: TPopupMenu;
MenuItem1: TMenuItem;
N2: TMenuItem;
TV2Column2: TcxGridDBColumn;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column22: TcxGridDBColumn;
v1Column21: TcxGridDBColumn;
v1Column32: TcxGridDBColumn;
v1Column1: TcxGridDBColumn;
Tv1Column4: TcxGridDBColumn;
v1Column13: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
v1Column23: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
v1Column27: TcxGridDBColumn;
v1Column28: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
Tv1Column11: TcxGridDBColumn;
Tv1Column12: TcxGridDBColumn;
Tv1Column10: TcxGridDBColumn;
v1Column12: TcxGridDBColumn;
v1Column42: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
Tv1Column7: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1Column34: TcxGridDBColumn;
v1Column40: TcxGridDBColumn;
v1Column46: TcxGridDBColumn;
VC_BaoNo: TcxGridDBColumn;
VC_PacketId: TcxGridDBColumn;
Tv1Column8: TcxGridDBColumn;
Tv1Column3: TcxGridDBColumn;
Tv1Column1: TcxGridDBColumn;
Tv1Column2: TcxGridDBColumn;
Tv1Column6: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
ToolButton1: TToolButton;
TV2Column4: TcxGridDBColumn;
Tv1Column5: TcxGridDBColumn;
Tv1Column9: TcxGridDBColumn;
Tv1Column13: TcxGridDBColumn;
frmFramePagingSel1: TfrmFramePagingSel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBExportClick(Sender: TObject);
procedure orderNoKeyPress(Sender: TObject; var Key: Char);
procedure BTLPClick(Sender: TObject);
procedure JYTypeChange(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure cxPageControl1Change(Sender: TObject);
procedure CDS_1BeforeOpen(DataSet: TDataSet);
procedure Tv1DataControllerFilterBeforeChange(Sender: TcxDBDataFilterCriteria; ADataSet: TDataSet; const AFilterText: string);
procedure ToolButton4Click(Sender: TObject);
procedure PM11Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure TV2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
procedure MenuItem1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure TV2CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
procedure Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
procedure ToolButton1Click(Sender: TObject);
procedure Tv1DataControllerSummaryFooterSummaryItemsSummary(ASender: TcxDataSummaryItems; Arguments: TcxSummaryEventArguments; var OutArguments: TcxSummaryEventOutArguments);
procedure Tv1TcxGridDBDataControllerTcxDataSummaryFooterSummaryItems6GetText(Sender: TcxDataSummaryItem; const AValue: Variant; AIsFooter: Boolean; var AText: string);
procedure cxButton3Click(Sender: TObject);
procedure frmFramePagingSel1TCBNORPropertiesChange(Sender: TObject);
private
CurrentPage, RecordsNumber: Integer;
lstPacketId: TStringList;
procedure InitGrid(WSql: string);
procedure InitPage();
procedure SetStatus();
{ Private declarations }
public
canshu1, FWorkshop: string;
{ Public declarations }
end;
implementation
uses
U_DataLink, U_RTFun, U_LabelPrint, U_TradeClothSplit;
{$R *.dfm}
procedure TfrmTradeClothStkList.InitPage();
begin
CurrentPage := 1;
case cxPageControl1.ActivePageIndex of
0:
begin
InitGrid(SGetHintFilters(Pnl_F2, 1, 2));
end;
1:
begin
InitGrid(SGetHintFilters(Pnl_F1, 1, 2));
end;
end;
end;
procedure TfrmTradeClothStkList.SetStatus();
begin
// if canshu1 then
end;
procedure TfrmTradeClothStkList.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
FreeAndNil(lstPacketId);
Action := caFree;
end;
procedure TfrmTradeClothStkList.FormCreate(Sender: TObject);
begin
inherited;
lstPacketId := TStringList.Create;
FWorkshop := trim(Self.fParameters3);
end;
procedure TfrmTradeClothStkList.InitGrid(WSql: string);
var
SqlStr: string;
begin
case cxPageControl1.ActivePageIndex of
0:
begin
SqlStr := ' select kl= DATEDIFF(dd,IOTime, GETDATE()), IOTime=CONVERT(VARCHAR(10),IOTime,120),OrderNo,C_Name,PCId,IOType,Grade,CustName,C_Width,C_GramWeight,CIMachNo,Workshop,BatchNo,IOPosition,C_Color,C_Pattern';
SqlStr := SqlStr + ' ,COUNT(PieceNo) SumPieceNo,sum(GrossWeight) SumGrossWeight,sum(Tare) SumTare,sum(NetWeight) SumNetWeight';
SqlStr := SqlStr + ' ,Sum(Meter) SumMeter,Sum(Yardage) SumYardage';
SqlStr := SqlStr + ' from V_Trade_Cloth_Stk A where 1=1 ';
if trim(FWorkshop) <> '' then
SqlStr := SqlStr + ' and Workshop=''' + trim(FWorkshop) + ''' ';
if trim(WSql) <> '' then
SqlStr := SqlStr + 'and ' + WSql;
SqlStr := SqlStr + ' GROUP BY DATEDIFF(dd,IOTime, GETDATE()), CONVERT(VARCHAR(10),IOTime,120),OrderNo,C_Name,PCId,IOType,Grade,CustName,C_Width,C_GramWeight,CIMachNo,Workshop,BatchNo,IOPosition,C_Color,C_Pattern';
InitCDSData(ADOQueryMain, CDS_2, Tv2, SqlStr, '', '');
end;
1:
begin
SqlStr := ' select top ' + inttostr(RecordsNumber) + ' * ';
SqlStr := SqlStr + ' from ';
SqlStr := SqlStr + '(select rownumber=cast((row_number() over(order by AA.IOTime desc)) as int)';
SqlStr := SqlStr + ',COUNT(1) OVER() AS TotalCount';
SqlStr := SqlStr + ', kl= DATEDIFF(dd,IOTime, GETDATE()),* from V_Trade_Cloth_Stk AA where 1=1 ';
if trim(WSql) <> '' then
SqlStr := SqlStr + 'and ' + WSql;
if trim(FWorkshop) <> '' then
SqlStr := SqlStr + ' and Workshop=''' + trim(FWorkshop) + '''';
SqlStr := SqlStr + 'and 1=1 ' + WSql;
SqlStr := SqlStr + ') temp_row';
SqlStr := SqlStr + ' where rownumber> ' + inttostr(((CurrentPage - 1) * RecordsNumber));
SqlStr := SqlStr + ' order by rownumber';
InitCDSData(ADOQueryMain, CDS_1, Tv1, SqlStr, '', 'stkid');
frmFramePagingSel1.LBDQY.Caption := inttostr(CurrentPage);
frmFramePagingSel1.LBZYS.Caption := inttostr(ceil(CDS_1.FieldByName('TotalCount').AsInteger / RecordsNumber));
end;
end;
end;
procedure TfrmTradeClothStkList.TBRafreshClick(Sender: TObject);
begin
InitPage();
end;
procedure TfrmTradeClothStkList.CDS_1BeforeOpen(DataSet: TDataSet);
begin
lstPacketId.Clear;
end;
procedure TfrmTradeClothStkList.cxButton3Click(Sender: TObject);
begin
if CurrentPage < CDS_1.FieldByName('TotalCount').AsInteger / RecordsNumber then
CurrentPage := CurrentPage + 1;
InitGrid(SGetHintFilters(Pnl_F1, 1, 2));
end;
procedure TfrmTradeClothStkList.cxPageControl1Change(Sender: TObject);
begin
SetStatus();
end;
procedure TfrmTradeClothStkList.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmTradeClothStkList.FormShow(Sender: TObject);
begin
inherited;
ReadCxGrid(trim(self.Caption) + 'Tv1', Tv1, <>׳<EFBFBD>Ʒ<EFBFBD>ֿ<EFBFBD>');
ReadCxGrid(trim(self.Caption) + 'Tv2', Tv2, <>׳<EFBFBD>Ʒ<EFBFBD>ֿ<EFBFBD>');
CurrentPage := 1;
RecordsNumber := 500;
canshu1 := Trim(Self.fParameters1);
SetStatus();
InitPage();
end;
procedure TfrmTradeClothStkList.frmFramePagingSel1TCBNORPropertiesChange(Sender: TObject);
begin
RecordsNumber := StrToInt(frmFramePagingSel1.TCBNOR.Text);
CurrentPage := 1;
InitGrid(SGetHintFilters(Pnl_F1, 1, 2));
end;
procedure TfrmTradeClothStkList.TBExportClick(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then
exit;
TcxGridToExcel(Self.Caption, cxGrid1);
end;
procedure TfrmTradeClothStkList.orderNoKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
InitPage();
end;
end;
procedure TfrmTradeClothStkList.PM11Click(Sender: TObject);
begin
SelOKNo(CDS_1, false);
end;
procedure TfrmTradeClothStkList.Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
if AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('kl').Index] > 90 then
ACanvas.Brush.Color := $B3DEF5;
end;
procedure TfrmTradeClothStkList.Tv1DataControllerFilterBeforeChange(Sender: TcxDBDataFilterCriteria; ADataSet: TDataSet; const AFilterText: string);
begin
lstPacketId.Clear; //<2F><><EFBFBD>´<EFBFBD><C2B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>lstPacketId
end;
procedure TfrmTradeClothStkList.Tv1DataControllerSummaryFooterSummaryItemsSummary(ASender: TcxDataSummaryItems; Arguments: TcxSummaryEventArguments; var OutArguments: TcxSummaryEventOutArguments);
var
BaoID: string;
begin
//<2F><> VC_PacketId <20>еĺϼƽ<CFBC><C6BD>д<EFBFBD><D0B4><EFBFBD>
if TcxGridDBTableSummaryItem(Arguments.SummaryItem).Column = VC_PacketId then
begin
BaoID := vartostr(ASender.DataController.Values[Arguments.RecordIndex, VC_PacketId.Index]);
if BaoID = '' then
Exit;
if BaoID = null then
Exit;
if lstPacketId.IndexOf(BaoID) = -1 then
begin
lstPacketId.Add(BaoID); //<2F><><EFBFBD><EFBFBD>֮ǰδ<C7B0><CEB4><EFBFBD>ֹ<EFBFBD><D6B9>İ<EFBFBD><C4B0><EFBFBD><EFBFBD><EFBFBD>
end;
end;
end;
procedure TfrmTradeClothStkList.Tv1TcxGridDBDataControllerTcxDataSummaryFooterSummaryItems6GetText(Sender: TcxDataSummaryItem; const AValue: Variant; AIsFooter: Boolean; var AText: string);
begin
if lstPacketId <> nil then
AText := IntToStr(lstPacketId.Count);
end;
procedure TfrmTradeClothStkList.TV2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
cxPageControl1.ActivePageIndex := 1;
SetStatus();
InitGrid(SGetCDSFilters(Tv2, CDS_2));
end;
procedure TfrmTradeClothStkList.TV2CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
if AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('kl').Index] > 90 then
ACanvas.Brush.Color := $B3DEF5;
end;
procedure TfrmTradeClothStkList.BTLPClick(Sender: TObject);
begin
if CurrentPage > 1 then
CurrentPage := CurrentPage - 1;
InitGrid(SGetHintFilters(Pnl_F1, 1, 2));
end;
procedure TfrmTradeClothStkList.JYTypeChange(Sender: TObject);
begin
CurrentPage := 1;
InitPage();
end;
procedure TfrmTradeClothStkList.MenuItem1Click(Sender: TObject);
begin
Clipboard.SetTextBuf(PChar(Trim(CDS_2.fieldbyname(TV2.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
end;
procedure TfrmTradeClothStkList.N1Click(Sender: TObject);
begin
SelOKNo(CDS_1, true);
end;
procedure TfrmTradeClothStkList.N2Click(Sender: TObject);
begin
Clipboard.SetTextBuf(PChar(Trim(CDS_1.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
end;
procedure TfrmTradeClothStkList.ToolButton1Click(Sender: TObject);
begin
try
frmTradeClothSplit := TfrmTradeClothSplit.Create(Application);
with frmTradeClothSplit do
begin
FStkID := trim(self.CDS_1.FieldByName('StkID').AsString);
if ShowModal = 1 then
begin
InitGrid('');
end;
end;
finally
frmTradeClothSplit.Free;
end;
end;
procedure TfrmTradeClothStkList.ToolButton2Click(Sender: TObject);
var
WSql: string;
begin
if CDS_1.IsEmpty then
Exit;
if not CDS_1.Locate('SSel', True, []) 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 + ',' + QuotedStr(Trim(CDS_1.fieldbyname('CIID').AsString));
end
else
begin
WSql := QuotedStr(Trim(CDS_1.fieldbyname('CIID').AsString));
end;
end;
Next;
end;
end;
ShowMessage(WSql);
CDS_1.Locate('SSel', True, []);
CDS_1.EnableControls;
try
frmLabelPrint := TfrmLabelPrint.Create(Application);
with frmLabelPrint do
begin
FLMType := 'TradeClothStk';
FFiltration1 := WSql;
if ShowModal = 1 then
begin
end;
end;
finally
frmLabelPrint.Free;
end;
end;
procedure TfrmTradeClothStkList.ToolButton4Click(Sender: TObject);
begin
WriteCxGrid(trim(self.Caption) + 'Tv1', Tv1, <>׳<EFBFBD>Ʒ<EFBFBD>ֿ<EFBFBD>');
WriteCxGrid(trim(self.Caption) + 'Tv2', Tv2, <>׳<EFBFBD>Ʒ<EFBFBD>ֿ<EFBFBD>');
end;
end.