📄 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 homerepair : System.Web.UI.Page
{
BaseClass bc = new BaseClass();//定义一个公共类的实例
protected void Page_Load(object sender, EventArgs e)
{
if (Convert.ToString(Session["code"]) == "")
{
Response.Redirect("../login.aspx");
}
if (!IsPostBack)
{
this.bind();
}
}
public void bind()
{
string ownerID = Convert.ToString(Session["code"]);
string strsql = "select * from homeReport where code='" + ownerID + "'";
bc.ExecGridView(GridView1, strsql);
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.GridView1.PageIndex = e.NewPageIndex;
this.bind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[3].Text == "0")
{
e.Row.Cells[3].Text = "<font color=blue>未审核</font>";
}
else
{
e.Row.Cells[3].Text = "<font color=red>审核</font>";
}
((LinkButton)(e.Row.Cells[5].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_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void Changed(object sender, EventArgs e)
{
}
protected void GridView1_RowDeleting1(object sender, GridViewDeleteEventArgs e)
{
string id = this.GridView1.DataKeys[e.RowIndex].Value.ToString();
string sqlstr = "delete from homeReport where ID='" + id + "'";
if (bc.ExecSql(sqlstr))
{
Response.Write("<script>alert('删除信息成功!');</script>");
this.bind();
}
else
{
Response.Write("<script>alert('操作失败!');</script>");
}
bc.Closeconn();
}
//编辑
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
string id = this.GridView1.DataKeys[e.NewEditIndex].Value.ToString();
int sign;
string valsql = "select sign from homeReport where ID='" + id + "'";
sign = (int)bc.ExecCscalar(valsql);
if (sign == 0) //验证是否审核,如审核可编辑,否则不可编辑
{
//Response.Write("<script>window.open('edithomerepair.aspx?ID=" + id + "','','width=550,height=600')</script>");
Response.Redirect("edithomereport.aspx?ID=" + id + "");
Response.Write("<script>location='javascript:history.go(-1)'</script>");
}
else
{
Response.Write("<script>alert('已审核的报修记录不允许修改!');</script>");
return;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -