温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:达达ASP.NET企业信息管理系统
当前文件路径:DaDaEnterprise/Admin/Admin_EditWorks.aspx.cs

1using System; 2
using System.Collections; 3
using System.Configuration; 4
using System.Data; 5
using System.Web; 6
using System.IO; 7
using System.Web.Security; 8
using System.Web.UI; 9
using System.Web.UI.HtmlControls; 10
using System.Web.UI.WebControls; 11
using System.Web.UI.WebControls.WebParts; 12
13
public partial class Admin_Admin_EditWorks : System.Web.UI.Page 14
{ 15
protected void Page_Load(object sender, EventArgs e) 16
{ 17
DataAccess.IsAdmin(); 18
string sql = "select * from [Works] where id=" + Request.QueryString["id"]; 19
DataTable Dt = DataAccess.GetDataTable(sql); 20
if (!IsPostBack) 21
{ 22
if (Dt.Rows[0]["show"].ToString() == "1") 23
{ 24
CheckBox1.Checked = true; 25
} 26
else CheckBox1.Checked = false; 27
28
TextBox1.Text = Dt.Rows[0]["Name"].ToString(); 29
Content.Value = Dt.Rows[0]["Content"].ToString(); 30
TextBox2.Text = Dt.Rows[0]["PhotoUrl"].ToString(); 31
Money.Text = Dt.Rows[0]["Money"].ToString(); 32
TextBox4.Text = Dt.Rows[0]["WorksUrl"].ToString(); 33
Demo.Text = Dt.Rows[0]["Demo"].ToString(); 34
} 35
} 36
37
//上传事件 38
protected void UpFile_Click(object sender, EventArgs e) 39
{ 40
if (FileUpload1.HasFile) 41
{ 42
string Name = FileUpload1.FileName; 43
//文档上传到的固定目录 如果需要修改必须必须2个都修改 44
string SaveSoft = Server.MapPath("..\\Photo\\"); 45
46
string Fe = Name.Substring(Name.LastIndexOf(".") + 1); 47
48
SaveSoft += Name; 49
50
Directory.CreateDirectory(Server.MapPath("..\\Photo\\")); 51
52
FileUpload1.SaveAs(SaveSoft); 53
54
TextBox2.Text = "Photo\\" + Name; 55
56
} 57
else Response.Write("<script>alert('请选择要上传的文件');</script>"); 58
} 59
60
protected void Sub_Click(object sender, EventArgs e) 61
{ 62
int show; 63
if (CheckBox1.Checked) 64
{ 65
show = 1; 66
} 67
else show = 2; 68
string sql = "update [Works] set Name='" 69
+ TextBox1.Text + "', Content='" 70
+ Content.Value + "',PhotoUrl='" 71
+ TextBox2.Text + "',[Money]='" 72
+ Money.Text + "',WorksUrl='" 73
+ TextBox4.Text + "',Demo='" 74
+ Demo.Text + "',show='" + show + "' where id=" + Request.QueryString["id"]; 75
if (!String.IsNullOrEmpty(TextBox1.Text)) 76
{ 77
if (DataAccess.ExecuteCmd(sql) > 0) 78
{ 79
Response.Redirect("./Admin_Works.aspx"); 80
} 81
else Response.Write("<script>alert('编辑失败!');</script>"); 82
} 83
else Response.Write("<script>alert('作品名不能为空!');</script>"); 84
} 85
} 86





}
}