Imports OraDal
Imports System.Data.OleDb
Imports System.io
Imports bll
Imports Model
Imports System
Imports System.Web
Imports System.Web.UI.WebControls
Public Class front_pro_edit
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents im_struct As System.Web.UI.WebControls.Image
Protected WithEvents ddl_class As System.Web.UI.WebControls.DropDownList
Protected WithEvents tb_name As System.Web.UI.WebControls.TextBox
Protected WithEvents tb_chem_name As System.Web.UI.WebControls.TextBox
Protected WithEvents tb_cas As System.Web.UI.WebControls.TextBox
Protected WithEvents tb_chem_formula As System.Web.UI.WebControls.TextBox
Protected WithEvents FCK_intro As FredCK.FCKeditorV2.FCKeditor
Protected WithEvents FCK_main_use As FredCK.FCKeditorV2.FCKeditor
'Protected model_detail As New Model.gemsen_pro
Protected WithEvents btn_submit As System.Web.UI.WebControls.Button
Protected WithEvents cb_new As System.Web.UI.WebControls.CheckBox
Protected WithEvents cb_hot As System.Web.UI.WebControls.CheckBox
Protected WithEvents lb_class As System.Web.UI.WebControls.Label
Protected WithEvents lb_main_use As System.Web.UI.WebControls.Label
Protected WithEvents lb_name As System.Web.UI.WebControls.Label
Protected WithEvents lb_chem_name As System.Web.UI.WebControls.Label
Protected WithEvents lb_cas As System.Web.UI.WebControls.Label
Protected WithEvents lb_chem_formula As System.Web.UI.WebControls.Label
Protected WithEvents lb_ipath As System.Web.UI.WebControls.Label
Protected WithEvents lb_intro As System.Web.UI.WebControls.Label
Protected WithEvents acf_ipath As System.Web.UI.HtmlControls.HtmlInputFile
Protected WithEvents cb_change_image As System.Web.UI.WebControls.CheckBox
Protected WithEvents RequiredFieldValidator1 As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents HyperLink1 As System.Web.UI.WebControls.HyperLink
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
'不要删除或移动它。
Private designerPlaceholderDeclaration As System.Object
Private model_detail As New Model.gemsen_pro
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
'Dim load_pro As New DaG_pro
'Repeater1.DataSource = load_pro.Pro_Search("", "1")
'Repeater1.DataBind()
If Not Request.QueryString("id") Is Nothing Then
value_get()
'Else
'lb_tag.Text = "Add"
End If
End If
'在此处放置初始化页的用户代码
End Sub
Private Sub value_get()
Dim load As New DaG_pro
model_detail = load.Pro_detail(Request.QueryString("id").Trim())
'lb_tag.Text = "Edit"
tb_name.Text = model_detail.name
tb_chem_name.Text = model_detail.chem_name
tb_cas.Text = model_detail.cas
tb_chem_formula.Text = model_detail.chem_formula
im_struct.ImageUrl = "..\gemsen_pro_db\" + model_detail.ipath
FCK_intro.Value = model_detail.intro
FCK_main_use.Value = model_detail.main_use
cb_new.Checked = model_detail.isnew
cb_hot.Checked = model_detail.ishot
Dim ddl As New front_pro_list
ddl.ddl_load(ddl_class)
'ddl_class.Items.FindByText(str_class).Selected=true;
ddl_class.Items.FindByValue(model_detail.g_class).Selected = True
End Sub
Private Sub value_set()
'Dim load As New DaG_pro
'load.Pro_detail(Request.QueryString("id").Trim()) = model_detail
model_detail.name = tb_name.Text
model_detail.chem_name = tb_chem_name.Text
model_detail.cas = tb_cas.Text
model_detail.chem_formula = tb_chem_formula.Text
'im_struct.ImageUrl = "..\gemsen_pro_db\" + model_detail.ipath
model_detail.intro = FCK_intro.Value
model_detail.main_use = FCK_main_use.Value
model_detail.isnew = cb_new.Checked
model_detail.ishot = cb_hot.Checked
model_detail.g_class = ddl_class.SelectedValue
If Not acf_ipath.PostedFile Is Nothing Then
model_detail.ipath = Generate_filename()
Else
model_detail.ipath = ""
End If
'Dim ddl As New front_pro_list
'ddl.ddl_load(ddl_class)
'ddl_class.Items.FindByValue(model_detail.g_class).Selected = True
End Sub
Public Function Generate_filename() As String
Return CStr(Now.Year & Now.Month & Now.Day & Now.Hour & Now.Minute & Now.Millisecond & model_detail.cas & Path.GetExtension(acf_ipath.PostedFile.FileName))
End Function
Private Sub btn_submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_submit.Click
If Not model_detail.name Is Nothing Then
value_set()
If Not acf_ipath.PostedFile Is Nothing Then
model_detail.ipath = Generate_filename()
Else
model_detail.ipath = ""
End If
'设置数据到产品对象
Dim up_sub As New DaG_pro
Dim str_MESSAGE As String = ""
If cb_change_image.Checked = True Then
If acf_ipath.PostedFile.ContentLength > 0 Then
acf_ipath.PostedFile.SaveAs(Server.MapPath("..\gemsen_pro_db\") + model_detail.ipath)
Else
'Response.Write("<script language ='javascript'>confirm('删除产品结构图?');</script>")
model_detail.ipath = "no.gif"
End If
Else
model_detail.ipath = ""
End If
str_MESSAGE = up_sub.Pro_detail_update(model_detail) '上传的同时删除原来的图片,再更新数据库.
value_get()
End If
End Sub
End Class