GridView级联显示 与Nettier的合成应用Sample[较乱,附代码]

本文介绍了一个用于管理财务统驭科目及其子科目的Web应用示例,包括科目创建、编辑等功能,并展示了ASP.NET与C#相结合的具体实现方式。


这是一个财务统驭科目ChartOfAccount 和子帐科目间的数据操作Sample
  1ExpandedBlockStart.gifContractedBlock.gif<%dot.gif@ Page Language="C#" AutoEventWireup="true" CodeFile="ChartOfAccount.aspx.cs" Inherits="WebModules_CommonMasterData_ChartOfAccount" %>
  2None.gif
  3None.gif<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4None.gif
  5None.gif<html xmlns="http://www.w3.org/1999/xhtml" >
  6None.gif<head runat="server">
  7None.gif    <title>无标题页</title>
  8None.gif</head>
  9None.gif<body>
 10None.gif    <form id="form1" runat="server">
 11None.gif    <div>
 12None.gif        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ChartID"
 13None.gif            DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" OnRowCommand="GridView1_RowCommand" ShowFooter="True" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="855px" AllowPaging="True" OnRowEditing="GridView1_RowEditing">
 14None.gif            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
 15None.gif            <Columns>
 16None.gif                <asp:TemplateField ShowHeader="False">
 17None.gif                    <ItemTemplate>
 18None.gif                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Select"
 19None.gif                            Text="选中"></asp:LinkButton>
 20None.gif                    </ItemTemplate>
 21None.gif                </asp:TemplateField>
 22None.gif                <asp:TemplateField HeaderText="统驭科目ID" SortExpression="ChartID">
 23None.gif                    <EditItemTemplate>
 24None.gif                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("ChartID") %>'></asp:Label>
 25None.gif                    </EditItemTemplate>
 26None.gif                    <FooterTemplate>
 27None.gif                        <asp:Button ID="btnCreate" runat="server" CommandName="Insert" Text="新建" />
 28None.gif                    </FooterTemplate>
 29None.gif                    <ItemTemplate>
 30None.gif                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("ChartID") %>'></asp:Label>
 31None.gif                    </ItemTemplate>
 32None.gif                </asp:TemplateField>
 33None.gif                <asp:TemplateField HeaderText="统驭科目名" SortExpression="ChartOfAccountName">
 34None.gif                    <EditItemTemplate>
 35None.gif                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("ChartOfAccountName") %>'></asp:TextBox>
 36None.gif                    </EditItemTemplate>
 37None.gif                    <FooterTemplate>
 38None.gif                        <asp:TextBox ID="newChartOfAccountName" runat="server"></asp:TextBox>
 39None.gif                    </FooterTemplate>
 40None.gif                    <ItemTemplate>
 41None.gif                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("ChartOfAccountName") %>'></asp:Label>
 42None.gif                    </ItemTemplate>
 43None.gif                </asp:TemplateField>
 44None.gif                <asp:TemplateField HeaderText="注释" SortExpression="Description">
 45None.gif                    <EditItemTemplate>
 46None.gif                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
 47None.gif                    </EditItemTemplate>
 48None.gif                    <FooterTemplate>
 49None.gif                        <asp:TextBox ID="newDescription" runat="server"></asp:TextBox>
 50None.gif                    </FooterTemplate>
 51None.gif                    <ItemTemplate>
 52None.gif                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
 53None.gif                    </ItemTemplate>
 54None.gif                </asp:TemplateField>
 55None.gif                <asp:TemplateField HeaderText="统驭科目编码" SortExpression="ChartCode">
 56None.gif                    <EditItemTemplate>
 57None.gif                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ChartCode") %>'></asp:TextBox>
 58None.gif                    </EditItemTemplate>
 59None.gif                    <FooterTemplate>
 60None.gif                        <asp:TextBox ID="txtChartOfCode" runat="server"></asp:TextBox>
 61None.gif                    </FooterTemplate>
 62None.gif                    <ItemTemplate>
 63None.gif                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("ChartCode") %>'></asp:Label>
 64None.gif                    </ItemTemplate>
 65None.gif                </asp:TemplateField>
 66None.gif                <asp:BoundField DataField="CreateDate" HeaderText="创建日期" SortExpression="CreateDate" />
 67None.gif                <asp:BoundField DataField="status" HeaderText="status" SortExpression="status" />
 68None.gif                <asp:TemplateField HeaderText="下属科目" Visible="False">
 69None.gif                    <EditItemTemplate>
 70None.gif                        &nbsp;<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
 71None.gif                            BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px"
 72None.gif                            CellPadding="3" DataKeyNames="LengendID" DataSourceID="SqlDataSource3" GridLines="Horizontal"
 73None.gif                            Height="50px" Width="125px">
 74None.gif                            <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
 75None.gif                            <EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
 76None.gif                            <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
 77None.gif                            <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
 78None.gif                            <Fields>
 79None.gif                                <asp:BoundField DataField="LegendCode" HeaderText="LegendCode" SortExpression="LegendCode" />
 80None.gif                                <asp:BoundField DataField="LegendName" HeaderText="LegendName" SortExpression="LegendName" />
 81None.gif                                <asp:BoundField DataField="LengendID" HeaderText="LengendID" InsertVisible="False"
 82None.gif                                    ReadOnly="True" SortExpression="LengendID" />
 83None.gif                                <asp:BoundField DataField="ChartID" HeaderText="ChartID" SortExpression="ChartID" />
 84None.gif                                <asp:BoundField DataField="ChartCode" HeaderText="ChartCode" SortExpression="ChartCode" />
 85None.gif                                <asp:BoundField DataField="status" HeaderText="status" SortExpression="status" />
 86None.gif                            </Fields>
 87None.gif                            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
 88None.gif                            <AlternatingRowStyle BackColor="#F7F7F7" />
 89None.gif                        </asp:DetailsView>
 90None.gif                        <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:BLUEBEANSConnectionString %>"
 91None.gif                            SelectCommand="SELECT [LegendCode], [LegendName], [LengendID], [ChartID], [ChartCode], [status] FROM [FinanceLegend]">
 92None.gif                        </asp:SqlDataSource>
 93None.gif                    </EditItemTemplate>
 94None.gif                </asp:TemplateField>
 95None.gif                <asp:CommandField ShowEditButton="True" />
 96None.gif            </Columns>
 97None.gif            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
 98None.gif            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
 99None.gif            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
100None.gif            <AlternatingRowStyle BackColor="White" />
101None.gif            <RowStyle BackColor="#EFF3FB" HorizontalAlign="Center" />
102None.gif            <EditRowStyle BackColor="#2461BF" />
103None.gif        </asp:GridView>
104None.gif        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp;
105None.gif        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BLUEBEANSConnectionString %>"
106None.gif            SelectCommand="SELECT [ChartID], [ChartOfAccountName], [ProfitCenterName], [status], [Description], [ProfitCenterID], [EndCode], [BeginCode], [ChartCode], [CreateDate] FROM [FinanceCharOfAccount]">
107None.gif        </asp:SqlDataSource>
108None.gif        &nbsp;
109None.gif        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:BLUEBEANSConnectionString %>"
110None.gif            SelectCommand="SELECT [LegendCode], [LegendName], [LengendID], [ChartID], [ChartCode], [status] FROM [FinanceLegend]">
111None.gif        </asp:SqlDataSource>
112None.gif        <asp:Label ID="Label6" runat="server" Text="子科目代码"></asp:Label>
113None.gif        <asp:TextBox ID="txtLengendCode" runat="server"></asp:TextBox>
114None.gif        <asp:Label ID="Label5" runat="server" Text="子科目名" Width="57px"></asp:Label>
115None.gif        <asp:TextBox ID="txtLengendName" runat="server"></asp:TextBox>
116None.gif        <asp:Button ID="btnCreateLengend" runat="server" OnClick="btnCreateLengend_Click"
117None.gif            Text="创建子科目" />
118None.gif        <asp:GridView ID="GridView2" runat="server" AllowPaging="True" AutoGenerateColumns="False"
119None.gif            DataSourceID="SqlDataSource4" PageSize="5" OnRowCommand="GridView2_RowCommand" HorizontalAlign="Left">
120None.gif            <Columns>
121None.gif                <asp:TemplateField HeaderText="子科目代码" SortExpression="LegendCode">
122None.gif                    <EditItemTemplate>
123None.gif                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("LegendCode") %>'></asp:TextBox>
124None.gif                    </EditItemTemplate>
125None.gif                    <FooterTemplate>
126None.gif                        <asp:TextBox ID="newLengendCode" runat="server"></asp:TextBox>
127None.gif                    </FooterTemplate>
128None.gif                    <ItemTemplate>
129None.gif                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("LegendCode") %>'></asp:Label>
130None.gif                    </ItemTemplate>
131None.gif                </asp:TemplateField>
132None.gif                <asp:TemplateField HeaderText="科目名称" SortExpression="LegendName">
133None.gif                    <EditItemTemplate>
134None.gif                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("LegendName") %>'></asp:TextBox>
135None.gif                    </EditItemTemplate>
136None.gif                    <FooterTemplate>
137None.gif                        <asp:TextBox ID="newLengendName" runat="server"></asp:TextBox>
138None.gif                    </FooterTemplate>
139None.gif                    <ItemTemplate>
140None.gif                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("LegendName") %>'></asp:Label>
141None.gif                    </ItemTemplate>
142None.gif                </asp:TemplateField>
143None.gif                <asp:BoundField DataField="ChartCode" HeaderText="统驭科目代码" SortExpression="ChartCode" />
144None.gif                <asp:BoundField DataField="ChartID" HeaderText="统驭科目ID" SortExpression="ChartID" />
145None.gif                <asp:TemplateField HeaderText="状态" SortExpression="status">
146None.gif                    <EditItemTemplate>
147None.gif                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("status") %>'></asp:TextBox>
148None.gif                    </EditItemTemplate>
149None.gif                    <FooterTemplate>
150None.gif                        <asp:Button ID="btnCreateLengend" runat="server" CommandName="Insert" Text="创建子科目" />
151None.gif                    </FooterTemplate>
152None.gif                    <ItemTemplate>
153None.gif                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("status") %>'></asp:Label>
154None.gif                    </ItemTemplate>
155None.gif                </asp:TemplateField>
156None.gif            </Columns>
157None.gif            <RowStyle HorizontalAlign="Center" />
158None.gif        </asp:GridView>
159None.gif        &nbsp; &nbsp;
160None.gif        <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:BLUEBEANSConnectionString %>"
161None.gif            SelectCommand="SELECT [LegendCode], [LegendName], [ChartCode], [ChartID], [status] FROM [FinanceLegend] WHERE ([ChartID] = @ChartID)">
162None.gif            <SelectParameters>
163None.gif                <asp:ControlParameter ControlID="GridView1" Name="ChartID" PropertyName="SelectedValue"
164None.gif                    Type="Int32" />
165None.gif            </SelectParameters>
166None.gif        </asp:SqlDataSource>
167None.gif        <asp:DetailsView ID="DetailsView2" runat="server" Height="50px" Width="125px">
168None.gif        </asp:DetailsView>
169None.gif    
170None.gif    </div>
171None.gif    </form>
172None.gif</body>
173None.gif</html>
174None.gif

