?? invmoldstk.pas
字號:
unit InvMoldStk;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ComCtrls, EnhLV, GLLV, ExtCtrls, xlsConst,
ClipBrd, ComObj, dpConst, InvDef, Math, StrUtils;
type
TfrmMoldInv = class(TForm)
Panel2: TPanel;
Panel3: TPanel;
rdogpRelation: TRadioGroup;
GroupBox1: TGroupBox;
edtMoldID: TLabeledEdit;
ListView: TGradLineListView;
stsBarCnt: TStatusBar;
BitBtn1: TBitBtn;
Panel8: TPanel;
Panel1: TPanel;
Panel5: TPanel;
Panel4: TPanel;
btnClose: TBitBtn;
BitBtn2: TBitBtn;
chkStkLess0: TCheckBox;
chkNoneMoldID: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure BitBtn2Click(Sender: TObject);
procedure ListViewColumnClick(Sender: TObject; Column: TListColumn);
procedure BitBtn1Click(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
private
{ Private declarations }
procedure SetListColumn;
procedure SetListView;
function Set_QryCondition(lcP: PInvCurrQty): Boolean;
procedure MakeItemCaption(Item: TListItem);
procedure Read_MoldInvInfo;
public
{ Public declarations }
Procedure PrintProc;
function CopyToClipBoard(var RecCnt, ColCnt: Integer): string;
end;
var
frmMoldInv: TfrmMoldInv;
FMoldInvList: TList;
FColumnCount: Integer;
ListSortKey: Integer;
implementation
uses Main, InvDM;
{$R *.dfm}
/////////////////////////////////////////////////////////////////////////////
function ListSortCompare(Item1, Item2: Pointer): Longint;
var DataType: Integer;
Str1, Str2: string;
Int1, Int2: Integer;
Dbl1, Dbl2: Double;
Dat1, Dat2: TDateTime;
begin
Result := 0;
Str1 := ''; Str2 := '';
Int1 := 0; Int2 := 0;
Dbl1 := 0; Dbl2 := 0;
Dat1 := 0; Dat2 := 0;
case Abs(ListSortKey) of
1: begin //--
Str1 := TInvCurrQryInfo(Item1^).stk_id;
Str2 := TInvCurrQryInfo(Item2^).stk_id;
DataType := 0;
end;
2: begin //--
Str1 := dm_inventory.GetMaterialCode(TInvCurrQryInfo(Item1^).mat_rid)+RightStr(('0000000'+InttoStr(TInvCurrQryInfo(Item1^).GUAGE_ID)),6);
Str2 := dm_inventory.GetMaterialCode(TInvCurrQryInfo(Item2^).mat_rid)+RightStr(('0000000'+InttoStr(TInvCurrQryInfo(Item2^).GUAGE_ID)),6);
DataType := 0;
end;
3: begin //--
Str1 := dm_inventory.GetMaterialName(TInvCurrQryInfo(Item1^).mat_rid);
Str2 := dm_inventory.GetMaterialName(TInvCurrQryInfo(Item2^).mat_rid);
DataType := 0;
end;
4: begin //--
Str1 := dm_inventory.GetMaterialCode(TInvCurrQryInfo(Item1^).mat_rid)+RightStr(('0000000'+InttoStr(TInvCurrQryInfo(Item1^).GUAGE_ID)),6);
Str2 := dm_inventory.GetMaterialCode(TInvCurrQryInfo(Item2^).mat_rid)+RightStr(('0000000'+InttoStr(TInvCurrQryInfo(Item2^).GUAGE_ID)),6);
DataType := 0;
end;
6: begin //--
Str1 := dm_inventory.GetUnitTypeName(TInvCurrQryInfo(Item1^).mat_rid);
Str2 := dm_inventory.GetUnitTypeName(TInvCurrQryInfo(Item2^).mat_rid);
DataType := 0;
end;
7: begin //--
Dbl1 := TInvCurrQryInfo(Item1^).quantity;
Dbl2 := TInvCurrQryInfo(Item2^).quantity;
DataType := 2;
end;
8: begin //--
Dbl1 := TInvCurrQryInfo(Item1^).totla_price;
Dbl2 := TInvCurrQryInfo(Item2^).totla_price;
DataType := 2;
end;
else Exit;
end;
case DataType of
0: if Str1 < Str2 then Result := -1
else if Str1 > Str2 then Result := 1
else Result := 0;
1: if Int1 < Int2 then Result := -1
else if Int1 > Int2 then Result := 1
else Result := 0;
2: if Dbl1 < Dbl2 then Result := -1
else if Dbl1 > Dbl2 then Result := 1
else Result := 0;
3: if Dat1 < Dat2 then Result := -1
else if Dat1 > Dat2 then Result := 1
else Result := 0;
else Result := 0;
end;
if ListSortKey < 0 then Result := Result * -1;
end;
procedure TfrmMoldInv.FormCreate(Sender: TObject);
begin
FMoldInvList := TList.Create;
FMoldInvList.Clear;
SetListColumn;
end;
procedure TfrmMoldInv.FormShow(Sender: TObject);
begin
Top := frmMain.Height;
Left := 0;
Width := Screen.Width;
Height := Screen.Height-(frmMain.Height+stsBarCnt.Height+8);
edtMoldID.Text := '';
rdogpRelation.ItemIndex := 0;
chkNoneMoldID.Checked := true;
chkStkLess0.Checked := true;
Read_MoldInvInfo;
end;
procedure TfrmMoldInv.FormClose(Sender: TObject; var Action: TCloseAction);
begin
WindowState := wsMinimized;
Action := cafree;
end;
procedure TfrmMoldInv.SetListColumn;
var Column: TListColumn;
begin
FColumnCount := 0;
ListView.Columns.Clear;
Column := ListView.Columns.Add;
Column.Width := ListView.Font.Size * 5;
Column.Caption := GetMultiLingalMsg(90027, 'Stock ID');
Inc(FColumnCount);
Column := ListView.Columns.Add;
Column.Width := ListView.Font.Size * 14;
Column.Caption := GetMultiLingalMsg(90028, 'Material Code');
Inc(FColumnCount);
Column := ListView.Columns.Add;
Column.Width := ListView.Font.Size * 14;
Column.Caption := GetMultiLingalMsg(90029, 'Material Name');
Inc(FColumnCount);
Column := ListView.Columns.Add;
Column.Width := ListView.Font.Size * 7;
Column.Caption := GetMultiLingalMsg(90030, 'Guage ID');
Inc(FColumnCount);
Column := ListView.Columns.Add;
Column.Width := ListView.Font.Size * 18;
Column.Caption := GetMultiLingalMsg(90031, 'Guage Name');
Inc(FColumnCount);
Column := ListView.Columns.Add;
Column.Width := ListView.Font.Size * 6;
Column.Caption := GetMultiLingalMsg(90032, 'Unit Name');
Inc(FColumnCount);
Column := ListView.Columns.Add;
Column.Width := ListView.Font.Size * 10;
Column.Alignment := taRightJustify;
Column.Caption := GetMultiLingalMsg(90034, 'Inventory Quantity');
Inc(FColumnCount);
Column := ListView.Columns.Add;
Column.Width := ListView.Font.Size * 12;
Column.Alignment := taRightJustify;
Column.Caption := GetMultiLingalMsg(90035, 'Inventory Amount');
Inc(FColumnCount);
//--
Column := ListView.Columns.Add;
Column.Width := ListView.Font.Size * 12;
Column.Alignment := taRightJustify;
Column.Caption := '模號';
Inc(FColumnCount);
end;
procedure TfrmMoldInv.Read_MoldInvInfo;
begin
dm_inventory.Read_MoldInvInfo(FMoldInvList, rdogpRelation.ItemIndex);
Screen.Cursor := crHourGlass;
try
SetListView;
finally
Screen.Cursor := crDefault;
end;
end;
procedure TfrmMoldInv.SetListView;
var i, j: Integer;
lcP: PInvCurrQty;
Item: TListItem;
Tmp: string;
begin
Screen.Cursor := crHourGlass;
with ListView.Items do begin
BeginUpdate;
Clear;
EndUpdate;
end;
//////////////////////////////////
ListView.Items.BeginUpdate;
try
FMoldInvList.Sort(TListSortCompare(@ListSortCompare));
for i:=0 to FMoldInvList.Count-1 do begin
lcP := FMoldInvList.Items[i];
if not Set_QryCondition(lcp) then continue;
Item := ListView.Items.Add;
for j:=0 to FColumnCount-1 do Item.Subitems.Add('');
Item.Data := lcP;
MakeItemCaption(Item);
end;
finally
ListView.Items.EndUpdate;
ListView.Items.EndUpdate;
if ListView.Items.Count > 0 then
begin
ListView.TopItem.Selected := True;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -