public PdfPacketInfoListViewItem(PdfPacketInfoEx p) { _p = p; _p.OnDataChanged += new EventHandler(_p_OnDataChanged); this.UseItemStyleForSubItems = false; //this.Text = index.ToString("000"); this.SubItems.Add(PdfPacketInfo.GetPacketTypeDesc(_p.Type)); this.SubItems.Add(_p.MatchedRecipientName); this.SubItems.Add(_p.RecipientName); this.SubItems.Add(_p.ReceiverPhone); this.SubItems.Add(_p.ShipmentNumber); this.SubItems.Add(_p.Weight.ToString("0.0kg")); this.SubItems.Add(_p.Status); this.SubItems.Add(_p.Address); this.SubItems.Add(Path.GetFileName(_p.Filename)); this.SubItems[2].BackColor = Color.LightBlue; if (string.IsNullOrEmpty(_p.ShipmentNumber)) { this.SubItems[5].Text = "未找到国际单号"; this.SubItems[5].ForeColor = Color.Red; } }
public static PdfPacketInfoEx GetPdfPacketInfoEx(string filename) { PdfPacketInfo ppi = PdfPacketInfo.GetPdfPacketInfo(filename); if (null == ppi) { return(null); } return(new PdfPacketInfoEx(filename, ppi.Type, ppi.RecipientName, ppi.ShipmentNumber, ppi.Weight)); }
private bool IsPacketExist(PdfPacketInfo p, List <PdfPacketInfoEx> packetInfos) { if (null == packetInfos) { return(false); } foreach (PdfPacketInfo pi in packetInfos) { if (p.ShipmentNumber.Equals(pi.ShipmentNumber)) { return(true); } } return(false); }
private void tsbtnGetLocalPdfPackets_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "选择1个目录. 此目录中包含包裹单文件(pdf)."; //fbd.SelectedPath = Path.GetDirectoryName(Application.ExecutablePath); if (Directory.Exists(@"J:\=egode=\=出单=")) { fbd.SelectedPath = @"J:\=egode=\=出单="; } if (DialogResult.OK == fbd.ShowDialog(this)) { List <PdfPacketInfoEx> pdfPackets = PdfPacketInfo.GetPdfPacketInfos(fbd.SelectedPath, false); if (null == pdfPackets) { MessageBox.Show(this, "No PDF file found in selected folder.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } foreach (PdfPacketInfoEx p in pdfPackets) { if (IsPacketExist(p, _packetInfos)) { continue; } _packetInfos.Add(p); lvwPdfPacketInfos.Items.Add(new PdfPacketInfoListViewItem(p)); } if (_packetInfos.Count > 0) { tsbtnPackingList.Enabled = true; } RefreshIndex(); CheckDuplication(); } Cursor.Current = Cursors.Default; }