Option Strict Off
Imports System
Imports System.Collections
Imports System.Text
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Class BaseClass

Inherits System.Web.UI.Page
protected Grid1 as DataGrid
Protected Message as label, title as label
Protected acode_value as dropdownlist, selection as dropdownlist
Protected AddPanel as Panel
Protected adate as TextBox, aref as TextBox, aqty_in as TextBox
Protected  aqty_out as TextBox , anarr as TextBox 
Protected addshow as button
Dim ds           As New DataSet
Dim ConnStr      As String
Dim SQL          As String

Sub Page_Load(Source As Object, E As EventArgs) 
   ConnStr = "Provider=SQLOLEDB; Data Source=(local); "
   ConnStr = ConnStr+" Initial Catalog=ASPNET;User ID=sa;"
    if NOT (isPostBack)
        rebind
    end if
End Sub
Sub ReBind()
	Dim t As New NameSpaceHersh.SQLService
	Dim ds as DataSet
	'设置DataSetCommand
	SQL = "select * from tr_header h, stock_detail s, stock_master m"
	SQL = SQL + " where h.doc_no = s.doc_no" 
	SQL = SQL + " AND s.code_value = m.code_value"
	ds = t.Populate(ConnStr, SQL)
	Grid1.DataSource=ds.Tables("vTable").DefaultView
	Grid1.DataBind()
	'填充在增加模式下选定的drop down list
	SQL = "Select * from stock_master"
	ds = t.Populate(ConnStr, SQL)
	acode_value.DataSource=ds.Tables("vTable").DefaultView
	acode_value.DataBind()
	addshow.visible = true
End Sub
Sub Grid1_Edit(Sender As Object, E As DataGridCommandEventArgs)
	Grid1.EditItemIndex = E.Item.ItemIndex
	ReBind()
End Sub
Sub Grid1_Cancel(Sender As Object, E As DataGridCommandEventArgs)
	Grid1.EditItemIndex = -1
	ReBind()
End Sub
Sub RunSql(vsql as string)
	
	Dim t As New NameSpaceHersh.SQLService
	Dim s as string
	s = t.RunSQL(ConnStr,vSQL)
	Grid1.EditItemIndex = -1
	Rebind
	if s <> "Success" then
	   Message.Text = s
	   Message.Style("color") = "red"
	End if
End sub
sub hidePanel()
	if AddPanel.visible = true then
	   AddPanel.visible = false
	   '重新设定值
	   adate.text = ""
	   aref.text = ""
	   aqty_in.text = ""
	   aqty_out.text = ""
	   anarr.text = ""
	end if
end sub
End Class
