using BLL; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.BoSheng { public partial class BoPersonEdit : PageBase { #region 定义项 /// /// 主键 /// private string Id { get { return (string)ViewState["Id"]; } set { ViewState["Id"] = value; } } #endregion /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.Id = Request.Params["id"]; if (!string.IsNullOrEmpty(this.Id)) { Model.Bo_Sheng_Person person = BLL.BOSHENGService.GetBoPersonById(this.Id); if (person != null) { this.txtName.Text = person.Name; this.txtDepartName.Text = person.DepartName; this.txtIdentifyID.Text = person.IdentifyID; this.rblSex.SelectedValue = person.Sex; this.txtBirthDay.Text = person.BirthDay.HasValue ? string.Format("{0:yyyy-MM-dd}", person.BirthDay) : ""; this.txtStation.Text = person.Station; this.txtAddress.Text = person.Address; this.txtPolice.Text = person.Police; this.txtValidPeriodStart.Text = string.Format("{0:yyyy-MM-dd}", person.ValidPeriodStart); this.txtValidPeriodEnd.Text = string.Format("{0:yyyy-MM-dd}", person.ValidPeriodEnd); this.txtTelephone.Text = person.Telephone; this.txtJobNumber.Text = person.JobNumber; this.txtNewAddress.Text = person.NewAddress; this.txtRegisterDate.Text = person.RegisterDate.HasValue ? string.Format("{0:yyyy-MM-dd HH:mm:ss}", person.RegisterDate) : ""; this.txtCategoryLevel.Text = person.CategoryLevel; this.txtEntranceDate.Text = person.EntranceDate.HasValue ? string.Format("{0:yyyy-MM-dd HH:mm:ss}", person.EntranceDate) : ""; this.txtLeaveDate.Text = person.LeaveDate.HasValue ? string.Format("{0:yyyy-MM-dd hh:mm:ss}", person.LeaveDate) : ""; if (person.IsOut == "1") { this.cbIsOutName.Checked = true; } if (person.IsBlackList == "1") { this.cbIsBlackListName.Checked = true; } this.txtUploadTime.Text = person.UploadTime.HasValue ? string.Format("{0:yyyy-MM-dd HH:mm:ss}", person.UploadTime) : ""; } } } } /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { Model.Bo_Sheng_Person person = BLL.BOSHENGService.GetBoPersonById(this.Id); if (person != null) { person.ID = this.Id; person.Name = this.txtName.Text.Trim(); person.DepartName = this.txtDepartName.Text.Trim(); person.IdentifyID = this.txtIdentifyID.Text.Trim(); person.Sex = this.rblSex.SelectedValue; person.BirthDay = Funs.GetNewDateTime(this.txtBirthDay.Text.Trim()); person.Station = this.txtStation.Text.Trim(); person.Address = this.txtAddress.Text.Trim(); person.Police = this.txtPolice.Text.Trim(); person.ValidPeriodStart =this.txtValidPeriodStart.Text.Trim(); person.ValidPeriodEnd = this.txtValidPeriodEnd.Text.Trim(); person.Telephone = this.txtTelephone.Text.Trim(); person.JobNumber = this.txtJobNumber.Text.Trim(); person.NewAddress = this.txtNewAddress.Text.Trim(); if (!string.IsNullOrEmpty(this.txtRegisterDate.Text)) { person.RegisterDate = Convert.ToDateTime(this.txtRegisterDate.Text); } person.CategoryLevel = this.txtCategoryLevel.Text.Trim(); if (!string.IsNullOrEmpty(this.txtEntranceDate.Text)) { person.EntranceDate = Convert.ToDateTime(this.txtEntranceDate.Text); } if (!string.IsNullOrEmpty(this.txtLeaveDate.Text)) { person.LeaveDate = Convert.ToDateTime(this.txtLeaveDate.Text); } person.IsOut = this.cbIsOutName.Checked? "1" : "0"; person.IsBlackList = this.cbIsBlackListName.Checked ? "1" : "0"; if (!string.IsNullOrEmpty(this.txtUploadTime.Text)) { person.UploadTime = Convert.ToDateTime(this.txtUploadTime.Text); } BLL.BOSHENGService.UpdateBoPerson(person); ShowNotify("修改成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } } }