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

📄 employeeinfo.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.IO;
using System.Data.SqlClient;

public partial class Module_Employee_ProRes_EmployeeInfo : System.Web.UI.Page
{

    static string path;  //保存图片路径

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserName"] != null)
        {
            if (Session["Popedom"].ToString() == "0")
            {
                this.lnkbtnAdd.Visible = true;
            }
        }
        else
        {
            Response.Write("<script language=javascript>top.location.href='../../Index.aspx'</script>");
        }
        SqlData da = new SqlData();
        string cmdtxt = "select * from tb_User";
        this.GridView1.DataSource = da.ExceDS(cmdtxt, "tb_User");
        this.GridView1.DataBind();
        if (!IsPostBack)
        {
            string cmdtxt1 = "select Distinct DepName from tb_Department";
            SqlCommand Com = new SqlCommand(cmdtxt1, da.ExceCon());
            SqlDataReader dr = Com.ExecuteReader();
            while (dr.Read())
            {
                this.dropDept.Items.Add(dr["DepName"].ToString());
            }
            dr.Close();
        }
    }
    protected void btnFind_Click(object sender, EventArgs e)
    {
        if (this.txtKeyWord.Text == "")
        {
            Response.Write("<script language=javascript>alert('关键字不能为空!');location='EmployeeInfo.aspx'</script>");
            return;
        }

        SqlData da = new SqlData();
        string search = this.dropClass.SelectedValue;
        switch (search)
        {
            case "员工ID":
                da.BindData(this.GridView1, "Select * From tb_User Where ID  Like  '%" + this.txtKeyWord.Text + "%'", "tb_User");
                break;
            case "员工姓名":
                da.BindData(this.GridView1, "Select * From tb_User Where Name  Like  '%" + this.txtKeyWord.Text + "%'", "tb_User");
                break;
            case "员工学历":
                da.BindData(this.GridView1, "Select * From tb_User Where Learn  Like  '%" + this.txtKeyWord.Text + "%'", "tb_User");
                break;
            default:
                Response.Write("<script lanuage=javascript>alert('出错拉!');location='javascript:history.go(-1)'</script>");
                break;
        }
    }
    protected void lnkbtnAdd_Click1(object sender, EventArgs e)
    {
        this.Panel3.Visible = false;
        this.Panel1.Visible = true;
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        SqlData da = new SqlData();
        string search = this.dropClass.SelectedValue;
        switch (search)
        {
            case "员工ID":
                da.BindData(this.GridView1, "Select * From tb_User Where ID  Like  '%" + this.txtKeyWord.Text + "%'", "tb_User");
                break;
            case "员工姓名":
                da.BindData(this.GridView1, "Select * From tb_User Where Name  Like  '%" + this.txtKeyWord.Text + "%'", "tb_User");
                break;
            case "员工学历":
                da.BindData(this.GridView1, "Select * From tb_User Where Learn  Like  '%" + this.txtKeyWord.Text + "%'", "tb_User");
                break;
            default:
                Response.Write("<script lanuage=javascript>alert('出错拉!');location='javascript:history.go(-1)'</script>");
                break;
        }
    }

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

        string ss = str.Substring(str.LastIndexOf("\\") + 1);
        string s = Server.MapPath("..\\..\\Images\\Picture\\" + ss);
        path = "..\\..\\Images\\Picture\\" + ss;
        if (File.Exists(s))
        {
            Response.Write("<script language=javascript>alert('图片已经存在!')</script>");
            return;
        }
        this.FileUpload1.PostedFile.SaveAs(s);
        Image1.ImageUrl = path;
    }

    protected void btnOK_Click(object sender, EventArgs e)
    {
        SqlData da = new SqlData();
        SqlCommand Com = new SqlCommand("select * from tb_User where UserName='" + this.txtUid.Text + "'",da.ExceCon());
        SqlDataReader read = Com.ExecuteReader();
        read.Read();
        if (read.HasRows)
        {
            if (this.txtUid.Text == read["UserName"].ToString())
            {
                Response.Write("<script language=javascript>alert('对不起,该用户已经注册!');location='javascript:history.go(-1)'</script>");
                return;
            }
            if (this.txtIdenCard.Text == read["IdenCard"].ToString())
            {
                Response.Write("<script language=javascript>alert('对不起,该身份证号已经注册!');location='javascript:history.go(-1)'</script>");
                return;
            }
        }
        read.Close();
        string cmdtxt = "INSERT INTO tb_User(UserName,PassWord,Name,Sex,Birthday,Learn,Picture,DepName,Post,Address,PhoneH";
        cmdtxt += ",PhoneJ,PhoneM,IdenCard,JobTime,JobCompanyTime,NativePlace,Nation,PactStartTime,PactEndTime,IsPost,Popedom,IP,PostCard)";
        cmdtxt +=" VALUES('"+this.txtUid.Text+"','"+this.txtPwd.Text+"','"+this.txtName.Text+"','"+this.RadioButtonList1.SelectedValue+"'";
        cmdtxt += ",'"+this.txtBirthday.Text+"','"+this.txtLearn.Text+"','"+path+"','"+this.dropDept.SelectedValue+"'";
        cmdtxt += ",'"+this.txtPost.Text+"','"+this.txtAddress.Text+"','"+this.txtPhoneH.Text+"','"+this.txtPhoneJ.Text+"'";
        cmdtxt += ",'"+this.txtPhoneM.Text+"','"+this.txtIdenCard.Text+"','"+this.txtJobTime.Text+"','"+this.txtJobCompanyTime.Text+"'";
        cmdtxt += ",'"+this.txtNaPlace.Text+"','"+this.txtNation.Text+"','"+this.txtPactStart.Text+"','"+this.txtPactEnd.Text+"'";
        cmdtxt += ",'"+this.RadioButtonList2.SelectedValue+"','"+this.RadioButtonList3.SelectedIndex+"','"+Request.UserHostAddress+"','"+this.txtPostCard.Text+"')";
        if (da.ExceSQL(cmdtxt))
        {
            Response.Write("<script language=javascript>alert('操作成功!');location='EmployeeInfo.aspx'</script>");
        }
        else
        {
            Response.Write("<script language=javascript>alert('操作失败!')</script>");
        }
    }
    protected void btnVial_Click(object sender, EventArgs e)
    {
        SqlData da = new SqlData();
        SqlCommand Com = new SqlCommand("select * from tb_User where UserName='" + this.txtUid.Text + "'", da.ExceCon());
        SqlDataReader read = Com.ExecuteReader();
        read.Read();
        if (read.HasRows)
        {
            if (this.txtUid.Text == read["UserName"].ToString())
            {
                Response.Write("<script language=javascript>alert('对不起,该用户已经注册!')</script>");
            }
        }
        else
        {
            Response.Write("<script language=javascript>alert('恭喜您,该用户可以注册!')</script>");
        }
        read.Close();
    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        Response.Write("<script>this.parent.rightFrame.location='EmployeeInfo.aspx'</script>");
    }
}

⌨️ 快捷键说明

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