using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; namespace FineUIPro.Web.Person { public partial class PersonView : PageBase { #region 定义项 /// /// 主键 /// public string PersonId { get { return (string)ViewState["PersonId"]; } set { ViewState["PersonId"] = value; } } #endregion #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.PersonId = Request.Params["PersonId"]; this.InitDropDownList(); if (!string.IsNullOrEmpty(this.PersonId)) { var person = BLL.Person_PersonsService.GetPerson_PersonsById(this.PersonId); if (person != null) { #region 基本信息 this.txtPersonName.Text = person.PersonName; this.txtJobNum.Text = person.JobNum; this.drpUnit.SelectedValue = person.UnitId; if (!string.IsNullOrEmpty(person.DepartId)) { this.drpDepart.SelectedValue = person.DepartId; } this.txtAccount.Text = person.Account; if (!string.IsNullOrEmpty(person.RoleIds)) { this.drpRole.SelectedValueArray = person.RoleIds.Split(','); } if (!string.IsNullOrEmpty(person.WorkPostId)) { this.drpWorkPost.SelectedValue = person.WorkPostId; } if (person.IsForeign.HasValue) { this.ckIsForeign.Checked = person.IsForeign.Value; } if (person.IsOffice.HasValue) { this.ckIsOffice.Checked = person.IsOffice.Value; } this.txtPersonType.Text = DropListService.getPersonTypeNameByValue(person.PersonType); if (!string.IsNullOrEmpty(person.IdcardType)) { this.drpIdcardType.SelectedValue = person.IdcardType; } this.txtIdentityCard.Text = person.IdentityCard; this.txtIdcardAddress.Text = person.IdcardAddress; if (!string.IsNullOrEmpty(person.IdcardForever)) { this.rblIdcardForever.SelectedValue = person.IdcardForever; if (person.IdcardForever == "Y") { this.txtIdcardEndDate.ShowRedStar = false; this.txtIdcardEndDate.Required = false; } } this.txtIdcardStartDate.Text = string.Format("{0:yyyy-MM-dd}", person.IdcardStartDate); this.txtIdcardEndDate.Text = string.Format("{0:yyyy-MM-dd}", person.IdcardEndDate); if (!string.IsNullOrEmpty(person.Sex)) { this.rblSex.SelectedValue = person.Sex; } if (person.Birthday.HasValue) { this.txtBirthday.Text = string.Format("{0:yyyy-MM-dd}", person.Birthday); this.txtAge.Text = IDCardValid.CalculateAgeCorrect(person.Birthday.Value).ToString(); } this.txtTelephone.Text = person.Telephone; if (!string.IsNullOrEmpty(person.PhotoUrl)) { imgPhoto.ImageUrl = ("~/" + person.PhotoUrl); } if (!string.IsNullOrEmpty(person.QRCodeAttachUrl)) { imgQR.ImageUrl = ("~/" + person.QRCodeAttachUrl); } if (!string.IsNullOrEmpty(person.IDCardUrl)) { imgIDCard.ImageUrl = ("~/" + person.IDCardUrl); } if (!string.IsNullOrEmpty(person.IDCardBackUrl)) { imgIDCardBack.ImageUrl = ("~/" + person.IDCardBackUrl); } #endregion #region 详细信息 this.txtIntoDate.Text = string.Format("{0:yyyy-MM-dd}", person.IntoDate); this.txtWorkDate.Text = string.Format("{0:yyyy-MM-dd}", person.WorkDate); this.txtRetirementDate.Text = string.Format("{0:yyyy-MM-dd}", person.RetirementDate); this.txtValidityDate.Text = string.Format("{0:yyyy-MM-dd}", person.ValidityDate); if (!string.IsNullOrEmpty(person.PositionId)) { this.drpPosition.SelectedValue = person.PositionId; } if (!string.IsNullOrEmpty(person.PostTitleId)) { this.drpPostTitle.SelectedValue = person.PostTitleId; } this.txtPostTitleDate.Text = string.Format("{0:yyyy-MM-dd}", person.PostTitleDate); this.txtGraduate.Text = person.Graduate; this.txtMajor.Text = person.Major; this.txtForeignLanguage.Text = person.ForeignLanguage; if (!string.IsNullOrEmpty(person.CountryCode)) { this.drpCountryCode.SelectedValue = person.CountryCode; CityService.InitCityDropDownList(this.drpProvinceCode, person.CountryCode, false); } if (!string.IsNullOrEmpty(person.ProvinceCode)) { this.drpProvinceCode.SelectedValue = person.ProvinceCode; } if (!string.IsNullOrEmpty(person.Nation)) { this.drpNation.SelectedValue = person.Nation; } if (!string.IsNullOrEmpty(person.PoliticsStatus)) { this.drpPoliticsStatus.SelectedValue = person.PoliticsStatus; } if (!string.IsNullOrEmpty(person.EduLevel)) { this.drpEduLevel.SelectedValue = person.EduLevel; } if (!string.IsNullOrEmpty(person.MaritalStatus)) { this.drpMaritalStatus.SelectedValue = person.MaritalStatus; } this.txtRelativeName.Text = person.RelativeName; this.txtRelativeTel.Text = person.RelativeTel; this.txtAddress.Text = person.Address; #endregion } } getInitGridCertificate(); getInitGridTrain(); getInitGridDuty(); getInitGridInOut(); getInitGridQuarterCheck(); } } #endregion #region 下拉框初始化 /// /// 初始化下拉框 /// private void InitDropDownList() { UnitService.InitUnitDropDownList(this.drpUnit, string.Empty, false); this.drpUnit.SelectedValue = this.CurrUser.UnitId ?? Const.UnitId_SEDIN; DepartService.InitDepartDropDownList(this.drpDepart, true); RoleService.InitRoleDropDownList(this.drpRole, null, null, true); WorkPostService.InitWorkPostDropDownList(this.drpWorkPost, true); PositionService.InitPositionDropDownList(this.drpPosition, true); PostTitleService.InitPostTitleDropDownList(this.drpPostTitle, true); BasicDataService.InitBasicDataProjectUnitDropDownList(this.drpEduLevel, "EDU_LEVEL", true); BasicDataService.InitBasicDataProjectUnitDropDownList(this.drpMaritalStatus, "MARITAL_STATUS", true); BasicDataService.InitBasicDataProjectUnitDropDownList(this.drpIdcardType, "ZHENGJIAN_TYPE", false); this.drpIdcardType.SelectedValue = "SHENFEN_ZHENGJIAN"; BasicDataService.InitBasicDataProjectUnitDropDownList(this.drpPoliticsStatus, "POLITICAL_LANDSCAPE", true); BasicDataService.InitBasicDataProjectUnitDropDownList(this.drpNation, "MINZU_TYPE", true); SynchroSetService.InitCountryDropDownList(this.drpCountryCode, false); this.drpCountryCode.SelectedValue = "101"; CityService.InitCityDropDownList(this.drpProvinceCode, this.drpCountryCode.SelectedValue, true); PositionService.InitPositionDropDownList(this.drpPosition, true); ; } #endregion #region 证书信息 /// /// /// private void getInitGridCertificate() { Funs.DropDownPageSize(this.ddlPageSizeGridCertificate); BindGridCertificate(); } #region 绑定数据 /// /// 绑定数据 /// private void BindGridCertificate() { var getData = PersonQualityService.getListData(this.PersonId, GridCertificate); GridCertificate.RecordCount = PersonQualityService.count; GridCertificate.DataSource = getData; GridCertificate.DataBind(); } #endregion #region 分页 /// /// 分页 /// /// /// protected void GridCertificate_PageIndexChange(object sender, GridPageEventArgs e) { BindGridCertificate(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSizeGridCertificate_SelectedIndexChanged(object sender, EventArgs e) { GridCertificate.PageSize = Convert.ToInt32(ddlPageSizeGridCertificate.SelectedValue); BindGridCertificate(); } /// /// 排序 /// /// /// protected void GridCertificate_Sort(object sender, FineUIPro.GridSortEventArgs e) { BindGridCertificate(); } #endregion /// /// 双击事件 /// /// /// protected void GridCertificate_RowDoubleClick(object sender, GridRowClickEventArgs e) { this.EditDataCertificate(); } protected void btnCertificateEdit_Click(object sender, EventArgs e) { this.EditDataCertificate(); } /// /// 编辑数据方法 /// private void EditDataCertificate() { if (GridCertificate.SelectedRowIndexArray.Length == 0) { Alert.ShowInParent("请至少选择一条记录!", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../HSSE/QualityAudit/PersonQualityEdit.aspx?PersonQualityId={0}&value=0", GridCertificate.SelectedRowID, "编辑 - "))); } #endregion #region 培训信息 /// /// /// private void getInitGridTrain() { Funs.DropDownPageSize(this.ddlPageSizeGridTrain); BindGridTrain(); } #region 绑定数据 /// /// 绑定数据 /// private void BindGridTrain() { var getData = Person_PersonTrainService.getListData(this.PersonId, GridTrain); GridTrain.RecordCount = Person_PersonTrainService.count; GridTrain.DataSource = getData; GridTrain.DataBind(); } #endregion #region 分页 /// /// 分页 /// /// /// protected void GridTrain_PageIndexChange(object sender, GridPageEventArgs e) { BindGridTrain(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSizeGridTrain_SelectedIndexChanged(object sender, EventArgs e) { GridTrain.PageSize = Convert.ToInt32(ddlPageSizeGridTrain.SelectedValue); BindGridTrain(); } /// /// 排序 /// /// /// protected void GridTrain_Sort(object sender, FineUIPro.GridSortEventArgs e) { BindGridTrain(); } #endregion /// /// 双击事件 /// /// /// protected void GridTrain_RowDoubleClick(object sender, GridRowClickEventArgs e) { this.EditDataTrain(); } protected void btnTrainEdit_Click(object sender, EventArgs e) { this.EditDataTrain(); } /// /// 编辑数据方法 /// private void EditDataTrain() { if (GridTrain.SelectedRowIndexArray.Length == 0) { Alert.ShowInParent("请至少选择一条记录!", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PersonTrainEdit.aspx?PersonTrainId={0}&value=0", GridTrain.SelectedRowID, "编辑 - "))); } #endregion #region 员工考核 /// /// /// private void getInitGridQuarterCheck() { Funs.DropDownPageSize(this.ddlPageSizeGridQuarterCheck); BindGridQuarterCheck(); } #region 绑定数据 /// /// 绑定数据 /// private void BindGridQuarterCheck() { string strSql = @"select QuarterCheckId, QuarterCheckName, C.UserId, C.ProjectId, StartTime,EndTime,State,R.RoleName,P.ProjectName,(case when c.State ='1' then '考核结束' else '正在考核' end) as StateName from [dbo].[Person_QuarterCheck] C left join Sys_Role R on C.RoleId=R.RoleId left join Base_Project P on C.ProjectId=P.ProjectId where 1=1 "; List listStr = new List(); if (this.CurrUser.PersonId != BLL.Const.sysglyId && this.CurrUser.PersonId != BLL.Const.hfnbdId) { strSql += " AND C.UserId=@UserId "; listStr.Add(new SqlParameter("@UserId", this.PersonId)); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); GridQuarterCheck.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(GridQuarterCheck, tb); GridQuarterCheck.DataSource = table; GridQuarterCheck.DataBind(); } #endregion #region gv字段转换 /// /// /// /// /// protected string ConvertGrade(object QuarterCheckId) { decimal grade = 0; if (!string.IsNullOrEmpty(QuarterCheckId.ToString())) { var list = BLL.Person_QuarterCheckItemService.GetCheckItemListById(QuarterCheckId.ToString()); foreach (var item in list) { if (item.Grade != null) { grade += item.Grade.Value * item.StandardGrade.Value / 100; } } } return grade.ToString("0.##"); } #endregion #region 分页 /// /// 分页 /// /// /// protected void GridQuarterCheck_PageIndexChange(object sender, GridPageEventArgs e) { BindGridQuarterCheck(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSizeGridQuarterCheck_SelectedIndexChanged(object sender, EventArgs e) { GridQuarterCheck.PageSize = Convert.ToInt32(ddlPageSizeGridQuarterCheck.SelectedValue); BindGridQuarterCheck(); } /// /// 排序 /// /// /// protected void GridQuarterCheck_Sort(object sender, FineUIPro.GridSortEventArgs e) { BindGridQuarterCheck(); } #endregion /// /// 双击事件 /// /// /// protected void GridQuarterCheck_RowDoubleClick(object sender, GridRowClickEventArgs e) { this.EditDataQuarterCheck(); } protected void btnQuarterCheckEdit_Click(object sender, EventArgs e) { this.EditDataQuarterCheck(); } /// /// 编辑数据方法 /// private void EditDataQuarterCheck() { if (GridQuarterCheck.SelectedRowIndexArray.Length == 0) { Alert.ShowInParent("请至少选择一条记录!", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DepartPersonCheckingView.aspx?QuarterCheckId={0}", GridQuarterCheck.SelectedRowID, "编辑 - "))); } #endregion #region 员工责任书 /// /// /// private void getInitGridDuty() { Funs.DropDownPageSize(this.ddlPageSizeGridDuty); BindGridDuty(); } #region 绑定数据 /// /// 绑定数据 /// private void BindGridDuty() { var getData = Person_DutyService.getListData(this.PersonId, GridDuty); GridDuty.RecordCount = Person_DutyService.count; GridDuty.DataSource = getData; GridDuty.DataBind(); } #endregion #region 分页 /// /// 分页 /// /// /// protected void GridDuty_PageIndexChange(object sender, GridPageEventArgs e) { BindGridDuty(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSizeGridDuty_SelectedIndexChanged(object sender, EventArgs e) { GridDuty.PageSize = Convert.ToInt32(ddlPageSizeGridDuty.SelectedValue); BindGridDuty(); } /// /// 排序 /// /// /// protected void GridDuty_Sort(object sender, FineUIPro.GridSortEventArgs e) { BindGridDuty(); } #endregion /// /// 双击事件 /// /// /// protected void GridDuty_RowDoubleClick(object sender, GridRowClickEventArgs e) { this.EditDataDuty(); } protected void btnDutyEdit_Click(object sender, EventArgs e) { this.EditDataDuty(); } /// /// 编辑数据方法 /// private void EditDataDuty() { if (GridDuty.SelectedRowIndexArray.Length == 0) { Alert.ShowInParent("请至少选择一条记录!", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DepartPersonDutyView.aspx?DutyId={0}", GridDuty.SelectedRowID, "编辑 - "))); } #endregion #region 人员工作经历 /// /// /// private void getInitGridInOut() { Funs.DropDownPageSize(this.ddlPageSizeGridInOut); BindGridInOut(); } #region 绑定数据 /// /// 绑定数据 /// private void BindGridInOut() { var getData = SitePerson_PersonItemService.getListData(null, null, this.PersonId, null, null, null, null, GridInOut); GridInOut.RecordCount = Person_PersonsService.count; GridInOut.DataSource = getData; GridInOut.DataBind(); } #endregion #region 分页 /// /// 分页 /// /// /// protected void GridInOut_PageIndexChange(object sender, GridPageEventArgs e) { BindGridInOut(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSizeGridInOut_SelectedIndexChanged(object sender, EventArgs e) { GridInOut.PageSize = Convert.ToInt32(ddlPageSizeGridInOut.SelectedValue); BindGridInOut(); } /// /// 排序 /// /// /// protected void GridInOut_Sort(object sender, FineUIPro.GridSortEventArgs e) { BindGridInOut(); } #endregion #region 数据操作事件 /// /// 双击事件 /// /// /// protected void GridInOut_RowDoubleClick(object sender, GridRowClickEventArgs e) { this.EditDataInOut(); } protected void btnInOutEdit_Click(object sender, EventArgs e) { this.EditDataInOut(); } /// /// 编辑数据方法 /// private void EditDataInOut() { if (GridInOut.SelectedRowIndexArray.Length == 0) { Alert.ShowInParent("请至少选择一条记录!", MessageBoxIcon.Warning); return; } PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PersonItemEdit.aspx?PersonItemId={0}&value=0", GridInOut.SelectedRowID, "编辑 - "))); } #endregion #endregion } }