/// <summary> /// Updates the listbox based on the Invoice Number Combobox selection /// </summary> /// <param name="sender">Combobox</param> /// <param name="e">Args</param> private void cb_InvoiceNum_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { // Checks to make sure that the selected index is not the reset value ComboBox temp = (ComboBox)sender; if (temp.SelectedIndex != -1) { // Reset other comboboxes //cb_InvoiceDate.SelectedIndex = -1; //cb_TotalCost.SelectedIndex = -1; // Clear items out of Listbox source UIInvoices.Clear(); string invoiceNum = ((ComboBox)sender).SelectedItem.ToString(); // Add items that match into listbox foreach (Invoice item in DAInvoice.ListInvoices()) { if (item.iInvoiceNumber == invoiceNum) { if (cb_TotalCost.SelectedIndex != -1 && cb_InvoiceDate.SelectedIndex != -1) { if (item.dTotal.ToString("c") == cb_TotalCost.SelectedItem.ToString() && item.sInvoiceDate == (DateTime)cb_InvoiceDate.SelectedItem) { UIInvoices.Add(item); } } else if (cb_TotalCost.SelectedIndex != -1) { if (item.dTotal.ToString("c") == cb_TotalCost.SelectedItem.ToString()) { UIInvoices.Add(item); } } else if (cb_InvoiceDate.SelectedIndex != -1) { if (item.sInvoiceDate == (DateTime)cb_InvoiceDate.SelectedItem) { UIInvoices.Add(item); } } else { UIInvoices.Add(item); } } //if (item.iInvoiceNumber == invoiceNum) //{ // UIInvoices.Add(item); //} } lb_srch_Invoices.Items.Refresh(); } } catch (Exception ex) { Exceptions.Spool(ex); } }
public void EPT_BatchImport() { int size = EntityTest.BATCH_IMPORT_DATA_SIZE; var repo = RF.ResolveInstance <InvoiceRepository>(); using (RF.TransactionScope(repo)) { var list = new InvoiceList(); for (int i = 0; i < size; i++) { var item = new Invoice(); list.Add(item); } repo.CreateImporter().Save(list); list.Clear(); repo.CreateImporter().Save(list); Assert.AreEqual(repo.CountAll(), 0, "幽灵状态的实体,应该无法通过正常的 API 查出。"); using (PhantomContext.DontFilterPhantoms()) { Assert.AreEqual(repo.CountAll(), size, "幽灵状态的实体,可以使用特定 API 查出。"); var all2 = repo.GetAll(); Assert.AreEqual(all2.Count, size, "幽灵状态的实体,应该无法通过正常的 API 查出。"); Assert.AreEqual(EntityPhantomExtension.GetIsPhantom(all2[0]), true, "幽灵状态的实体,IsPhantom 值为 true。"); } } }
public void EPT_Clear_Query() { var repo = RF.ResolveInstance <InvoiceRepository>(); using (RF.TransactionScope(repo)) { var InvoiceList = new InvoiceList { new Invoice(), new Invoice(), new Invoice() }; repo.Save(InvoiceList); Assert.AreEqual(repo.CountAll(), 3); InvoiceList.Clear(); repo.Save(InvoiceList); Assert.AreEqual(repo.CountAll(), 0, "幽灵状态的实体,应该无法通过正常的 API 查出。"); var all = repo.GetAll(); Assert.AreEqual(all.Count, 0, "幽灵状态的实体,应该无法通过正常的 API 查出。"); using (PhantomContext.DontFilterPhantoms()) { Assert.AreEqual(repo.CountAll(), 3, "幽灵状态的实体,可以使用特定 API 查出。"); var all2 = repo.GetAll(); Assert.AreEqual(all2.Count, 3, "幽灵状态的实体,应该无法通过正常的 API 查出。"); Assert.AreEqual(EntityPhantomExtension.GetIsPhantom(all2[0]), true, "幽灵状态的实体,IsPhantom 值为 true。"); Assert.AreEqual(EntityPhantomExtension.GetIsPhantom(all2[1]), true, "幽灵状态的实体,IsPhantom 值为 true。"); Assert.AreEqual(EntityPhantomExtension.GetIsPhantom(all2[2]), true, "幽灵状态的实体,IsPhantom 值为 true。"); } } }
public void EPT_BatchImport_Aggt() { if (IsTestDbSQLite()) { return; } int size = EntityTest.BATCH_IMPORT_DATA_SIZE; var repo = RF.ResolveInstance <InvoiceRepository>(); var itemRepo = RF.ResolveInstance <InvoiceItemRepository>(); using (RF.TransactionScope(repo)) { var invoices = new InvoiceList(); for (int i = 0; i < size; i++) { var Invoice = new Invoice { InvoiceItemList = { new InvoiceItem(), new InvoiceItem(), } }; invoices.Add(Invoice); } var importer = repo.CreateImporter(); importer.Save(invoices); Assert.AreEqual(size, repo.CountAll()); Assert.AreEqual(size * 2, itemRepo.CountAll()); invoices.Clear(); importer.Save(invoices); Assert.AreEqual(repo.CountAll(), 0, "幽灵状态的实体,应该无法通过正常的 API 查出。"); Assert.AreEqual(itemRepo.CountAll(), 0, "幽灵状态的实体,应该无法通过正常的 API 查出。"); using (PhantomContext.DontFilterPhantoms()) { Assert.AreEqual(repo.CountAll(), size, "幽灵状态的实体,可以使用特定 API 查出。"); var roots = repo.GetAll(); Assert.AreEqual(roots.Count, size, "幽灵状态的实体,应该无法通过正常的 API 查出。"); Assert.AreEqual(EntityPhantomExtension.GetIsPhantom(roots[0]), true, "幽灵状态的实体,IsPhantom 值为 true。"); Assert.AreEqual(itemRepo.CountAll(), size * 2, "幽灵状态的实体,可以使用特定 API 查出。"); var items = itemRepo.GetAll(); Assert.AreEqual(items.Count, size * 2, "幽灵状态的实体,应该无法通过正常的 API 查出。"); Assert.AreEqual(EntityPhantomExtension.GetIsPhantom(items[0]), true, "幽灵状态的实体,IsPhantom 值为 true。"); } } }
public void EPT_Clear() { var repo = RF.ResolveInstance <InvoiceRepository>(); using (RF.TransactionScope(repo)) { var InvoiceList = new InvoiceList { new Invoice(), new Invoice(), new Invoice() }; repo.Save(InvoiceList); Assert.AreEqual(repo.CountAll(), 3); InvoiceList.Clear(); repo.Save(InvoiceList); Assert.AreEqual(repo.CountAll(), 0); } }