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

📄 invhistory.pas

📁 文件包含程序源原文件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  edtStkID.Text     := '';
  edtStkName.Text   := '';
  edtDate.Text      := '';
  edtPaperNo.Text   := '';
  edtCode.Text      := '';
  edtName.Text      := '';
  edtIssGuageID.Value := 0;
  edtIssGuageName.Text := '';
  edtUPrice.Value   := 0;
  edtQuantity.Value := 0;
  edtMakePrice.Value := 0;
  lblTPrice.Caption := '0';
  lblUType.Caption  := '';
  edtUseGuageName.Text := '';
  edtUseQuantity.Value := 0;
  lblUseAmount.Caption := '0';
  edtOrderSerial.Text  := '';
  edtHatCode.Text      := '';
  edtMoldID.Text       := '';
  edtPartID.Text       := '';
  edtSequalNo.Text     := '';
  edtSuplierCode.Value := 0;
  edtMakerCode.Value   := 0;
  edtMatOutID.Text     := '';
  edtOutIDName.Text    := '';
  edtRecEmpID.Text     := '';
  edtInputEmpID.Text   := '';
  edtInputEmpName.Text := '';
  edtInvoiceNo.Text    := '';
  edtIssPaper.Text     := '';
  edtNote.Text         := '';
  btnReturnGoods.Enabled := False;
end;

function  TfrmInvHistory.MakeNewRecord: Pointer;
var lcP: PINVENTORY;
begin
  New(lcP);
  ZeroMemory(lcP, SizeOf(TINVENTORY));
  Dec(FNewRecId);
  Result := lcP;
end;

function  TfrmInvHistory.UpdateProc: Boolean;
var List, UpdateListList: TList;
    lcP:  PUPDATE_LIST;
    lcInvP: PINVENTORY;
    i, k, Recid, Error: LongInt;
    ErrMsg: string;
begin
  Result := False;
  UpdateListList := GetUpdateListList;
  Screen.Cursor := crSqlWait;
  RecIdType := 0;
  try
    for i:=0 to UpdateListList.Count-1 do begin
      List  := UpdateListList[i];
      lcP   := List[0];
      Recid := lcP^.REC_ID;
      Error := dm_inventory.UpdateDatabase('inventory_sheet', Recid, List);
      if Error < 0 then begin
        Screen.Cursor := crDefault;
        ErrMsg := Format('update database is error!', [Error]);
        MessageDlg(ErrMsg, mtError, [mbOk], 0);
        Exit;
      end;
      for k:=0 to List.Count-1 do begin
        lcInvP := PUPDATE_LIST(List[k])^.Parent;
        if lcInvP^.REC_ID <> Recid then lcInvP^.REC_ID := Recid;
      end;
    end;
  finally
    RecIdType := 1;
    Screen.Cursor := crDefault;
  end;
  for i:=0 to FUpdateList.Count-1 do Dispose(FUpdateList[i]);
  FUpdateList.Clear;
  Result := True;
end;

////////////////////////////////////////////////////////////
function  TfrmInvHistory.SetListColumn: Integer;
var Column: TListColumn;
    Count:  Integer;
begin
  ListView.Columns.Clear;
  Count := 0;

  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 6;
  Column.Caption := '类型';
  Inc(Count);

  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 5;
  Column.Caption := GetMultiLingalMsg(90027, 'Stock ID');
  Inc(Count);
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 8;
  Column.Caption := GetMultiLingalMsg(90052, 'Date');
  Inc(Count);
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 10;
  Column.Caption := GetMultiLingalMsg(90063, 'Mold Code');
  Inc(Count);
  //--
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 12;
  Column.Caption := GetMultiLingalMsg(90028, 'Material Code');
  Inc(Count);

  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 20;
  Column.Caption := GetMultiLingalMsg(90029, 'Material Name');
  Inc(Count);
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 12;
  Column.Caption := GetMultiLingalMsg(90101, 'I/O Guage');
  Inc(Count);
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 7;
  Column.Caption := GetMultiLingalMsg(90032, 'Unit Name');
  Inc(Count);

  Column := ListView.Columns.Add;
  Column.Width     := ListView.Font.Size * 8;
  Column.Alignment := taRightJustify;
  Column.Caption   := GetMultiLingalMsg(90033, 'Unit Price');
  Inc(Count);

  Column := ListView.Columns.Add;
  Column.Width     := ListView.Font.Size * 8;
  Column.Alignment := taRightJustify;
  Column.Caption   := GetMultiLingalMsg(90102, 'I/O Quantity');
  Inc(Count);

  Column := ListView.Columns.Add;
  Column.Width     := ListView.Font.Size * 8;
  Column.Alignment := taRightJustify;
  Column.Caption   := GetMultiLingalMsg(70222, 'Process Cost');
  Inc(Count);

  Column := ListView.Columns.Add;
  Column.Width     := ListView.Font.Size * 10;
  Column.Alignment := taRightJustify;
  Column.Caption   := GetMultiLingalMsg(90103, 'I/O Amount');
  Inc(Count);
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 12;
  Column.Caption := GetMultiLingalMsg(90084, 'Use Guage');
  Inc(Count);
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 8;
  Column.Caption := GetMultiLingalMsg(90085, 'Use Quantity');
  Inc(Count);
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 10;
  Column.Caption := GetMultiLingalMsg(90086, 'Use Amount');
  Inc(Count);

  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 8;
  Column.Caption := GetMultiLingalMsg(90062, 'Order Serial');
  Inc(Count);

  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 12;
  Column.Caption := GetMultiLingalMsg(32093,'Order Code');
  Inc(Count);

  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 10;
  Column.Caption := GetMultiLingalMsg(90064, 'Part Code');
  Inc(Count);

  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 14;
  Column.Caption := GetMultiLingalMsg(10042,'Sequal No');
  Inc(Count);

  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 16;
  Column.Caption := GetMultiLingalMsg(90057, 'Suplier');
  Inc(Count);
  //-- paperno
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 7;
  Column.Caption := GetMultiLingalMsg(90058, 'Maker');
  Inc(Count);
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 12;
  Column.Caption := GetMultiLingalMsg(90246, 'Paper NO');
  Inc(Count);
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 8;
  Column.Caption := GetMultiLingalMsg(90097, 'Manager Type');
  Inc(Count);
  //-- recieve empid
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 10;
  Column.Caption := GetMultiLingalMsg(90088, 'Receive Man');
  Inc(Count);
  //-- input empid
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 10;
  Column.Caption := GetMultiLingalMsg(90247, 'Manager Man');
  Inc(Count);
  //-- invoice_no empid
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 10;
  Column.Caption := GetMultiLingalMsg(90061, 'Invoice NO');
  Inc(Count);
  //-- invoice_no empid
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 10;
  Column.Caption := GetMultiLingalMsg(90236, 'Issue Paper');
  Inc(Count);
  //--
  Column := ListView.Columns.Add;
  Column.Width   := ListView.Font.Size * 12;
  Column.Caption := GetMultiLingalMsg(90065, 'Remarks');
  Inc(Count);
  Result := Count;
end;

function  TfrmInvHistory.SetListView(StartIX: Integer; SelRecID: LongInt): Integer;
  //---- default query condition ----------
  function SetLVCheck(lcP: PINVENTORY): Boolean;
  begin
    Result := True;
    //--- defauly query date
    if ((tmpWdate[0] > 2)and(tmpWdate[0] > lcP^.DATE))or
       ((tmpWdate[1] > 2)and(tmpWdate[1] < lcP^.DATE))then begin
      Result := False;
      Exit;
    end;
  end;
var IX_1, IX_2, ItemCNT: Integer;
    lcP: PINVENTORY;
    Item: TListItem;
    SelNo: Integer;
begin
  Screen.Cursor  := crHourGlass;
  SetNull;
  ItemCNT := 0;
  if StartIX<=0 then begin
    FListViewClear := True;
    with ListView.Items do begin
      BeginUpdate;
      Clear;
      EndUpdate;
    end;
    FListViewClear := False;
  end;

  //--
  FOnMakeItemCaption := True;
  ListView.Items.BeginUpdate;
  SelNo := 0;
  try
    for IX_1:=StartIX to FList.Count-1 do begin
      lcP  := FList.Items[IX_1];
      if not(SetLVCheck(lcP)) then Continue;

      Item := ListView.Items.Add;
      for IX_2:=0 to FColumnCount-2 do Item.Subitems.Add('');
      lcP^.ITEM := Item;
      Item.Data := lcP;
      MakeItemCaption(Item);
      Inc(ItemCNT);
      if SelRecID = lcP^.REC_ID then SelNo := IX_1;
    end;
  finally
    ListView.Items.EndUpdate;
    FOnMakeItemCaption := False;
    if ListView.Items.Count > 0 then
    begin
      ListView.TopItem.Selected := True;
      ListView.Selected.Selected := true;
    end;
    Screen.Cursor := crDefault;
    stsBarCnt.Panels[0].Text := '符合条件的记录有:'+ IntToStr(ListView.Items.Count)+' 条';
  end;
  if SelRecID > 0 then Result := SelNo
  else Result := ItemCNT;
end;

function  TfrmInvHistory.ListSelCheck: Boolean;
begin
  Result := True;
  if ListView.SelCount = 0 then begin
    MessageDlg('please selected one record!', mtWarning, [mbOK], 0);
    Result := False;
  end;
end;

function  TfrmInvHistory.RECExists(RecID: LongInt): Boolean;
var i: Integer;
begin
  Result := False;
  for i:=0 to FList.Count-1 do
    if RecID = PINVENTORY(FList[i])^.REC_ID then begin
      Result := True;
      Break;
    end;
end;

procedure TfrmInvHistory.DrawExplanatoryNotes;
var
  SExplains: array[0..4] of string;
  i, x, y, TextW: Integer;
begin
  SExplains[0] := GetMultiLingalMsg(90104, 'In');
  SExplains[1] := GetMultiLingalMsg(90105, 'Out');
  SExplains[2] := GetMultiLingalMsg(90098, 'Return');
  SExplains[3] := GetMultiLingalMsg(90099, 'Tune');
  SExplains[4] := GetMultiLingalMsg(90248, 'Bala');

  with Image1.Canvas do begin
    TextW := TextWidth(SExplains[0]);
    if TextW < TextWidth(SExplains[1]) then
      TextW := TextWidth(SExplains[1]);

    if TextW < TextWidth(SExplains[2]) then
      TextW := TextWidth(SExplains[2]);

    if TextW < TextWidth(SExplains[3]) then
      TextW := TextWidth(SExplains[3]);

    if TextW < TextWidth(SExplains[4]) then
      TextW := TextWidth(SExplains[4]);

    Pen.Color := clBlack;
    Brush.Color := clBtnFace;
    FillRect(ClientRect);
    y := 5;
    for i:= 0 to 4 do begin
      x := i * (ImageList.Width+4 + TextW);
      ImageList.Draw(Image1.Canvas, x, y, i);
      TextOut(x+17, y+2, SExplains[i]);
    end;
  end;
end;

procedure TfrmInvHistory.SetInvValue(Data: PINVENTORY; var InvValue: TINVENTORY_VALUE);
begin
  with InvValue do begin
    inv_rec_id      := Data^.REC_ID;
    order_no        := Data^.HAT_RID;
    order_rec_id    := Data^.ODR_RID;
    part_rec_id     := Data^.PAT_RID;
    material_rec_id := Data^.MAT_RID;
    quantity        := Abs(Data^.QUANTITY);
    unit_price      := Abs(Data^.UNT_PRICE);
    total_price     := Abs(Data^.TTL_PRICE);
  end;
end;

Procedure TfrmInvHistory.Set_EditReadOnly(iBool: Boolean; iKind: Integer; is_account,is_close: Integer);
begin
  if ((is_account=1)or(is_close=1)) then   //-- 发票已结算或已月结的数据 全部不能修改
  begin
    edtStkID.ReadOnly       := true;
    edtDate.ReadOnly        := true;
    edtPaperNo.ReadOnly     := true;
    edtCode.ReadOnly        := true;
    edtName.ReadOnly        := true;
    edtIssGuageID.ReadOnly  := true;
    edtUPrice.ReadOnly      := true;
    edtQuantity.ReadOnly    := true;
    edtMakePrice.ReadOnly    := true;
    edtUseGuageName.ReadOnly := true;
    edtUseQuantity.ReadOnly := true;

⌨️ 快捷键说明

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