📄 update.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
namespace gllbysj
{
/// <summary>
/// update 的摘要说明。
/// </summary>
public class update : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox8;
protected System.Web.UI.WebControls.TextBox TextBox7;
protected System.Web.UI.WebControls.TextBox TextBox6;
protected System.Web.UI.WebControls.TextBox TextBox5;
protected System.Web.UI.WebControls.TextBox TextBox4;
protected System.Web.UI.WebControls.TextBox TextBox3;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.LinkButton LinkButton1;
protected System.Web.UI.WebControls.LinkButton LinkButton2;
protected System.Web.UI.HtmlControls.HtmlInputFile File1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.HyperLink HyperLink1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.Image Image1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!this.IsPostBack)
{
//this.LinkButton1.Attributes.Add
Session["delid"]=Request.QueryString["voidid"].ToString();
this.bind();
}
this.LinkButton1.Attributes.Add("OnClick","return confirm('请确定信息无误!')");
}
public void bind()
{
string id1=Session["delid"].ToString();
string str="select * from mess where id="+id1;
string[] clas={"爱情片","动作片","武侠片","科幻片","喜剧片","惊悚片","战争片"};
SqlConnection con=db.createcon();
con.Open();
SqlCommand cmm=new SqlCommand(str,con);
SqlDataReader sdr=cmm.ExecuteReader();
if(sdr.Read())
{
//this.TextBox1.Text=sdr["class1"].ToString();
string class1=sdr["class1"].ToString().Trim();
switch(class1)
{
case "爱情片":
this.DropDownList1.SelectedIndex=0;
break;
case "动作片":
this.DropDownList1.SelectedIndex=1;
break;
case "武侠片":
this.DropDownList1.SelectedIndex=2;
break;
case "科幻片":
this.DropDownList1.SelectedIndex=3;
break;
case "喜剧片":
this.DropDownList1.SelectedIndex=4;
break;
case "惊悚片":
this.DropDownList1.SelectedIndex=5;
break;
case "战争片":
this.DropDownList1.SelectedIndex=6;
break;
}
this.TextBox2.Text=sdr["name"].ToString();
this.TextBox3.Text=sdr["filename"].ToString();
this.TextBox4.Text=sdr["sizev"].ToString();
this.TextBox5.Text=sdr["hits"].ToString();
this.TextBox6.Text=sdr["times"].ToString();
this.TextBox7.Text=sdr["主要演员"].ToString();
this.TextBox8.Text=sdr["descr"].ToString();
//this.File1.="upimage/"+sdr["image"].ToString();
this.Image1.ImageUrl="upimage/"+sdr["image"].ToString();
}
con.Close();
this.Label2.Text="当前位置:更新影片";
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void LinkButton1_Click(object sender, System.EventArgs e)
{
int id1=Convert.ToInt32(Session["delid"].ToString());
string fullname=this.File1.PostedFile.FileName;
string image=fullname.Substring(fullname.LastIndexOf("\\")+1);
string type=fullname.Substring(fullname.LastIndexOf(".")+1);
//string filename1=this.File2.PostedFile.FileName;
//string filename=filename1.Substring(filename1.LastIndexOf("\\")+1);
//string filetype=filename1.Substring(filename1.LastIndexOf(".")+1);
string a,b,c,d,k,g,h,i,f;
//a=this.TextBox1.Text;
a=this.DropDownList1.SelectedItem.Text;
b=this.TextBox2.Text;
c=this.TextBox3.Text;
//c=filename;
d=this.TextBox4.Text;
k=this.TextBox5.Text;
f=this.TextBox6.Text;
g=this.TextBox7.Text;
h=this.TextBox8.Text;
i=image;
string str="update mess set class1='"+a+"',name='"+b+"',filename='"+c+"',sizev='"+d+"',times='"+f+"',hits='"+k+"',主要演员='"+g+"',descr='"+h+"',image='"+i+"' where id="+id1;
string str1="update mess set class1='"+a+"',name='"+b+"',filename='"+c+"',sizev='"+d+"',times='"+f+"',hits='"+k+"',主要演员='"+g+"',descr='"+h+"' where id="+id1;
if(fullname=="")
{
str=str1;
SqlConnection cn=db.createcon();
cn.Open();
SqlCommand cmm=new SqlCommand(str,cn);
cmm.ExecuteNonQuery();
//this.File1.PostedFile.SaveAs(Server.MapPath("upimage")+"\\"+image);
this.Label1.Text="更新成功!!";
cn.Close();
this.bind();
}
else
if(type=="bmp"||type=="jpg"||type=="gif")
{
//x1.Text+",name="+this.TextBox2.Text+",filename="+this.TextBox3.Text+",sizev="+this.TextBox4.Text+",hits="+this.TextBox5.Text+",times="+this.TextBox6.Text+",主要演员"+this.TextBox7.Text+",descr="+this.TextBox8.Text+",image="+image+"where id="+id1;
SqlConnection cn=db.createcon();
cn.Open();
SqlCommand cmm=new SqlCommand(str,cn);
cmm.ExecuteNonQuery();
this.File1.PostedFile.SaveAs(Server.MapPath("upimage")+"\\"+image);
this.Label1.Text="更新成功!!";
cn.Close();
this.bind();
}
else
{
Response.Write("<script language=javascript>alert('图片格试不正确!!')</script>");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -