- 新增 BpjbDAC(SelectPage/SelectCount) - dsBPJBGrid 改 ObjectDataSource;Search/Selected 調整
88 lines
2.6 KiB
C#
88 lines
2.6 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Data.Common;
|
|
using System.Text;
|
|
using System.ComponentModel;
|
|
using Wellan.Data;
|
|
|
|
/// <summary>
|
|
/// 職稱等級設定的資料處理類別
|
|
/// </summary>
|
|
[DataObject(true)]
|
|
public class BpjbDAC : Wellan.Data.WDAC
|
|
{
|
|
public BpjbDAC()
|
|
{
|
|
}
|
|
|
|
public BpjbDAC(string connectionConfig, string connectionConfigName)
|
|
: this()
|
|
{
|
|
this._connectionConfig = connectionConfig;
|
|
this._connectionConfigName = connectionConfigName;
|
|
}
|
|
|
|
public BpjbDAC(WQuery query)
|
|
{
|
|
this._query = query;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 職稱等級設定 Grid 分頁查詢
|
|
/// </summary>
|
|
[DataObjectMethod(DataObjectMethodType.Select)]
|
|
public DataTable SelectPage(int startRowIndex, int maximumRows, string BPPYN, string BPJNO)
|
|
{
|
|
DbCommand cmd = Query.NewCommand();
|
|
|
|
StringBuilder filter = new StringBuilder();
|
|
BuildFilter(filter, cmd, BPPYN, BPJNO);
|
|
|
|
cmd.CommandText = String.Format(
|
|
@"SELECT * FROM
|
|
(
|
|
SELECT *, ROW_NUMBER() OVER (ORDER BY BPPYN, BPJNO, BPCNO) AS ROWID
|
|
FROM BPJB WHERE 1=1 {0}
|
|
) AS TMP
|
|
WHERE ROWID BETWEEN @STARTROWINDEX + 1 AND @STARTROWINDEX + @MAXIMUMROWS
|
|
ORDER BY ROWID",
|
|
filter.ToString());
|
|
cmd.Parameters.Add(Query.NewParameter("STARTROWINDEX", startRowIndex));
|
|
cmd.Parameters.Add(Query.NewParameter("MAXIMUMROWS", maximumRows));
|
|
|
|
return Query.Select(cmd);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 職稱等級設定 Grid 查詢筆數
|
|
/// </summary>
|
|
[DataObjectMethod(DataObjectMethodType.Select)]
|
|
public int SelectCount(string BPPYN, string BPJNO)
|
|
{
|
|
DbCommand cmd = Query.NewCommand();
|
|
|
|
StringBuilder filter = new StringBuilder();
|
|
BuildFilter(filter, cmd, BPPYN, BPJNO);
|
|
|
|
cmd.CommandText = String.Format("SELECT COUNT(*) FROM BPJB WHERE 1=1 {0}", filter.ToString());
|
|
return WDAC.GetInt32Value(Query.ExecuteScalar(cmd));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 組出職稱等級設定 Grid 的查詢條件 (與舊 AddSearch 行為一致)
|
|
/// </summary>
|
|
private void BuildFilter(StringBuilder sb, DbCommand cmd, string BPPYN, string BPJNO)
|
|
{
|
|
if (!string.IsNullOrEmpty(BPPYN))
|
|
{
|
|
sb.Append(" AND BPPYN LIKE @BPPYN1 ");
|
|
cmd.Parameters.Add(Query.NewParameter("BPPYN1", BPPYN + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(BPJNO))
|
|
{
|
|
sb.Append(" AND BPJNO LIKE @BPJNO1 ");
|
|
cmd.Parameters.Add(Query.NewParameter("BPJNO1", BPJNO + "%"));
|
|
}
|
|
}
|
|
}
|