private void queryBuilder1_QueryElementControlCreated(QueryElement queryElement, IQueryElementControl queryElementControl) { if (queryElementControl is IQueryColumnListControl) { IQueryColumnListControl queryColumnListControl = (IQueryColumnListControl)queryElementControl; DataGridView dataGridView = (DataGridView)queryColumnListControl.DataGrid; _customColumn?.Dispose(); // Create custom column _customColumn = new DataGridViewCheckBoxColumn { Name = "CustomColumn", HeaderText = "Custom Column", Width = 100, FlatStyle = FlatStyle.Standard, ValueType = typeof(CheckState), TrueValue = CheckState.Checked, FalseValue = CheckState.Unchecked, IndeterminateValue = CheckState.Indeterminate }; _customColumn.HeaderCell.Style.Font = new Font("Tahoma", 8, FontStyle.Bold); // Insert custom column to specified position dataGridView.Columns.Insert(2, _customColumn); // Handle required events dataGridView.CellBeginEdit += DataGridView_CellBeginEdit; dataGridView.CellValueNeeded += DataGridView_CellValueNeeded; dataGridView.CellValuePushed += DataGridView_CellValuePushed; } }
public void TestQueryingNonQueriableStoreThrows() { var queriable = (TypeBasedPersistance)PersistanceStore; Assert.That(() => queriable.Query <PersistedString>(new[] { QueryElement.FieldEquals("id", "1") }), Throws.TypeOf <NotSupportedException>()); }
public virtual string BuildQueryElement(QueryElement e, ref int count, int taskIndex) { var template = count == 0 ? genericWhereClause : e.UseOr ? genericOrClause : genericAndClause; var openBlock = e.OpenBlock ? "(" : string.Empty; var closeBlock = e.CloseBlock ? ")" : string.Empty; var o = OperatorFormats[e.Operator]; string p = string.Empty; if (e.Operator == Operator.In) { foreach (var u in e.GetUniqueParameters("q")) { p += u + "_" + taskIndex + "_" + count++ + ", "; } } else { p = e.GetUniqueParameter("q") + "_" + taskIndex + "_" + count++; } var valOp = string.Format(o, p.TrimEnd(',', ' ')); return(string.Format(template, openBlock, e.TableAlias, e.FieldName, valOp, closeBlock)); }
public BooleanQueryClause(BooleanOperator @operator, QueryElement item1, QueryElement item2) { Type = QueryElementType.BooleanQueryClause; Operator = @operator; Item1 = item1; Item2 = item2; }
/// <summary> /// Changes the string value of any <see name="Value" /> instances to match the property types /// </summary> /// <param name="map">The table mapping</param> /// <param name="targettype">The type to change the item to</param> /// <param name="el">The element to visit</param> private static void CorrectValues(TableMapping map, Type targettype, QueryElement el) { while (el is ParenthesisExpression p) { el = (QueryElement)p.Expression; } if (el is Arithmetic a) { CorrectValues(map, targettype, (QueryElement)a.LeftHandSide, (QueryElement)a.RightHandSide); } if (el is Compare c) { CorrectValues(map, targettype, (QueryElement)c.LeftHandSide, (QueryElement)c.RightHandSide); } if (el is And andExp) { foreach (var n in andExp.Items) { CorrectValues(map, targettype, (QueryElement)n); } } if (el is Or orExp) { foreach (var n in orExp.Items) { CorrectValues(map, targettype, (QueryElement)n); } } // Change the type if we get here if (el is Value v && targettype != null && v.Item is string vs) { v.Item = ConvertEl(vs, targettype); }
public void TestElementIsBuiltCorrectly() { _element = new QueryElement("field", FieldComparison.Equals, "value"); Assert.AreEqual("field", _element.Field); Assert.AreEqual(FieldComparison.Equals, _element.Comparison); Assert.AreEqual("value", _element.Value); }
private void queryBuilder1_QueryElementControlCreated(QueryElement queryElement, IQueryElementControl queryElementControl) { if (queryElementControl is IQueryColumnListControl) { IQueryColumnListControl queryColumnListControl = (IQueryColumnListControl)queryElementControl; DataGridView dataGridView = (DataGridView)queryColumnListControl.DataGrid; _customColumn?.Dispose(); // Create custom column _customColumn = new ComboBoxWithButtonColumn { Name = "CustomColumn", HeaderText = "Custom Column", Width = 200, DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing, // hide the combobox if cell is not focused ValueType = typeof(string) }; _customColumn.HeaderCell.Style.Font = new Font("Tahoma", 8, FontStyle.Bold); _customColumn.ShowButton = true; // Insert custom column to specified position dataGridView.Columns.Insert(2, _customColumn); // Handle requierd events dataGridView.CellEnter += DataGridView_CellEnter; dataGridView.CellLeave += DataGridView_CellLeave; dataGridView.CellBeginEdit += DataGridView_CellBeginEdit; dataGridView.CellValueNeeded += DataGridView_CellValueNeeded; dataGridView.CellValuePushed += DataGridView_CellValuePushed; dataGridView.EditingControlShowing += DataGridView_EditingControlShowing; } }
public void TestFieldEqualsBuildAProperElement() { _element = QueryElement.FieldEquals("field", "value"); Assert.AreEqual("field", _element.Field); Assert.AreEqual(FieldComparison.Equals, _element.Comparison); Assert.AreEqual("value", _element.Value); }
protected void QueryFilterAdd(string field, ParaEnums.QueryCriteria criteria, string value) { var internalCrit = ""; switch (criteria) { case ParaEnums.QueryCriteria.Equal: internalCrit = "="; break; case ParaEnums.QueryCriteria.LessThan: internalCrit = "_max_="; break; case ParaEnums.QueryCriteria.Like: internalCrit = "_like_="; break; case ParaEnums.QueryCriteria.MoreThan: internalCrit = "_min_="; break; } var qe = new QueryElement { QueryName = field, QueryFilter = internalCrit, QueryValue = value }; QueryElementsRemoveDuplicate(qe); QElements.Add(qe); }
private void queryBuilder1_QueryElementControlCreated(QueryElement queryElement, IQueryElementControl queryElementControl) { if (queryElementControl is IQueryColumnListControl) { var queryColumnListControl = (IQueryColumnListControl)queryElementControl; DataGridView dataGridView = (DataGridView)queryColumnListControl.DataGrid; _customColumn?.Dispose(); // Create custom column _customColumn = new DataGridViewTextBoxColumn { Name = "CustomColumn", HeaderText = "Custom Column", Width = 200, ValueType = typeof(string) }; _customColumn.HeaderCell.Style.Font = new Font("Tahoma", 8, FontStyle.Bold); // Insert custom column to specified position dataGridView.Columns.Insert(2, _customColumn); // Handle requierd events dataGridView.CellBeginEdit += DataGridView_CellBeginEdit; dataGridView.CellValueNeeded += DataGridView_CellValueNeeded; dataGridView.CellValuePushed += DataGridView_CellValuePushed; } }
private void QueryColumnListOnElementRemoving(QueryElement sender, QueryElement child) { var queryColumnListItem = (QueryColumnListItem)child; queryColumnListItem.Updated -= QueryColumnListItem_Updated; if (_dictionarySubQuery.ContainsKey(queryBuilder1.ActiveUnionSubQuery)) { if (_dictionarySubQuery[queryBuilder1.ActiveUnionSubQuery].ContainsKey(queryColumnListItem)) { _dictionarySubQuery[queryBuilder1.ActiveUnionSubQuery].Remove(queryColumnListItem); } } else { foreach (var key in _dictionarySubQuery.Keys) { if (!_dictionarySubQuery[key].ContainsKey(queryColumnListItem)) { continue; } _dictionarySubQuery[key].Remove(queryColumnListItem); } } }
public void TestNothingWhenNotFound() { var query = QueryElement.FieldEquals("Version", 1); var result = QueryStore.Query <QueryableTestObject>(query); Assert.AreEqual(0, result.Count()); }
public IList <EntityType> Select(QueryElement query, int skip, int take, bool withChildren = false) { using (var reader = GetReader()) { reader.Where(query); reader.WithAllJoins(); if (take > 0) { reader.WithTop(take); } if (skip > 0) { reader.WithSkip(skip); } var res = reader.QueryResult(); if (withChildren) { reader.SetAllChildrenForExisting(res); } return(res); } }
private bool ElementContainsSiteAndWords(string itemHtml, QueryElement query) { return(false); //itemHtml = itemHtml.ToLower().Trim(); //var ourSite = query.OurSite.ToLower().Trim(); //return itemHtml.Contains(ourSite); }
public string MakeScreenshot(QueryElement query) { var ss = ((ITakesScreenshot)_driver).GetScreenshot(); var screenshotAsByteArray = ss.AsByteArray; File.WriteAllBytes(GetFilePath(query), screenshotAsByteArray); return(GetFilePath(query)); }
private YandexPage GetResultPage(QueryElement query, IWebDriver driver, RegionElement region) { //var driver = WebDriverProvider.GetWebDriver(); var yaPage = new YandexPage(driver, query, region); //driver.Close(); return(yaPage); }
/// <summary> /// Deletes items matching the where clause /// </summary> /// <param name="connection">The connection to use</param> /// <param name="query">The query to use</param> /// <typeparam name="T">The data type parameter.</typeparam> /// <returns>The number of items</returns> public static int Delete <T>(this IDbConnection connection, QueryElement query) { return(Delete(connection, GetDialect(connection) .Query <T>() .Delete() .Where(query) )); }
/// <summary> /// Updates one or more items with the given values. /// </summary> /// <returns>The number of rows updated.</returns> /// <param name="connection">The connection to use</param> /// <param name="item">The item with values to update.</param> /// <param name="query">The where clause to use</param> /// <typeparam name="T">The data type parameter.</typeparam> public static int Update <T>(this IDbConnection connection, object item, QueryElement query) { return(Update(connection, GetDialect(connection). Query <T>() .Update(item) .Where(query) )); }
public List <IWebElement> GetElementsWithOurAdvertisement(QueryElement query) { var requestItems = _driver .FindElements(By.CssSelector(".serp-item")) .Where(i => ElementContainsSiteAndWords(i.Text, query)) .ToList(); return(requestItems); }
public override void Save() { DatabaseQuery query = new DatabaseQuery(Database.Tables.LEAVE_DATES); query.Add(Database.Tables.LeaveDates.Date, QueryElement.DateOf(Date)); query.Add(Database.Tables.LeaveDates.StaffId, Owner); DoSave(query); StaffsManager.Add(this); }
public YandexPage(IWebDriver driver, QueryElement query, RegionElement region) { this._driver = driver; _region = region; Query = query.Query; Frequency = query.Frequency; QueryGroup = query.Group; SearchRequest(); ResultItems = GetResultItems(); }
public IEnumerable <DomainEvent> Get(Guid aggregateId, int fromVersion) { var aggregates = _queryStore.Query <PersistedDomainEvent>(new [] { QueryElement.FieldEquals("EventId", aggregateId.ToString()), QueryElement.FieldCompare("Version", FieldComparison.GreaterEquals, fromVersion), }); return(aggregates.OrderBy(x => x.Version).Select(x => x.Source).ToList()); }
private void QBuilder_OnQueryElementControlDestroying(QueryElement owner, IQueryElementControl control) { if (QElementDestroying.IsChecked != true) { return; } BoxLogEvents.Text = "QueryElementControl Destroying \"" + control.GetType().Name + "\"" + Environment.NewLine + BoxLogEvents.Text; }
/// <summary> /// Gets some items for a given type /// </summary> /// <returns>The items that match.</returns> /// <param name="connection">The connection to use</param> /// <param name="query">The query to use</param> /// <typeparam name="T">The data type parameter.</typeparam> public static IEnumerable <T> Select <T>(this IDbConnection connection, QueryElement query) where T : new() { return(Select(connection, GetDialect(connection) .Query <T>() .Select() .Where(query) )); }
protected void btnBorrowQuerySubmit_Click(object sender, EventArgs e) { queryList = new List<QueryElement>(); #region 查询条件验证 if (!string.IsNullOrEmpty(this.txtBorrowQueryBBorrowDate.Text.Trim()) || !string.IsNullOrEmpty(this.txtBorrowQueryEBorrowDate.Text.Trim())) { if (!string.IsNullOrEmpty(this.txtBorrowQueryBBorrowDate.Text.Trim()) && string.IsNullOrEmpty(this.txtBorrowQueryEBorrowDate.Text.Trim())) { Alert.Show(this, "请输入一个时间段!"); this.txtBorrowQueryEBorrowDate.Focus(); return; } else if (string.IsNullOrEmpty(this.txtBorrowQueryBBorrowDate.Text.Trim()) && !string.IsNullOrEmpty(this.txtBorrowQueryEBorrowDate.Text.Trim())) { Alert.Show(this, "请输入一个时间段!"); this.txtBorrowQueryBBorrowDate.Focus(); return; } else { bool flag = HelperCommon.ValidDateTime(this.txtBorrowQueryBBorrowDate.Text.Trim(), this.txtBorrowQueryEBorrowDate.Text.Trim()); if (!flag) { Alert.Show(this, "开始日期不能大于结束日期!"); this.txtBorrowQueryEBorrowDate.Focus(); return; } } } #endregion if (!string.IsNullOrEmpty(this.txtBorrowQueryBorrower.Text.Trim())) { QueryElement query = new QueryElement { Queryname = "Borrower", QueryElementType = MySqlDbType.String, Queryvalue = this.txtBorrowQueryBorrower.Text.Trim(), QueryOperation = "like" }; queryList.Add(query); } if (!string.IsNullOrEmpty(this.dropBorrowQueryStatus.SelectedValue)) { QueryElement query = new QueryElement { Queryname = "Status", QueryElementType = MySqlDbType.Int32, Queryvalue = Convert.ToInt32(this.dropBorrowQueryStatus.SelectedValue) }; queryList.Add(query); } if (!string.IsNullOrEmpty(this.txtBorrowQueryBBorrowDate.Text.Trim()) && !string.IsNullOrEmpty(this.txtBorrowQueryEBorrowDate.Text.Trim())) { QueryElement query = new QueryElement { Queryname = "HappenedDate", QueryElementType = MySqlDbType.DateTime, Queryvalue = this.txtBorrowQueryBBorrowDate.Text.Trim(), QueryOperation = ">=" }; queryList.Add(query); query = new QueryElement { Queryname = "HappenedDate", QueryElementType = MySqlDbType.DateTime, Queryvalue = this.txtBorrowQueryEBorrowDate.Text.Trim(), QueryOperation = "<" }; queryList.Add(query); } BindBorrowListDataGrid(queryList); this.ClientScript.RegisterStartupScript(this.GetType(), "", "DisplayQueryBorrowdiv();", true); InitializeBorrowQuery(); }
public IEntityReader Where(QueryElement query) { if (string.IsNullOrWhiteSpace(query.TableAlias)) { query.TableAlias = TableAlias; } _queries.Add(query); return(this); }
// Getting leave dates within a set range through the staff ID. public static List <MedicalStaff> GetMedicalStaffLeavesFrom(DateTime start, DateTime end, bool not) { DatabaseQuery nestedQuery = new DatabaseQuery(Database.Tables.LEAVE_DATES); if (start.Date.Equals(end.Date)) { nestedQuery.Comparator = new QueryComparator { Source = new QueryElement(Database.Tables.LeaveDates.Date), Operand = new QueryElement(null, QueryElement.DateOf(start)) }; } else { nestedQuery.Comparator = new QueryComparator { Source = new QueryComparator() { Source = new QueryElement(Database.Tables.LeaveDates.Date), Operand = new QueryElement(null, QueryElement.DateOf(start)), Equal = !not, More = !not, Less = not }, Operand = new QueryComparator() { Source = new QueryElement(Database.Tables.LeaveDates.Date), Operand = new QueryElement(null, QueryElement.DateOf(end)), Equal = !not, Less = !not, More = not }, And = !not, Or = not }; } nestedQuery.Add(Database.Tables.LeaveDates.StaffId); return(ManagerHelper.FilterType <MedicalStaff> ( StaffManager.Merge ( Database.Tables.STAFFS, ManagerHelper.GetInComparator ( Database.Tables.Generic.ID, nestedQuery ) ) )); }
/// <summary> /// Parses a query element and returns the SQL and arguments /// </summary> /// <param name="type">The type to query</param> /// <param name="element">The query element</param> /// <returns>The parsed query and the arguments</returns> public override KeyValuePair <string, object[]> RenderWhereClause(Type type, QueryElement element) { var lst = new List <object>(); var q = RenderWhereClause(type, element, lst); if (!string.IsNullOrWhiteSpace(q)) { q = "WHERE " + q; } return(new KeyValuePair <string, object[]>(q, lst.ToArray())); }
public static void Write(this QueryElement element, CSideWriter writer) { switch (element) { case DataItemQueryElement d: d.Write(writer); break; case ColumnQueryElement c: c.Write(writer); break; case FilterQueryElement f: f.Write(writer); break; } }
/// <summary> /// Before adding a query element, making sure that no duplicates is there. /// </summary> /// <param name="QueryName"></param> protected void QueryElementsRemoveDuplicate(QueryElement qe) { foreach (var qes in QElements) { if (string.Compare(qes.QueryName, qe.QueryName, true) == 0 && string.Compare(qes.QueryFilter, qe.QueryFilter) == 0) { QElements.Remove(qe); return; } } }
protected void QueryFilterAdd(string field, ParaEnums.QueryCriteria criteria, string value) { var internalCrit = ""; switch (criteria) { case ParaEnums.QueryCriteria.Equal: internalCrit = "="; break; case ParaEnums.QueryCriteria.LessThan: internalCrit = "_max_="; break; case ParaEnums.QueryCriteria.Like: internalCrit = "_like_="; break; case ParaEnums.QueryCriteria.MoreThan: internalCrit = "_min_="; break; } var qe = new QueryElement { QueryName = field, QueryFilter = internalCrit, QueryValue = value }; QueryElementsRemoveDuplicate(qe); QElements.Add(qe); }
/// <summary> /// Before adding a query element, making sure that no duplicates is there. /// </summary> /// <param name="QueryName"></param> protected void QueryElementsRemoveDuplicate(QueryElement qe) { foreach (var qes in QElements) { if (string.Compare(qes.QueryName, qe.QueryName, true) == 0 && string.Compare(qes.QueryFilter, qe.QueryFilter) == 0) { QElements.Remove(qe); return; } } }
protected void btnIncomeQuerySelect_Click(object sender, EventArgs e) { this.ClientScript.RegisterStartupScript(this.GetType(), "", "DisplayQueryIncomediv();", true); #region 查询条件验证 if (!string.IsNullOrEmpty(this.txtIncomeQueryBDepositDate.Text.Trim()) || !string.IsNullOrEmpty(this.txtIncomeQueryEDepositDate.Text.Trim())) { if (!string.IsNullOrEmpty(this.txtIncomeQueryBDepositDate.Text.Trim()) && string.IsNullOrEmpty(this.txtIncomeQueryEDepositDate.Text.Trim())) { Alert.Show(this, "请输入一个时间段!"); this.txtIncomeQueryEDepositDate.Focus(); return; } else if (string.IsNullOrEmpty(this.txtIncomeQueryBDepositDate.Text.Trim()) && !string.IsNullOrEmpty(this.txtIncomeQueryEDepositDate.Text.Trim())) { Alert.Show(this, "请输入一个时间段!"); this.txtIncomeQueryBDepositDate.Focus(); return; } else { bool flag = HelperCommon.ValidDateTime(this.txtIncomeQueryBDepositDate.Text.Trim(), this.txtIncomeQueryEDepositDate.Text.Trim()); if (!flag) { Alert.Show(this, "开始日期不能大于结束日期!"); this.txtIncomeQueryEDepositDate.Focus(); return; } } } #endregion queryList = new List<QueryElement>(); if (!string.IsNullOrEmpty(this.txtIncomeQueryCardNumber.Text.Trim())) { QueryElement query = new QueryElement { Queryname = "CardNumber", QueryElementType = MySqlDbType.String, Queryvalue = this.txtIncomeQueryCardNumber.Text.Trim()}; queryList.Add(query); } if (!string.IsNullOrEmpty(this.dropIncomeQueryIncomeType.SelectedValue)) { QueryElement query = new QueryElement { Queryname = "IncomeType", QueryElementType = MySqlDbType.Int32, Queryvalue = Convert.ToInt32(this.dropIncomeQueryIncomeType.SelectedValue) }; queryList.Add(query); } if (!string.IsNullOrEmpty(this.txtIncomeQueryOwnerName.Text.Trim())) { QueryElement query = new QueryElement { Queryname = "OwnerName",QueryElementType=MySqlDbType.String,Queryvalue=this.txtIncomeQueryOwnerName.Text.Trim(),QueryOperation="like" }; queryList.Add(query); } if (!string.IsNullOrEmpty(this.dropIncomeQueryMode.SelectedValue)) { QueryElement query = new QueryElement { Queryname = "Mode" ,QueryElementType=MySqlDbType.Int32,Queryvalue=this.dropIncomeQueryMode.SelectedValue}; queryList.Add(query); } if (!string.IsNullOrEmpty(this.txtIncomeQueryDepositorName.Text.Trim())) { QueryElement query = new QueryElement { Queryname = "DepositorName", QueryElementType = MySqlDbType.String, Queryvalue = this.txtIncomeQueryDepositorName.Text.Trim(),QueryOperation="like" }; queryList.Add(query); } if (!string.IsNullOrEmpty(this.dropIncomeQueryDepositMode.SelectedValue)) { QueryElement query = new QueryElement { Queryname = "DepositMode", QueryElementType = MySqlDbType.Int32, Queryvalue = this.dropIncomeQueryDepositMode.SelectedValue }; queryList.Add(query); } if (!string.IsNullOrEmpty(this.txtIncomeQueryBDepositDate.Text.Trim()) && !string.IsNullOrEmpty(this.txtIncomeQueryEDepositDate.Text.Trim())) { QueryElement query = new QueryElement { Queryname = "DepositDate",QueryElementType=MySqlDbType.DateTime,Queryvalue=this.txtIncomeQueryBDepositDate.Text.Trim(),QueryOperation=">=" }; queryList.Add(query); query = new QueryElement { Queryname = "DepositDate",QueryElementType=MySqlDbType.DateTime,Queryvalue=this.txtIncomeQueryEDepositDate.Text.Trim(),QueryOperation="<" }; queryList.Add(query); } BindIncomeListDataGrid(queryList); this.ClientScript.RegisterStartupScript(this.GetType(), "", "DisplayQueryIncomediv();", true); InitializeIncomeQuery(); }
private void UserQuerySumbit(ref List<QueryElement> list) { if (!string.IsNullOrEmpty(this.txtUserQueryUserName.Text.Trim())) { QueryElement queryElement = new QueryElement { Queryname = "Name", QueryElementType = MySqlDbType.String, Queryvalue = this.txtUserQueryUserName.Text.Trim(), QueryOperation = "like" }; list.Add(queryElement); } if (!string.IsNullOrEmpty(this.txtUserQueryIdCode.Text.Trim())) { QueryElement queryElement = new QueryElement { Queryname = "Code", QueryElementType = MySqlDbType.String, Queryvalue = this.txtUserQueryIdCode.Text.Trim() }; list.Add(queryElement); } }
protected void btnLoanQuerySubmit_Click(object sender, EventArgs e) { queryList = new List<QueryElement>(); #region 查询条件验证 if (!string.IsNullOrEmpty(this.txtLoanQueryBLoanDate.Text.Trim()) || !string.IsNullOrEmpty(this.txtLoanQueryELoanDate.Text.Trim())) { if (!string.IsNullOrEmpty(this.txtLoanQueryBLoanDate.Text.Trim()) && string.IsNullOrEmpty(this.txtLoanQueryELoanDate.Text.Trim())) { Alert.Show(this, "请输入一个时间段!"); this.txtLoanQueryBLoanDate.Focus(); return; } else if (string.IsNullOrEmpty(this.txtLoanQueryBLoanDate.Text.Trim()) && !string.IsNullOrEmpty(this.txtLoanQueryELoanDate.Text.Trim())) { Alert.Show(this, "请输入一个时间段!"); this.txtLoanQueryBLoanDate.Focus(); return; } else { bool flag = HelperCommon.ValidDateTime(this.txtLoanQueryBLoanDate.Text.Trim(), this.txtLoanQueryELoanDate.Text.Trim()); if (!flag) { Alert.Show(this, "开始日期不能大于结束日期!"); this.txtLoanQueryELoanDate.Focus(); return; } } } #endregion if (!string.IsNullOrEmpty(this.txtLoanQueryLoaner.Text.Trim())) { QueryElement query = new QueryElement { Queryname = "Lender", QueryElementType = MySqlDbType.String, Queryvalue = this.txtLoanQueryLoaner.Text.Trim(), QueryOperation = "like" }; queryList.Add(query); } if (!string.IsNullOrEmpty(this.dropLoanQueryStatus.SelectedValue)) { QueryElement query = new QueryElement { Queryname = "Status", QueryElementType = MySqlDbType.Int32, Queryvalue = Convert.ToInt32(this.dropLoanQueryStatus.SelectedValue) }; queryList.Add(query); } if (!string.IsNullOrEmpty(this.txtLoanQueryBLoanDate.Text.Trim()) && !string.IsNullOrEmpty(this.txtLoanQueryELoanDate.Text.Trim())) { QueryElement query = new QueryElement { Queryname = "LoanDate", QueryElementType = MySqlDbType.DateTime, Queryvalue = this.txtLoanQueryBLoanDate.Text.Trim(), QueryOperation = ">=" }; queryList.Add(query); query = new QueryElement { Queryname = "LoanDate", QueryElementType = MySqlDbType.DateTime, Queryvalue = this.txtLoanQueryELoanDate.Text.Trim(), QueryOperation = "<" }; queryList.Add(query); } BindLoanListDataGrid(queryList); this.ClientScript.RegisterStartupScript(this.GetType(), "", "DisplayQueryLoandiv();", true); }
/// <summary> /// 查询提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnExpensesQuerySubmit_Click(object sender, EventArgs e) { #region 验证 if (!string.IsNullOrEmpty(this.txtExpensesQueryBSpendDate.Text.Trim()) || !string.IsNullOrEmpty(this.txtExpensesQueryESpendDate.Text.Trim())) { if (!string.IsNullOrEmpty(this.txtExpensesQueryBSpendDate.Text.Trim()) && string.IsNullOrEmpty(this.txtExpensesQueryESpendDate.Text.Trim())) { Alert.Show(this, "请输入一个时间段!"); this.txtExpensesQueryESpendDate.Focus(); return; } else if (string.IsNullOrEmpty(this.txtExpensesQueryBSpendDate.Text.Trim()) && !string.IsNullOrEmpty(this.txtExpensesQueryESpendDate.Text.Trim())) { Alert.Show(this, "请输入一个时间段!"); this.txtExpensesQueryBSpendDate.Focus(); return; } else { bool flag = HelperCommon.ValidDateTime(this.txtExpensesQueryBSpendDate.Text.Trim(), this.txtExpensesQueryESpendDate.Text.Trim()); if (!flag) { Alert.Show(this, "开始日期不能大于结束日期!"); this.txtExpensesQueryESpendDate.Focus(); return; } } } #endregion queryList = new List<QueryElement>(); if (!string.IsNullOrEmpty(this.txtExpensesQueryCardNumber.Text.Trim())) { QueryElement query = new QueryElement { Queryname = "CardNumber", QueryElementType = MySqlDbType.String, Queryvalue = this.txtExpensesQueryCardNumber.Text.Trim() }; queryList.Add(query); } if (!string.IsNullOrEmpty(this.dropExpensesQuerySpendType.SelectedValue)) { QueryElement query = new QueryElement { Queryname = "SpendType", QueryElementType = MySqlDbType.Int32, Queryvalue = Convert.ToInt32(this.dropExpensesQuerySpendType.SelectedValue) }; queryList.Add(query); } if (!string.IsNullOrEmpty(this.dropExpensesQuerySpendMode.SelectedValue)) { QueryElement query = new QueryElement { Queryname = "SpendMode", QueryElementType = MySqlDbType.Int32, Queryvalue = Convert.ToInt32(this.dropExpensesQuerySpendMode.SelectedValue) }; queryList.Add(query); } if (!string.IsNullOrEmpty(this.txtExpensesQueryConsumerName.Text.Trim())) { QueryElement query = new QueryElement { Queryname = "ConsumerName", QueryElementType = MySqlDbType.String, Queryvalue = this.txtExpensesQueryConsumerName.Text.Trim(), QueryOperation = "like" }; queryList.Add(query); } if (!string.IsNullOrEmpty(this.txtExpensesQueryBSpendDate.Text.Trim()) && !string.IsNullOrEmpty(this.txtExpensesQueryESpendDate.Text.Trim())) { QueryElement query = new QueryElement { Queryname = "SpendDate", QueryElementType = MySqlDbType.DateTime, Queryvalue = this.txtExpensesQueryBSpendDate.Text.Trim(), QueryOperation = ">=" }; queryList.Add(query); query = new QueryElement { Queryname = "SpendDate", QueryElementType = MySqlDbType.DateTime, Queryvalue = this.txtExpensesQueryESpendDate.Text.Trim(), QueryOperation = "<" }; queryList.Add(query); } BindExpensesListDataGrid(queryList); this.ClientScript.RegisterStartupScript(this.GetType(), "", "DisplayExpensesQuerydiv();", true); InitializeExpensesQuery(); }
public override List<QueryElement> GetQueryElements(object queryType = null) { var type = queryType == null ? SearchType.Free : (SearchType) queryType; var elements = new List<QueryElement>(); var day1OfCurrentMonth = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1); var day1OfCurrentYear = new DateTime(DateTime.Today.Year, 1, 1); var icIds = GetInternalCustomerIdsOfCurrentUser(); for (int i = 0; i < icIds.Count; i ++) { var e = new QueryElement { FieldName = "Quota.Contract.InternalCustomerId", Operator = Operator.Equal, Value = icIds[i]}; if (i == 0) { e.WithLeftBracket = true; } else { e.RelationToLeft = Relation.Or; } if (i == icIds.Count - 1) { e.WithRightBracket = true; } elements.Add(e); } switch (type) { case SearchType.CurrentMonth: { elements.Add(new QueryElement { FieldName = "WarehouseOutDate", Operator = Operator.GreaterEqualThan, Value = day1OfCurrentMonth}); elements.Add(new QueryElement { FieldName = "WarehouseOutDate", Operator = Operator.LessEqualThan, Value = day1OfCurrentMonth.AddMonths(1).AddDays(-1)}); } break; case SearchType.CurrentYear: { elements.Add(new QueryElement { FieldName = "WarehouseOutDate", Operator = Operator.GreaterEqualThan, Value = day1OfCurrentYear }); elements.Add(new QueryElement { FieldName = "WarehouseOutDate", Operator = Operator.LessEqualThan, Value = day1OfCurrentMonth.AddYears(1).AddDays(-1) }); } break; case SearchType.LastMonth: { elements.Add(new QueryElement { FieldName = "WarehouseOutDate", Operator = Operator.GreaterEqualThan, Value = day1OfCurrentMonth.AddMonths(-1) }); elements.Add(new QueryElement { FieldName = "WarehouseOutDate", Operator = Operator.LessEqualThan, Value = day1OfCurrentMonth.AddDays(-1) }); } break; case SearchType.LastYear: { elements.Add(new QueryElement { FieldName = "WarehouseOutDate", Operator = Operator.GreaterEqualThan, Value = day1OfCurrentYear.AddYears(-1) }); elements.Add(new QueryElement { FieldName = "WarehouseOutDate", Operator = Operator.LessEqualThan, Value = day1OfCurrentMonth.AddDays(-1) }); } break; case SearchType.Free: { if (SupplierId > 0) { elements.Add(new QueryElement { FieldName = "Quota.Contract.BPId", Operator = Operator.Equal, Value = SupplierId}); } if (WarehouseId > 0) { elements.Add(new QueryElement{FieldName = "WarehouseId", Operator = Operator.Equal, Value = WarehouseId}); } if (StartDate != null) { elements.Add(new QueryElement { FieldName = "WarehouseOutDate", Operator = Operator.GreaterEqualThan, Value = StartDate}); } if (EndDate != null) { elements.Add(new QueryElement { FieldName = "WarehouseOutDate", Operator = Operator.LessEqualThan, Value = EndDate}); } if (SelectedVerifiedStatus > 0) { elements.Add(new QueryElement{FieldName = "IsVerified", Operator = Operator.Equal, Value = (SelectedVerifiedStatus == (int)IsVerified.True)}); } if (CommodityId > 0) { elements.Add(new QueryElement{FieldName = "Quota.CommodityId", Operator = Operator.Equal, Value = CommodityId}); } if (OnlyCurrentUser) { elements.Add(new QueryElement{FieldName = "CreatedBy", Operator = Operator.Equal, Value = CurrentUser.Id}); } } break; } return elements; }
/// <summary> /// Initializes a new instance of the <see cref="QueryNode"/> class. /// </summary> /// <param name="elem">The element of query</param> public QueryNode(QueryElement elem) { this.element = elem; }
void LoadData(bool forceFeeds) { // // Load the data // List<UserQuery> queries = null; List<UserFeed> feeds = null; using (var repo = new Repo ()) { queries = repo.GetQueries (Service); feeds = repo.GetFeeds (Service); feeds.Sort ((x, y) => x.Category.CompareTo (y.Category)); if (feeds.Count == 0 || Service.ShouldUpdateFeeds || forceFeeds) { BeginDownloadFeeds (); } } // // Update the UI // if (feeds.Count > 0) { RemoveLoading (); foreach (var f in _feeds) { Sections.Remove (f); } DialogSection feedSection = null; foreach (var f in feeds) { if (feedSection == null || feedSection.Header != f.Category) { feedSection = new DialogSection (f.Category); _feeds.Add (feedSection); Sections.Add (feedSection); } var e = new FeedElement (Service, f, UITableViewCellAccessory.DisclosureIndicator); e.Selected += delegate { PushDataViewController (e.Feed); }; feedSection.Add (e); } } _queries.Clear (); foreach (var q in queries) { var e = new QueryElement (q); _queries.Add (e); } if (queries.Count > 0 && !Sections.Contains (_queries)) { Sections.Insert (0, _queries); } TableView.ReloadData (); }