📄 editpark.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.SqlClient;
public partial class admin_editareafac : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Convert.ToString(Session["UID"]) == "")
{
Response.Redirect("login.aspx");
}
else
{
this.bind();
}
}
}
protected void bind()
{ string ID=Request.QueryString["parkID"].ToString();
string str="select * from basepark where parkID='"+ID+"'";
BaseClass bc = new BaseClass();
SqlDataReader sda=bc.ExecRead(str);
if(sda.Read())
{ //绑定数据
TextBox1.Text = sda["Name"].ToString();
TextBox2.Text = sda["Amount"].ToString();
TextBox6.Text = sda["Memo"].ToString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
BaseClass bcc = new BaseClass();
string ID = Request.QueryString["parkID"].ToString();
string valsql = "select count(*) from basepark where Name='" + TextBox1.Text.Trim() + "' and parkID!="+ID;
int count = (int)bcc.ExecCscalar(valsql);
if (count > 0)
{
Response.Write("<script>alert('已存在停车场:" + TextBox1.Text + "');</script>");
return;
}
int parkcount=Convert.ToInt32(TextBox2.Text);
string sql = "select count(*) as amount from homepark where parkID=" + ID + "";
//Response.Write(sql);
//Response.End();
SqlDataReader sda = bcc.ExecRead(sql);
if (sda.Read())
{
count = Convert.ToInt32(sda["amount"]);
if(parkcount<count) //判断输入的数量是否小于homepark表的停车位数量
{
Response.Write("<script language=javascript>alert('新停车位小于住户的停车位数量!');</script>");
return;
}
}
BaseClass bccc = new BaseClass();
string sqlstr = "update basepark set Name='" + TextBox1.Text + "',Amount=" + TextBox2.Text + ",Memo='" + TextBox6.Text +"' where parkID="+ID+"";
//Response.Write(sqlstr);
//Response.End();
if (bccc.ExecSql(sqlstr))
{
Response.Write("<script language=javascript>alert('修改成功!');opener.location='park.aspx';window.close()</script>");
}
else
{
Response.Write("<script>alert(修改失败,请重试!');</script>");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -