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

📄 addemployee.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
{
 public  static string picpath="..\\photo\\default.gif";//存放照片的地址

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Convert.ToString(Session["UID"]) == "")
        {
            Response.Redirect("login.aspx");

        }
      
    }


















   //上传图片文件
    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)
    {
        BaseClass bc = new BaseClass();
        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 = "select count(*) from employee where ID='" + id + "'";
        int count = (int)bc.ExecCscalar(sql);
        if (count > 0)
        {
            Response.Write("<script>alert('编号重复');</script>");
            return;
        }

        sql="insert into employee(ID,name,sex,job,arrage,address,tel,mobile,cardID,photoPath) values('";
        sql=sql+id+"','"+name+"',"+sex+",'"+job+"','"+arrage+"','"+address+"','"+tel+"','"+mobile+"','"+cardid+"','"+picpath+"')";

     //   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 + -