⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fixrepair.aspx.cs

📁 物业管理系统
💻 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
{
    public static string sql = "";
    BaseClass bc = new BaseClass();
    stringoperator stroper = new stringoperator();
     protected void Page_Load(object sender, EventArgs e)
    {
            if (Convert.ToString(Session["UID"]) == "")
            {
                Response.Redirect("login.aspx");

            }
            if (!IsPostBack)
            {
               
                this.bind();
            }
            
                
           

        
        
    }

    public void bind()
    {
       
        string strsql = "SELECT * FROM dbo.fixManager INNER JOIN dbo.fixRepair ON dbo.fixManager.fixID = dbo.fixRepair.fixID "+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[5].Text == "0")
            {
                e.Row.Cells[5].Text ="<Font color=blue> 未付款</font>";
                

            }
            else
            {
                e.Row.Cells[5].Text = "<font color=red>已付款</font>";
                ((Button)(e.Row.Cells[8].Controls[0])).Enabled = false;
            }
           // Response.Write();
           // Response.End();
            ((LinkButton)(e.Row.Cells[0].Controls[0])).Attributes.Add("onclick", "window.open('editfix.aspx?fixID=" + ((LinkButton)(e.Row.Cells[0].Controls[0])).Text + "','','width=450,height=450,scrollbars=yes')");
            ((LinkButton)(e.Row.Cells[9].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 fixrepair 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.Write("<script>window.open('editfixrepair.aspx?ID=" + id + "','','width=550,height=600')</script>");
        Response.Write("<script>location='javascript:history.go(-1)'</script>");
    }
  

    protected void GridView_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 fixrepair 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";
        }
        else
        {
            sign = "0";
        }
        scd.CommandText = "update fixrepair set sign=" + sign + " where ID=" + id;
        //Response.Write(sign);
        //Response.End();
        scd.ExecuteNonQuery();
        this.bind();
        conn.Close();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        sql = "";
        this.bind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Hashtable htabel = new Hashtable();
        if (CheckBox1.Checked)
        {
            htabel.Add("name", TextBox1.Text);
            // Response.Write(htabel["unitName"].GetType().ToString());
            //  Response.End();

        }
        if (CheckBox2.Checked)
        {
            htabel.Add("mainHead", TextBox2.Text);

        }
        if (CheckBox3.Checked)
        {
            htabel.Add("repairUnit", TextBox3.Text);
        }
        if (CheckBox4.Checked)
        {
            if (TextBox4.Text.Trim()=="")
            {
                Response.Write("<script>alert('费用不能为空!');</script>");
                return;
                
            }
            htabel.Add("repairSum",Convert.ToInt32(TextBox4.Text));
        }
        if (CheckBox5.Checked)
        {
            htabel.Add("sign", Convert.ToInt32(DropDownList1.SelectedValue));
        }
        if (CheckBox6.Checked)
        {
            sql = stroper.GetConditionClause(htabel, true);
        }
        else
        {
            sql = stroper.GetConditionClause(htabel, false);
        }

       //  Response.Write(sql);
       //  Response.End();
        this.bind();

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -