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

📄 editemployee.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;
using System.IO;

public partial class admin_Default2 : System.Web.UI.Page
{
    BaseClass bc = new BaseClass();
  public static string picpath;//存放照片的地址

    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 id = Request.QueryString["ID"].ToString();
        string sqlstr = "select * from employee where ID='" + id + "'";
        try
        {
            SqlDataReader sda = bc.ExecRead(sqlstr);
            if (sda.Read())
            {
                ID.Text = id;
                Name.Text = sda["Name"].ToString();
                SEX.Text = sda["sex"].ToString();
                Job.Text = sda["job"].ToString();
                Arrage.Text = sda["arrage"].ToString();
                Address.Text = sda["address"].ToString();
                TEL.Text = sda["tel"].ToString();
                Mobile.Text = sda["mobile"].ToString();
                CardID.Text = sda["cardID"].ToString();
                Image1.ImageUrl = sda["photoPath"].ToString();
                picpath = sda["photoPath"].ToString();
                //Response.Write(sda["photoPath"].ToString());
                //Response.End();
            }
            else
            {
                Response.Write("<script>alert('数据读取错误,请重试!');</script>");
                return;
            }
        }
        catch (Exception ex)
        {
            Response.Write("系统出错,出错原因:"+ex.Message);
            return;
        }
    }
















   //上传图片文件
    protected void Button3_Click(object sender, EventArgs e)
    {
       string str= this.FileUpload1.PostedFile.FileName;
       if (str == "")
       {
           Response.Write("<script>alert('请选择图片!');</script>");
           return;
       }

         string name=str.Substring(str.LastIndexOf("\\")+1);
         string path=Server.MapPath("..\\photo\\")+name;//获得图片上传到系统之后的物理路径
           picpath = "..\\photo\\" + name;//存放到数据库的图片路径
          
        //Response.Write(path);
        //Response.End();
    if(File.Exists(path))
    {
        Response.Write("<script>alert('图片已存在,请选择其它图片!');</script>");
           return;
    }
    this.FileUpload1.SaveAs(path);
    Image1.Visible = true;
    Image1.ImageUrl = picpath;
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        
       
        string id = ID.Text;
        string name = Name.Text;
        string sex = SEX.SelectedValue.ToString();
        string job = Job.Text;
        string arrage=Arrage .Text;
        string cardid = CardID.Text;
        string address = Address.Text;
        string mobile = Mobile.Text;
        string tel = TEL.Text;


        string sql = "update employee set ID='" + id + ",Name='" + name + "',sex=" + sex + ",job='" + job + "',arrage='" + arrage + "',cardID='" + cardid + "',address='";
        sql = sql + address + "',mobile='" + mobile + "',tel='" + tel + "',photoPath='" + picpath+"'"+" where ID="+id+"";
        //Response.Write(sql);
        //Response.End();

        if (bc.ExecSql(sql))
        {
            Response.Write("<script language=javascript>alert('更新物业管理人员成功!');location='employee.aspx'</script>");
        }
        else
        {
            Response.Write("<script>alert('编辑失败,请重试!');</script>");
        }

        
        
    }
   
}

⌨️ 快捷键说明

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