| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 682 人关注过本帖
标题:[求助]我的.net要请大虾们帮忙???
只看楼主 加入收藏
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2005-5-25
收藏
 问题点数:0 回复次数:1 
[求助]我的.net要请大虾们帮忙???

Imports System.Data.oledb Imports System.Data Imports System.IO Imports System.Drawing Public Class input Inherits System.Web.UI.Page

#Region " Web 窗体设计器生成的代码 "

'该调用是 Web 窗体设计器所必需的。 <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub Protected WithEvents Button1 As System.Web.UI.WebControls.Button Protected WithEvents dpdbigtype As System.Web.UI.WebControls.DropDownList Protected WithEvents dpdsubtype As System.Web.UI.WebControls.DropDownList Protected WithEvents txtproID As System.Web.UI.WebControls.TextBox Protected WithEvents txtshiprice As System.Web.UI.WebControls.TextBox Protected WithEvents txthuiprice As System.Web.UI.WebControls.TextBox Protected WithEvents txtmemo As System.Web.UI.WebControls.TextBox Protected WithEvents txtcu As System.Web.UI.WebControls.TextBox Protected WithEvents Fileup As System.Web.UI.HtmlControls.HtmlInputFile Protected WithEvents RequiredFieldValidator1 As System.Web.UI.WebControls.RequiredFieldValidator Protected WithEvents RequiredFieldValidator2 As System.Web.UI.WebControls.RequiredFieldValidator

'注意: 以下占位符声明是 Web 窗体设计器所必需的。 '不要删除或移动它。 Private designerPlaceholderDeclaration As System.Object

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 IsPostBack Then dpdbigtype_bind() End If End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If IsValid And dpdbigtype.SelectedItem.Text <> "请选择" And dpdsubtype.SelectedItem.Text <> "请选择" Then Dim smallpath, bigpath As String Dim connstr As String connstr = System.Configuration.ConfigurationSettings.AppSettings("Provider") & "data source=" & Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings("Data Source")) Dim cn As New OleDbConnection(connstr) Try If Fileup.PostedFile.ContentLength = 0 Then smallpath = "" bigpath = "" Else Dim filesplit() As String = Split(Fileup.PostedFile.FileName, "\") If (filesplit(filesplit.Length - 1).Substring(Len(filesplit(filesplit.Length - 1)) - 3, 3)) = "jpg" Or (filesplit(filesplit.Length - 1).Substring(Len(filesplit(filesplit.Length - 1)) - 3, 3)) = "gif" Then

'保存图片 Dim ff As String = Now.Year.ToString & Now.Month.ToString & Now.Day.ToString & Now.Hour.ToString & Now.Minute.ToString & Now.Second.ToString & "." & (filesplit(filesplit.Length - 1).Substring(Len(filesplit(filesplit.Length - 1)) - 3, 3)) Fileup.PostedFile.SaveAs(Server.MapPath("big/" & ff))

smallpath = "/chanpin/small/" & ff bigpath = "/chanpin/big/" & ff

'存入略缩图 Dim image As Image, width, height As Single, newwidth, newheight As Single Dim callb As System.Drawing.Image.GetThumbnailImageAbort image = System.Drawing.Image.FromFile(Server.MapPath("big/" & ff)) width = image.Width height = image.Height If width > height Then newwidth = 160 newheight = image.Height / image.Width * newwidth Else newheight = 160 newwidth = image.Width / image.Height * newheight End If

Dim size As System.Drawing.Size size = New System.Drawing.Size(newwidth, newheight) '新建一个图片() Dim ibitmap As System.Drawing.Bitmap = New System.Drawing.Bitmap(size.Width, size.Height)

'新建一个画版 Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(ibitmap) '设置高质量插值法 g.InterpolationMode = Drawing.Drawing2D.InterpolationMode.High '设置高质量,低速度呈现平滑程度 g.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality g.Clear(Color.Blue) '在指定位置画图片 g.DrawImage(image, New System.Drawing.Rectangle(0, 0, ibitmap.Width, ibitmap.Height), _ New System.Drawing.Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel) If (filesplit(filesplit.Length - 1).Substring(Len(filesplit(filesplit.Length - 1)) - 3, 3)) = "jpg" Then ibitmap.Save(Server.MapPath("small/" & ff), System.Drawing.Imaging.ImageFormat.Jpeg) Else ibitmap.Save(Server.MapPath("small/" & ff), System.Drawing.Imaging.ImageFormat.Gif) End If g.Dispose() End If End If

cn.Open() Dim sql4 As String = "insert into product(bigtype,subtype,productID,shiprice,huiprice,smallimg,bigimg,cu,m) values('" & dpdbigtype.SelectedItem.Text & "','" & dpdsubtype.SelectedItem.Text & "','" & txtproID.Text & "'," & CSng(txtshiprice.Text) & "," & CSng(txthuiprice.Text) & ",'" & smallpath & "','" & bigpath & "','" & txtcu.Text & "','" & txtmemo.Text & "')" Dim comm4 As New OleDbCommand(sql4, cn) comm4.ExecuteNonQuery()

comm4 = Nothing cn.Close() Catch ex As Exception Response.Write(ex.Message) End Try Else Response.Write("<script language= javascript>alert('请选择种类!');</script>") End If End Sub

Private Sub dpdbigtype_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dpdbigtype.SelectedIndexChanged Dim connstr As String connstr = System.Configuration.ConfigurationSettings.AppSettings("Provider") & "data source=" & Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings("Data Source")) Dim cn As New OleDbConnection(connstr) Try cn.Open() Dim comm As OleDbCommand cn = New OleDbConnection(connstr) cn.Open() Dim sql As String = "select distinct subtype from protype where bigtype='" & dpdbigtype.SelectedItem.Text & "'" comm = New OleDbCommand(sql, cn) Dim read As OleDbDataReader read = comm.ExecuteReader dpdsubtype.Items.Clear() dpdsubtype.Items.Add("请选择") While read.Read dpdsubtype.Items.Add(read.Item("subtype")) End While comm.Dispose() read.Close() cn.Close() Catch ex As Exception

End Try End Sub Sub dpdbigtype_bind() Dim connstr As String connstr = System.Configuration.ConfigurationSettings.AppSettings("Provider") & "data source=" & Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings("Data Source")) Dim cn As New OleDbConnection(connstr) Try cn.Open() Dim comm As OleDbCommand cn = New OleDbConnection(connstr) cn.Open() Dim sql As String = "select distinct bigtype from protype" comm = New OleDbCommand(sql, cn) Dim read As OleDbDataReader read = comm.ExecuteReader dpdbigtype.Items.Clear() dpdbigtype.Items.Add("请选择") While read.Read dpdbigtype.Items.Add(read.Item("bigtype")) End While comm.Dispose() read.Close() cn.Close() Catch ex As Exception

End Try End Sub End Class

搜索更多相关主题的帖子: 设计 
2005-05-25 11:27
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
发错地方了。
去VB区吧

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-05-25 14:36
快速回复:[求助]我的.net要请大虾们帮忙???
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016433 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved