⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 invbomcheck.pas

📁 文件包含程序源原文件
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit InvBomCheck;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ExtCtrls, Grids, EnhLV, GLLV, InvDef, dpConst,
  StdCtrls, Buttons, ImgList;

type
  TfrmBomCheck = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel6: TPanel;
    tabsGroup: TTabControl;
    rdoGroupBy: TRadioGroup;
    edtFMatCode: TLabeledEdit;
    edtEMatCode: TLabeledEdit;
    edtMatClass: TLabeledEdit;
    btnExcel: TBitBtn;
    ComboBox1: TComboBox;
    BitBtn1: TBitBtn;
    Edit1: TEdit;
    BitBtn2: TBitBtn;
    Panel3: TPanel;
    Panel5: TPanel;
    Panel4: TPanel;
    Panel7: TPanel;
    Panel8: TPanel;
    ListViewMRP: TGradLineListView;
    rdoMRP: TRadioGroup;
    Bevel3: TBevel;
    Bevel2: TBevel;
    btnInvQuery: TSpeedButton;
    btnAutoOrder: TSpeedButton;
    Bevel4: TBevel;
    btnMRP: TSpeedButton;
    Bevel5: TBevel;
    ListViewBomInfo: TListView;
    Image1: TImage;
    ImageList: TImageList;
    Image3: TImage;
    edtMatCode: TLabeledEdit;
    Bevel1: TBevel;
    ComboBox2: TComboBox;
    LabeledEdit1: TLabeledEdit;
    Edit2: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure btnExitClick(Sender: TObject);
    procedure tabsGroupChange(Sender: TObject);
    procedure tabsGroupChanging(Sender: TObject; var AllowChange: Boolean);
    procedure rdoGroupByClick(Sender: TObject);
    procedure ListViewBomInfoColumnClick(Sender: TObject;
      Column: TListColumn);
    procedure ListViewBomInfoSelectItem(Sender: TObject; Item: TListItem;
      Selected: Boolean);
    procedure btnInvQueryClick(Sender: TObject);
    procedure btnMRPClick(Sender: TObject);
  private
    { Private declarations }
    //////////////////////////////////////////////////////
    procedure Read_BomCheckInfoList;
    Function  Set_QueryedList(sList: TList): TList;
    procedure CreateTabs_ByGroup(rdoIndex: integer; sList: TList);
    procedure Set_QryList_FromTabs(iTab: integer; FGroupList: TList);
    Function  CheckViewData(lcPA: Pointer; rdoTitleIndex,TabIndex: integer): boolean;
    
    procedure SetListView;
    function  SetListColumn(sListView: TListView): Integer;
    procedure MakeItemCaption(Item: TListItem);

    function  SetMRPListColumn(sListView: TGradLineListView; imode: integer): Integer;
    procedure MakeMRPItemCaption(Item: TListItem; imode: integer);

    Procedure DrawSafeStockImage;
  public
     iOldTab,iCurrTab: integer;
    { Public declarations }

  end;

var
  frmBomCheck: TfrmBomCheck;
  /////////////////////////////////////////////////////
  FBomCheckList,
  FQueryList: TList;
  FListViewClear,
  FOnMakeItemCaption,
  FOnCloseForm: Boolean;
  FSelectedItem: TListItem;
  FColCnt,FColumnCnt: Integer;
  iShiZaiKubun: integer;

  /////////////////////
  FGroupValue: array[0..120000] of variant;  //-- TabControl tabs group value

implementation

uses Main, InvDM;

{$R *.dfm}

procedure TfrmBomCheck.FormCreate(Sender: TObject);
begin
  Top  := 0;
  Left := frmMain.Width;
  Height := Screen.Height-(Height - ClientHeight);
  Width := Screen.Width- frmMain.Width;

  FBomCheckList := TList.Create;
  FBomCheckList.Clear;
  FQueryList    := TList.Create;
  FQueryList.Clear;
end;

procedure TfrmBomCheck.FormShow(Sender: TObject);
begin
  dm_Inventory.Read_BomCheckInfo(FBomCheckList);
  Set_QueryedList(FQueryList);
  CreateTabs_ByGroup(rdoGroupBy.ItemIndex,FQueryList);
  tabsGroupChange(Self);

  DrawSafeStockImage;
end;

procedure TfrmBomCheck.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
//
end;

procedure TfrmBomCheck.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := CaFree;
end;

procedure TfrmBomCheck.BitBtn1Click(Sender: TObject);
var i: integer;
begin
{
  for i := 1 to TKGridView1.RowCount-1 do
  begin
    TKGridView1.Cells[1,i] := 'AAAA';
  end;}
end;

procedure TfrmBomCheck.BitBtn2Click(Sender: TObject);
begin
  Close;
end;

procedure TfrmBomCheck.btnExitClick(Sender: TObject);
var i: integer;
    s: string;
begin
  s:='';
  for i:= 0 to ListViewBomInfo.Items.Count-1 do
  begin
    if ListViewBomInfo.Items[i].Checked then s := s+ListViewBomInfo.Items[i].Caption +' true'
    else s := s+ListViewBomInfo.Items[i].Caption +' false'
  end;
  showmessage(s);
end;

procedure TfrmBomCheck.tabsGroupChange(Sender: TObject);
var lcp: PBomCheckInfo;
begin
  if tabsGroup.Tabs.Count <= 0 then iOldTab := -1;
  iCurrTab := tabsGroup.TabIndex;
  if tabsGroup.TabIndex <> iOldTab then
  begin
    case MessageDlg('需要按前一页设定的方式进行处理吗?',mtConfirmation,[mbYes, mbNo,mbCancel],0) of
      mrYes: tabsGroup.TabIndex := iCurrTab;
      mrNo:  tabsGroup.TabIndex := iCurrTab;
      mrCancel: tabsGroup.TabIndex := iOldTab;
    end;
  end;
  dm_Inventory.Read_BomCheckInfo(FBomCheckList);
  Set_QueryedList(FQueryList);
  Set_QryList_FromTabs(TabsGroup.TabIndex, FQueryList);
  SetListView;

  if ListViewBomInfo.Items.Count>0 then begin
    ListViewBomInfo.ToPItem.Selected := False;
    ListViewBomInfo.ToPItem.Selected := True;
    lcp := ListViewBomInfo.Selected.Data;
    edtMatCode.Text := dm_inventory.GetMaterialCode(lcp^.shizai_rec_id);
  end;
end;

procedure TfrmBomCheck.tabsGroupChanging(Sender: TObject; var AllowChange: Boolean);
begin
  if AllowChange then iOldTab := tabsGroup.TabIndex;
end;


////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
procedure TfrmBomCheck.Read_BomCheckInfoList;
begin
  dm_Inventory.Read_BomCheckInfo(FBomCheckList);
  Set_QueryedList(FQueryList);
  CreateTabs_ByGroup(rdoGroupBy.ItemIndex,FQueryList);
  tabsGroupChange(Self);
end;

Function TfrmBomCheck.Set_QueryedList(sList: TList): TList;
  function SetQryCheck(lcP: PBomCheckInfo): Boolean;
  var i: Integer;
      WMtlCode: array[0..1] of string;
  begin
    Result := True;
    //--
    if trim(edtFMatCode.Text)='' then WMtlCode[0] := '0000000000'
    else  WMtlCode[0] := trim(edtFMatCode.Text);
    if trim(edtEMatCode.Text)='' then WMtlCode[1] := 'ZZZZZZZZZZ'
    else  WMtlCode[1] := trim(edtEMatCode.Text);
    if ((WMtlCode[0] > dm_inventory.GetMaterialCode(lcp^.shizai_rec_id)) or
     (WMtlCode[1] < dm_inventory.GetMaterialCode(lcp^.shizai_rec_id))) then begin
    result := false;
    exit;
  end;

  iShiZaiKubun := dm_inventory.GetShiZaiKubunID(trim(edtMatClass.Text));
  if (trim(edtMatClass.Text)<>'') then
    if not (dm_inventory.Get_KubunRecID_FromShiZai(lcp^.shizai_rec_id) = iShiZaiKubun) then begin
      result := false;
      exit;
    end;
  end;
var
  ix: integer;
  lcpA: PBomCheckInfo;
begin
   sList.Clear;
   for ix := 0 to FBomCheckList.Count - 1 do
   begin
     lcpA := FBomCheckList[ix];
     if not SetQryCheck(lcpA) then continue;
     sList.Add(lcpA);
   end;
   result := sList
end;

procedure TfrmBomCheck.CreateTabs_ByGroup(rdoIndex: integer; sList: TList);
var tmpTabIndex: integer;
    i,j: integer;
    lcp: PBomCheckInfo;
    tmpGroupTitle: variant;
    iGroupFind: Boolean;
begin
  tmpTabIndex := 0;
  tabsGroup.Tabs.Clear;

  for i := 0 to sList.Count - 1 do
  begin
    lcp := sList[i];
    if lcp = nil then continue;

    case rdoIndex of
      0:    tmpGroupTitle := dm_inventory.GetMaterialCode(lcp^.shizai_rec_id);
      1:    tmpGroupTitle := dm_inventory.GetOrderNo(lcp^.mold_id);
      2:    tmpGroupTitle := dm_inventory.GetMaterialCode(lcp^.shizai_rec_id);
      3:    tmpGroupTitle := 'ALL';
      else tmpGroupTitle := 'ALL';
    end;

    //-- 判断是否有找到抬头信息
    iGroupFind := false;
    for j := 0 to tmpTabIndex - 1 do
    begin
      try
        if tmpGroupTitle = FGroupValue[j] then begin
          iGroupFind := true;
          break;
        end;
      except
      end;
    end;

    if not iGroupFind then begin   //-- 没找到当前资料的抬头则新增tabs
      FGroupValue[tmpTabIndex] := tmpGroupTitle;
      inc(tmpTabIndex);

      tabsGroup.Tabs.Add(tmpGroupTitle);
    end;

  end;
  //////////////////////////////////////////////
  //-- tabsGroup.TabIndex value
  if tmpTabIndex >0 then tabsGroup.TabIndex := 0
  else tabsGroup.TabIndex := -1;
end;


procedure TfrmBomCheck.Set_QryList_FromTabs(iTab: integer; FGroupList: TList);
  function SetQryCheck(lcP: PBomCheckInfo): Boolean;
  var i: Integer;
      WMtlCode: array[0..1] of string;
  begin
    Result := True;
    //--
    if trim(edtFMatCode.Text)='' then WMtlCode[0] := '0000000000'
    else  WMtlCode[0] := trim(edtFMatCode.Text);
    if trim(edtEMatCode.Text)='' then WMtlCode[1] := 'ZZZZZZZZZZ'
    else  WMtlCode[1] := trim(edtEMatCode.Text);
    if ((WMtlCode[0] > dm_inventory.GetMaterialCode(lcp^.shizai_rec_id)) or
     (WMtlCode[1] < dm_inventory.GetMaterialCode(lcp^.shizai_rec_id))) then begin
    result := false;
    exit;
  end;

  iShiZaiKubun := dm_inventory.GetShiZaiKubunID(trim(edtMatClass.Text));
  if (trim(edtMatClass.Text)<>'') then
    if not (dm_inventory.Get_KubunRecID_FromShiZai(lcp^.shizai_rec_id) = iShiZaiKubun) then begin
      result := false;
      exit;
    end;
  end;
var i,j: integer;
    lcP,lcPA: PBomCheckInfo;
    iView: Boolean;
    iBool: Boolean;
begin
  if FBomCheckList = nil then exit;
  if FBomCheckList.Count = 0 then exit;
  FQueryList.Clear;

  for i := 0 to FBomCheckList.Count-1 do begin
    lcP := FBomCheckList.Items[i];
    if not SetQryCheck(lcp) then continue;
    iView := CheckViewData(lcP, rdoGroupBy.ItemIndex, TabsGroup.TabIndex);
    if not iView then Continue;
    FQueryList.Add(lcP);
  end;
end;

Function  TfrmBomCheck.CheckViewData(lcPA: Pointer; rdoTitleIndex,TabIndex: integer): boolean;
var
  TmpV: Variant;
  lcp: PBomCheckInfo;
begin

      Result := False;

      if lcPA=Nil then Exit;
      lcp := LcpA;
      if (rdoTitleIndex<0) or (TabIndex<0) then Exit;

      if rdoTitleIndex = 3 then
      begin
           Result:=True;
           Exit;
      end;

    case rdoTitleIndex of
      0:    TmPV := dm_inventory.GetMaterialCode(lcp^.shizai_rec_id);
      1:    TmPV := dm_inventory.GetOrderNo(lcp^.mold_id);
      2:    TmPV := dm_inventory.GetMaterialCode(lcp^.shizai_rec_id);
      3:    TmPV := 'ALL';
      else TmPV := 'ALL'
    end;
    try
      if TmPV = FGroupValue[TabIndex] then Result:=True;
    except
      Result:=False;
    end;
end;

procedure TfrmBomCheck.SetListView;
var i,j: Integer;
    lcP: PBomCheckInfo;
    Item: TListItem;
begin
  Screen.Cursor  := crHourGlass;
  with ListViewBomInfo.Items do begin
    BeginUpdate;
    Clear;
    EndUpdate;
  end;

  SetListColumn(ListViewBomInfo);
  //--

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -