347 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			347 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C#
		
	
	
	
| 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.SubPackManage
 | |
| {
 | |
|     public partial class SubPackPersonnelRegistrationEdit : PageBase
 | |
|     {
 | |
|         /// <summary>
 | |
|         /// 主键
 | |
|         /// </summary>
 | |
|         public string SubPackPersonnelID
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 return (string)ViewState["SubPackPersonnelID"];
 | |
|             }
 | |
|             set
 | |
|             {
 | |
|                 ViewState["SubPackPersonnelID"] = value;
 | |
|             }
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 所属项目
 | |
|         /// </summary>
 | |
|         public string ProjectId
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 return (string)ViewState["ProjectId"];
 | |
|             }
 | |
|             set
 | |
|             {
 | |
|                 ViewState["ProjectId"] = value;
 | |
|             }
 | |
|         }
 | |
|         protected void Page_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             if (!IsPostBack)
 | |
|             {
 | |
|                 this.ProjectId = this.CurrUser.LoginProjectId;
 | |
|                 this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
 | |
|                 GetButtonPower();
 | |
|                 BLL.BaseBranchTeamListTeamService.DropSelectUnitWork(drpUnit, this.ProjectId, true);
 | |
|                 drpUnit.SelectedValue = Const._Null;
 | |
| 
 | |
|                 this.SubPackPersonnelID = Request.Params["SubPackPersonnelID"];
 | |
|                 string _unitWorkId = Request.Params["UnitWorkId"];
 | |
|                 string _teamListId = Request.Params["teamListId"];
 | |
|                 string _laborTeamId = Request.Params["laborTeamId"];
 | |
| 
 | |
| 
 | |
|                 var subPackPersonnel = Funs.DB.SubPack_SubPackPersonnel.FirstOrDefault(p => p.SubPackPersonnelID == this.SubPackPersonnelID);
 | |
|                 if (subPackPersonnel != null)
 | |
|                 {
 | |
|                     drpUnit.SelectedValue = subPackPersonnel.UnitId;
 | |
|                     //修改的时候下拉框加载全部劳务公司 为了修改以前的数据在下拉框中找到
 | |
|                     BLL.SubPackTeamListService.DropSelectTeamWorkUpdate(drpBranchTeamList, drpUnit.SelectedValue, this.ProjectId, true);
 | |
|                     drpBranchTeamList.SelectedValue = subPackPersonnel.BranchTeamListId;
 | |
|                     //劳务队伍
 | |
|                     BLL.SubPackLaborTeamService.DropSelectLaborTeamUpdate(drpLaborTeam, subPackPersonnel.UnitId, subPackPersonnel.BranchTeamListId, this.ProjectId, true);
 | |
|                     drpLaborTeam.SelectedValue = subPackPersonnel.LaborTeamId;
 | |
|                     //修改的时候下拉框加载全部劳务班组 为了修改以前的数据在下拉框中找到
 | |
|                     BLL.SubPackSubPackPersonnelService.DropSelectTeamUpdate(drpTeam, subPackPersonnel.UnitId, subPackPersonnel.BranchTeamListId, subPackPersonnel.LaborTeamId, this.ProjectId, true);
 | |
|                     drpTeam.SelectedValue = subPackPersonnel.BranchTeamListTeamId;
 | |
| 
 | |
|                     txtPersonName.Text = subPackPersonnel.PersonName;
 | |
|                     txtIdentityCard.Text = subPackPersonnel.IdentityCard;
 | |
|                     txtRemark.Text = subPackPersonnel.Remark;
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     //分包商下拉框
 | |
|                     if (!string.IsNullOrWhiteSpace(_unitWorkId))
 | |
|                         drpUnit.SelectedValue = _unitWorkId;
 | |
|                     else
 | |
|                     {
 | |
|                         _unitWorkId = "-1";
 | |
|                     }
 | |
| 
 | |
|                     //劳务公司下拉框
 | |
|                     if (!string.IsNullOrWhiteSpace(_teamListId))
 | |
|                     {
 | |
|                         BLL.SubPackTeamListService.DropSelectTeamWork(drpBranchTeamList, _unitWorkId, this.ProjectId, true);
 | |
|                         drpBranchTeamList.SelectedValue = _teamListId;
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         _teamListId = "-1";
 | |
|                         BLL.SubPackTeamListService.DropSelectTeamWork(drpBranchTeamList, _unitWorkId, this.ProjectId, true);
 | |
|                         drpBranchTeamList.SelectedValue = Const._Null;
 | |
|                     }
 | |
|                     //劳务队伍
 | |
|                     if (!string.IsNullOrWhiteSpace(_laborTeamId))
 | |
|                     {
 | |
|                         BLL.SubPackLaborTeamService.DropSelectLaborTeam(drpLaborTeam, _unitWorkId, _teamListId, this.ProjectId, true);
 | |
|                         drpLaborTeam.SelectedValue = _laborTeamId;
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         _laborTeamId = "-1";
 | |
|                         BLL.SubPackLaborTeamService.DropSelectLaborTeam(drpLaborTeam, _unitWorkId, _teamListId, this.ProjectId, true);
 | |
|                         drpLaborTeam.SelectedValue = Const._Null;
 | |
|                     }
 | |
|                     //劳务班组
 | |
|                     BLL.SubPackSubPackPersonnelService.DropSelectTeam(drpTeam, _unitWorkId, _teamListId, _laborTeamId, this.ProjectId, true);
 | |
|                     drpTeam.SelectedValue = Const._Null;
 | |
|                 }
 | |
| 
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         protected void btnSave_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (BLL.CommonService.GetAllButtonPowerList(null, this.CurrUser.UserId, BLL.Const.SubPackPersonnelRegistrationMenuId, BLL.Const.BtnSave))
 | |
|             {
 | |
|                 string allMess = string.Empty;
 | |
|                 if (!string.IsNullOrWhiteSpace(txtIdentityCard.Text))
 | |
|                 {
 | |
|                     allMess = SubPackBlacklistService.GetMessAlert(txtIdentityCard.Text.Trim(), Const.SubPackBlackListPersonnel);
 | |
|                 }
 | |
|                 if (!string.IsNullOrWhiteSpace(allMess))
 | |
|                 {
 | |
|                     allMess += "是否继续操作?";
 | |
|                     PageContext.RegisterStartupScript(Confirm.GetShowReference(allMess,
 | |
|                     String.Empty,
 | |
|                     MessageBoxIcon.Question,
 | |
|                     PageManager1.GetCustomEventReference(true, "btnSave_OK"), // 第一个参数 false 用来指定当前不是AJAX请求
 | |
|                     PageManager1.GetCustomEventReference("btnSave_Cancel")));
 | |
|                     return;
 | |
|                 }
 | |
| 
 | |
|                 //保存失败时
 | |
|                 if (SaveDate("save") == 0)
 | |
|                     return;
 | |
| 
 | |
| 
 | |
|                 if (string.IsNullOrEmpty(Request.Params["Main"]))
 | |
|                 {
 | |
|                     PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     PageContext.RegisterStartupScript(String.Format("window.close();"));
 | |
|                 }
 | |
| 
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 保存方法
 | |
|         /// </summary>
 | |
|         /// <param name="saveType"></param>
 | |
|         private int SaveDate(string saveType)
 | |
|         {
 | |
|             if (drpUnit.SelectedValue == BLL.Const._Null)
 | |
|             {
 | |
|                 Alert.ShowInTop("请选择施工分包商!", MessageBoxIcon.Warning);
 | |
|                 return 0;
 | |
|             }
 | |
| 
 | |
|             if (drpBranchTeamList.SelectedValue == BLL.Const._Null)
 | |
|             {
 | |
|                 Alert.ShowInTop("请选择分包队伍!", MessageBoxIcon.Warning);
 | |
|                 return 0;
 | |
|             }
 | |
| 
 | |
|             if (drpTeam.SelectedValue == BLL.Const._Null)
 | |
|             {
 | |
|                 Alert.ShowInTop("请选择劳务!", MessageBoxIcon.Warning);
 | |
|                 return 0;
 | |
|             }
 | |
|             string identityCard = txtIdentityCard.Text.Trim();
 | |
|             if (identityCard.Length > 50)
 | |
|             {
 | |
|                 Alert.ShowInTop("你录入的身份证信息错误!", MessageBoxIcon.Warning);
 | |
|                 return 0;
 | |
|             }
 | |
| 
 | |
|             if (!IDCardValid.CheckIDCard(identityCard))
 | |
|             {
 | |
|                 Alert.ShowInTop("身份证号码非法!", MessageBoxIcon.Warning);
 | |
|                 return 0;
 | |
|             }
 | |
| 
 | |
|             var subPackPersonnel = Funs.DB.SubPack_SubPackPersonnel.FirstOrDefault(p => p.SubPackPersonnelID == this.SubPackPersonnelID);
 | |
|             if (subPackPersonnel != null)
 | |
|             {
 | |
|                 if (BLL.SubPackSubPackPersonnelService.GetPersonCountByIdentityCard(identityCard, this.SubPackPersonnelID, this.ProjectId) > 0)
 | |
|                 {
 | |
|                     Alert.ShowInTop("身份证号码已经在此项目中使用,不能重复使用!", MessageBoxIcon.Warning);
 | |
|                     return 0;
 | |
|                 }
 | |
|                 subPackPersonnel.ProjectId = this.ProjectId;
 | |
|                 subPackPersonnel.UnitId = drpUnit.SelectedValue;
 | |
|                 subPackPersonnel.BranchTeamListId = drpBranchTeamList.SelectedValue;
 | |
|                 subPackPersonnel.LaborTeamId = drpLaborTeam.SelectedValue;
 | |
|                 subPackPersonnel.BranchTeamListTeamId = drpTeam.SelectedValue;
 | |
|                 subPackPersonnel.PersonName = txtPersonName.Text.Trim();
 | |
|                 subPackPersonnel.IdentityCard = txtIdentityCard.Text.Trim();
 | |
|                 subPackPersonnel.Remark = txtRemark.Text.Trim();
 | |
|                 BLL.SubPackSubPackPersonnelService.UpdateSubPackSubPackPersonnel(subPackPersonnel);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 if (BLL.SubPackSubPackPersonnelService.GetPersonCountByIdentityCard(identityCard, this.ProjectId) > 0)
 | |
|                 {
 | |
|                     Alert.ShowInTop("身份证号码已经在此项目中使用,不能重复使用!", MessageBoxIcon.Warning);
 | |
|                     return 0;
 | |
|                 }
 | |
| 
 | |
|                 Model.SubPack_SubPackPersonnel newBranchTeamList = new Model.SubPack_SubPackPersonnel();
 | |
|                 newBranchTeamList.SubPackPersonnelID = SQLHelper.GetNewID(typeof(Model.SubPack_SubPackPersonnel));
 | |
|                 newBranchTeamList.ProjectId = this.ProjectId;
 | |
|                 newBranchTeamList.UnitId = drpUnit.SelectedValue;
 | |
|                 newBranchTeamList.BranchTeamListId = drpBranchTeamList.SelectedValue;
 | |
|                 newBranchTeamList.LaborTeamId = drpLaborTeam.SelectedValue;
 | |
|                 newBranchTeamList.BranchTeamListTeamId = drpTeam.SelectedValue;
 | |
|                 newBranchTeamList.PersonName = txtPersonName.Text.Trim();
 | |
|                 newBranchTeamList.IdentityCard = txtIdentityCard.Text.Trim();
 | |
|                 newBranchTeamList.Remark = txtRemark.Text.Trim();
 | |
|                 BLL.SubPackSubPackPersonnelService.AddSubPackSubPackPersonnel(newBranchTeamList);
 | |
|             }
 | |
|             return 1;
 | |
|         }
 | |
| 
 | |
|         #region 获取按钮权限
 | |
|         /// <summary>
 | |
|         /// 获取按钮权限
 | |
|         /// </summary>
 | |
|         /// <param name="button"></param>
 | |
|         /// <returns></returns>
 | |
|         private void GetButtonPower()
 | |
|         {
 | |
|             if (Request.Params["value"] == "0")
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             var buttonList = BLL.CommonService.GetAllButtonList(null, this.CurrUser.UserId, BLL.Const.SubPackPersonnelRegistrationMenuId);
 | |
|             if (buttonList.Count() > 0)
 | |
|             {
 | |
|                 if (buttonList.Contains(BLL.Const.BtnSave))
 | |
|                 {
 | |
|                     this.btnSave.Hidden = false;
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 施工分包商下拉框
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             if (string.IsNullOrWhiteSpace(this.SubPackPersonnelID))
 | |
|             {
 | |
|                 BLL.SubPackTeamListService.DropSelectTeamWork(drpBranchTeamList, drpUnit.SelectedValue, this.ProjectId, true);
 | |
|                 BLL.SubPackLaborTeamService.DropSelectLaborTeam(drpLaborTeam, drpUnit.SelectedValue, "-1", this.ProjectId, true);
 | |
|                 BLL.SubPackSubPackPersonnelService.DropSelectTeam(drpTeam, drpUnit.SelectedValue, "-1", "-1", this.ProjectId, true);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 BLL.SubPackTeamListService.DropSelectTeamWorkUpdate(drpBranchTeamList, drpUnit.SelectedValue, this.ProjectId, true);
 | |
|                 BLL.SubPackLaborTeamService.DropSelectLaborTeamUpdate(drpLaborTeam, drpUnit.SelectedValue, "-1", this.ProjectId, true);
 | |
|                 BLL.SubPackSubPackPersonnelService.DropSelectTeamUpdate(drpTeam, drpUnit.SelectedValue, "-1","-1", this.ProjectId, true);
 | |
|             }
 | |
| 
 | |
|             drpBranchTeamList.SelectedValue = BLL.Const._Null;
 | |
|             drpLaborTeam.SelectedValue = BLL.Const._Null;
 | |
|             drpTeam.SelectedValue = BLL.Const._Null;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         ///劳务公司下拉框
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void drpBranchTeamList_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             if (string.IsNullOrWhiteSpace(this.SubPackPersonnelID))
 | |
|             {
 | |
|                 BLL.SubPackLaborTeamService.DropSelectLaborTeam(drpLaborTeam, drpUnit.SelectedValue, drpBranchTeamList.SelectedValue, this.ProjectId, true);
 | |
|                 BLL.SubPackSubPackPersonnelService.DropSelectTeam(drpTeam, drpUnit.SelectedValue, drpBranchTeamList.SelectedValue,"-1", this.ProjectId, true);
 | |
|             }
 | |
|             else 
 | |
|             {
 | |
|                 BLL.SubPackLaborTeamService.DropSelectLaborTeamUpdate(drpLaborTeam, drpUnit.SelectedValue, drpBranchTeamList.SelectedValue, this.ProjectId, true);
 | |
|                 BLL.SubPackSubPackPersonnelService.DropSelectTeamUpdate(drpTeam, drpUnit.SelectedValue, drpBranchTeamList.SelectedValue,"-1", this.ProjectId, true);
 | |
|             }
 | |
|             drpLaborTeam.SelectedValue = BLL.Const._Null;
 | |
|             drpTeam.SelectedValue = BLL.Const._Null;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         ///劳务队伍下拉框
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void drpLaborTeam_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             if (string.IsNullOrWhiteSpace(this.SubPackPersonnelID))
 | |
|             {
 | |
|                 BLL.SubPackSubPackPersonnelService.DropSelectTeam(drpTeam, drpUnit.SelectedValue, drpBranchTeamList.SelectedValue, drpLaborTeam.SelectedValue, this.ProjectId, true);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 BLL.SubPackSubPackPersonnelService.DropSelectTeamUpdate(drpTeam, drpUnit.SelectedValue, drpBranchTeamList.SelectedValue, drpLaborTeam.SelectedValue, this.ProjectId, true);
 | |
|             }
 | |
|             drpTeam.SelectedValue = BLL.Const._Null;
 | |
|         }
 | |
| 
 | |
|         protected void PageManager1_CustomEvent(object sender, CustomEventArgs e)
 | |
|         {
 | |
|             if (e.EventArgument == "btnSave_OK")
 | |
|             {
 | |
|                 //保存失败时
 | |
|                 if (SaveDate("save") == 0)
 | |
|                     return;
 | |
| 
 | |
|                 if (string.IsNullOrEmpty(Request.Params["Main"]))
 | |
|                 {
 | |
|                     PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     PageContext.RegisterStartupScript(String.Format("window.close();"));
 | |
|                 }
 | |
|             }
 | |
|             else if (e.EventArgument == "btnSave_Cancel")
 | |
|             {
 | |
|                 // AJAX回发
 | |
|                 ShowNotify("已取消保存!");
 | |
|             }
 | |
| 
 | |
|         }
 | |
|     }
 | |
| } |