📄 homepark.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;
public partial class admin_areafacility : System.Web.UI.Page
{
stringoperator stroper = new stringoperator();
public static string sql = "";
BaseClass bc = new BaseClass();
protected void Page_Load(object sender, EventArgs e)
{
if (Convert.ToString(Session["UID"]) == "")
{
Response.Redirect("login.aspx");
}
if(!IsPostBack)
{
bc.ExecDropDownList(ddlPavilion, "select * from pavilion", "Name", "paID");//楼宇
bc.ExecDropDownList(ddlCell, "select * from type where type='DY'", "name", "code");//单元
bc.ExecDropDownList(DropDownList1, "select * from basepark", "Name", "parkID");
this.bind();
}
}
public void bind()
{
string strsql = "select * from v_homepark "+sql;
bc.ExecGridView(GridView1, strsql);//绑定数据
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((LinkButton)(e.Row.Cells[8].Controls[0])).Attributes.Add("onclick", "return confirm('确定删除吗?')");
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#99ccff';this.Style.color='buttontext';this.Style.cursor='default';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='';this.style.color='';");
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.GridView1.PageIndex = e.NewPageIndex;
this.bind();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string id = this.GridView1.DataKeys[e.RowIndex].Value.ToString();
//Response.Write(id);
//Response.End();
BaseClass bcc = new BaseClass();
string sqlstr = "delete from homepark where ID='" + id + "'";
if (bcc.ExecSql(sqlstr))
{
Response.Write("<script>alert('删除信息成功!');</script>");
this.bind();
}
else
{
Response.Write("<script>alert('操作失败!');</script>");
}
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
string id = this.GridView1.DataKeys[e.NewEditIndex].Value.ToString();
Response.Redirect("edithomepark.aspx?ID=" + id + "");
//Response.Write("<script>window.open('edithomepark.aspx?ownerID=" + ownerid + "','','width=450,height=450')</script>");
Response.Write("<script>location='javascript:history.go(-1)'</script>");
}
protected void ddlPavilion_SelectedIndexChanged(object sender, EventArgs e)
{
string pavID = ddlPavilion.SelectedItem.Value;
sql = " where left(code," + pavID.Length + ")='" + pavID + "'";
this.bind();
}
protected void ddlCell_SelectedIndexChanged(object sender, EventArgs e)
{
string pavID = ddlPavilion.SelectedItem.Value;
string cellID = ddlCell.SelectedItem.Value;
string left = pavID + cellID;
int leftlenth = left.Length;
sql = " where left(code," + leftlenth + ")='" + left + "'";
this.bind();
}
protected void Button2_Click(object sender, EventArgs e)
{
string pavID = ddlPavilion.SelectedItem.Value;
string cellID = ddlCell.SelectedItem.Value;
string left = pavID + cellID;
int leftlenth = left.Length;
string floor;
int num = Convert.ToInt32(TextBox1.Text);
if (num < 10)
{
floor = "0" + num.ToString();
}
else
{
floor = num.ToString();
}
sql = " where left(code," + leftlenth + ")='" + left + "' and substring(code," + (leftlenth + 1) + "," + floor.Length + ")='" + floor + "'";
// Response.Write(sql);
// Response.End();
this.bind();
}
protected void Button3_Click(object sender, EventArgs e)
{
}
// 显示所有
protected void Button5_Click(object sender, EventArgs e)
{
sql = "";
Panel1.Visible = true;
Panel2.Visible = false;
this.bind();
}
//根据要求生成查找条件
protected void Button4_Click(object sender, EventArgs e)
{
Hashtable htabel = new Hashtable();
if (CheckBox1.Checked)
{
htabel.Add("ownerID",TextBox2.Text);
// Response.Write(htabel["unitName"].GetType().ToString());
// Response.End();
}
//停车位
if (CheckBox2.Checked)
{
htabel.Add("carplace",TextBox3.Text);
}
//停车场
if (CheckBox3.Checked)
{
htabel.Add("parkID",Convert.ToInt32(DropDownList1.SelectedValue));
}
//车牌号
if (CheckBox4.Checked)
{
htabel.Add("carID", TextBox4.Text);
}
if (CheckBox5.Checked)
{
htabel.Add("type", TextBox5.Text);
}
//精确还是模糊查找
if (CheckBox6.Checked)
{
sql = stroper.GetConditionClause(htabel, true);
}
else
{
sql = stroper.GetConditionClause(htabel, false);
}
// Response.Write(sql);
// Response.End();
this.bind();
}
//高级查找
protected void Button1_Click(object sender, EventArgs e)
{
Panel1.Visible = false;
Panel2.Visible = true;
}
protected void TextBox5_TextChanged(object sender, EventArgs e)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -