protected void btndelinfo_Click(object sender, EventArgs e) { HyoaClass.Hyoa_user Hyoa_user = new HyoaClass.Hyoa_user(); HyoaClass.Hyoa_user_detail Hyoa_user_detail = new HyoaClass.Hyoa_user_detail(); String[] v_uids = this.txtuids.Value.Split(','); for (var i = 0; i < v_uids.Length; i++) { if (v_uids[i] != "") { //写删除人员系统日志start DataTable dtuser = Hyoa_user.Getuser(v_uids[i]); HyoaClass.Hyoa_log Hyoa_log = new HyoaClass.Hyoa_log(); Hyoa_log.ID = System.Guid.NewGuid().ToString(); Hyoa_log.hy_createtime = System.DateTime.Now.ToString(); string userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (userip == null || userip == "") { userip = Request.ServerVariables["REMOTE_ADDR"]; } Hyoa_log.hy_oppip = userip; Hyoa_log.hy_opptype = "删除"; Hyoa_log.hy_oppcontent = dtuser.Rows[0]["hy_username"].ToString() + "被删除"; Hyoa_log.hy_oppuserid = this.Session["hyuid"].ToString(); Hyoa_log.hy_oppusername = this.Session["hyuname"].ToString(); Hyoa_log.Insert(); //写删除人员系统日志end Hyoa_user.hy_userid = v_uids[i]; Hyoa_user.Delete(); Hyoa_user_detail.hy_userid = v_uids[i]; Hyoa_user_detail.Delete(); } } this.txtuids.Value = ""; //DataPlay(1); DataPlay(System.Int32.Parse(this.curpage.Text)); }
//保存 protected void Button_Save_Click(object sender, EventArgs e) { if (this.Session["hyuid"].ToString() == "") this.Response.Redirect("/login.aspx"); string ls_tip = "保存成功!"; //新文档时 HyoaClass.Hyoa_user Hyoa_user = new HyoaClass.Hyoa_user(); HyoaClass.Hyoa_user_detail Hyoa_user_detail = new HyoaClass.Hyoa_user_detail(); if (this.txtop.Value == "add") { //先判断这个用户是否已经存在 DataTable dtjudge = Hyoa_user.Getuser(this.txtuserid.Text); if (dtjudge.Rows.Count > 0) { Response.Write("<script>alert('该用户名已注册,请重新注册!');history.back();</script>"); return; } else { Hyoa_user.hy_userid = this.txtuserid.Text; Hyoa_user.hy_deptid = this.hy_deptid.Text; Hyoa_user.hy_username = this.txtusername.Value; Hyoa_user.hy_post = this.txtposition.Value; Hyoa_user.hy_ifleader = this.ddlifleader.SelectedValue.ToString(); Hyoa_user.hy_officetel = this.txtofficetel.Value; Hyoa_user.hy_hometel = this.txthometel.Value; Hyoa_user.hy_mobile = this.txtmobile.Value; Hyoa_user.hy_virtualnumber = this.txtvirtualtel.Value; Hyoa_user.hy_sort = System.Int32.Parse(this.txtuserno.Value); Hyoa_user.hy_isenabled = this.ddlisenabled.SelectedValue.ToString(); Hyoa_user.hy_createtime = System.DateTime.Now.ToString(); Hyoa_user.Insert(); } } else { Hyoa_user.hy_userid = this.txtuserid.Text; Hyoa_user.hy_deptid = this.hy_deptid.Text; Hyoa_user.hy_username = this.txtusername.Value; Hyoa_user.hy_post = this.txtposition.Value; Hyoa_user.hy_ifleader = this.ddlifleader.SelectedValue.ToString(); Hyoa_user.hy_officetel = this.txtofficetel.Value; Hyoa_user.hy_hometel = this.txthometel.Value; Hyoa_user.hy_mobile = this.txtmobile.Value; Hyoa_user.hy_virtualnumber = this.txtvirtualtel.Value; Hyoa_user.hy_sort = System.Int32.Parse(this.txtuserno.Value); Hyoa_user.hy_isenabled = this.ddlisenabled.SelectedValue.ToString(); Hyoa_user.Update(); } //先判断这个用户详细信息是否已经存在 DataTable dtdetail = Hyoa_user_detail.Getuserdetail(this.txtuserid.Text); if (dtdetail.Rows.Count > 0) { //更新详细信息 Hyoa_user_detail.hy_userid = this.txtuserid.Text; Hyoa_user_detail.hy_birthday = this.txtbirthday.Value; Hyoa_user_detail.hy_ifsrtx = ""; Hyoa_user_detail.hy_fjh = this.txtfjh.Value; Hyoa_user_detail.hy_xb = this.ddlxb.SelectedValue; Hyoa_user_detail.hy_zzmm = this.txtzzmm.Value; Hyoa_user_detail.hy_xl = this.txtxl.Value; Hyoa_user_detail.hy_byyx = this.txtbyyx.Value; Hyoa_user_detail.hy_jdwsj = this.txtjdwsj.Value; Hyoa_user_detail.hy_jtzz = this.txtjtzz.Value; Hyoa_user_detail.hy_sfzhm = this.txtsfzhm.Value; Hyoa_user_detail.Update(); } else { //插入详细信息 Hyoa_user_detail.hy_userid = this.txtuserid.Text; Hyoa_user_detail.hy_birthday = this.txtbirthday.Value; Hyoa_user_detail.hy_ifsrtx = ""; Hyoa_user_detail.hy_fjh = this.txtfjh.Value; Hyoa_user_detail.hy_xb = this.ddlxb.SelectedValue; Hyoa_user_detail.hy_zzmm = this.txtzzmm.Value; Hyoa_user_detail.hy_xl = this.txtxl.Value; Hyoa_user_detail.hy_byyx = this.txtbyyx.Value; Hyoa_user_detail.hy_jdwsj = this.txtjdwsj.Value; Hyoa_user_detail.hy_jtzz = this.txtjtzz.Value; Hyoa_user_detail.hy_sfzhm = this.txtsfzhm.Value; Hyoa_user_detail.Insert(); } //处理完成后的提示及跳转 if (this.txtifpop.Value == "") { Response.Write("<script>alert('" + ls_tip + "');window.location='" + this.txturl.Value + "'</script>"); } else { Response.Write("<script>alert('" + ls_tip + "');self.close();</script>"); } }
private void DataPlay() { if (this.Request.QueryString["op"] != null) { this.txtop.Value = this.Request.QueryString["op"].ToString(); //新增还是修改 //判断当前用户是否有保存的权限 HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global(); if (Hyoa_global.isHaveRole("Role9999", this.Session["hyuid"].ToString())) { this.btn_submit.Visible = true; //保存 } else { this.btn_submit.Visible = false; //保存 } //新文档 if (this.Request.QueryString["op"] == "add") { if (this.hy_deptid.Text != "") { //根据部门ID得到部门名称 HyoaClass.Hyoa_dept Hyoa_dept = new HyoaClass.Hyoa_dept(); DataTable dtdept = Hyoa_dept.Getdept(this.hy_deptid.Text); if (dtdept.Rows.Count > 0) this.hy_deptname.Text = dtdept.Rows[0]["hy_deptname"].ToString(); this.ddlifleader.Items.Insert(0, "否"); this.ddlifleader.Items.Insert(1, "是"); this.ddlisenabled.Items.Insert(0, "是"); this.ddlisenabled.Items.Insert(1, "否"); this.ddlxb.Items.Insert(0, "--请选择--"); this.ddlxb.Items.Insert(1, "男"); this.ddlxb.Items.Insert(2, "女"); dtdept.Clear(); } } //旧文档 if (this.Request.QueryString["op"] == "modify") { if (this.Request.QueryString["userid"] != null) { this.ddlifleader.Items.Insert(0, "否"); this.ddlifleader.Items.Insert(1, "是"); this.ddlisenabled.Items.Insert(0, "是"); this.ddlisenabled.Items.Insert(1, "否"); this.ddlxb.Items.Insert(0, "--请选择--"); this.ddlxb.Items.Insert(1, "男"); this.ddlxb.Items.Insert(2, "女"); //根据用户ID得到信息 this.txtuserid.Text = this.Request.QueryString["userid"].ToString(); HyoaClass.Hyoa_user Hyoa_user = new HyoaClass.Hyoa_user(); HyoaClass.Hyoa_user_detail Hyoa_user_detail = new HyoaClass.Hyoa_user_detail(); DataTable dtuser = Hyoa_user.Getuserallinfo(this.txtuserid.Text); if (dtuser.Rows.Count > 0) { this.txtusername.Value = dtuser.Rows[0]["hy_username"].ToString(); this.hy_deptid.Text = dtuser.Rows[0]["hy_deptid"].ToString(); this.hy_deptname.Text = dtuser.Rows[0]["hy_deptname"].ToString(); this.txtposition.Value = dtuser.Rows[0]["hy_post"].ToString(); if (dtuser.Rows[0]["hy_ifleader"].ToString() == "是") this.ddlifleader.SelectedIndex = 1; else this.ddlifleader.SelectedIndex = 0; this.txtofficetel.Value = dtuser.Rows[0]["hy_officetel"].ToString(); this.txthometel.Value = dtuser.Rows[0]["hy_hometel"].ToString(); this.txtmobile.Value = dtuser.Rows[0]["hy_mobile"].ToString(); this.txtvirtualtel.Value = dtuser.Rows[0]["hy_virtualnumber"].ToString(); this.txtuserno.Value = dtuser.Rows[0]["hy_sort"].ToString(); if (dtuser.Rows[0]["hy_isenabled"].ToString() == "是") this.ddlisenabled.SelectedIndex = 0; else this.ddlisenabled.SelectedIndex = 1; DataTable dtdetail = Hyoa_user_detail.Getuserdetail(this.txtuserid.Text); if (dtdetail.Rows.Count > 0) { this.txtbirthday.Value = System.DateTime.Parse(dtdetail.Rows[0]["hy_birthday"].ToString()).ToString("yyyy-MM-dd"); this.txtfjh.Value = dtdetail.Rows[0]["hy_fjh"].ToString(); this.ddlxb.SelectedValue = dtdetail.Rows[0]["hy_xb"].ToString(); this.txtzzmm.Value = dtdetail.Rows[0]["hy_zzmm"].ToString(); this.txtxl.Value = dtdetail.Rows[0]["hy_xl"].ToString(); this.txtbyyx.Value = dtdetail.Rows[0]["hy_byyx"].ToString(); if (dtdetail.Rows[0]["hy_jdwsj"].ToString() != "" && dtdetail.Rows[0]["hy_jdwsj"].ToString() != null && dtdetail.Rows[0]["hy_jdwsj"].ToString() != "1900-01-01") this.txtjdwsj.Value = System.DateTime.Parse(dtdetail.Rows[0]["hy_jdwsj"].ToString()).ToShortDateString(); this.txtjtzz.Value = dtdetail.Rows[0]["hy_jtzz"].ToString(); this.txtsfzhm.Value = dtdetail.Rows[0]["hy_sfzhm"].ToString(); } if (Hyoa_global.isHaveRole("Role9999", this.Session["hyuid"].ToString())) { } else { this.txtsfzhm.Value = "您无权查看,如有需要请联系管理员!"; } } dtuser.Clear(); this.txtuserid.Enabled = false; } } } }