SGGL_SHJ/SGGL/FineUIPro.Web/HSSE/SitePerson/ReadWriteCard.aspx.cs

98 lines
3.2 KiB
C#

using BLL;
using System;
using System.Linq;
namespace FineUIPro.Web.HSSE.SitePerson
{
public partial class ReadWriteCard : PageBase
{
#region
/// <summary>
/// 人员Id
/// </summary>
public string StiePersonId
{
get
{
return (string)ViewState["StiePersonId"];
}
set
{
ViewState["StiePersonId"] = value;
}
}
#endregion
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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);
}
/// <summary>
/// 发卡
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSendCard_Click(object sender, EventArgs e)
{
try
{
var getSitePerson = SitePerson_PersonService.GetSitePersonById(this.StiePersonId);
if (getSitePerson != null)
{
SitePerson_PersonService.SendCarNobySiteperson(getSitePerson);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
ShowNotify("发卡未成功!", MessageBoxIcon.Warning);
return;
}
}
catch
{
ShowNotify("发卡未成功!", MessageBoxIcon.Warning);
return;
}
}
#region
/// <summary>
/// 验证卡号是否存在
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
}
}