📄 invmoldstk.~pas
字号:
ListView.Selected.Selected := true;
end;
Screen.Cursor := crDefault;
stsBarCnt.Panels[0].Text := '符合条件的记录有:'+ IntToStr(ListView.Items.Count)+' 条';
end;
end;
function TfrmMoldInv.Set_QryCondition(lcP: PInvCurrQty): Boolean;
var
iMatAttr: Integer;
WMtlCode: array[0..1] of string;
WDate: array[0..1] of TDateTime;
begin
Result := True;
//////////////////////
if chkStkLess0.Checked then begin
if RoundTo(lcp^.quantity,-2)<=0.00 then
begin
result := false;
exit;
end;
end;
if chkNoneMoldID.Checked then
begin
if lcp^.order_rid=0 then
begin
result := false;
exit;
end;
end;
if trim(edtMoldID.Text)<>'' then
if NOT(dm_Inventory.GetOrderRID(trim(edtMoldID.Text))=lcp^.order_rid) then
begin
result := false;
exit;
end;
end;
procedure TfrmMoldInv.MakeItemCaption(Item: TListItem);
var lcP: PInvCurrQty;
begin
if Item = nil then Exit;
if Item.Data = nil then Exit;
lcP := Item.Data;
Item.Caption := lcp^.stk_id;
Item.SubItems[00] := dm_inventory.GetMaterialCode(lcP^.mat_rid);
Item.SubItems[01] := dm_inventory.GetMaterialName(lcp^.mat_rid);
Item.SubItems[02] := IntToStr(lcp^.guage_id);
Item.SubItems[03] := dm_inventory.Get_GuageName(lcp^.mat_rid, lcp^.guage_id);
Item.SubItems[04] := dm_inventory.GetUnitTypeName(lcP^.mat_rid);
Item.SubItems[05] := FormatFloat('#,##0.00', lcP^.quantity);
Item.SubItems[06] := FormatFloat('#,##0.00', lcP^.totla_price);
Item.SubItems[07] := dm_inventory.GetOrderNo(lcP^.order_rid);
end;
procedure TfrmMoldInv.BitBtn2Click(Sender: TObject);
begin
close;
end;
procedure TfrmMoldInv.ListViewColumnClick(Sender: TObject; Column: TListColumn);
////////////////////////////////////////
function StrToFloatEx(S: string): Double;
begin
S := StringReplace(S, ',', '', [rfReplaceAll]);
S := StringReplace(S, '\', '', [rfReplaceAll]);
try Result := StrToFloat(S);
except Result := 0;
end;
end;
var WSB_Pos: Integer;
begin
if ListView.Items.Count = 0 then Exit;
WSB_Pos := GetScrollPos(ListView.Handle, SB_HORZ);
ListSortKey := Column.Index + 1;
with ListView do
case ListSortKey of
1: if Items[0].Caption < Items[Items.Count-1].Caption then
ListSortKey := ListSortKey * -1;
7..8: //--
if StrToFloatEx(Items[0].SubItems[ListSortKey-2]) <
StrToFloatEx(Items[Items.Count-1].SubItems[ListSortKey-2]) then
ListSortKey := ListSortKey * -1;
else if Items[0].SubItems[ListSortKey-2] <
Items[Items.Count-1].SubItems[ListSortKey-2] then
ListSortKey := ListSortKey * -1;
end;
FMoldInvList.Sort(TListSortCompare(@ListSortCompare));
SetListView;
ListView.Scroll(WSB_Pos, 0);
end;
procedure TfrmMoldInv.BitBtn1Click(Sender: TObject);
begin
Screen.Cursor := crDefault;
Read_MoldInvInfo;
Screen.Cursor := crDefault;
end;
procedure TfrmMoldInv.btnCloseClick(Sender: TObject);
begin
if ListView.Items.Count > 0 then PrintProc;
end;
{*********************************************************************}
procedure TfrmMoldInv.PrintProc;
var
V: OleVariant;
RecCnt, ColCnt: Integer;
i: Integer;
S: string;
ireport,isheet: integer;
begin
try
V := CreateOleObject('Excel.Application');
except
MessageDlg('Excel Application is Created Error!', mtError, [mbOk], 0);
Exit;
end;
V.Visible := True;
V.WorkBooks.Add;
V.WorkBooks[1].Activate;
V.WorkSheets[1].Activate;
V.WorkSheets[1].Name := 'Mold Inventory';
V.ActiveSheet.Cells[1, 2].Value := ' ' +'Mold Inventory List';
RecCnt := 0;
ColCnt := 0;
ClipBoard.asText := CopyToClipBoard(RecCnt, ColCnt);
//-- setting Paper title/report
V.ActiveSheet.PageSetUp.Orientation := xlPortrait; //xlLandscape;()
V.ActiveSheet.PageSetUp.PrintTitleRows := '$1:$3'; //--
V.ActiveSheet.PageSetUp.RightHeader := //--
'&9 '+FormatDateTime('yyyy/mm/dd hh:nn', Now) + ' ' +
'Print Date';
V.ActiveSheet.PageSetUp.CenterFooter := '&9&P/&N Page'; //--
V.ActiveSheet.PageSetUp.Order := xlOverThenDown; //--
//page format
V.ActiveSheet.PageSetUp.LeftMargin := V.InchesToPoints(10/25.4); // 15mm
V.ActiveSheet.PageSetUp.RightMargin := V.InchesToPoints(10/25.4); // 15mm
V.ActiveSheet.PageSetUp.TopMargin := V.InchesToPoints(15/25.4); // 15mm
V.ActiveSheet.PageSetUp.BottomMargin := V.InchesToPoints(15/25.4); // 15mm
V.ActiveSheet.PageSetUp.HeaderMargin := V.InchesToPoints(10/25.4); // 10mm
V.ActiveSheet.PageSetUp.FooterMargin := V.InchesToPoints(10/25.4); // 10mm
//-- report title caption stytle
V.ActiveSheet.Cells.Font.Size := 9;
V.ActiveSheet.Cells[1, 1].HorizontalAlignment := xlLeft;
V.ActiveSheet.Cells[1, 1].Font.Size := 16;
V.ActiveSheet.Cells[1, 1].Font.Bold := True;
V.ActiveSheet.Cells[1, 1].Font.Italic := True;
V.ActiveSheet.Rows[3].HorizontalAlignment := xlCenter;
V.ActiveSheet.Rows[3].Font.Size := 11;
V.ActiveSheet.Rows[3].Font.Bold := True;
///--
V.ActiveSheet.Columns[2].NumberFormatLocal := '@'; //--
V.ActiveSheet.Columns[3].NumberFormatLocal := '@'; //--
V.ActiveSheet.Columns[6].NumberFormatLocal := '@'; //--
V.ActiveSheet.Columns[7].NumberFormatLocal := '#,##0.00'; //--
V.ActiveSheet.Columns[8].NumberFormatLocal := '#,##0.00'; //--
//--
S := 'A3:'+Chr(Ord('A')+(ColCnt-1))+IntToStr(RecCnt+3);
V.ActiveSheet.Range[S].Borders[xlDiagonalDown].LineStyle := xlNone;
V.ActiveSheet.Range[S].Borders[xlDiagonalUp].LineStyle := xlNone;
V.ActiveSheet.Range[S].Borders[xlEdgeLeft].LineStyle := xlContinuous;
V.ActiveSheet.Range[S].Borders[xlEdgeLeft].Weight := xlThin;
V.ActiveSheet.Range[S].Borders[xlEdgeLeft].ColorIndex := xlAutomatic;
V.ActiveSheet.Range[S].Borders[xlEdgeTop].LineStyle := xlContinuous;
V.ActiveSheet.Range[S].Borders[xlEdgeTop].Weight := xlThin;
V.ActiveSheet.Range[S].Borders[xlEdgeTop].ColorIndex := xlAutomatic;
V.ActiveSheet.Range[S].Borders[xlEdgeBottom].LineStyle := xlContinuous;
V.ActiveSheet.Range[S].Borders[xlEdgeBottom].Weight := xlThin;
V.ActiveSheet.Range[S].Borders[xlEdgeBottom].ColorIndex := xlAutomatic;
V.ActiveSheet.Range[S].Borders[xlEdgeRight].LineStyle := xlContinuous;
V.ActiveSheet.Range[S].Borders[xlEdgeRight].Weight := xlThin;
V.ActiveSheet.Range[S].Borders[xlEdgeRight].ColorIndex := xlAutomatic;
V.ActiveSheet.Range[S].Borders[xlInsideVertical].LineStyle := xlDot;
V.ActiveSheet.Range[S].Borders[xlInsideVertical].Weight := xlThin;
V.ActiveSheet.Range[S].Borders[xlInsideVertical].ColorIndex := xlAutomatic;
V.ActiveSheet.Range[S].Borders[xlInsideHorizontal].LineStyle := xlDot;
V.ActiveSheet.Range[S].Borders[xlInsideHorizontal].Weight := xlThin;
V.ActiveSheet.Range[S].Borders[xlInsideHorizontal].ColorIndex := xlAutomatic;
S := 'A3:'+Chr(Ord('A')+(ColCnt-1))+'3';
V.ActiveSheet.Range[S].Borders[xlDiagonalDown].LineStyle := xlNone;
V.ActiveSheet.Range[S].Borders[xlDiagonalUp].LineStyle := xlNone;
V.ActiveSheet.Range[S].Borders[xlEdgeLeft].LineStyle := xlContinuous;
V.ActiveSheet.Range[S].Borders[xlEdgeLeft].Weight := xlThin;
V.ActiveSheet.Range[S].Borders[xlEdgeLeft].ColorIndex := xlAutomatic;
V.ActiveSheet.Range[S].Borders[xlEdgeTop].LineStyle := xlContinuous;
V.ActiveSheet.Range[S].Borders[xlEdgeTop].Weight := xlThin;
V.ActiveSheet.Range[S].Borders[xlEdgeTop].ColorIndex := xlAutomatic;
V.ActiveSheet.Range[S].Borders[xlEdgeBottom].LineStyle := xlContinuous;
V.ActiveSheet.Range[S].Borders[xlEdgeBottom].Weight := xlThin;
V.ActiveSheet.Range[S].Borders[xlEdgeBottom].ColorIndex := xlAutomatic;
V.ActiveSheet.Range[S].Borders[xlEdgeRight].LineStyle := xlContinuous;
V.ActiveSheet.Range[S].Borders[xlEdgeRight].Weight := xlThin;
V.ActiveSheet.Range[S].Borders[xlEdgeRight].ColorIndex := xlAutomatic;
//--
V.ActiveSheet.Cells[3, 1].PasteSpecial;
V.ActiveSheet.Cells[3, 1].Select;
//--
V.ActiveSheet.Columns['A:'+Chr(Ord('A')+(ColCnt-1))].EntireColumn.AutoFit;
for i:=1 to ColCnt do
V.ActiveSheet.Columns[i].ColumnWidth := V.ActiveSheet.Columns[i].ColumnWidth + 2;
if frmMain.IniData.isExcelPrint then V.Print;
end;
///////////////////////////////////////////////////////////////////
function TfrmMoldInv.CopyToClipBoard(var RecCnt, ColCnt: Integer): string;
var i, j: Integer;
Buf: string;
begin
RecCnt := 0; ColCnt := 0;
Buf := '';
for i:=0 to FColumnCount-1 do begin
Buf := Buf + ListView.Column[i].Caption + #9;
Inc(ColCnt);
end;
Buf := Buf + #13#10;
for i:=0 to ListView.Items.Count-1 do begin
for j:=0 to FColumnCount-1 do
if j = 0 then Buf := Buf + Trim(ListView.Items[i].Caption) + #9
else Buf := Buf + Trim(ListView.Items[i].SubItems[j-1]) + #9;
Buf := Buf + #13#10;
Inc(RecCnt);
end;
Result := Buf;
end;
///////////////////////////////////////////////////////////////////
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -