323 lines
14 KiB
C#
323 lines
14 KiB
C#
namespace FineUIPro.Web.Personal
|
||
{
|
||
using BLL;
|
||
using System;
|
||
using System.IO;
|
||
using System.Linq;
|
||
|
||
public partial class PersonalInfo : PageBase
|
||
{
|
||
#region 定义变量
|
||
/// <summary>
|
||
/// 照片附件路径
|
||
/// </summary>
|
||
public string PhotoAttachUrl
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["PhotoAttachUrl"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["PhotoAttachUrl"] = value;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 加载页面
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
BasicDataService.InitBasicDataProjectUnitDropDownList(this.drpMaritalStatus, "MARITAL_STATUS", true);
|
||
BasicDataService.InitBasicDataProjectUnitDropDownList(this.drpNation, "MINZU_TYPE", true);
|
||
BasicDataService.InitBasicDataProjectUnitDropDownList(this.drpEduLevel, "EDU_LEVEL", true);
|
||
PositionService.InitPositionDropDownList(this.drpPosition, true);
|
||
PostTitleService.InitPostTitleDropDownList(this.drpPostTitle, true);
|
||
WorkPostService.InitWorkPostDropDownList(this.drpLogWorkPost, true);
|
||
SpecialEquipmentService.InitAllSpecialEquipmentDropDownList(this.drpLogMachine, true);
|
||
/// Tab1加载页面方法
|
||
this.Tab1LoadData();
|
||
if (this.CurrUser.PersonId == Const.hfnbdId)
|
||
{
|
||
this.btnCustomQuery.Hidden = false;
|
||
this.lbSystemVersion.Hidden = false;
|
||
this.lbSystemVersion.Text = Funs.SystemVersion;
|
||
}
|
||
}
|
||
}
|
||
|
||
#region Tab1
|
||
/// <summary>
|
||
/// Tab1加载页面方法
|
||
/// </summary>
|
||
private void Tab1LoadData()
|
||
{
|
||
var getData = Person_PersonsService.GetPerson_PersonsById(this.CurrUser.PersonId);
|
||
if (getData != null)
|
||
{
|
||
this.txtUserName.Text = getData.PersonName;
|
||
this.txtJobNum.Text = getData.JobNum;
|
||
if (!string.IsNullOrEmpty(getData.Sex))
|
||
{
|
||
this.rblSex.SelectedValue = getData.Sex;
|
||
}
|
||
|
||
this.txtBirthday.Text = string.Format("{0:yyyy-MM-dd}", getData.Birthday);
|
||
this.drpMaritalStatus.SelectedValue = getData.MaritalStatus ?? Const._Null;
|
||
this.drpNation.SelectedValue = getData.Nation;
|
||
this.txtUnit.Text = UnitService.GetUnitNameByUnitId(getData.UnitId);
|
||
this.txtAccount.Text = getData.Account;
|
||
this.txtIdentityCard.Text = getData.IdentityCard;
|
||
this.txtTelephone.Text = getData.Telephone;
|
||
this.txtGraduate.Text = getData.Graduate;
|
||
this.drpEduLevel.SelectedValue = getData.EduLevel ?? Const._Null;
|
||
this.drpPosition.SelectedValue = getData.PositionId ?? Const._Null;
|
||
this.drpPostTitle.SelectedValue = getData.PostTitleId ?? Const._Null;
|
||
if (!string.IsNullOrEmpty(getData.LogWorkPostId))
|
||
{
|
||
this.drpLogWorkPost.SelectedValueArray = getData.LogWorkPostId.Split(',');
|
||
}
|
||
if (!string.IsNullOrEmpty(getData.LogMachineId))
|
||
{
|
||
this.drpLogMachine.SelectedValueArray = getData.LogMachineId.Split(',');
|
||
}
|
||
if (!string.IsNullOrEmpty(getData.PhotoUrl))
|
||
{
|
||
this.PhotoAttachUrl = getData.PhotoUrl;
|
||
imgPhoto.ImageUrl = ("~/" + getData.PhotoUrl);
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
protected void btnCustomQuery_Click(object sender, EventArgs e)
|
||
{
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../SysManage/CustomQuery.aspx"), "查询"));
|
||
}
|
||
|
||
/// <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 txtIdentityCard_Blur(object sender, EventArgs e)
|
||
{
|
||
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.CurrUser.PersonId);
|
||
if (q2 != null)
|
||
{
|
||
ShowNotify("输入的身份证号码已存在!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
if (!IDCardValid.CheckIDCard(idCard))
|
||
{
|
||
isok = false;
|
||
ShowNotify("输入的身份证号码有误!", MessageBoxIcon.Warning);
|
||
}
|
||
if (isok)
|
||
{
|
||
///生成二维码
|
||
this.hdUrl.Text = BLL.CreateQRCodeService.CreateCode_Simple("person$" + idCard);
|
||
DateTime? birth = IDCardValid.getBirthByIDCard(idCard);
|
||
if (birth.HasValue)
|
||
{
|
||
this.txtBirthday.Text = string.Format("{0:yyyy-MM-dd}", birth.Value);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
var getData = Person_PersonsService.GetPerson_PersonsById(this.CurrUser.PersonId);
|
||
if (getData != null)
|
||
{
|
||
getData.JobNum = this.txtJobNum.Text.Trim();
|
||
getData.Sex = this.rblSex.SelectedValue;
|
||
getData.IdentityCard = this.txtIdentityCard.Text.Trim();
|
||
getData.Birthday = IDCardValid.getBirthByIDCard(getData.IdentityCard);
|
||
getData.Telephone = this.txtTelephone.Text.Trim();
|
||
getData.Graduate = this.txtGraduate.Text.Trim();
|
||
if (!string.IsNullOrEmpty(this.hdUrl.Text))
|
||
{
|
||
getData.QRCodeAttachUrl = this.hdUrl.Text;
|
||
}
|
||
if (this.drpMaritalStatus.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.drpMaritalStatus.SelectedValue))
|
||
{
|
||
getData.MaritalStatus = this.drpMaritalStatus.SelectedValue;
|
||
}
|
||
if (this.drpNation.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.drpNation.SelectedValue))
|
||
{
|
||
getData.Nation = this.drpNation.SelectedValue;
|
||
}
|
||
if (this.drpNation.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.drpNation.SelectedValue))
|
||
{
|
||
getData.Nation = this.drpNation.SelectedValue;
|
||
}
|
||
if (this.drpEduLevel.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.drpEduLevel.SelectedValue))
|
||
{
|
||
getData.EduLevel = this.drpEduLevel.SelectedValue;
|
||
}
|
||
if (this.drpPosition.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.drpPosition.SelectedValue))
|
||
{
|
||
getData.PositionId = this.drpPosition.SelectedValue;
|
||
}
|
||
if (this.drpPostTitle.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.drpPostTitle.SelectedValue))
|
||
{
|
||
getData.PostTitleId = this.drpPostTitle.SelectedValue;
|
||
}
|
||
string logWorkPostId = string.Empty;
|
||
foreach (var item in this.drpLogWorkPost.SelectedValueArray)
|
||
{
|
||
if (item != BLL.Const._Null)
|
||
{
|
||
logWorkPostId += item + ",";
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(logWorkPostId))
|
||
{
|
||
logWorkPostId = logWorkPostId.Substring(0, logWorkPostId.Length - 1);
|
||
}
|
||
getData.LogWorkPostId = logWorkPostId;
|
||
string logMachineId = string.Empty;
|
||
foreach (var item in this.drpLogMachine.SelectedValueArray)
|
||
{
|
||
if (item != BLL.Const._Null)
|
||
{
|
||
logMachineId += item + ",";
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(logMachineId))
|
||
{
|
||
logMachineId = logMachineId.Substring(0, logMachineId.Length - 1);
|
||
}
|
||
getData.LogMachineId = logMachineId;
|
||
if (!string.IsNullOrEmpty(imgPhoto.ImageUrl) && imgPhoto.ImageUrl != "~/res/images/blank.png")
|
||
{
|
||
getData.PhotoUrl = imgPhoto.ImageUrl.Replace("~/", "");
|
||
getData.HeadImage = AttachFileService.SetImageToByteArray(Funs.RootPath + getData.PhotoUrl);
|
||
}
|
||
else
|
||
{
|
||
getData.PhotoUrl = null;
|
||
getData.HeadImage = null;
|
||
}
|
||
string info = Person_PersonsService.ValidPersonInfo(getData);
|
||
if (string.IsNullOrEmpty(info))
|
||
{
|
||
Person_PersonsService.UpdatePerson(getData);
|
||
this.CurrUser.LogWorkPostId = getData.LogWorkPostId;
|
||
this.CurrUser.LogMachineId = getData.LogMachineId;
|
||
LogService.AddSys_Log(this.CurrUser, getData.PersonName, getData.PersonId, BLL.Const.PersonalInfoMenuId, BLL.Const.BtnModify);
|
||
Alert.ShowInParent("保存成功!", MessageBoxIcon.Success);
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInParent(info, MessageBoxIcon.Warning);
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnALLSave_Click(object sender, EventArgs e)
|
||
{
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../Person/PersonEdit.aspx?PersonId={0}", this.CurrUser.PersonId, "编辑 - ")));
|
||
}
|
||
|
||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||
{
|
||
this.Tab1LoadData();
|
||
}
|
||
|
||
#region 下载模板
|
||
/// <summary>
|
||
/// 下载模板按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnDownLoad_Click(object sender, EventArgs e)
|
||
{
|
||
PageContext.RegisterStartupScript(Confirm.GetShowReference("确定下载操作手册吗?", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_OK"), PageManager1.GetCustomEventReference("Confirm_Cancel")));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 下载导入模板
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void PageManager1_CustomEvent(object sender, CustomEventArgs e)
|
||
{
|
||
if (e.EventArgument == "Confirm_OK")
|
||
{
|
||
string rootPath = Server.MapPath("~/");
|
||
string uploadfilepath = rootPath + Const.HelpUrl;
|
||
string filePath = Const.HelpUrl;
|
||
string fileName = Path.GetFileName(filePath);
|
||
FileInfo info = new FileInfo(uploadfilepath);
|
||
long fileSize = info.Length;
|
||
Response.ClearContent();
|
||
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||
Response.ContentType = "excel/plain";
|
||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||
Response.AddHeader("Content-Length", fileSize.ToString().Trim());
|
||
Response.TransmitFile(uploadfilepath, 0, fileSize);
|
||
Response.End();
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
} |