您目前尚未登陆,请选择【登陆】或【注册
首页->电子商务->淘淘网电子商务网站源码(毕业设计)>>Admin/AddTopNews.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:淘淘网电子商务网站源码(毕业设计)
当前文件:文件类型 TaoTaoBiz/Admin/AddTopNews.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Collections; 3using System.ComponentModel; 4using System.Data; 5using System.Drawing; 6using System.Web; 7using System.Web.SessionState; 8using System.Web.UI; 9using System.Web.UI.WebControls; 10using System.Web.UI.HtmlControls; 11using web.Code; 12//该源码下载自www.51aspx.com(51aspx.com) 13 14namespace web.Admin 15{ 16 /// <summary> 17 /// AddTopNews 的摘要说明。 18 /// </summary> 19 public partial class AddTopNews : System.Web.UI.Page 20 { 21 protected System.Web.UI.HtmlControls.HtmlImage IMG1; 22 23 protected void Page_Load(object sender, System.EventArgs e) 24 { 25 // 在此处放置用户代码以初始化页面 26 27// updown updown1; 28// updown1=(updown)Context.Handler; 29// TextBox2.Text = TextBox2.Text + updown1.ImgUrl; 30 ImageButton1.Attributes.Add("onclick", "return btnOpen_Click();"); 31 btnAdd.Attributes.Add("onclick", "return checkEmpty(TextBox1)&&checkEmpty(TextBox2);"); 32 } 33 34 Web 窗体设计器生成的代码 53 54 private string getCategoryName() 55 { 56 string categoryname = null; 57 switch( DropDownList1.SelectedValue.ToString() ) 58 { 59 case "1": 60 categoryname = "电脑"; 61 break; 62 case "2": 63 categoryname = "手机"; 64 break; 65 case "3": 66 categoryname = "数码相机"; 67 break; 68 case "4": 69 categoryname = "MP3"; 70 break; 71 case "5": 72 categoryname = "办公外设"; 73 break; 74 } 75 return categoryname; 76 } 77 78 79 protected void btnAdd_Click(object sender, System.EventArgs e) 80 { 81 TopNewsVO topNewsVO = new TopNewsVO(); 82 topNewsVO.Title = TextBox1.Text.Trim(); 83 topNewsVO.Content = TextBox2.Text.Replace("\n","<br>"); 84 topNewsVO.AddDate = DateTime.Now.ToString(); 85 if(CheckBox1.Checked) 86 { 87 topNewsVO.IsAtIndex = 1; 88 topNewsVO.IsFirst = 1; 89 } 90 else if(CheckBox2.Checked) 91 { 92 topNewsVO.IsAtIndex = 1; 93 topNewsVO.IsFirst = 0; 94 } 95 else 96 { 97 topNewsVO.IsAtIndex = 0; 98 topNewsVO.IsFirst = 0; 99 } 100 topNewsVO.CategoryName = getCategoryName(); 101 TopNewsDAO topNewDAO = new TopNewsDAO(); 102 if( topNewDAO.AddTopNewsArticle( topNewsVO ) != 0 ) 103 { 104 TextBox1.Text=null; 105 TextBox2.Text=null; 106 DropDownList1.SelectedIndex=0; 107 CheckBox2.Checked=false; 108 CheckBox1.Checked=false; 109 Response.Write("<script>alert('新闻已经添加!')</script>"); 110 } 111 } 112 113 protected void Button1_Click(object sender, System.EventArgs e) 114 { 115 string fullFileName = up1.PostedFile.FileName; 116 string FileName = fullFileName.Substring( fullFileName.LastIndexOf("\\")+1 ); 117 string FileType = fullFileName.Substring( fullFileName.LastIndexOf(".")+1 ); 118 if( FileType == "bmp" || FileType == "jpg" || FileType == "gif" ) 119 { 120 up1.PostedFile.SaveAs( Server.MapPath("../TopNews/UpDownImg/Home"+"\\"+FileName) ); 121 Response.Write("<script>alert('上传成功!')</script>"); 122 } 123 else 124 { 125 Response.Write("<script>alert('你上传的文件格式不对!')</script>"); 126 } 127 } 128 129 protected void CheckBox2_CheckedChanged(object sender, System.EventArgs e) 130 { 131 if(CheckBox2.Checked) 132 { 133 Panel1.Visible=true; 134 } 135 else 136 { 137 Panel1.Visible=false; 138 } 139 } 140 141 } 142} 143
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:淘淘网电子商务网站源码(毕业设计)
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号