/// <summary> /// 添加发票信息 /// </summary> /// <param name="one">发票信息实体</param> /// <returns></returns> private bool InsertOne(string pkgNo, InvoiceModel one = null) { if (!String.IsNullOrEmpty(pkgNo)) { var pkg = PackageList.SingleOrDefault(f => f.PkgNumber == pkgNo); if (pkg == null) { pkgIndex = 1; PackageList.Add(new PackageModel { PkgNumber = pkgNo, InvoiceList = new List <InvoiceModel>() }); return(true); } else { pkgIndex = pkg.InvoiceList.Count + 1; } return(true); } if (one == null) { return(true); } if (invoiceList.Count > 0) { var exist = invoiceList.Where(f => f.Number == one.Number); if (exist.Count() != 0) { if (MessageBox.Show(string.Format("发票号码:{0} 已存在,是否重复添加?", one.Number), "扫描提示", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.No) { return(false); } } } if (isAllowInsert) { //invoiceList.Where(f => f.PkgNumber == one.PkgNumber && f.PkgIndex >= one.PkgIndex).ToList(); invoiceList.Insert(insertIndex, one); IsAllowInsert = false; } else { invoiceList.Add(one); } IsNeedSave = true; return(true); }