type
TFrmCKRealTimeStorageRep = class(TFrmCKCellEditor)
Panel1: TPanel;
ClbStorage: TCheckListBox;
SBtnQuery: TSpeedButton;
UISet: TUISet;
CDSStorage: TClientDataSet;
CellReport: TCellReport;
CDSSource: TClientDataSet;
procedure SBtnQueryClick(Sender: TObject);
procedure CellReportAfterExecReport(Cell: TCell);
private
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
var
FrmCKRealTimeStorageRep: TFrmCKRealTimeStorageRep;
implementation
{$R *.dfm}
{ TFrmCKRealTimeStorageRep }
constructor TFrmCKRealTimeStorageRep.Create(AOwner: TComponent);
var
sSQL: string;
begin
inherited;
sSQL := ''select * from T_CK_BASE_STORAGE'';
CDSStorage.Data := UISet.GetData(sSQL);
ClbStorage.Items.Clear;
CDSStorage.First;
while not CDSStorage.Eof do
begin
ClbStorage.Items.Add(CDSStorage.FieldByName(''F_NAME'').AsString);
CDSStorage.Next;
end;
end;
destructor TFrmCKRealTimeStorageRep.Destroy;
begin
inherited;
end;
procedure TFrmCKRealTimeStorageRep.SBtnQueryClick(Sender: TObject);
var
sSQL: string;
sStorageList: string;
I: Integer;
begin
inherited;
for I := 0 to ClbStorage.Count - 1 do
begin
if ClbStorage.Checked[I] then
begin
CDSStorage.First;
CDSStorage.MoveBy(I);
if sStorageList = '''' then
sStorageList := CDSStorage.FieldByName(''ID'').AsString
else
sStorageList := sStorageList + '','' +
CDSStorage.FieldByName(''ID'').AsString;
end;
end;
if sStorageList = '''' then
raise Exception.Create(''请选择仓库'');
sSQL := ''select '' +
'' a.F_CODE,'' +
'' a.F_NAME as F_ITEM_NAME, '' +
'' a.F_SPEC as F_SPEC,'' +
'' d.F_UNIT as F_UNIT,'' +
'' a.F_PRICE as F_PRICE,'' +
'' b.F_NAME AS F_STORAGE,'' +
'' c.F_NUM as F_NUM,'' +
'' c.F_NUM * a.F_PRICE as F_MONEY'' +
'' from '' +
'' T_CK_ITEM a,'' +
'' T_CK_BASE_STORAGE b,'' +
'' T_CK_TIME_STORAGE c,'' +
'' T_SYS_UNIT d'' +
'' where '' +
'' c.F_ITEM_ID = A.ID '' +
'' and c.F_STORAGE = b.ID '' +
'' and a.F_UNIT = d.ID '' +
'' and c.F_STORAGE in ( '' +
sStorageList +
'')'';
CDSSource.Data := UISet.GetData(sSQL);
CellReport.Cell := Cell;
CellReport.CloneClientDataSet(CDSSource, CellReport.CDSSource);
CellReport.CloneClientData(CDSSource, CellReport.CDSSource);
CellReport.ExecReport(7);
end;
procedure TFrmCKRealTimeStorageRep.CellReportAfterExecReport(Cell: TCell);
begin
inherited;
// 执行后期处理 -- 表头
Cell.SetCellString(1, 1, Cell.GetCurSheet, ''分仓库实时库存表'');
Cell.SetCellAlign(1, 1, Cell.GetCurSheet, 36);
Cell.SetCellFontStyle(1, 1, Cell.GetCurSheet, 10);
Cell.SetCellFontSize(1, 1, Cell.GetCurSheet, 24);
Cell.SetRowHeight(1, Cell.GetRowBestHeight(1), 1, Cell.GetCurSheet);
Cell.MergeCells(1, 1, Cell.GetCols(Cell.GetCurSheet) - 1, 1);
// 制表人
Cell.SetCellString(1, Cell.GetRows(Cell.GetCurSheet) - 1,
Cell.GetCurSheet, ''制表人:'' + gUserInfo.UserName);
Cell.MergeCells(1, Cell.GetRows(Cell.GetCurSheet) - 1,
3, Cell.GetRows(Cell.GetCurSheet) - 1);
// 制表日期
Cell.SetCellString(4, Cell.GetRows(Cell.GetCurSheet) - 1,
Cell.GetCurSheet, ''制表时间:'' + DateToStr(Now));
Cell.MergeCells(4, Cell.GetRows(Cell.GetCurSheet) - 1,
Cell.GetCols(Cell.GetCurSheet) - 1, Cell.GetRows(Cell.GetCurSheet) - 1