public SapInstanceCriteria GetSuUserCriteria()
        {
            SapInstanceCriteria sa = new SapInstanceCriteria();

            sa.AliasName = ctlAliasName.Text;

            sa.MsgServerHost = ctlMsgServerHost.Text;
            return(sa);
        }
        public int RequestCount()
        {
            SapInstanceCriteria criteria = GetSuUserCriteria();

            return(ScgDbQueryProvider.DbSapInstanceQuery.CountSapInstance(criteria));
        }
        public Object RequestData(int startRow, int pageSize, string sortExpression)
        {
            SapInstanceCriteria criteria = GetSuUserCriteria();

            return(ScgDbQueryProvider.DbSapInstanceQuery.GetSapInstanceListByCriteria(criteria, startRow, pageSize, sortExpression));
        }
        public ISQLQuery FindSapInstanceByCriteria(SapInstanceCriteria criteria, string sortExpression, bool isCount)
        {
            StringBuilder         sqlBuilder   = new StringBuilder();
            QueryParameterBuilder paramBuilder = new QueryParameterBuilder();

            if (!isCount)
            {
                sqlBuilder.Append(" select Code ,AliasName,SystemID,Client,UserName,Password,Language,SystemNumber,MsgServerHost,LogonGroup,UserCPIC,DocTypeExpPostingDM,DocTypeExpRmtPostingDM,DocTypeExpPostingFR,DocTypeExpRmtPostingFR,DocTypeExpICPostingFR,DocTypeAdvancePostingDM,DocTypeAdvancePostingFR,DocTypeRmtPosting,UpdBy, UpdDate, CreBy,CreDate,UpdPgm,RowVersion, DocTypeFixedAdvance as DocTypeFixedAdvancePosting,DocTypeFixedAdvanceReturn as DocTypeFixedAdvanceReturnPosting  ");
            }
            else
            {
                sqlBuilder.Append(" select count(*) as Count ");
            }

            sqlBuilder.Append("  from DbSapInstance where 1=1  ");

            if (!string.IsNullOrEmpty(criteria.AliasName))
            {
                sqlBuilder.Append(" and AliasName like :aliasname ");
                paramBuilder.AddParameterData("aliasname", typeof(string), criteria.AliasName);
            }
            if (!string.IsNullOrEmpty(criteria.MsgServerHost))
            {
                sqlBuilder.Append(" and MsgServerHost like :msgserverhost ");
                paramBuilder.AddParameterData("msgserverhost", typeof(string), criteria.MsgServerHost);
            }
            if (!string.IsNullOrEmpty(sortExpression))
            {
                sqlBuilder.Append(String.Format(" order by {0} ", sortExpression));
            }

            ISQLQuery query = GetCurrentSession().CreateSQLQuery(sqlBuilder.ToString());

            paramBuilder.FillParameters(query);
            if (isCount)
            {
                query.AddScalar("Count", NHibernateUtil.Int32);
            }
            else
            {
                query.AddScalar("Code", NHibernateUtil.String);
                query.AddScalar("AliasName", NHibernateUtil.String);
                query.AddScalar("SystemID", NHibernateUtil.String);
                query.AddScalar("Client", NHibernateUtil.String);
                query.AddScalar("UserName", NHibernateUtil.String);
                query.AddScalar("Password", NHibernateUtil.String);
                query.AddScalar("Language", NHibernateUtil.String);
                query.AddScalar("SystemNumber", NHibernateUtil.String);
                query.AddScalar("MsgServerHost", NHibernateUtil.String);
                query.AddScalar("LogonGroup", NHibernateUtil.String);
                query.AddScalar("UserCPIC", NHibernateUtil.String);
                query.AddScalar("DocTypeExpPostingDM", NHibernateUtil.String);
                query.AddScalar("DocTypeExpRmtPostingDM", NHibernateUtil.String);
                query.AddScalar("DocTypeExpPostingFR", NHibernateUtil.String);
                query.AddScalar("DocTypeExpRmtPostingFR", NHibernateUtil.String);
                query.AddScalar("DocTypeExpICPostingFR", NHibernateUtil.String);
                query.AddScalar("DocTypeAdvancePostingDM", NHibernateUtil.String);
                query.AddScalar("DocTypeAdvancePostingFR", NHibernateUtil.String);
                query.AddScalar("DocTypeRmtPosting", NHibernateUtil.String);
                query.AddScalar("DocTypeFixedAdvancePosting", NHibernateUtil.String);
                query.AddScalar("DocTypeFixedAdvanceReturnPosting", NHibernateUtil.String);
                query.SetResultTransformer(Transformers.AliasToBean(typeof(DbSapInstance)));
            }
            return(query);
        }
 public IList <DbSapInstance> GetSapInstanceListByCriteria(SapInstanceCriteria criteria, int startRow, int pageSize, string sortExpression)
 {
     return(NHibernateQueryHelper.FindPagingByCriteria <DbSapInstance>(ScgDbQueryProvider.DbSapInstanceQuery, "FindSapInstanceByCriteria", new object[] { criteria, sortExpression, false }, startRow, pageSize, sortExpression));
 }
 public int CountSapInstance(SapInstanceCriteria criteria)
 {
     return(NHibernateQueryHelper.CountByCriteria(ScgDbQueryProvider.DbSapInstanceQuery, "FindSapInstanceByCriteria", new object[] { criteria, string.Empty, true }));
 }