feat: fmBpaa GridView 改用 ObjectDataSource
- BpaaDAC 新增 SelectPage/SelectCount/SelectBPAAIndex - dsBPAAGrid 改 ObjectDataSource(EnablePaging) - Search/Selected/DataBound 調整;跳回選取列改用 SelectBPAAIndex - 計畫文檔更新
This commit is contained in:
@@ -3,12 +3,15 @@ using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using Wellan.Common;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 取得專案年度接單資料
|
||||
/// </summary>
|
||||
[DataObject(true)]
|
||||
public class BpaaDAC : Wellan.Data.WDAC
|
||||
{
|
||||
public BpaaDAC()
|
||||
@@ -325,4 +328,96 @@ public class BpaaDAC : Wellan.Data.WDAC
|
||||
cmd.Parameters.Add(Query.NewParameter("BPPNM", bppnm));
|
||||
return WDAC.GetStringValue(Query.ExecuteScalar(cmd));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 年度接單 Grid 分頁查詢
|
||||
/// </summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectPage(int startRowIndex, int maximumRows, string BPPNM, string BPYER, string BPPYN, string BPPYM)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
|
||||
StringBuilder filter = new StringBuilder();
|
||||
BuildFilter(filter, cmd, BPPNM, BPYER, BPPYN, BPPYM);
|
||||
|
||||
cmd.CommandText = String.Format(
|
||||
@"SELECT * FROM
|
||||
(
|
||||
SELECT *, ROW_NUMBER() OVER (ORDER BY BPPNM, BPYER) AS ROWID
|
||||
FROM BPAA 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 BPPNM, string BPYER, string BPPYN, string BPPYM)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
|
||||
StringBuilder filter = new StringBuilder();
|
||||
BuildFilter(filter, cmd, BPPNM, BPYER, BPPYN, BPPYM);
|
||||
|
||||
cmd.CommandText = String.Format("SELECT COUNT(*) FROM BPAA WHERE 1=1 {0}", filter.ToString());
|
||||
return WDAC.GetInt32Value(Query.ExecuteScalar(cmd));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得指定年度接單在查詢結果中的序號 (0 起算)
|
||||
/// </summary>
|
||||
public int SelectBPAAIndex(string targetBPPNM, string targetBPYER, string BPPNM, string BPYER, string BPPYN, string BPPYM)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
|
||||
StringBuilder filter = new StringBuilder();
|
||||
BuildFilter(filter, cmd, BPPNM, BPYER, BPPYN, BPPYM);
|
||||
|
||||
cmd.CommandText = String.Format(
|
||||
@"SELECT ROWID - 1 FROM
|
||||
(
|
||||
SELECT BPPNM, BPYER, ROW_NUMBER() OVER (ORDER BY BPPNM, BPYER) AS ROWID
|
||||
FROM BPAA WHERE 1=1 {0}
|
||||
) AS TMP WHERE BPPNM = @TARGET_BPPNM AND BPYER = @TARGET_BPYER",
|
||||
filter.ToString());
|
||||
cmd.Parameters.Add(Query.NewParameter("TARGET_BPPNM", targetBPPNM));
|
||||
cmd.Parameters.Add(Query.NewParameter("TARGET_BPYER", targetBPYER));
|
||||
|
||||
object o = Query.ExecuteScalar(cmd);
|
||||
return (o is Int32 || o is Int64) ? WDAC.GetInt32Value(o) : -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 組出年度接單 Grid 的查詢條件 (與舊 AddSearch 行為一致)
|
||||
/// </summary>
|
||||
private void BuildFilter(StringBuilder sb, DbCommand cmd, string BPPNM, string BPYER, string BPPYN, string BPPYM)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(BPPNM))
|
||||
{
|
||||
sb.Append(" AND BPPNM LIKE @BPPNM1 ");
|
||||
cmd.Parameters.Add(Query.NewParameter("BPPNM1", BPPNM + "%"));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(BPYER))
|
||||
{
|
||||
sb.Append(" AND BPYER LIKE @BPYER1 ");
|
||||
cmd.Parameters.Add(Query.NewParameter("BPYER1", BPYER + "%"));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(BPPYN))
|
||||
{
|
||||
sb.Append(" AND BPPYN LIKE @BPPYN1 ");
|
||||
cmd.Parameters.Add(Query.NewParameter("BPPYN1", BPPYN + "%"));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(BPPYM))
|
||||
{
|
||||
sb.Append(" AND BPPYM LIKE @BPPYM1 ");
|
||||
cmd.Parameters.Add(Query.NewParameter("BPPYM1", BPPYM + "%"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user