📄 homereport.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_fixrepair : System.Web.UI.Page
{
BaseClass bc = new BaseClass();
public static string sql = "";
protected void Page_Load(object sender, EventArgs e)
{
if (Convert.ToString(Session["UID"]) == "")
{
Response.Redirect("login.aspx");
}
//else
//{
if (!IsPostBack)
{
bc.ExecDropDownList(ddlPavilion, "select * from pavilion", "Name", "paID");//楼宇
bc.ExecDropDownList(ddlCell, "select * from type where type='DY'", "name", "code");//单元
this.bind();
}
//}
}
public void bind()
{
string strsql = "select * from v_homereport " + sql+" order by ID desc" ;
bc.ExecGridView(GridView1, strsql);//绑定数据
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[4].Text == "0")
{
e.Row.Cells[4].Text = "<font color=blue>未处理</font>";
}
else
{
e.Row.Cells[4].Text = "<font color=red>已处理</font>";
((Button)(e.Row.Cells[7].Controls[0])).Enabled = false;
}
((LinkButton)(e.Row.Cells[6].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 homereport where ID='" + id + "'";
if (bcc.ExecSql(sqlstr))
{
Response.Write("<script>alert('删除信息成功!');</script>");
this.bind();
}
else
{
Response.Write("<script>alert('操作失败!');</script>");
}
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
string setting = Convert.ToString(ConfigurationManager.ConnectionStrings["SmallHouseConn"]);
SqlConnection conn = new SqlConnection(setting);
conn.Open();
string id = this.GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
string sqlstr = "select sign from homereport where ID=" + id + "";
//Response.Write(sqlstr);
//Response.End();
SqlCommand scd = new SqlCommand(sqlstr, conn);
string sign = Convert.ToString(scd.ExecuteScalar());
if (sign =="0")
{
sign ="1";
//Response.Write("<script>alert('审核成功!');</script>");
}
else
{
sign = "0";//如果加入此行将可以重复审核
// Response.Write("<script>alert('不能重复审核处理!');</script>");
//return;
}
scd.CommandText = "update homereport set sign=" + sign + " where id=" + id;
//Response.Write(sign);
//Response.End();
scd.ExecuteNonQuery();
this.bind();
conn.Close();
}
//选择楼宇后
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 + "'";
this.bind();
}
protected void Button3_Click(object sender, EventArgs e)
{
sql = "";
this.bind();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -