191 lines
		
	
	
		
			7.7 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			191 lines
		
	
	
		
			7.7 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Web;
 | |
| using System.Web.UI;
 | |
| using System.Web.UI.WebControls;
 | |
| using BLL;
 | |
| using FineUIPro.Web.Comprehensive;
 | |
| 
 | |
| namespace FineUIPro.Web.ZHGL.Person
 | |
| {
 | |
|     public partial class CompanyPersonEdit : PageBase
 | |
|     {
 | |
|         #region 定义项
 | |
|         /// <summary>
 | |
|         /// 用户主键
 | |
|         /// </summary>
 | |
|         public string CompanyBranchPersonId
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 return (string)ViewState["CompanyBranchPersonId"];
 | |
|             }
 | |
|             set
 | |
|             {
 | |
|                 ViewState["CompanyBranchPersonId"] = value;
 | |
|             }
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 单位主键
 | |
|         /// </summary>
 | |
|         public string UnitId
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 return (string)ViewState["UnitId"];
 | |
|             }
 | |
|             set
 | |
|             {
 | |
|                 ViewState["UnitId"] = value;
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 用户编辑页面
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Page_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             if (!IsPostBack)
 | |
|             {
 | |
|                 this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
 | |
|                 string type = Request.Params["type"];
 | |
|                 ///权限
 | |
|                 this.GetButtonPower();
 | |
|                 this.CompanyBranchPersonId = Request.Params["CompanyBranchPersonId"];
 | |
|                 WorkPostService.InitWorkPostDropDownList(this.drpWorkPost, true);
 | |
|                 if (!string.IsNullOrEmpty(this.CompanyBranchPersonId))
 | |
|                 {
 | |
|                     var CompanyBranchPerson = BLL.CompanyBranchPersonService.GetCompanyBranchPersonById(this.CompanyBranchPersonId);
 | |
|                     if (CompanyBranchPerson != null)
 | |
|                     {
 | |
|                         this.hdCompanyBranchPersonId.Text = this.CompanyBranchPersonId;
 | |
|                         this.txtPersonName.Text = CompanyBranchPerson.PersonName;
 | |
|                         if (!string.IsNullOrEmpty(CompanyBranchPerson.Sex))
 | |
|                         {
 | |
|                             this.rblSex.SelectedValue = CompanyBranchPerson.Sex;
 | |
|                         }
 | |
|                         this.txtIdentityCard.Text = CompanyBranchPerson.IdentityCard;
 | |
|                         if (!string.IsNullOrEmpty(CompanyBranchPerson.WorkPostId))
 | |
|                         {
 | |
|                             this.drpWorkPost.SelectedValue = CompanyBranchPerson.WorkPostId;
 | |
|                         }
 | |
|                         this.txtTelephone.Text = CompanyBranchPerson.Telephone;
 | |
|                         this.txtAddress.Text = CompanyBranchPerson.Address;
 | |
|                         if (CompanyBranchPerson.IsOnJob == true)
 | |
|                         {
 | |
|                             this.rblIsOnJob.SelectedValue = "True";
 | |
|                         }
 | |
|                         else
 | |
|                         {
 | |
|                             this.rblIsOnJob.SelectedValue = "False";
 | |
|                         }
 | |
|                         this.txtRemark.Text = CompanyBranchPerson.Remark;
 | |
|                         this.txtSortIndex.Text = CompanyBranchPerson.SortIndex.HasValue ? CompanyBranchPerson.SortIndex.ToString() : "";
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 保存按钮
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnSave_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (this.drpWorkPost.SelectedValue == Const._Null)
 | |
|             {
 | |
|                 Alert.ShowInParent("请选择岗位!", MessageBoxIcon.Warning);
 | |
|                 return;
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(this.txtIdentityCard.Text) && BLL.CompanyBranchPersonService.IsExistPersonIdentityCard(this.CompanyBranchPersonId, this.txtIdentityCard.Text.Trim()) == true)
 | |
|             {
 | |
|                 Alert.ShowInParent("输入的身份证号码已存在!", MessageBoxIcon.Warning);
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             Model.Person_CompanyBranchPerson newCompanyBranchPerson = new Model.Person_CompanyBranchPerson
 | |
|             {
 | |
|                 PersonName = this.txtPersonName.Text.Trim(),
 | |
|                 Sex = this.rblSex.SelectedValue,
 | |
|                 IdentityCard = this.txtIdentityCard.Text.Trim(),
 | |
|                 Telephone = this.txtTelephone.Text.Trim(),
 | |
|                 Address = this.txtAddress.Text.Trim(),
 | |
|                 IsOnJob = Convert.ToBoolean(this.rblIsOnJob.SelectedValue),
 | |
|                 Remark = this.txtRemark.Text.Trim()
 | |
|             };
 | |
|             newCompanyBranchPerson.SortIndex = Funs.GetNewInt(this.txtSortIndex.Text.Trim());
 | |
|             if (this.drpWorkPost.SelectedValue != Const._Null)
 | |
|             {
 | |
|                 newCompanyBranchPerson.WorkPostId = this.drpWorkPost.SelectedValue;
 | |
|             }
 | |
|             newCompanyBranchPerson.UnitId = BLL.Const.UnitId_CWCEC;
 | |
|             if (string.IsNullOrEmpty(this.CompanyBranchPersonId))
 | |
|             {
 | |
|                 if (string.IsNullOrEmpty(this.hdCompanyBranchPersonId.Text))
 | |
|                 {
 | |
|                     newCompanyBranchPerson.CompanyBranchPersonId = SQLHelper.GetNewID(typeof(Model.Person_CompanyBranchPerson));
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     newCompanyBranchPerson.CompanyBranchPersonId = this.hdCompanyBranchPersonId.Text;
 | |
|                 }
 | |
|                 CompanyBranchPersonService.AddCompanyBranchPerson(newCompanyBranchPerson);
 | |
|                 LogService.AddSys_Log(this.CurrUser, newCompanyBranchPerson.PersonName, newCompanyBranchPerson.CompanyBranchPersonId, BLL.Const.CompanyPersonMenuId, BLL.Const.BtnAdd);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 newCompanyBranchPerson.CompanyBranchPersonId = this.CompanyBranchPersonId;
 | |
|                 CompanyBranchPersonService.UpdateCompanyBranchPerson(newCompanyBranchPerson);
 | |
|                 LogService.AddSys_Log(this.CurrUser, newCompanyBranchPerson.PersonName, newCompanyBranchPerson.CompanyBranchPersonId, BLL.Const.CompanyPersonMenuId, BLL.Const.BtnModify);
 | |
|             }
 | |
|             PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
 | |
|         }
 | |
| 
 | |
|         #region 获取按钮权限
 | |
|         /// <summary>
 | |
|         /// 获取按钮权限
 | |
|         /// </summary>
 | |
|         /// <param name="button"></param>
 | |
|         /// <returns></returns>
 | |
|         private void GetButtonPower()
 | |
|         {
 | |
|             if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
 | |
|             {
 | |
|                 this.btnSave.Hidden = false;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.CompanyPersonMenuId);
 | |
|                 if (buttonList.Count() > 0)
 | |
|                 {
 | |
|                     if (buttonList.Contains(BLL.Const.BtnSave))
 | |
|                     {
 | |
|                         this.btnSave.Hidden = false;
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 附件上传
 | |
|         /// <summary>
 | |
|         /// 上传附件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnAttachUrl_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (string.IsNullOrEmpty(this.hdCompanyBranchPersonId.Text))
 | |
|             {
 | |
|                 this.hdCompanyBranchPersonId.Text = SQLHelper.GetNewID();
 | |
|             }
 | |
|             PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CompanyPersonAttachUrl&menuId={1}", this.hdCompanyBranchPersonId.Text, BLL.Const.CompanyPersonMenuId)));
 | |
|         }
 | |
|         #endregion
 | |
|     }
 | |
| } |