📄 add_staff.aspx.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;
public partial class add_staff : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Session["uname"].ToString() != null && Session["role"].ToString() == "1")
{
if (!IsPostBack)
{
position p = new position();
this.dropdepartment.DataSource = p.band_department();
dropdepartment.DataTextField = "d_name";
dropdepartment.DataValueField = "d_id";
dropdepartment.DataBind();
this.btn_add.Enabled = false;
}
}
}
catch
{
Response.Redirect("login.aspx");
}
}
protected void dropdepartment_SelectedIndexChanged(object sender, EventArgs e)
{
int d_id = Convert.ToInt32(dropdepartment.SelectedValue);
position p = new position();
this.dropposition.DataSource = p.select_position(d_id);
this.dropposition.DataTextField = "p_name";
this.dropposition.DataValueField = "p_id";
this.dropposition.DataBind();
int a = Convert.ToInt32(dropposition.Items.Count);
if (a > 0)
{
btn_add.Enabled = true;
}
else
{
btn_add.Enabled = false;
}
}
protected void btn_add_Click(object sender, EventArgs e)
{
ArrayList arr = new ArrayList();
arr.Add(this.tname.Text.Trim().ToString());
arr.Add(this.radio_sex.SelectedValue.ToString());
arr.Add(this.tnation.Text.Trim().ToString());
arr.Add(this.tbirthday.Text.Trim().ToString());
arr.Add(this.tschool.Text.Trim().ToString());
arr.Add(this.tcollage.Text.Trim().ToString());
string phone = tqnum.Text.ToString() + "-" + tphone.Text.ToString();
arr.Add(phone);
arr.Add(this.tmobile.Text.Trim().ToString());
arr.Add(this.tmail.Text.Trim().ToString());
arr.Add(this.dropdepartment.SelectedItem.Text.ToString());
arr.Add(this.dropdepartment.SelectedValue.ToString());
arr.Add(this.dropposition.SelectedItem.Text.ToString());
arr.Add(this.dropposition.SelectedValue.ToString());
arr.Add(Convert.ToDateTime(DateTime.Now.ToShortDateString()));
string password=FormsAuthentication.HashPasswordForStoringInConfigFile("123456","MD5");
arr.Add(password);
staff s = new staff();
int staff_id=s.Addstaff(arr);
Response.Write("<script>alert('员工信息添加成功,员工号为:"+staff_id+"')</script>");
}
protected void btn_cancel_Click(object sender, EventArgs e)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -