📄 pictureedit.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class admins_PictureEdit : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (this.Session["name"] == null)
{
base.Response.Redirect("login.aspx");
}
else if ((base.Request.QueryString["id"] != null) && !base.IsPostBack)
{
string id = base.Request.QueryString["id"].ToString();
this.getInf(id);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (base.Request.QueryString["id"] != null)
{
string id = base.Request.QueryString["id"].ToString();
this.upPicture(id);
base.Response.Redirect("PictureManager.aspx");
}
else
{
this.Insert();
base.Response.Redirect("PictureManager.aspx");
}
}
protected void Button2_Click(object sender, EventArgs e)
{
base.Response.Redirect("PictureManager.aspx");
}
protected void Button3_Click(object sender, EventArgs e)
{
if (this.TbxUrls.Text.Trim() != "")
{
this.Image1.ImageUrl = this.TbxUrls.Text.Trim();
}
}
protected static string GetConnString()
{
string str2 = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string path = ConfigurationManager.ConnectionStrings["DBPaths"].ConnectionString;
string str4 = HttpContext.Current.Server.MapPath(path);
return (str2 + str4 + ";");
}
private void getInf(string id)
{
DataSet dataSet = new DataSet();
string connString = GetConnString();
new OleDbDataAdapter("select [picname] as 名称, [size] as 大小 , [counts] as 空间, [type] as 类型,[urls] as 地址 from [Pictures] where [id]=" + id + " and DeleteFlag=False", connString).Fill(dataSet, "Tb1");
if (dataSet.Tables[0].Rows.Count != 0)
{
this.TbxName.Text = dataSet.Tables[0].Rows[0]["名称"].ToString();
this.TbxSize.Text = dataSet.Tables[0].Rows[0]["大小"].ToString();
this.TbxSpace.Text = dataSet.Tables[0].Rows[0]["空间"].ToString();
this.TbxType.Text = dataSet.Tables[0].Rows[0]["类型"].ToString();
this.TbxUrls.Text = dataSet.Tables[0].Rows[0]["地址"].ToString();
this.Image1.ImageUrl = dataSet.Tables[0].Rows[0]["地址"].ToString();
}
}
private void Insert()
{
OleDbConnection connection = new OleDbConnection(GetConnString());
OleDbCommand command = new OleDbCommand("Insert Into [Pictures] ([picname],[size],[counts],[type],[urls],DeleteFlag) Values('" + this.TbxName.Text.Trim() + "','" + this.TbxSize.Text.Trim() + "' ,'" + this.TbxSpace.Text.Trim() + "','" + this.TbxType.Text.Trim() + "','" + this.TbxUrls.Text.Trim() + "',0)", connection);
connection.Open();
command.ExecuteNonQuery();
connection.Close();
}
private void upPicture(string id)
{
OleDbConnection connection = new OleDbConnection(GetConnString());
OleDbCommand command = new OleDbCommand("update [Pictures] set [picname]='" + this.TbxName.Text.Trim() + "',[size]='" + this.TbxSize.Text.Trim() + "' ,[counts] ='" + this.TbxSpace.Text.Trim() + "',[type]='" + this.TbxType.Text.Trim() + "',[urls] ='" + this.TbxUrls.Text.Trim() + "' where id= " + id, connection);
connection.Open();
command.ExecuteNonQuery();
connection.Close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -