SGGL_SHJ/SGGL/FineUIPro.Web/Person/PersonEdit.aspx.cs

1236 lines
47 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using BLL;
using Model;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web.UI.DataVisualization.Charting;
namespace FineUIPro.Web.Person
{
public partial class PersonEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string PersonId
{
get
{
return (string)ViewState["PersonId"];
}
set
{
ViewState["PersonId"] = value;
}
}
/// <summary>
/// 签名附件路径
/// </summary>
public string SignatureUrl
{
get
{
return (string)ViewState["SignatureUrl"];
}
set
{
ViewState["SignatureUrl"] = value;
}
}
/// <summary>
/// 人员分配类型 P-派遣 Shunt-分流
/// </summary>
public string Type
{
get
{
return (string)ViewState["Type"];
}
set
{
ViewState["Type"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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;
}
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;
}
}
else
{
if (this.Type == "Shunt")
{
this.ckIsPost.Checked = false;
}
}
getInitGridCertificate();
getInitGridTrain();
getInitGridDuty();
getInitGridInOut();
getInitGridQuarterCheck();
}
}
#endregion
#region
/// <summary>
/// 初始化下拉框
/// </summary>
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");
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
/// <summary>
/// 头像上传
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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();
}
}
/// <summary>
/// 身份证正面上传
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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();
}
}
/// <summary>
/// 读取身份证
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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);
}
}
}
}
/// <summary>
/// 身份证背面上传
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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();
}
}
/// <summary>
/// 身份证号码
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void txtIdentityCard_Blur(object sender, EventArgs e)
{
this.IdentityCardChange();
}
/// <summary>
/// 根据身份证生成二维码
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnQR_Click(object sender, EventArgs e)
{
this.IdentityCardChange();
}
/// <summary>
/// 按身份证生成二维码方法
/// </summary>
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
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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.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
/// <summary>
/// 角色选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpRole_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.drpRole.SelectedItemArray.Count() > 4)
{
this.drpRole.SelectedValueArray = null;
Alert.ShowInParent("最多可选择4个角色", MessageBoxIcon.Warning);
}
else
{
this.drpRole.SelectedValueArray = Funs.RemoveDropDownListNull(this.drpRole.SelectedValueArray);
}
}
#endregion
#region
/// <summary>
/// 验证账号是否存在
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
/// <summary>
/// 上传签名
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
/// <summary>
/// 重置密码
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnArrowRefresh_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.PersonId))
{
BLL.Person_PersonsService.UpdatePassword(this.PersonId, BLL.Const.Password);
ShowNotify("密码已重置为原始密码!", MessageBoxIcon.Success);
}
else
{
ShowNotify("请至少选中一行!", MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
///
/// </summary>
private void getInitGridCertificate()
{
Funs.DropDownPageSize(this.ddlPageSizeGridCertificate);
this.btnCertificateNew.OnClientClick = Window1.GetShowReference("../HSSE/QualityAudit/PersonQualityEdit.aspx?PersonId=" + this.PersonId) + "return false;";
BindGridCertificate();
}
#region
/// <summary>
/// 绑定数据
/// </summary>
private void BindGridCertificate()
{
var getData = PersonQualityService.getListData(this.PersonId, GridCertificate);
GridCertificate.RecordCount = PersonQualityService.count;
GridCertificate.DataSource = getData;
GridCertificate.DataBind();
}
#endregion
#region
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridCertificate_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGridCertificate();
}
/// <summary>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSizeGridCertificate_SelectedIndexChanged(object sender, EventArgs e)
{
GridCertificate.PageSize = Convert.ToInt32(ddlPageSizeGridCertificate.SelectedValue);
BindGridCertificate();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridCertificate_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
BindGridCertificate();
}
#endregion
/// <summary>
/// 双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridCertificate_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
this.EditDataCertificate();
}
protected void btnCertificateEdit_Click(object sender, EventArgs e)
{
this.EditDataCertificate();
}
/// <summary>
/// 编辑数据方法
/// </summary>
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, "编辑 - ")));
}
/// <summary>
/// 删除证书信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnCertificateDelete_Click(object sender, EventArgs e)
{
if (GridCertificate.SelectedRowIndexArray.Length > 0)
{
PersonQualityService.DeleteData(GridCertificate.SelectedRowID);
BindGridCertificate();
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
}
}
#endregion
#region
/// <summary>
///
/// </summary>
private void getInitGridTrain()
{
Funs.DropDownPageSize(this.ddlPageSizeGridTrain);
this.btnTrainNew.OnClientClick = Window1.GetShowReference("PersonTrainEdit.aspx?PersonId=" + this.PersonId) + "return false;";
BindGridTrain();
}
#region
/// <summary>
/// 绑定数据
/// </summary>
private void BindGridTrain()
{
var getData = Person_PersonTrainService.getListData(this.PersonId, GridTrain);
GridTrain.RecordCount = Person_PersonTrainService.count;
GridTrain.DataSource = getData;
GridTrain.DataBind();
}
#endregion
#region
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridTrain_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGridTrain();
}
/// <summary>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSizeGridTrain_SelectedIndexChanged(object sender, EventArgs e)
{
GridTrain.PageSize = Convert.ToInt32(ddlPageSizeGridTrain.SelectedValue);
BindGridTrain();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridTrain_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
BindGridTrain();
}
#endregion
/// <summary>
/// 双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridTrain_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
this.EditDataTrain();
}
protected void btnTrainEdit_Click(object sender, EventArgs e)
{
this.EditDataTrain();
}
/// <summary>
/// 编辑数据方法
/// </summary>
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, "编辑 - ")));
}
/// <summary>
/// 删除证书信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnTrainDelete_Click(object sender, EventArgs e)
{
if (GridTrain.SelectedRowIndexArray.Length > 0)
{
Person_PersonTrainService.DeleteData(GridTrain.SelectedRowID);
BindGridTrain();
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
}
}
#endregion
#region
/// <summary>
///
/// </summary>
private void getInitGridQuarterCheck()
{
Funs.DropDownPageSize(this.ddlPageSizeGridQuarterCheck);
BindGridQuarterCheck();
}
#region
/// <summary>
/// 绑定数据
/// </summary>
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<SqlParameter> listStr = new List<SqlParameter>();
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字段转换
/// <summary>
///
/// </summary>
/// <param name="QuarterCheckId"></param>
/// <returns></returns>
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
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridQuarterCheck_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGridQuarterCheck();
}
/// <summary>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSizeGridQuarterCheck_SelectedIndexChanged(object sender, EventArgs e)
{
GridQuarterCheck.PageSize = Convert.ToInt32(ddlPageSizeGridQuarterCheck.SelectedValue);
BindGridQuarterCheck();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridQuarterCheck_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
BindGridQuarterCheck();
}
#endregion
/// <summary>
/// 双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridQuarterCheck_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
this.EditDataQuarterCheck();
}
protected void btnQuarterCheckEdit_Click(object sender, EventArgs e)
{
this.EditDataQuarterCheck();
}
/// <summary>
/// 编辑数据方法
/// </summary>
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
/// <summary>
///
/// </summary>
private void getInitGridDuty()
{
Funs.DropDownPageSize(this.ddlPageSizeGridDuty);
BindGridDuty();
}
#region
/// <summary>
/// 绑定数据
/// </summary>
private void BindGridDuty()
{
var getData = Person_DutyService.getListData(this.PersonId, GridDuty);
GridDuty.RecordCount = Person_DutyService.count;
GridDuty.DataSource = getData;
GridDuty.DataBind();
}
#endregion
#region
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridDuty_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGridDuty();
}
/// <summary>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSizeGridDuty_SelectedIndexChanged(object sender, EventArgs e)
{
GridDuty.PageSize = Convert.ToInt32(ddlPageSizeGridDuty.SelectedValue);
BindGridDuty();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridDuty_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
BindGridDuty();
}
#endregion
/// <summary>
/// 双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridDuty_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
this.EditDataDuty();
}
protected void btnDutyEdit_Click(object sender, EventArgs e)
{
this.EditDataDuty();
}
/// <summary>
/// 编辑数据方法
/// </summary>
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
/// <summary>
///
/// </summary>
private void getInitGridInOut()
{
Funs.DropDownPageSize(this.ddlPageSizeGridInOut);
this.btnInOutNew.OnClientClick = Window1.GetShowReference("PersonItemEdit.aspx?PersonId=" + this.PersonId) + "return false;";
BindGridInOut();
}
#region
/// <summary>
/// 绑定数据
/// </summary>
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
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridInOut_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGridInOut();
}
/// <summary>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSizeGridInOut_SelectedIndexChanged(object sender, EventArgs e)
{
GridInOut.PageSize = Convert.ToInt32(ddlPageSizeGridInOut.SelectedValue);
BindGridInOut();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridInOut_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
BindGridInOut();
}
#endregion
#region
/// <summary>
/// 双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridInOut_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
this.EditDataInOut();
}
protected void btnInOutEdit_Click(object sender, EventArgs e)
{
this.EditDataInOut();
}
/// <summary>
/// 编辑数据方法
/// </summary>
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, "编辑 - ")));
}
/// <summary>
/// 删除证书信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnInOutDelete_Click(object sender, EventArgs e)
{
if (GridInOut.SelectedRowIndexArray.Length > 0)
{
SitePerson_PersonItemService.DeletePersonItem(GridInOut.SelectedRowID);
BindGridInOut();
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
}
}
#endregion
#endregion
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ckIsPost_CheckedChanged(object sender, CheckedEventArgs e)
{
if (!this.ckIsPost.Checked)
{
Alert.ShowInParent("人员不在职,则当前人所在的所有项目都将离场!", MessageBoxIcon.Warning);
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ckIsMultiProject_CheckedChanged(object sender, CheckedEventArgs e)
{
if (this.ckIsMultiProject.Checked)
{
Alert.ShowInParent("人员可在多个项目上同时在岗!", MessageBoxIcon.Warning);
}
}
}
}