<%@Page Language="VB" Inherits="BaseClass" Src="masters2.vb" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<script language="VB" runat="server">
 Sub Grid1_Update(sender As Object, e As DataGridCommandEventArgs)
	dim sql as string
	Dim code_display  As String 
	Dim code_category As String 
	Dim type As String 
	Dim opening As String 
	Dim closing As String 
	Dim myTextBox    As TextBox
	'主键：由DataKey检索得到，只读
	Dim code_value as string   = Grid1.DataKeys.Item(E.Item.ItemIndex).ToString
	myTextBox = E.Item.FindControl("edit_name")
	code_display = mytextbox.text
	myTextBox = E.Item.FindControl("edit_group")
	code_category = mytextbox.text
	myTextBox = E.Item.FindControl("edit_type")
	type = mytextbox.text
	myTextBox = E.Item.FindControl("edit_opening")
	opening = mytextbox.text
	myTextBox = E.Item.FindControl("edit_closing")
	closing = mytextbox.text
	'执行存储过程
	sql = "Execute p_masters " + code_value + ", '" + code_display + " '," 
	sql = sql + code_category + ", '" + type +"' ,"  + opening + "," + closing
	RunSql(sql)
	Grid1.EditItemIndex = -1
	ReBind()
 End Sub
</script>
<body style="font: 10pt verdana">
<form runat="server">
<h3><font face="Verdana">Accounts表 </font></h3>
<asp:Label id="Message" runat="server"/>
<asp:DataGrid id="Grid1" runat="server"
AutoGenerateColumns="false"
BackColor="White"
BorderWidth="1px" BorderStyle="Solid" BorderColor="Tan"
CellPadding="2" CellSpacing="0"
Font-Name="Verdana" Font-Size="8pt"
OnEditCommand="Grid1_Edit"
OnCancelCommand="Grid1_Cancel"
OnUpdateCommand="Grid1_Update"
DataKeyField="code_value">
<Columns>
 <asp:EditCommandColumn
    EditText="编辑"
    CancelText="取消"
    UpdateText="确定"
    ItemStyle-Wrap="false"
    HeaderText="Click to Edit"
    HeaderStyle-Wrap="false"/>
    <asp:BoundColumn HeaderText="Account #" ReadOnly="true" DataField="code_value"/>
    <asp:TemplateColumn HeaderText="Name" >
	   <ItemTemplate>
	   <asp:Label Text='<%# Container.DataItem("code_display") %>' runat="server"/>
	   </ItemTemplate>
	   <EditItemTemplate>
	   <asp:TextBox id="edit_name" Text='<%# Container.DataItem("code_display") %>'
	    runat="server"/>
	  </EditItemTemplate>
   </asp:TemplateColumn>
   <asp:TemplateColumn HeaderText="组" >
	 <ItemTemplate>
	 <asp:Label Text='<%# Container.DataItem("code_category") %>' runat="server"/>
	 </ItemTemplate>
	 <EditItemTemplate>
	 <asp:TextBox id="edit_group" Text='<%# Container.DataItem("code_category") %>'
	    runat="server"/>
	</EditItemTemplate>
   </asp:TemplateColumn>
   <asp:TemplateColumn HeaderText="类型" >
	    <ItemTemplate>
	    <asp:Label Text='<%# Container.DataItem("type") %>' runat="server"/>
	    </ItemTemplate>
	    <EditItemTemplate>
	    <asp:TextBox id="edit_type" BorderStyle="None" Readonly="True" Text='<%# Container.DataItem("type") %>'
	    runat="server"/>
	    </EditItemTemplate>
   </asp:TemplateColumn>
   <asp:TemplateColumn HeaderText="Opening" >
	    <ItemTemplate>
	    <asp:Label Text='<%# Container.DataItem("opening") %>' runat="server"/>
	    </ItemTemplate>
	    <EditItemTemplate>
	    <asp:TextBox id="edit_opening"  Text='<%# Container.DataItem("opening") %>'
	    runat="server"/>    
	    </EditItemTemplate>
   </asp:TemplateColumn>
   <asp:TemplateColumn HeaderText="Closing" >
	    <ItemTemplate>
	    <asp:Label Text='<%# Container.DataItem("closing") %>' runat="server"/>
	    </ItemTemplate>
	    <EditItemTemplate>
	    <asp:TextBox id="edit_closing" BorderStyle="None" Readonly="True" Text='<%# Container.DataItem("closing") %>'
	    runat="server"/>
	    </EditItemTemplate>
   </asp:TemplateColumn>
</Columns>
<HeaderStyle BackColor="DarkRed" ForeColor="White" Font-Bold="true">
</HeaderStyle>
<ItemStyle ForeColor="DarkSlateBlue">
</ItemStyle>
<AlternatingItemStyle BackColor="Beige">
</AlternatingItemStyle>
    </asp:DataGrid>
  </form>
</body>
</html>
