feat: fmBpaa GridView 改用 ObjectDataSource
- BpaaDAC 新增 SelectPage/SelectCount/SelectBPAAIndex - dsBPAAGrid 改 ObjectDataSource(EnablePaging) - Search/Selected/DataBound 調整;跳回選取列改用 SelectBPAAIndex - 計畫文檔更新
This commit is contained in:
@@ -66,10 +66,16 @@
|
||||
TextMessageId="" Visible="False"></cc1:WLabel>
|
||||
</asp:View>
|
||||
<asp:View ID="EditView" runat="server">
|
||||
<asp:SqlDataSource ID="dsBPAAGrid" runat="server"
|
||||
ConflictDetection="CompareAllValues" SelectCommand="SELECT * FROM BPAA WHERE 1=0"
|
||||
ConnectionString="Data Source=(local);Initial Catalog=THINKYU_WEB;Persist Security Info=True;User ID=sa"
|
||||
ProviderName="System.Data.SqlClient" OnSelected="dsBPAAGrid_Selected"></asp:SqlDataSource>
|
||||
<asp:ObjectDataSource ID="dsBPAAGrid" runat="server"
|
||||
TypeName="BpaaDAC" SelectMethod="SelectPage" SelectCountMethod="SelectCount"
|
||||
EnablePaging="true" OnSelected="dsBPAAGrid_Selected">
|
||||
<SelectParameters>
|
||||
<asp:Parameter Name="BPPNM" Type="String" />
|
||||
<asp:Parameter Name="BPYER" Type="String" />
|
||||
<asp:Parameter Name="BPPYN" Type="String" />
|
||||
<asp:Parameter Name="BPPYM" Type="String" />
|
||||
</SelectParameters>
|
||||
</asp:ObjectDataSource>
|
||||
<asp:SqlDataSource ID="dsBPAAForm" runat="server"
|
||||
InsertCommand="INSERT INTO BPAA
|
||||
(BPPNM, BPYER, BPPYN, BPPYM, BPBGT, BPFED, BPSAL, BPOTT, BPOTD, BPALT, APPNO, TRDAT, TRMOD,
|
||||
|
||||
@@ -27,10 +27,6 @@ public partial class forms_customer_fmBpaa : Wellan.Web.UI.WUserControlBase
|
||||
private string _BPPYM = "";
|
||||
//private int _OLD_BPYER = 0;
|
||||
//private string _OLD_BPPYN = "";
|
||||
private string select = "SELECT * ";
|
||||
private string from = " FROM BPAA ";
|
||||
private string where = " WHERE 1=1 ";
|
||||
private string order = " ORDER BY BPPNM, BPYER";
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
@@ -42,7 +38,6 @@ public partial class forms_customer_fmBpaa : Wellan.Web.UI.WUserControlBase
|
||||
{
|
||||
base.OnInit(e);
|
||||
dsBPAAForm.ConnectionString = ConnectionString;
|
||||
dsBPAAGrid.ConnectionString = ConnectionString;
|
||||
|
||||
//_BPPNM = ViewState["BPPNM"] != null ? ViewState["BPPNM"].ToString() : "";
|
||||
//_BPYER = ViewState["BPYER"] != null ? ViewState["BPYER"].ToString() : "";
|
||||
@@ -113,17 +108,27 @@ public partial class forms_customer_fmBpaa : Wellan.Web.UI.WUserControlBase
|
||||
// 查詢動作
|
||||
private new void Search()
|
||||
{
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.Append(select);
|
||||
sql.Append(from);
|
||||
sql.Append(where);
|
||||
dsBPAAGrid.SelectParameters.Clear();
|
||||
AddSearch(sql, dsBPAAGrid, "BPPNM", _BPPNM, "", true);
|
||||
AddSearch(sql, dsBPAAGrid, "BPYER", _BPYER, "", true);
|
||||
AddSearch(sql, dsBPAAGrid, "BPPYN", _BPPYN, "", true);
|
||||
AddSearch(sql, dsBPAAGrid, "BPPYM", _BPPYM, "", true);
|
||||
sql.Append(order);
|
||||
dsBPAAGrid.SelectCommand = sql.ToString();
|
||||
dsBPAAGrid.SelectParameters["BPPNM"].DefaultValue = _BPPNM;
|
||||
dsBPAAGrid.SelectParameters["BPYER"].DefaultValue = _BPYER;
|
||||
dsBPAAGrid.SelectParameters["BPPYN"].DefaultValue = _BPPYN;
|
||||
dsBPAAGrid.SelectParameters["BPPYM"].DefaultValue = _BPPYM;
|
||||
|
||||
// 返回時,回到之前選擇的那一筆
|
||||
if (ParamList != null && ParamList.ContainsKey("BPPNM") && ParamList.ContainsKey("BPYER"))
|
||||
{
|
||||
int rowIndex = new BpaaDAC(Query).SelectBPAAIndex(
|
||||
WDAC.GetStringValue(ParamList["BPPNM"]),
|
||||
WDAC.GetStringValue(ParamList["BPYER"]),
|
||||
_BPPNM, _BPYER, _BPPYN, _BPPYM);
|
||||
|
||||
if (rowIndex >= 0)
|
||||
{
|
||||
gvBPAA.PageIndex = rowIndex / gvBPAA.PageSize;
|
||||
gvBPAA.SelectedIndex = rowIndex - gvBPAA.PageIndex * gvBPAA.PageSize;
|
||||
}
|
||||
|
||||
ParamList.Remove("BPYER");
|
||||
}
|
||||
}
|
||||
|
||||
private void CalcFields(System.Collections.Specialized.IOrderedDictionary values)
|
||||
@@ -155,22 +160,6 @@ public partial class forms_customer_fmBpaa : Wellan.Web.UI.WUserControlBase
|
||||
if (gvBPAA.SelectedIndex == -1)
|
||||
gvBPAA.SelectedIndex = 0;
|
||||
|
||||
// 返回時,回到之前選擇的那一筆
|
||||
if (ParamList.ContainsKey("BPPNM") && ParamList.ContainsKey("BPYER"))
|
||||
{
|
||||
DataView dv = dsBPAAGrid.Select(new DataSourceSelectArguments()) as DataView;
|
||||
dv.RowFilter = String.Format("BPPNM='{0}' and BPYER={1}", ParamList["BPPNM"], ParamList["BPYER"]);
|
||||
if (dv.Count > 0)
|
||||
{
|
||||
int rowIndex = dv.Table.Rows.IndexOf(dv[0].Row);
|
||||
gvBPAA.PageIndex = (rowIndex / gvBPAA.PageSize);
|
||||
gvBPAA.SelectedIndex = rowIndex - gvBPAA.PageIndex * gvBPAA.PageSize;
|
||||
}
|
||||
|
||||
// ParamList.Remove("BPPNM");
|
||||
ParamList.Remove("BPYER");
|
||||
}
|
||||
|
||||
fvBPAA.DataBind();
|
||||
}
|
||||
}
|
||||
@@ -182,9 +171,9 @@ public partial class forms_customer_fmBpaa : Wellan.Web.UI.WUserControlBase
|
||||
gvBPAA.DataBind();
|
||||
}
|
||||
|
||||
protected void dsBPAAGrid_Selected(object sender, SqlDataSourceStatusEventArgs e)
|
||||
protected void dsBPAAGrid_Selected(object sender, ObjectDataSourceStatusEventArgs e)
|
||||
{
|
||||
if (e.AffectedRows == 0)
|
||||
if (e.ReturnValue is Int32 && WDAC.GetInt32Value(e.ReturnValue) == 0)
|
||||
{
|
||||
fvBPAA.ChangeMode(FormViewMode.Insert);
|
||||
fvBPAA_ModeChanged(sender, e);
|
||||
|
||||
Reference in New Issue
Block a user