コード例 #1
0
        public static IList <FormApproverEntity> GetApprovers(string formId, int formType)
        {
            var sql = string.Format(@"select {0} from form_approvers 
where form_id=@p_form_id and form_type=@p_form_type
order by sequence", COLUMN_SQL);

            var db = DatabaseFactory.CreateDatabase();
            var dc = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_form_id", DbType.String, formId);
            db.AddInParameter(dc, "p_form_type", DbType.Int32, formType);

            var list = new List <FormApproverEntity>();

            using (var reader = db.ExecuteReader(dc))
            {
                while (reader.Read())
                {
                    var approver = new FormApproverEntity();
                    approver.Init(reader);

                    list.Add(approver);
                }
            }

            return(list);
        }
コード例 #2
0
        public static IList <FormApproverEntity> Query(AuditQueryCondition condition, PagerInfo pager)
        {
            pager.ComputePageCount(QueryCount(condition));

            var list = new List <FormApproverEntity>();

            var orderSql = " ORDER BY ";

            if (pager.OrderFields.Count > 0)
            {
                foreach (var field in pager.OrderFields)
                {
                    orderSql += field.Field + (field.Desc ? " DESC" : "") + ",";
                }
            }
            else
            {
                orderSql += "form_no";
            }

            var sql = string.Format(@"SELECT {0} FROM form_approvers WHERE 1=1{1}", COLUMN_SQL, GetConditionSql(condition));

            sql = @"SELECT * FROM
            (
                SELECT ROW_NUMBER() OVER(" + orderSql + @") pid," + COLUMN_SQL + @"
                FROM (" + sql + @") t            
            ) t1 WHERE t1.pid BETWEEN @p_pageNo * @p_pageSize + 1 AND (@p_pageNo + 1) * @p_pageSize ";

            var db = DatabaseFactory.CreateDatabase();
            var dc = db.GetSqlStringCommand(sql);

            AddParameters(db, dc, condition);

            db.AddInParameter(dc, "p_pageNo", DbType.Int32, pager.PageIndex);
            db.AddInParameter(dc, "p_pageSize", DbType.Int32, pager.PageSize);

            using (IDataReader reader = db.ExecuteReader(dc))
            {
                while (reader.Read())
                {
                    var entity = new FormApproverEntity();
                    entity.Init(reader);

                    list.Add(entity);
                }
            }

            return(list);
        }
コード例 #3
0
        public static FormApproverEntity Get(string id)
        {
            var sql = string.Format("select {0} from form_approvers where id=@p_id", COLUMN_SQL);

            var db = DatabaseFactory.CreateDatabase();
            var dc = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_id", DbType.String, id);

            using (var reader = db.ExecuteReader(dc))
            {
                while (reader.Read())
                {
                    var entity = new FormApproverEntity();
                    entity.Init(reader);

                    return(entity);
                }
            }

            return(null);
        }