/// <summary> /// Test Find using the Query class /// </summary> private void Step_30_TestFindByQuery_Generated() { using (TransactionManager tm = CreateTransaction()) { //Insert Mock Instance Account mock = CreateMockInstance(tm); bool result = DataRepository.AccountProvider.Insert(tm, mock); Assert.IsTrue(result, "Could Not Test FindByQuery, Insert Failed"); AccountQuery query = new AccountQuery(); query.AppendEquals(AccountColumn.Branch, mock.Branch.ToString()); query.AppendEquals(AccountColumn.AccountId, mock.AccountId.ToString()); query.AppendEquals(AccountColumn.Abbreviat, mock.Abbreviat.ToString()); query.AppendEquals(AccountColumn.MofGl, mock.MofGl.ToString()); query.AppendEquals(AccountColumn.CustId, mock.CustId.ToString()); query.AppendEquals(AccountColumn.Name, mock.Name.ToString()); query.AppendEquals(AccountColumn.OpenDate, mock.OpenDate.ToString()); query.AppendEquals(AccountColumn.PrevDate, mock.PrevDate.ToString()); query.AppendEquals(AccountColumn.LastDate, mock.LastDate.ToString()); query.AppendEquals(AccountColumn.Creamt, mock.Creamt.ToString()); query.AppendEquals(AccountColumn.Debamt, mock.Debamt.ToString()); query.AppendEquals(AccountColumn.Status, mock.Status.ToString()); TList <Account> results = DataRepository.AccountProvider.Find(tm, query); Assert.IsTrue(results.Count == 1, "Find is not working correctly. Failed to find the mock instance"); } }
/// <summary> /// Bind grid /// </summary> public void Bind() { AccountService accountService = new AccountService(); AccountQuery filters = new AccountQuery(); //check Login id if (UserID.Text.Trim().Length > 0) { MembershipUser user = Membership.GetUser(UserID.Text.Trim()); if (user != null) { filters.AppendEquals(AccountColumn.UserID, user.ProviderUserKey.ToString()); } else { filters.AppendEquals(AccountColumn.UserID, UserID.Text.Trim()); } } //check OrderID if (OrderID.Text.Trim().Length > 0) { int orderID = int.Parse(OrderID.Text.Trim()); OrderService _orderService = new OrderService(); Order entity = _orderService.GetByOrderID(orderID); if (entity != null) { filters.AppendEquals(AccountColumn.AccountID, entity.AccountID.Value.ToString()); } else { filters.AppendEquals(AccountColumn.AccountID, "0"); } } //Filter query filters.Append(AccountColumn.BillingFirstName,"%" + FirstName.Text.Trim() + "%"); filters.Append(AccountColumn.BillingLastName, "%" + LastName.Text.Trim() + "%"); filters.Append(AccountColumn.BillingPostalCode, "%" + ZipCode.Text.Trim() + "%"); filters.Append(AccountColumn.BillingCompanyName, "%" + CompanyName.Text.Trim() + "%"); //get account list TList<Account> accountList = accountService.Find(filters.GetParameters()); if (accountList != null) { if (accountList.Count == 0) { lblSearhError.Text = "No users found."; } } else { lblSearhError.Text = "No users found."; } //Bind account list grid ui_FoundUsers.DataSource = accountList; ui_FoundUsers.DataBind(); }