后台数据:
  1None.gifusing System;
  2None.gifusing System.Data;
  3None.gifusing System.Configuration;
  4None.gifusing System.Collections;
  5None.gifusing System.Web;
  6None.gifusing System.Web.Security;
  7None.gifusing System.Web.UI;
  8None.gifusing System.Web.UI.WebControls;
  9None.gifusing System.Web.UI.WebControls.WebParts;
 10None.gifusing System.Web.UI.HtmlControls;
 11None.gifusing BlueBeans.Data;
 12None.gifusing BlueBeans.Entities;
 13None.gif
 14None.gifpublic partial class WebModules_CommonMasterData_ChartOfAccount : System.Web.UI.Page
 15ExpandedBlockStart.gifContractedBlock.gifdot.gif{
 16InBlock.gif    int _chartID = 0;
 17InBlock.gif    string _chartCode = string.Empty;
 18InBlock.gif    protected void Page_Load(object sender, EventArgs e)
 19ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 20InBlock.gif
 21ExpandedSubBlockEnd.gif    }

 22InBlock.gif    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 23ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 24InBlock.gif        if (e.CommandName.Equals("Insert"))
 25ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 26InBlock.gif            TextBox newChartOfAccountName = (TextBox)this.GridView1.FooterRow.FindControl("newChartOfAccountName");
 27InBlock.gif            TextBox newDescription = (TextBox)this.GridView1.FooterRow.FindControl("newDescription");
 28InBlock.gif            TextBox txtChartOfCode = (TextBox)this.GridView1.FooterRow.FindControl("txtChartOfCode");
 29InBlock.gif
 30InBlock.gif            FinanceCharOfAccount coa = new FinanceCharOfAccount();
 31InBlock.gif            coa.ChartCode = txtChartOfCode.Text;
 32InBlock.gif            coa.Description = newDescription.Text;
 33InBlock.gif            coa.ChartOfAccountName = newChartOfAccountName.Text;
 34InBlock.gif            coa.CreateDate = DateTime.Now;
 35InBlock.gif            coa.Status = 0;
 36InBlock.gif
 37InBlock.gif            try
 38ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 39InBlock.gif                DataRepository.FinanceCharOfAccountProvider.Save(coa);
 40ExpandedSubBlockEnd.gif            }

 41InBlock.gif            catch (Exception ex)
 42ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 43InBlock.gif                Response.Write(ex.Message);
 44ExpandedSubBlockEnd.gif            }

 45InBlock.gif
 46InBlock.gif            this.GridView1.DataBind();           
 47InBlock.gif
 48ExpandedSubBlockEnd.gif        }

 49InBlock.gif
 50ExpandedSubBlockEnd.gif    }

 51InBlock.gif
 52InBlock.gif    private void InsertLengendCode()
 53ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 54InBlock.gif        //DataTable dataTable = new DataTable();
 55InBlock.gif        //DataColumn col0 = dataTable.Columns.Add("ChartID", typeof(System.Int32));
 56InBlock.gif        //col0.AllowDBNull = false;
 57InBlock.gif        //DataColumn col1 = dataTable.Columns.Add("ChartOfAccountName", typeof(System.String));
 58InBlock.gif        //col1.AllowDBNull = false;
 59InBlock.gif        //DataColumn col2 = dataTable.Columns.Add("ProfitCenterName", typeof(System.String));
 60InBlock.gif        //col2.AllowDBNull = true;
 61InBlock.gif        //DataColumn col3 = dataTable.Columns.Add("status", typeof(System.Int32));
 62InBlock.gif        //col3.AllowDBNull = true;
 63InBlock.gif        //DataColumn col4 = dataTable.Columns.Add("Description", typeof(System.String));
 64InBlock.gif        //col4.AllowDBNull = true;
 65InBlock.gif        //DataColumn col5 = dataTable.Columns.Add("CreateDate", typeof(System.DateTime));
 66InBlock.gif        //col5.AllowDBNull = true;
 67InBlock.gif        //DataColumn col6 = dataTable.Columns.Add("ChartCode", typeof(System.String));
 68InBlock.gif        //col6.AllowDBNull = false;
 69InBlock.gif        //DataColumn col7 = dataTable.Columns.Add("BeginCode", typeof(System.String));
 70InBlock.gif        //col7.AllowDBNull = true;
 71InBlock.gif        //DataColumn col8 = dataTable.Columns.Add("EndCode", typeof(System.String));
 72InBlock.gif        //col8.AllowDBNull = true;
 73InBlock.gif        //DataColumn col9 = dataTable.Columns.Add("ProfitCenterID", typeof(System.Int32));
 74InBlock.gif        //col9.AllowDBNull = true;
 75InBlock.gif
 76InBlock.gif        //bulkCopy.ColumnMappings.Add("ChartID", "ChartID");
 77InBlock.gif        //bulkCopy.ColumnMappings.Add("ChartOfAccountName", "ChartOfAccountName");
 78InBlock.gif        //bulkCopy.ColumnMappings.Add("ProfitCenterName", "ProfitCenterName");
 79InBlock.gif        //bulkCopy.ColumnMappings.Add("status", "status");
 80InBlock.gif        //bulkCopy.ColumnMappings.Add("Description", "Description");
 81InBlock.gif        //bulkCopy.ColumnMappings.Add("CreateDate", "CreateDate");
 82InBlock.gif        //bulkCopy.ColumnMappings.Add("ChartCode", "ChartCode");
 83InBlock.gif        //bulkCopy.ColumnMappings.Add("BeginCode", "BeginCode");
 84InBlock.gif        //bulkCopy.ColumnMappings.Add("EndCode", "EndCode");
 85InBlock.gif        //bulkCopy.ColumnMappings.Add("ProfitCenterID", "ProfitCenterID");
 86InBlock.gif
 87InBlock.gif        //foreach (BlueBeans.Entities.FinanceCharOfAccount entity in entities)
 88InBlock.gif        //{
 89InBlock.gif        //    if (entity.EntityState != EntityState.Added)
 90InBlock.gif        //        continue;
 91InBlock.gif
 92InBlock.gif        //    DataRow row = dataTable.NewRow();
 93InBlock.gif
 94InBlock.gif        //    row["ChartID"] = entity.ChartID;
 95InBlock.gif
 96InBlock.gif
 97InBlock.gif        //    row["ChartOfAccountName"] = entity.ChartOfAccountName;
 98InBlock.gif
 99InBlock.gif
100InBlock.gif        //    row["ProfitCenterName"] = entity.ProfitCenterName;
101InBlock.gif
102InBlock.gif
103InBlock.gif        //    row["status"] = entity.Status.HasValue ? (object)entity.Status : System.DBNull.Value;
104InBlock.gif
105InBlock.gif
106InBlock.gif        //    row["Description"] = entity.Description;
107InBlock.gif
108InBlock.gif
109InBlock.gif        //    row["CreateDate"] = entity.CreateDate.HasValue ? (object)entity.CreateDate : System.DBNull.Value;
110InBlock.gif
111InBlock.gif
112InBlock.gif        //    row["ChartCode"] = entity.ChartCode;
113InBlock.gif
114InBlock.gif
115InBlock.gif        //    row["BeginCode"] = entity.BeginCode;
116InBlock.gif
117InBlock.gif
118InBlock.gif        //    row["EndCode"] = entity.EndCode;
119InBlock.gif
120InBlock.gif
121InBlock.gif        //    row["ProfitCenterID"] = entity.ProfitCenterID.HasValue ? (object)entity.ProfitCenterID : System.DBNull.Value;
122InBlock.gif
123InBlock.gif
124InBlock.gif        //    dataTable.Rows.Add(row);
125InBlock.gif            
126InBlock.gif        // }
127InBlock.gif      
128InBlock.gif        
129ExpandedSubBlockEnd.gif        }

130ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
131InBlock.gif    /// 获取主表数据
132InBlock.gif    /// </summary>
133InBlock.gif    /// <param name="sender"></param>
134ExpandedSubBlockEnd.gif    /// <param name="e"></param>

135InBlock.gif    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
136ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
137InBlock.gif        //Response.Write(this.GridView1.SelectedValue.ToString());
138InBlock.gif        this.ViewState["ChartID"= this.GridView1.SelectedValue.ToString();
139InBlock.gif        this._chartID = int.Parse(this.GridView1.SelectedValue.ToString());
140InBlock.gif        //this._chartCode = this.GridView1.SelectedRow.Cells[3];
141ExpandedSubBlockEnd.gif    }

142ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
143InBlock.gif    /// Insert从表数据
144InBlock.gif    /// </summary>
145InBlock.gif    /// <param name="sender"></param>
146ExpandedSubBlockEnd.gif    /// <param name="e"></param>

147InBlock.gif    protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
148ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
149InBlock.gif        //Response.Write(this.GridView1.SelectedValue.ToString());
150InBlock.gif        if (e.CommandName.Equals("Insert"))
151ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
152InBlock.gif            TextBox newLengendName = (TextBox)this.GridView2.FooterRow.FindControl("newLengendName");
153InBlock.gif            TextBox newLengendCode = (TextBox)this.GridView2.FooterRow.FindControl("newLengendCode");
154InBlock.gif
155InBlock.gif
156InBlock.gif            FinanceLegend lengend = new FinanceLegend();
157InBlock.gif            lengend.ChartID =int.Parse( this.GridView1.SelectedValue.ToString());
158InBlock.gif
159InBlock.gif            FinanceCharOfAccount coa = DataRepository.FinanceCharOfAccountProvider.GetByChartID(int.Parse(this.GridView1.SelectedValue.ToString()));
160InBlock.gif            lengend.ChartCode = coa.ChartCode;
161InBlock.gif
162InBlock.gif            lengend.LegendCode = newLengendCode.Text;
163InBlock.gif            lengend.LegendName = newLengendName.Text;
164InBlock.gif            
165InBlock.gif            lengend.Status = 0;
166InBlock.gif
167InBlock.gif            try
168ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
169InBlock.gif                DataRepository.FinanceLegendProvider.Save(lengend);
170ExpandedSubBlockEnd.gif            }

171InBlock.gif            catch (Exception ex)
172ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
173InBlock.gif                Response.Write(ex.Message);
174ExpandedSubBlockEnd.gif            }

175InBlock.gif
176InBlock.gif            this.GridView2.DataBind();
177InBlock.gif
178ExpandedSubBlockEnd.gif        }

179ExpandedSubBlockEnd.gif    }

180InBlock.gif    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
181ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
182InBlock.gif
183ExpandedSubBlockEnd.gif    }

184InBlock.gif    protected void btnCreateLengend_Click(object sender, EventArgs e)
185ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
186InBlock.gif
187InBlock.gif
188InBlock.gif
189InBlock.gif            FinanceLegend lengend = new FinanceLegend();
190InBlock.gif            lengend.ChartID = int.Parse(this.GridView1.SelectedValue.ToString());
191InBlock.gif            //FinanceCharOfAccount coa = new FinanceCharOfAccount();
192InBlock.gif            //coa = DataRepository.FinanceCharOfAccountProvider.GetByChartID(lengend.ChartID);
193InBlock.gif            FinanceCharOfAccount coa = DataRepository.FinanceCharOfAccountProvider.GetByChartID(int.Parse(this.GridView1.SelectedValue.ToString()));
194InBlock.gif            lengend.ChartCode = coa.ChartCode;
195InBlock.gif            lengend.LegendCode = this.txtLengendCode.Text;
196InBlock.gif            lengend.LegendName = this.txtLengendName.Text;
197InBlock.gif            
198InBlock.gif            lengend.Status = 0;
199InBlock.gif
200InBlock.gif            try
201ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
202InBlock.gif                DataRepository.FinanceLegendProvider.Save(lengend);
203ExpandedSubBlockEnd.gif            }

204InBlock.gif            catch (Exception ex)
205ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
206InBlock.gif                Response.Write(ex.Message);
207ExpandedSubBlockEnd.gif            }

208InBlock.gif        //Clear Text
209InBlock.gif            this.txtLengendCode.Text = string.Empty;
210InBlock.gif            this.txtLengendName.Text = string.Empty;
211InBlock.gif
212InBlock.gif            this.GridView2.DataBind();
213InBlock.gif
214InBlock.gif        
215InBlock.gif
216ExpandedSubBlockEnd.gif    }

217ExpandedBlockEnd.gif}

218None.gif

显示效果:


转载于:https://www.cnblogs.com/SlashOut/archive/2007/08/02/840593.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值