您目前尚未登陆,请选择【登陆】或【注册
首页->全站代码->海南岛旅游网全站源码>>admin/hotel_room_add.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:海南岛旅游网全站源码
当前文件:文件类型 HaiNanDaoTravel/admin/hotel_room_add.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Text; 3using System.Data; 4using System.Data.SqlClient; 5using System.Configuration; 6using System.Collections; 7using System.Web; 8using System.Web.Security; 9using System.Web.UI; 10using System.Web.UI.WebControls; 11using System.Web.UI.WebControls.WebParts; 12using System.Web.UI.HtmlControls; 13 14public partial class admin_hotel_room_add : Sper.baseadmin 15{ 16 protected void Page_Load(object sender, EventArgs e) 17 { 18 19 } 20 protected void Button1_Click(object sender, EventArgs e) 21 { 22 Add(); 23 } 24 protected void myGridView_RowUpdating(object sender, GridViewUpdateEventArgs e) 25 { 26 DropDownList dr = ((DropDownList)GridView1.Rows[e.RowIndex].Cells[3].FindControl("txtbreakfast2")); 27 string str = dr.SelectedValue; 28 e.NewValues["breakfast"] = str; 29 30 DropDownList dr2 = ((DropDownList)GridView1.Rows[e.RowIndex].Cells[4].FindControl("txtbedtype2")); 31 string str2 = dr2.SelectedValue; 32 e.NewValues["bedtype"] = str2; 33 34 DropDownList dr3 = ((DropDownList)GridView1.Rows[e.RowIndex].Cells[5].FindControl("txtBroadBand2")); 35 string str3 = dr3.SelectedValue; 36 e.NewValues["BroadBand"] = str3; 37 38 } 39 protected void myGridView_RowDataBound(object sender, GridViewRowEventArgs e) 40 { 41 //e.Row.Cells[0].Attributes.Add("onclick", "return confirm('确定删除吗?')"); 42 if (((DropDownList)e.Row.FindControl("txtbreakfast2")) != null) 43 { 44 DropDownList ddlstate = (DropDownList)e.Row.FindControl("txtbreakfast2"); 45 ddlstate.SelectedValue = ((HiddenField)e.Row.FindControl("hdstate")).Value; 46 47 DropDownList ddlstate2 = (DropDownList)e.Row.FindControl("txtbedtype2"); 48 ddlstate2.SelectedValue = ((HiddenField)e.Row.FindControl("hdstatebedtype")).Value; 49 50 DropDownList ddlstate3 = (DropDownList)e.Row.FindControl("txtBroadBand2"); 51 ddlstate3.SelectedValue = ((HiddenField)e.Row.FindControl("hdstateBroadBand")).Value; 52 } 53 54 } 55 /// <summary> 56 /// 增加一条数据 57 /// </summary> 58 public void Add() 59 { 60 string roomtpye = this.txtroomtpye.Text; 61 int priceA = int.Parse(this.txtpriceA.Text); 62 int priceB = int.Parse(this.txtpriceB.Text); 63 string breakfast = this.txtbreakfast.SelectedValue; 64 string bedtype = this.txtbedtype.SelectedValue; 65 string BroadBand = this.txtBroadBand.SelectedValue; 66 int hotelid = int.Parse(Request.QueryString["id"]); 67 68 69 string strErr = ""; 70 if (roomtpye == "") 71 { 72 strErr += "房型不能为空!\\n"; 73 } 74 if (!PageValidate.IsNumber(txtpriceA.Text)) 75 { 76 strErr += "门市价不是数字!\\n"; 77 } 78 if (!PageValidate.IsNumber(txtpriceB.Text)) 79 { 80 strErr += "本站会员价不是数字!\\n"; 81 } 82 if (breakfast == "") 83 { 84 strErr += "早餐不能为空!\\n"; 85 } 86 if (bedtype == "") 87 { 88 strErr += "床型不能为空!\\n"; 89 } 90 if (BroadBand == "") 91 { 92 strErr += "宽带不能为空!\\n"; 93 } 94 95 if (strErr != "") 96 { 97 MessageBox.Show(this, strErr); 98 return; 99 } 100 101 102 StringBuilder strSql = new StringBuilder(); 103 strSql.Append("insert into hotel_room("); 104 strSql.Append("roomtpye,priceA,priceB,breakfast,bedtype,BroadBand,hotelid)"); 105 strSql.Append(" values ("); 106 strSql.Append("@roomtpye,@priceA,@priceB,@breakfast,@bedtype,@BroadBand,@hotelid)"); 107 SqlParameter[] parameters = { 108 new SqlParameter("@roomtpye", SqlDbType.VarChar,50), 109 new SqlParameter("@priceA", SqlDbType.Int,4), 110 new SqlParameter("@priceB", SqlDbType.Int,4), 111 new SqlParameter("@breakfast", SqlDbType.VarChar,50), 112 new SqlParameter("@bedtype", SqlDbType.VarChar,50), 113 new SqlParameter("@BroadBand", SqlDbType.VarChar,50), 114 new SqlParameter("@hotelid", SqlDbType.Int,4)}; 115 parameters[0].Value = roomtpye; 116 parameters[1].Value = priceA; 117 parameters[2].Value = priceB; 118 parameters[3].Value = breakfast; 119 parameters[4].Value = bedtype; 120 parameters[5].Value = BroadBand; 121 parameters[6].Value = hotelid; 122 123 DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); 124 GridView1.DataBind(); 125 } 126} 127
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:海南岛旅游网全站源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号