protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { Maticsoft.Model.Operator oauser = (Maticsoft.Model.Operator)Session["user"]; if (oauser == null) { Response.Write(string.Format("<script>alert('登录超时!');window.top.location.href='login.aspx'</script>")); } else { Model.Staffmember st = sf.GetModel(Convert.ToInt32(oauser.StaffmemberID)); this.Label1.Text = st.Staffname; this.Label2.Text = Convert.ToString(System.DateTime.Now.ToString("yyyy 年 MM 月 dd 日")); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>"); } } } catch (Exception) { Response.Write("<script>alert('页面异常')</script>"); } }
/// <summary> /// 添加职员(确定按钮) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ImageButton1_Click(object sender, EventArgs e) { try { if (TextBox1.Text.Trim() != "") { if (DropDownList1.Text != "0") { if (DropDownList2.Text != "0") { Maticsoft.Model.Staffmember zhiyuan = new Model.Staffmember(); zhiyuan.Staffname = TextBox1.Text; zhiyuan.information = TextBox6.Text; zhiyuan.departmentID = Convert.ToInt32(DropDownList1.Text); zhiyuan.Positionid = Convert.ToInt32(DropDownList2.Text); zhiyuan.BY1 = 1; zhiyuan.Beizhu = TextBox2.Text; int a = st.Add(zhiyuan); if (a > 0) { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('添加成功!');</script>"); bind(sql); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('添加失败!');</script>"); bind(sql); } } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('没选择职务!');</script>"); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>"); } } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('没选择部门!');</script>"); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>"); } } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('职员名称不能为空!');</script>"); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>"); } } catch (Exception ee) { //Response.Write("<script>alert('确定异常 " + ee.Message + "')</script>"); ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('确定异常 " + ee.Message + "');</script>"); } }
/// <summary> /// 删除(验证该部门有职员绑定无法删除) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton2_Click(object sender, EventArgs e) { try { //获取button 控件 LinkButton lb = (LinkButton)sender; //获取传过来的commwntid int id = Convert.ToInt32(lb.CommandArgument); DataSet dwq = ot.GetList(" StaffmemberID like '" + id + "' or UserTabID like '" + id + "'"); if (dwq.Tables[0].Rows.Count > 0) { Model.Staffmember zhiyuan = st.GetModel(id); zhiyuan.BY1 = 0; bool b = st.Update(zhiyuan); if (b == true) { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('停用成功!');</script>"); bind(sql); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('停用失败!');</script>"); bind(sql); } } else { bool a = st.Delete(id); if (a == true) { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('删除成功!');</script>"); bind(sql); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('删除失败!');</script>"); bind(sql); } } } catch (Exception ee) { //Response.Write("<script>alert('确定异常 " + ee.Message + "')</script>"); ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('删除异常 " + ee.Message + "');</script>"); } }
/// <summary> /// 修改弹窗赋值 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton1_Click(object sender, EventArgs e) { try { //获取button 控件 LinkButton lb = (LinkButton)sender; //获取传过来的commwntid int id = Convert.ToInt32(lb.CommandArgument); Model.Staffmember po = st.GetModel(id); Label1.Text = po.id.ToString(); TextBox4.Text = po.Staffname; TextBox5.Text = po.information; DropDownList3.Text = po.departmentID.ToString(); DropDownList4.Text = po.Positionid.ToString(); TextBox7.Text = po.Beizhu; ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv2();</script>"); } catch (Exception ee) { //Response.Write("<script>alert('确定异常 " + ee.Message + "')</script>"); ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('修改弹窗异常 " + ee.Message + "');</script>"); } }