using BLL; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.IO; using System.Linq; namespace FineUIPro.Web.Person { public partial class PersonEdit : PageBase { #region 定义项 /// /// 主键 /// public string PersonId { get { return (string)ViewState["PersonId"]; } set { ViewState["PersonId"] = value; } } /// /// 签名附件路径 /// public string SignatureUrl { get { return (string)ViewState["SignatureUrl"]; } set { ViewState["SignatureUrl"] = value; } } /// /// 人员分配类型 P-派遣 Shunt-分流 /// public string Type { get { return (string)ViewState["Type"]; } set { ViewState["Type"] = value; } } #endregion #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.Type = Request.Params["Type"]; btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.PersonId = Request.Params["PersonId"]; this.InitDropDownList(); string unitId = Request.Params["UnitId"]; if (!string.IsNullOrEmpty(unitId)) { this.drpUnit.SelectedValue = unitId; this.drpUnit.Readonly = true; } string departId = Request.Params["DepartId"]; if (!string.IsNullOrEmpty(departId)) { this.drpDepart.SelectedValue = departId; this.drpDepart.Readonly = true; } 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; this.ckIsPost.Checked = person.IsPost ?? true; this.ckIsMultiProject.Checked = person.MultiProject ?? false; 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.rbPersonType.SelectedValue = 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; } cbIsInspectionBrigade.Checked = person.IsInspectionBrigade ?? false; this.txtRelativeName.Text = person.RelativeName; this.txtRelativeTel.Text = person.RelativeTel; this.txtAddress.Text = person.Address; if (!string.IsNullOrEmpty(person.HomePageType)) { this.rblHomePageType.SelectedValue = person.HomePageType; } #endregion if (!string.IsNullOrEmpty(person.SignatureUrl)) { this.SignatureUrl = person.SignatureUrl; this.Image2.ImageUrl = "~/" + this.SignatureUrl; } this.btnCertificateNew.Hidden = false; this.btnTrainNew.Hidden = false; this.btnInOutNew.Hidden = false; if (this.CurrUser.RoleIds == null || this.CurrUser.RoleIds.Contains(Const.sysglyId)) { this.rbPersonType.Readonly = false; } else { var getRoleNames = RoleService.getRoleNamesRoleIds(this.CurrUser.RoleIds); if (getRoleNames != null && getRoleNames.Contains("管理员")) { this.rbPersonType.Readonly = false; } } } } else { this.rbPersonType.Readonly = false; if (this.Type == "Shunt") { this.ckIsPost.Checked = false; } } 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); DropListService.InitConstRadioButtonList(this.rbPersonType, DropListService.Group_PersonType, "1"); } /// /// /// /// /// protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e) { // this.trRole.Hidden = true; if (this.drpUnit.SelectedValue == BLL.Const.UnitId_SEDIN) { // this.trRole.Hidden = false; this.txtIdentityCard.Required = false; this.txtIdentityCard.ShowRedStar = false; } else { this.txtIdentityCard.Required = true; this.txtIdentityCard.ShowRedStar = true; } } #endregion #region 头像、身份证及二维码生成 /// /// 头像上传 /// /// /// protected void filePhoto_FileSelected(object sender, EventArgs e) { if (filePhoto.HasFile) { string fileName = filePhoto.ShortFileName; if (!ValidateFileType(fileName)) { ShowNotify("无效的文件类型!"); return; } fileName = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_"); fileName = DateTime.Now.Ticks.ToString() + "_" + fileName; string url = "~/" + UploadFileService.PersonBaseInfoFilePath + DateTime.Now.Year + "-" + DateTime.Now.Month + "/"; string fileMapPath = Server.MapPath(url + fileName); filePhoto.SaveAs(fileMapPath); if (File.Exists(fileMapPath)) { FileInfo fileInfo = new FileInfo(fileMapPath); double size = Math.Ceiling(fileInfo.Length * 1.0 / 1024.0); if (size > 300) { Alert.ShowInTop("照片大小超过300KB,请重新上传!", MessageBoxIcon.Warning); return; } } imgPhoto.ImageUrl = url + fileName; // 清空文件上传组件 filePhoto.Reset(); } } /// /// 身份证正面上传 /// /// /// protected void fuIDCard_FileSelected(object sender, EventArgs e) { if (fuIDCard.HasFile) { string fileName = fuIDCard.ShortFileName; if (!ValidateFileType(fileName)) { ShowNotify("无效的文件类型!"); return; } fileName = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_"); fileName = DateTime.Now.Ticks.ToString() + "_" + fileName; string url = "~/" + UploadFileService.IdCardFilePath + DateTime.Now.Year + "-" + DateTime.Now.Month + "/"; string fileMapPath = Server.MapPath(url + fileName); fuIDCard.SaveAs(fileMapPath); imgIDCard.ImageUrl = url + fileName; // 清空文件上传组件 fuIDCard.Reset(); } } /// /// 读取身份证 /// /// /// protected void btnReadIdentityCard_Click(object sender, EventArgs e) { string idUrl = imgIDCard.ImageUrl; if (!string.IsNullOrEmpty(idUrl)) { string url = Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port + "/" + idUrl; string idInfo = APIIDCardInfoService.ReadIDCardInfo(url); if (!string.IsNullOrEmpty(idInfo)) { JObject obj = JObject.Parse(idInfo); string errcode = obj["errcode"].ToString(); if (errcode == "0") { string name = obj["name"].ToString(); if (!string.IsNullOrEmpty(name)) { this.txtPersonName.Text = name; } string id = obj["id"].ToString(); if (!string.IsNullOrEmpty(id) && this.txtIdentityCard.Text != id) { this.txtIdentityCard.Text = id; this.IdentityCardChange(); } string addr = obj["addr"].ToString(); if (!string.IsNullOrEmpty(addr)) { this.txtAddress.Text = addr; } string gender = obj["gender"].ToString(); if (!string.IsNullOrEmpty(gender)) { this.rblSex.SelectedValue = gender == "女" ? "2" : "1"; } // string nationality = obj["nationality"].ToString(); } else { Alert.ShowInParent("身份证读取失败!", MessageBoxIcon.Warning); } } } } /// /// 身份证背面上传 /// /// /// protected void fuIDCardBack_FileSelected(object sender, EventArgs e) { if (fuIDCardBack.HasFile) { string fileName = fuIDCardBack.ShortFileName; if (!ValidateFileType(fileName)) { ShowNotify("无效的文件类型!"); return; } fileName = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_"); fileName = DateTime.Now.Ticks.ToString() + "_" + fileName; string url = "~/" + UploadFileService.IdCardFilePath + DateTime.Now.Year + "-" + DateTime.Now.Month + "/"; string fileMapPath = Server.MapPath(url + fileName); fuIDCardBack.SaveAs(fileMapPath); imgIDCardBack.ImageUrl = url + fileName; // 清空文件上传组件 fuIDCardBack.Reset(); } } /// /// 身份证号码 /// /// /// protected void txtIdentityCard_Blur(object sender, EventArgs e) { this.IdentityCardChange(); } /// /// 根据身份证生成二维码 /// /// /// protected void btnQR_Click(object sender, EventArgs e) { this.IdentityCardChange(); } /// /// 按身份证生成二维码方法 /// private void IdentityCardChange() { this.imgQR.ImageUrl = string.Empty; bool isok = true; if (!string.IsNullOrEmpty(this.txtIdentityCard.Text)) { string idCard = this.txtIdentityCard.Text.Trim(); var q2 = Funs.DB.Person_Persons.FirstOrDefault(x => x.IdentityCard == idCard && (x.PersonId != this.PersonId || (this.PersonId == null && x.PersonId != null))); if (q2 != null) { this.PersonId = q2.PersonId; ShowNotify("输入的身份证号码已存在!", MessageBoxIcon.Warning); } if (this.drpIdcardType.SelectedValue == "SHENFEN_ZHENGJIAN") { if (!IDCardValid.CheckIDCard(idCard)) { isok = false; ShowNotify("输入的身份证号码有误!", MessageBoxIcon.Warning); } } if (isok) { ///生成二维码 string qrUrl = BLL.CreateQRCodeService.CreateCode_Simple("person$" + idCard); imgQR.ImageUrl = ("~/" + qrUrl); DateTime? birth = IDCardValid.getBirthByIDCard(idCard); if (birth.HasValue) { this.txtBirthday.Text = string.Format("{0:yyyy-MM-dd}", birth.Value); this.txtAge.Text = IDCardValid.CalculateAgeCorrect(birth.Value).ToString(); } } } } #endregion #region 保存按钮 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { Model.Person_Persons newPerson = new Model.Person_Persons { PersonId = this.PersonId, PersonName = this.txtPersonName.Text.Trim(), JobNum = this.txtJobNum.Text.Trim(), UnitId = this.drpUnit.SelectedValue, DepartId = this.drpDepart.SelectedValue == Const._Null ? null : this.drpDepart.SelectedValue, Account = this.txtAccount.Text.Trim(), WorkPostId = this.drpWorkPost.SelectedValue == Const._Null ? null : this.drpWorkPost.SelectedValue, PersonType = this.rbPersonType.SelectedValue, IsForeign = this.ckIsForeign.Checked, IdcardType = this.drpIdcardType.SelectedValue == Const._Null ? "SHENFEN_ZHENGJIAN" : this.drpIdcardType.SelectedValue, IdentityCard = this.txtIdentityCard.Text.Trim(), IdcardAddress = this.txtIdcardAddress.Text.Trim(), IdcardForever = this.rblIdcardForever.SelectedValue ?? "Y", IdcardStartDate = Funs.GetNewDateTime(this.txtIdcardStartDate.Text.Trim()), IdcardEndDate = Funs.GetNewDateTime(this.txtIdcardEndDate.Text.Trim()), Telephone = this.txtTelephone.Text.Trim(), Sex = this.rblSex.SelectedValue, Birthday = Funs.GetNewDateTime(this.txtBirthday.Text.Trim()), IntoDate = Funs.GetNewDateTime(this.txtIntoDate.Text), WorkDate = Funs.GetNewDateTime(this.txtWorkDate.Text), RetirementDate = Funs.GetNewDateTime(this.txtRetirementDate.Text), ValidityDate = Funs.GetNewDateTime(this.txtValidityDate.Text), PositionId = this.drpPosition.SelectedValue == Const._Null ? null : this.drpPosition.SelectedValue, PostTitleId = this.drpPostTitle.SelectedValue == Const._Null ? null : this.drpPostTitle.SelectedValue, PostTitleDate = Funs.GetNewDateTime(this.txtPostTitleDate.Text), Graduate = this.txtGraduate.Text.Trim(), Major = this.txtMajor.Text.Trim(), ForeignLanguage = this.txtForeignLanguage.Text.Trim(), CountryCode = this.drpCountryCode.SelectedValue == Const._Null ? null : this.drpCountryCode.SelectedValue, ProvinceCode = this.drpProvinceCode.SelectedValue == Const._Null ? null : this.drpProvinceCode.SelectedValue, Nation = this.drpNation.SelectedValue == Const._Null ? null : this.drpNation.SelectedValue, PoliticsStatus = this.drpPoliticsStatus.SelectedValue == Const._Null ? null : this.drpPoliticsStatus.SelectedValue, EduLevel = this.drpEduLevel.SelectedValue == Const._Null ? null : this.drpEduLevel.SelectedValue, MaritalStatus = this.drpMaritalStatus.SelectedValue == Const._Null ? null : this.drpMaritalStatus.SelectedValue, RelativeName = this.txtRelativeName.Text.Trim(), RelativeTel = this.txtRelativeTel.Text.Trim(), Address = this.txtAddress.Text.Trim(), SignatureUrl = this.SignatureUrl, IsPost = this.ckIsPost.Checked, MultiProject = this.ckIsMultiProject.Checked, IsOffice = this.ckIsOffice.Checked, }; newPerson.HomePageType = this.rblHomePageType.SelectedValue; newPerson.IsInspectionBrigade = cbIsInspectionBrigade.Checked; newPerson.RoleIds = Funs.GetStringByArray(this.drpRole.SelectedValueArray); if (!string.IsNullOrEmpty(imgPhoto.ImageUrl) && imgPhoto.ImageUrl != "~/res/images/blank.png") { newPerson.PhotoUrl = imgPhoto.ImageUrl.Replace("~/", ""); newPerson.HeadImage = AttachFileService.SetImageToByteArray(Funs.RootPath + newPerson.PhotoUrl); } else { newPerson.PhotoUrl = null; newPerson.HeadImage = null; } if (!string.IsNullOrEmpty(imgQR.ImageUrl) && imgQR.ImageUrl != "~/images/QRimage.png") { newPerson.QRCodeAttachUrl = imgQR.ImageUrl.Replace("~/", ""); } else { newPerson.QRCodeAttachUrl = null; } if (!string.IsNullOrEmpty(imgIDCard.ImageUrl) && imgQR.ImageUrl != "~/res/images/idcard.png") { newPerson.IDCardUrl = imgIDCard.ImageUrl.Replace("~/", ""); } else { newPerson.IDCardUrl = null; } if (!string.IsNullOrEmpty(imgIDCardBack.ImageUrl) && imgQR.ImageUrl != "~/res/images/idcard.png") { newPerson.IDCardBackUrl = imgIDCardBack.ImageUrl.Replace("~/", ""); } else { newPerson.IDCardBackUrl = null; } string info = Person_PersonsService.ValidPersonInfo(newPerson); if (string.IsNullOrEmpty(info) || this.Type == "Shunt") { if (!string.IsNullOrEmpty(newPerson.PersonId)) { Person_PersonsService.UpdatePerson(newPerson); LogService.AddSys_Log(this.CurrUser, newPerson.PersonName, newPerson.PersonId, BLL.Const.PersonLibMenuId, BLL.Const.BtnModify); } else { this.PersonId = newPerson.PersonId = SQLHelper.GetNewID(); Person_PersonsService.AddPerson(newPerson); LogService.AddSys_Log(this.CurrUser, newPerson.PersonName, newPerson.PersonId, BLL.Const.PersonLibMenuId, BLL.Const.BtnAdd); } Alert.ShowInParent("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } else { Alert.ShowInParent(info, MessageBoxIcon.Warning); } } #endregion #region 角色选择事件 /// /// 角色选择事件 /// /// /// protected void drpRole_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpRole.SelectedItemArray.Count() > 5) { this.drpRole.SelectedValueArray = null; Alert.ShowInParent("最多可选择5个角色!", MessageBoxIcon.Warning); } else { this.drpRole.SelectedValueArray = Funs.RemoveDropDownListNull(this.drpRole.SelectedValueArray); } } #endregion #region 验证账号是否存在 /// /// 验证账号是否存在 /// /// /// protected void txtAccount_Blur(object sender, EventArgs e) { string acc = this.txtAccount.Text.Trim(); var q2 = Funs.DB.Person_Persons.FirstOrDefault(x => x.Account == acc && (x.PersonId != this.PersonId || (this.PersonId == null && x.PersonId != null))); if (q2 != null) { ShowNotify("输入的账号已存在已存在!", MessageBoxIcon.Warning); } } #endregion #region 上传签名 /// /// 上传签名 /// /// /// protected void btnSignature_Click(object sender, EventArgs e) { if (fileSignature.HasFile) { string fileName = fileSignature.ShortFileName; if (!ValidateFileType(fileName)) { ShowNotify("无效的文件类型!", MessageBoxIcon.Warning); return; } this.SignatureUrl = UploadFileService.UploadAttachment(Funs.RootPath, this.fileSignature, this.SignatureUrl, UploadFileService.UserFilePath); this.Image2.ImageUrl = "~/" + this.SignatureUrl; } } protected void btnRet_Click(object sender, EventArgs e) { this.SignatureUrl = string.Empty; this.Image2.ImageUrl = "~/res/images/Signature0.png"; } #endregion #region 重置密码 /// /// 重置密码 /// /// /// protected void btnArrowRefresh_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.PersonId)) { var getperson = Person_PersonsService.GetPerson_PersonsById(this.PersonId); if (getperson != null) { BLL.Person_PersonsService.UpdatePassword(this.PersonId, Funs.getInitialPassword(getperson.UnitId, getperson.IdentityCard)); ShowNotify("密码已重置为原始密码!", MessageBoxIcon.Success); } } else { ShowNotify("请至少选中一行!", MessageBoxIcon.Warning); } } #endregion #region 证书信息 /// /// /// private void getInitGridCertificate() { Funs.DropDownPageSize(this.ddlPageSizeGridCertificate); this.btnCertificateNew.OnClientClick = Window1.GetShowReference("../HSSE/QualityAudit/PersonQualityEdit.aspx?PersonId=" + this.PersonId) + "return false;"; 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}", GridCertificate.SelectedRowID, "编辑 - "))); } /// /// 删除证书信息 /// /// /// protected void btnCertificateDelete_Click(object sender, EventArgs e) { if (GridCertificate.SelectedRowIndexArray.Length > 0) { PersonQualityService.DeleteData(GridCertificate.SelectedRowID); BindGridCertificate(); ShowNotify("删除数据成功!", MessageBoxIcon.Success); } } #endregion #region 培训信息 /// /// /// private void getInitGridTrain() { Funs.DropDownPageSize(this.ddlPageSizeGridTrain); this.btnTrainNew.OnClientClick = Window1.GetShowReference("PersonTrainEdit.aspx?PersonId=" + this.PersonId) + "return false;"; 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}", GridTrain.SelectedRowID, "编辑 - "))); } /// /// 删除证书信息 /// /// /// protected void btnTrainDelete_Click(object sender, EventArgs e) { if (GridTrain.SelectedRowIndexArray.Length > 0) { Person_PersonTrainService.DeleteData(GridTrain.SelectedRowID); BindGridTrain(); ShowNotify("删除数据成功!", MessageBoxIcon.Success); } } #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(); 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); this.btnInOutNew.OnClientClick = Window1.GetShowReference("PersonItemEdit.aspx?PersonId=" + this.PersonId) + "return false;"; 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}", GridInOut.SelectedRowID, "编辑 - "))); } /// /// 删除证书信息 /// /// /// protected void btnInOutDelete_Click(object sender, EventArgs e) { if (GridInOut.SelectedRowIndexArray.Length > 0) { SitePerson_PersonItemService.DeletePersonItem(GridInOut.SelectedRowID); BindGridInOut(); ShowNotify("删除数据成功!", MessageBoxIcon.Success); } } #endregion #endregion /// /// /// /// /// protected void ckIsPost_CheckedChanged(object sender, CheckedEventArgs e) { if (!this.ckIsPost.Checked) { Alert.ShowInParent("人员不在职,则当前人所在的所有项目都将离场!", MessageBoxIcon.Warning); } } /// /// /// /// /// protected void ckIsMultiProject_CheckedChanged(object sender, CheckedEventArgs e) { if (this.ckIsMultiProject.Checked) { Alert.ShowInParent("人员可在多个项目上同时在岗!", MessageBoxIcon.Warning); } } } }