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

📄 edithomehold.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_Default2 : System.Web.UI.Page
{
    BaseClass bc = new BaseClass();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Convert.ToString(Session["UID"]) == "")
        {
            Response.Redirect("login.aspx");

        }

        if (!IsPostBack)
        {
            this.bind();
        }
    }
    protected void bind()
    {
        string sql = "select ownerID from room where code='" + Request.QueryString["code"]+ "'";
      

        SqlDataReader sdr = bc.ExecRead(sql);
        if (sdr.Read())
        {
            codeName.Text = sdr["ownerID"].ToString();

            sdr.Close();//关闭数据库连接

        }
      
        else
        {
            Response.Write("<script>alert('数据加载失败,请重试!');</script>");
            return;
        }
    }




    //
    protected void Button1_Click(object sender, EventArgs e)
    {
     string sql = "select count(code) from room where ownerID='" + codeName.Text.Trim() + "'";
      int count=(int)bc.ExecCscalar(sql);
        if (count>0)
        {
            string strsql = "select * from homehold where Code in(select Code from room where ownerID='" + codeName.Text.Trim() + "')";

            //Response.Write(strsql);
            //Response.End();
            SqlDataReader sdr = bc.ExecRead(strsql);
            if (sdr.Read())
            {
                txtname.Text = sdr["Name"].ToString();//姓名
                txttel.Text = sdr["tel"].ToString();//电话
                txtroomID.Text = sdr["roomID"].ToString();
                txtcardid.Text = sdr["cardID"].ToString();//身份证
                txtcontact.Text = sdr["contact"].ToString();//联系地址
                txtmobile.Text = sdr["mobile"].ToString();//手机
                txtemail.Text = sdr["Email"].ToString();//电子邮件
                txtunit.Text = sdr["unit"].ToString();//单位
                txtuid.Text = sdr["uid"].ToString();//用户名
                txtpwd.Text = sdr["password"].ToString();//密码
                txtmemo.Text = sdr["memo"].ToString();//备注
            }
            else
            {
              
                txtname.Text = "";
                txttel.Text = "";
                txtroomID.Text = "";
                txtcardid.Text = "";
                txtcontact.Text = "";
                txtmobile.Text = "";
                txtemail.Text = "";
                txtunit.Text = "";
                txtuid.Text = "";
                txtpwd.Text = "";
                txtmemo.Text = "";
                Response.Write("<script>alert('该单元还没有住户!');</script>");
               

 
            }
        
            
        }
        else
        {
            Response.Write("<script>alert('该单元不存在!');</script>");
        }
    }



    //
    protected void Button2_Click(object sender, EventArgs e)
    {
        string name=txtname.Text.Trim();
        string tel=txttel.Text.Trim();
        string roomID=txtroomID.Text.Trim();
        string cardid=txtcardid.Text.Trim();
        string contact=txtcontact.Text.Trim();
        string mobile=txtmobile.Text.Trim();
        string email=txtemail.Text.Trim();
        string unit=txtunit.Text.Trim();
        string meme=txtmemo.Text.Trim();
        string uid,pwd;
        if(txtuid.Text=="")
        {
            uid=txtcardid.Text.Trim();
        }
        else
        {
            uid=txtuid.Text.Trim();
        }
        
        if(txtpwd.Text=="")
        {
            pwd=txtpwd.Text.Trim();

        }
        else
        {
            pwd=txtpwd.Text.Trim();
        }

       



      string code="";
      string sql = "select Code from room where ownerID='" + codeName.Text.Trim() + "'";
      //Response.Write(sql);
      //Response.End();
     
        SqlDataReader sdr = bc.ExecRead(sql);
        if (sdr.Read())
        {
            code = sdr["Code"].ToString();

            sdr.Close();//关闭数据库连接

            string varuser = "select Count(*) from homehold where uid='" + uid + "' and code!='"+code+"'";
          //  Response.Write(varuser);
          //  Response.End();
            int count = (int)bc.ExecCscalar(varuser);
            if (count > 0)
            {
                Response.Write("<script>alert('登录用户名重复,请选择其它用户名!');</script>");

                return;
            }


           
                sql = "update homehold set Name='" + name + "',tel='" + tel + "',contact='" + contact;
                sql = sql + "',mobile='" + mobile + "',Email='" + email + "',cardID='" + cardid +"',roomID='"+roomID+ "',unit='" + unit;
                sql = sql + "',password='" + pwd + "',uid='" + uid + "',memo='" + meme + "' where Code='" + code + "'";
                //Response.Write(sql);
                //Response.End();


           

            if (bc.ExecSql(sql))
            {
                Response.Write("<script>alert('数据保存成功!');location='homehold.aspx'</script>");

            }
            else
            {
                Response.Write("<script>alert('数据保存失败!');</script>");

                return;

            }







        }
        else
        {
            Response.Write("<script>alert('该单元不存在,无法保存数据!');</script>");
            return;
        }
       

        
    }
}

⌨️ 快捷键说明

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