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

📄 invoicelist.~pas

📁 文件包含程序源原文件
💻 ~PAS
📖 第 1 页 / 共 3 页
字号:
  FTmpList.Clear;

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




function TfrmInvoiceList.CheckViewData(lcP: PINVENTORY; rdoTitleIndex,TabIndex: integer): boolean;
var
  TmpV: Variant;
begin

      Result := False;

      if lcP=Nil then Exit;

      if (rdoTitleIndex<0) or (TabIndex<0) then Exit;


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

    case rdoTitleIndex of
      0: TmpV := strpas(lcp^.paperno);
      1: TmpV := dm_inventory.GetShigenName(lcp^.SUP_CD);
      2: TmpV := strPas(lcp^.invoice_no);
      3: TmpV := formatDatetime('yy/mm/dd',lcp^.DATE);
      4: TmpV := dm_inventory.GetOrderNo(lcp^.ODR_RID);
      5: TmpV := dm_inventory.GetShigenName(lcp^.MAK_CD);
      6: TmpV := strPas(lcp^.HAT_CODE);
      7: TmpV := strPas(lcp^.STK_ID);
      8: TmpV := 'ALL';
    end;

    try
      if TmPV = FGroupValue[TabIndex] then Result:=True;
    except
      Result:=False;
    end;
end;

procedure TfrmInvoiceList.cbxSupDropDown(Sender: TObject);
begin
  dm_inventory.Read_SupplyMake_ToCbx(cbxSup);
end;

procedure TfrmInvoiceList.cbxSupChange(Sender: TObject);
begin
  edtSuplier.Text   := Get_PosBeforeStr(cbxSup.Text,'_');
  edtSupName.Text   := Get_PosAfterStr(cbxSup.Text,'_');
  edtSuplier.SetFocus;
end;



procedure TfrmInvoiceList.btnAccountClick(Sender: TObject);
var
  Msg: String;
  SaveCursor: TCursor;
begin
  if TabsCtrlAccount.TabIndex=0 then
    Msg := '你确定要结算选定的 %d 笔入库记录!'
  else Msg := '你确定要取消结算选定的 %d 笔入库记录!';

  Msg := Format(Msg, [UnAcc_ListView.SelCount]);
  if MessageDlg(Msg, mtConfirmation, [mbOK, mbCancel], 0) = mrCancel then begin
    UnAcc_ListView.SetFocus;
    Exit;
  end;
  SaveCursor    := Screen.Cursor;
  Screen.Cursor := crSqlWait;
  UnAcc_ListView.Items.BeginUpdate;
  try
    if TabsCtrlAccount.TabIndex=0 then
      ConfirmOrCancel_AccountProc(1)
    else ConfirmOrCancel_AccountProc(0);
  finally
    UnAcc_ListView.Items.EndUpdate;
    Screen.Cursor := SaveCursor;
    btnQueryClick(self);
  end;
end;

procedure TfrmInvoiceList.ConfirmOrCancel_AccountProc(iAll_Sts: integer);
var
  Item, Item2, SetItem: TListItem;
  lcP: PINVENTORY;
  FListSTS: Boolean;
  Cnt: Integer;
  Msg: string;
begin
  SetItem := nil;
  FListSTS := false;
  Item := UnAcc_ListView.Selected;
  Screen.Cursor := crSqlWait;
  try
    while Item <> nil do begin
      lcP := Item.Data;
      Item2 := UnAcc_ListView.GetNextItem(Item, sdBelow, [isSelected]);
      if Item2 = Item then Item2 := nil;

      if lcP = nil then begin
        if not(FListSTS) then begin
          Item.Delete;
          SetItem := Item2;
        end;
        Item := Item2;
        Continue;
      end;
      dm_inventory.Update_InventorySheetActSts(lcP^.REC_ID,iAll_Sts);
      Item := Item2;
    end;
  finally
    stsBarCnt.Panels[0].Text := '符合条件的记录有:'+ IntToStr(UnAcc_ListView.Items.Count)+' 条';
    Screen.Cursor := crDefault;
  end;
end;

procedure TfrmInvoiceList.UnAcc_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 UnAcc_ListView.Items.Count = 0 then Exit;
  WSB_Pos := GetScrollPos(UnAcc_ListView.Handle, SB_HORZ);
  ListSortKey := Column.Index + 1;

  with UnAcc_ListView do
    case ListSortKey of
      1: if Items[0].Caption < Items[Items.Count-1].Caption then
           ListSortKey := ListSortKey * -1;
      12..15: //--
         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;
  FQueryList.Sort(TListSortCompare(@ListSortCompare));
  SetListView(UnAcc_ListView);
  UnAcc_ListView.Scroll(WSB_Pos, 0);
end;

//////////////////////////////////////////////////////////////////////////////////////
procedure TfrmInvoiceList.PrintProc;
var V: OleVariant;
    RecCnt, ColCnt: Integer;
    i: Integer;
    S: string;
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;

  RecCnt := 0; ColCnt := 0;
  ClipBoard.asText := CopyToClipBoard(RecCnt, ColCnt);

  V.ActiveSheet.PageSetUp.Orientation := 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;          //--
  //--
  V.ActiveSheet.PageSetUp.LeftMargin   := V.InchesToPoints(15/25.4); // 15mm
  V.ActiveSheet.PageSetUp.RightMargin  := V.InchesToPoints(15/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
  //--
  V.ActiveSheet.Cells.Font.Size := 9;
  V.ActiveSheet.Cells[1, 1].HorizontalAlignment := xlLeft;
  V.ActiveSheet.Cells[1, 1].Font.Size := 20;
  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[13].NumberFormatLocal := '#,##0.00';    //--
  V.ActiveSheet.Columns[14].NumberFormatLocal := '#,##0.00';    //--
  V.ActiveSheet.Columns[15].NumberFormatLocal := '#,##0.00';
  V.ActiveSheet.Columns[16].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;
  //--
  V.ActiveSheet.Cells[1, 1].Value := '  ' + 'report List';

  if frmMain.IniData.isExcelPrint then V.Print;
end;


function TfrmInvoiceList.CopyToClipBoard(var RecCnt,ColCnt: Integer): string;
var i, j: Integer;
    Buf: string;
begin
  RecCnt := 0; ColCnt := 0;
  Buf := '';
  for i:=0 to FColumnCnt-1 do begin
    Buf := Buf + UnAcc_ListView.Column[i].Caption + #9;
    Inc(ColCnt);
  end;
  Buf := Buf + #13#10;
  for i:=0 to UnAcc_ListView.Items.Count-1 do begin
    for j:=0 to FColumnCnt-1 do
      if j = 0 then Buf := Buf + Trim(UnAcc_ListView.Items[i].Caption) + #9
      else Buf := Buf + Trim(UnAcc_ListView.Items[i].SubItems[j-1]) + #9;
    Buf := Buf + #13#10;
    Inc(RecCnt);
  end;
  Result := Buf;
end;


procedure TfrmInvoiceList.SetMultilingual;
begin
  self.Caption         := GetMultiLingalMsg(90112,'Invoice List');

  rdoGroup.Caption     := GetMultiLingalMsg(90070,'Group By');
  rdoGroup.Items[0]    := GetMultiLingalMsg(90073,'by Paper NO');
  rdoGroup.Items[1]    := GetMultiLingalMsg(90071,'by Suplier');
  rdoGroup.Items[2]    := GetMultiLingalMsg(90061,'Invoice NO');
  rdoGroup.Items[3]    := GetMultiLingalMsg(90052,'by In Date');
  rdoGroup.Items[4]    := GetMultiLingalMsg(90063,'Mold Code');
  rdoGroup.Items[5]    := GetMultiLingalMsg(90058, 'Maker');
  rdoGroup.Items[6]    := GetMultiLingalMsg(32093,'Order Code');
  rdoGroup.Items[7]    := '依仓库';
  rdoGroup.Items[8]    := GetMultiLingalMsg(90079,'ALL');

  lblFDate.Caption               := GetMultiLingalMsg(90113,'Start Date')+'  ';
  lblEDate.Caption               := GetMultiLingalMsg(90114,'End Date')+'  ';
  edtSuplier.EditLabel.Caption   := GetMultiLingalMsg(90057,'Suplier')+'  ';
  edtPaperNo.EditLabel.Caption   := GetMultiLingalMsg(90053,'Paper NO')+'  ';
  edtInvoiceNo.EditLabel.Caption := GetMultiLingalMsg(90061,'Invoice NO')+'  ';
  edtMoldCode.EditLabel.Caption  := GetMultiLingalMsg(90063,'Mold Code')+'  ';
  edtOrderCode.EditLabel.Caption := GetMultiLingalMsg(32093,'Order Code')+'  ';

  btnQuery.Caption        := GetMultiLingalMsg(90115,'Filter Query');
  btnExit.Caption         := GetMultiLingalMsg(90025,'Exit');
  btnAccount.Caption      := GetMultiLingalMsg(90116,'Run Accounted');
  PNLList.Caption         := GetMultiLingalMsg(90117,'Un-Accounted List');
  TabsCtrlAccount.Tabs[0] := GetMultiLingalMsg(90117,'Un-Accounted List');
  TabsCtrlAccount.Tabs[1] := GetMultiLingalMsg(90118,'Accounted List');
end;

procedure TfrmInvoiceList.edtSuplierChange(Sender: TObject);
begin
   edtSupName.Text := dm_inventory.GetShigenName(StrToIntDef(trim(edtSuplier.Text),0));
end;

end.

⌨️ 快捷键说明

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