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

1using System; 2
using System.Collections; 3
using System.Configuration; 4
using System.Data; 5
using System.IO; 6
using System.Web; 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_AddWorks : System.Web.UI.Page 14
{ 15
protected void Page_Load(object sender, EventArgs e) 16
{ 17
DataAccess.IsAdmin(); 18
} 19
20
protected void Sub_Click(object sender, EventArgs e) 21
{ 22
int show; 23
if (CheckBox1.Checked) 24
{ 25
show = 1; 26
} 27
else show = 2; 28
29
string sql = "insert into [Works](Name,Content,show,PhotoUrl,[Money],WorksUrl,Demo) values('" 30
+ TextBox1.Text + "','" 31
+ Content.Value + "','" 32
+ show + "','" 33
+ TextBox2.Text + "','" 34
+ Money.Text + "','" 35
+ TextBox4.Text + "','" 36
+ Demo.Text + "')"; 37
if (!String.IsNullOrEmpty(TextBox1.Text)) 38
{ 39
if (DataAccess.ExecuteCmd(sql) > 0) 40
{ 41
Response.Redirect("./Admin_Works.aspx"); 42
} 43
else Response.Write("<script>alert('添加失败!');</script>"); 44
} 45
else Response.Write("<script>alert('作品名不能为空!');</script>"); 46
} 47
48
//上传事件 49
protected void UpFile_Click(object sender, EventArgs e) 50
{ 51
if (FileUpload1.HasFile) 52
{ 53
string Name = FileUpload1.FileName; 54
//文档上传到的固定目录 如果需要修改必须必须2个都修改 55
string SaveSoft = Server.MapPath("..\\Photo\\"); 56
57
string Fe = Name.Substring(Name.LastIndexOf(".") + 1); 58
59
SaveSoft += Name; 60
61
Directory.CreateDirectory(Server.MapPath("..\\Photo\\")); 62
63
FileUpload1.SaveAs(SaveSoft); 64
65
TextBox2.Text = "Photo\\" + Name; 66
67
} 68
else Response.Write("<script>alert('请选择要上传的文件');</script>"); 69
} 70
} 71





}
}