using BLL; using System; using System.Linq; namespace FineUIPro.Web.HSSE.SitePerson { public partial class ReadWriteCard : PageBase { #region 定义项 /// /// 人员Id /// public string StiePersonId { get { return (string)ViewState["StiePersonId"]; } set { ViewState["StiePersonId"] = value; } } #endregion /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.StiePersonId = Request.Params["PersonId"]; if (!string.IsNullOrEmpty(this.StiePersonId)) { var person = BLL.SitePerson_PersonService.GetSitePersonById(this.StiePersonId); if (person != null) { this.txtPersonName.Text = person.PersonName; this.txtUnitName.Text = BLL.UnitService.GetUnitNameByUnitId(person.UnitId); this.txtCardNo.Text = person.CardNo; } } } //this.SetDefaltButton(this.txtCardNo, this.TextBox2); } /// /// 发卡 /// /// /// protected void btnSendCard_Click(object sender, EventArgs e) { try { SitePerson_PersonService.SendCarNobySiteperson(this.StiePersonId); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } catch { ShowNotify("发卡未成功!", MessageBoxIcon.Warning); return; } } #region 验证卡号是否存在 /// /// 验证卡号是否存在 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtCardNo.Text)) { var q = Funs.DB.SitePerson_Person.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.CardNo == this.txtCardNo.Text.Trim() && (x.PersonId != this.StiePersonId || (this.StiePersonId == null && x.PersonId != null))); if (q != null) { ShowNotify("输入的卡号已存在!", MessageBoxIcon.Warning); } } } #endregion } }