public static bool HasChildren(ISession session, int operationId) { EntityQuery qry = session.CreateEntityQuery <Operation>(); qry.And(Exp.Eq("ParentId", operationId)); return(qry.Count() > 0); }
public static bool HasChildren(ISession session, int groupId) { EntityQuery qry = session.CreateEntityQuery <UserGroup>(); qry.And(Exp.Eq("ParentId", groupId)); return(qry.Count() > 0); }
/// <summary> /// Get query conditions from page , and query data from db, then bind the query result to Repeater /// </summary> private void QueryAndBindData(int pageIndex, int pageSize, bool fetchRecordCount) { string title = txtTitle.Text.Trim(); IList <string> layout = WebUtil.GetSelectedValues(cklLayout); string type = rdlType.SelectedValue; IList <string> status = WebUtil.GetSelectedValues(cklStatus); DateTime createTime; IList <DashPage> dataDashPage = null; int recordCount = 0; using (Session session = new Session()) { EntityQuery query = session.CreateEntityQuery <DashPage>(); if (!String.IsNullOrEmpty(title)) { query.And(Exp.Like("Title", "%" + title + "%")); } if (layout != null && layout.Count > 0) { query.And(Exp.In("Layout", layout)); } if (!String.IsNullOrEmpty(type)) { query.And(Exp.Eq("Type", type)); } if (status != null && status.Count > 0) { query.And(Exp.In("Status", status)); } if (DateTime.TryParse(txtCreateTime.Text.Trim(), out createTime)) { query.And(Exp.Ge("CreateTime", createTime)); } query.SetPage(pageIndex, pageSize); dataDashPage = query.List <DashPage>(); if (fetchRecordCount) { recordCount = query.Count(); } } this.rptDashPage.DataSource = dataDashPage; this.rptDashPage.DataBind(); if (fetchRecordCount) { this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = recordCount; } WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex); WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex); //After a query, save current query this.hidReturnUrl.Value = GetReturnUrl(); }
/// <summary> /// Get query conditions from page , and query data from db, then bind the query result to Repeater /// </summary> private void QueryAndBindData(int pageIndex, int pageSize, bool fetchRecordCount) { string opObjectType = ddlOpObjectType.SelectedValue; string opType = ddlOpType.SelectedValue; DateTime opTime; string operatorName = txtOperatorName.Text.Trim(); string operatorType = ddlOperatorType.SelectedValue; IList <OpLog> dataOpLog = null; int recordCount = 0; using (Session session = new Session()) { EntityQuery query = session.CreateEntityQuery <OpLog>(); if (!String.IsNullOrEmpty(opObjectType)) { query.And(Exp.Like("OpObjectType", "%" + opObjectType + "%")); } if (!String.IsNullOrEmpty(opType)) { query.And(Exp.Like("OpType", "%" + opType + "%")); } if (DateTime.TryParse(txtOpTime.Text.Trim(), out opTime)) { query.And(Exp.Ge("OpTime", opTime)); } if (!String.IsNullOrEmpty(operatorName)) { query.And(Exp.Like("OperatorName", "%" + operatorName + "%")); } if (!String.IsNullOrEmpty(operatorType)) { query.And(Exp.Eq("OperatorType", operatorType)); } query.SetPage(pageIndex, pageSize); dataOpLog = query.List <OpLog>(); if (fetchRecordCount) { recordCount = query.Count(); } } this.rptOpLog.DataSource = dataOpLog; this.rptOpLog.DataBind(); if (fetchRecordCount) { this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = recordCount; } WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex); WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex); //After a query, save current query this.hidReturnUrl.Value = GetReturnUrl(); }
/// <summary> /// 用户组是否存在 /// </summary> /// <param name="groupName"></param> /// <returns></returns> public bool UserGroupExists(string groupName) { { EntityQuery qry = _session.CreateEntityQuery <UserGroup>(); qry.Where(Exp.Eq("Name", groupName)); return(qry.Count() > 0); } }
/// <summary> /// Get query conditions from page , and query data from db, then bind the query result to Repeater /// </summary> private void QueryAndBindData(int pageIndex, int pageSize, bool fetchRecordCount) { string itemCode = txtItemCode.Text.Trim(); string groupCode = txtGroupCode.Text.Trim(); string name = txtName.Text.Trim(); string itemType = rdlItemType.SelectedValue; IList <DictionaryItem> dataDictionaryItem = null; int recordCount = 0; // using (_session = new Session()) { EntityQuery query = _session.CreateEntityQuery <DictionaryItem>(); if (!String.IsNullOrEmpty(itemCode)) { query.And(Exp.Like("ItemCode", "%" + itemCode + "%")); } if (!String.IsNullOrEmpty(groupCode)) { query.And(Exp.Eq("GroupCode", groupCode)); } else { query.And(Exp.Eq("GroupCode", DictionaryItem.Root.ItemCode)); } if (!String.IsNullOrEmpty(name)) { query.And(Exp.Like("Name", "%" + name + "%")); } if (!String.IsNullOrEmpty(itemType)) { query.And(Exp.Eq("ItemType", itemType)); } query.SetPage(pageIndex, pageSize); dataDictionaryItem = query.List <DictionaryItem>(); if (fetchRecordCount) { recordCount = query.Count(); } } this.rptDictionaryItem.DataSource = dataDictionaryItem; this.rptDictionaryItem.DataBind(); if (fetchRecordCount) { this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = recordCount; } WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex); WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex); //After a query, save current query this.hidReturnUrl.Value = GetReturnUrl(); }
/// <summary> /// Get query conditions from page , and query data from db, then bind the query result to Repeater /// </summary> private void QueryAndBindData(int pageIndex, int pageSize, bool fetchRecordCount) { string name = txtName.Text.Trim(); string description = txtDescription.Text.Trim(); IList <string> groupType = WebUtil.GetSelectedValues(cklGroupType); string modifyTime = txtModifyTime.Text.Trim(); IList <UserGroup> dataUserGroup = null; int recordCount = 0; using (Session session = new Session()) { EntityQuery query = session.CreateEntityQuery <UserGroup>(); if (!String.IsNullOrEmpty(name)) { query.And(Exp.Like("Name", "%" + name + "%")); } if (!String.IsNullOrEmpty(description)) { query.And(Exp.Like("Description", "%" + description + "%")); } if (groupType != null && groupType.Count > 0) { query.And(Exp.In("GroupType", groupType)); } if (!String.IsNullOrEmpty(modifyTime)) { query.And(Exp.Eq("ModifyTime", modifyTime)); } query.SetPage(pageIndex, pageSize); dataUserGroup = query.List <UserGroup>(); if (fetchRecordCount) { recordCount = query.Count(); } } this.rptUserGroup.DataSource = dataUserGroup; this.rptUserGroup.DataBind(); if (fetchRecordCount) { this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = recordCount; } WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex); WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex); //After a query, save current query this.hidReturnUrl.Value = GetReturnUrl(); }
/// <summary> /// Get query conditions from page , and query data from db, then bind the query result to Repeater /// </summary> private void QueryAndBindData(int pageIndex, int pageSize, bool fetchRecordCount) { string tmplCode = txtTmplCode.Text.Trim(); string name = txtName.Text.Trim(); string msgType = ddlMsgType.SelectedValue; IList <string> accessibility = WebUtil.GetSelectedValues(cklAccessibility); IList <MsgTemplate> dataMsgTemplate = null; int recordCount = 0; using (Session session = new Session()) { EntityQuery query = session.CreateEntityQuery <MsgTemplate>(); if (!String.IsNullOrEmpty(tmplCode)) { query.And(Exp.Like("TmplCode", "%" + tmplCode + "%")); } if (!String.IsNullOrEmpty(name)) { query.And(Exp.Like("Name", "%" + name + "%")); } if (!String.IsNullOrEmpty(msgType)) { query.And(Exp.Eq("MsgTypeId", msgType)); } if (accessibility != null && accessibility.Count > 0) { query.And(Exp.In("Accessibility", accessibility)); } query.SetPage(pageIndex, pageSize); dataMsgTemplate = query.List <MsgTemplate>(); if (fetchRecordCount) { recordCount = query.Count(); } } this.rptMsgTemplate.DataSource = dataMsgTemplate; this.rptMsgTemplate.DataBind(); if (fetchRecordCount) { this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = recordCount; } WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex); WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex); //After a query, save current query this.hidReturnUrl.Value = GetReturnUrl(); }
public bool Create(ISession session) { EntityQuery qry = session.CreateEntityQuery <User>(); qry.And(Exp.Eq("UserName", this.UserName)); if (qry.Count() > 0) { throw new ApplicationException("已经存在帐户名称为{0}的用户,请选择其他的名称!"); } return(EntityManager.Create(session, this)); }
/// <summary> /// Get query conditions from page , and query data from db, then bind the query result to Repeater /// </summary> private void QueryAndBindData(int pageIndex, int pageSize, bool fetchRecordCount) { string msgTypeId = ddlMsgTypeId.SelectedValue; string title = txtTitle.Text.Trim(); IList <string> accessibility = WebUtil.GetSelectedValues(chkAccessibility); IList <string> status = WebUtil.GetSelectedValues(ddlStatus); IList <Message> dataMessage = null; int recordCount = 0; using (Session session = new Session()) { EntityQuery query = session.CreateEntityQuery <Message>(); if (!String.IsNullOrEmpty(msgTypeId)) { query.And(Exp.Eq("MsgTypeId", msgTypeId)); } if (!String.IsNullOrEmpty(title)) { query.And(Exp.Like("Title", "%" + title + "%")); } if (accessibility != null && accessibility.Count > 0) { query.And(Exp.In("Accessibility", accessibility)); } if (status != null && status.Count > 0) { query.And(Exp.In("Status", status)); } query.SetPage(pageIndex, pageSize); dataMessage = query.List <Message>(); if (fetchRecordCount) { recordCount = query.Count(); } } this.rptMessage.DataSource = dataMessage; this.rptMessage.DataBind(); if (fetchRecordCount) { this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = recordCount; } WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex); WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex); //After a query, save current query this.hidReturnUrl.Value = GetReturnUrl(); }
/// <summary> /// 是否存在指定条件的用户的DashPage /// </summary> /// <param name="session"></param> /// <param name="propertyNames"></param> /// <param name="propertyValues"></param> /// <returns></returns> public static bool Exists(ISession session, string[] propertyNames, object[] propertyValues) { if (propertyNames != null && propertyValues != null && propertyNames.Length > 0 && propertyValues.Length == propertyNames.Length) { EntityQuery qry = session.CreateEntityQuery <UserDashpage>(); for (int i = 0; i < propertyNames.Length; i++) { qry.And(Exp.Eq(propertyNames[i], propertyValues[i])); } return(qry.Count() > 0); } return(false); }
/// <summary> /// 是否存在指定条件的实体 /// </summary> /// <param name="session"></param> /// <param name="conditonPropertyNames"></param> /// <param name="conditionPropertyValues"></param> /// <returns></returns> public static bool Exists(ISession session, string[] conditonPropertyNames, object[] conditionPropertyValues) { EntityQuery query = session.CreateEntityQuery <MsgSubscriber>(); if (conditionPropertyValues != null && conditonPropertyNames != null && conditionPropertyValues.Length == conditonPropertyNames.Length) { for (int i = 0; i < conditionPropertyValues.Length; i++) { query.And(Exp.Eq(conditonPropertyNames[i], conditionPropertyValues[i])); } } return(query.Count() > 0); }
/// <summary> /// Get query conditions from page , and query data from db, then bind the query result to Repeater /// </summary> private void QueryAndBindData(int pageIndex, int pageSize, bool fetchRecordCount) { string category = ddlCategory.SelectedValue; string title = txtTitle.Text.Trim(); IList <Dashlet> dataDashlet = null; int recordCount = 0; using (Session session = new Session()) { EntityQuery query = session.CreateEntityQuery <Dashlet>(); if (!String.IsNullOrEmpty(category)) { query.And(Exp.Like("Category", "%" + category + "%")); } if (!String.IsNullOrEmpty(title)) { query.And(Exp.Like("Title", "%" + title + "%")); } query.SetPage(pageIndex, pageSize); dataDashlet = query.List <Dashlet>(); if (fetchRecordCount) { recordCount = query.Count(); } } this.rptDashlet.DataSource = dataDashlet; this.rptDashlet.DataBind(); if (fetchRecordCount) { this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = recordCount; } WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex); WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex); //After a query, save current query this.hidReturnUrl.Value = GetReturnUrl(); }
void QueryAndBindData(ISession session, int pageIndex, int pageSize, bool fetchRecordCount) { string name = this.txtMemberName.Text.Trim(); string number = this.txtMemberNumber.Text.Trim(); EntityQuery query = session.CreateEntityQuery <Member>() .Where(Exp.Like("Name", "%" + name + "%")) .And(Exp.Like("MemberNumber", "%" + number + "%")) .SetPage(pageIndex, pageSize) .OrderBy("MemberNumber"); this.rptVendor.DataSource = query.List <Member>(); this.rptVendor.DataBind(); if (fetchRecordCount) { this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = query.Count(); } WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex); WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex); }