This commit is contained in:
geh
2026-03-23 15:22:29 +08:00
parent 94584d242b
commit c38590add8
173 changed files with 19679 additions and 4413 deletions
@@ -11,7 +11,24 @@ namespace FineUIPro.Web.HSSE.OccupationHealth
{
public partial class PhysicalExamination : PageBase
{
#region
/// <summary>
/// 项目主键
/// </summary>
public string ProjectId
{
get { return (string)ViewState["ProjectId"]; }
set { ViewState["ProjectId"] = value; }
}
public string MenuId = Const.CompanySafePersonMenuId;
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
@@ -21,73 +38,145 @@ namespace FineUIPro.Web.HSSE.OccupationHealth
{
if (!IsPostBack)
{
Funs.DropDownPageSize(this.ddlPageSize);
////权限按钮方法
this.GetButtonPower();
this.btnNew.OnClientClick = Window1.GetShowReference("PhysicalExaminationEdit.aspx") + "return false;";
if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
this.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(Request.Params["projectId"]) &&
Request.Params["projectId"] != this.CurrUser.LoginProjectId)
{
Grid1.PageSize = this.CurrUser.PageSize.Value;
this.ProjectId = Request.Params["projectId"];
}
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
this.ucTree.UnitId = this.CurrUser.UnitId;
this.ucTree.ProjectId = this.ProjectId;
BLL.UnitService.InitUnitDropDownList(this.drpUnitId, this.ProjectId, true);
if (BLL.ProjectUnitService.GetProjectUnitTypeByProjectIdUnitId(this.ProjectId, this.CurrUser.UnitId))
{
this.drpUnitId.SelectedValue = this.CurrUser.UnitId;
this.drpUnitId.Enabled = false;
}
Funs.DropDownPageSize(this.ddlPageSize);
// 绑定表格
this.BindGrid();
this.BindGrid();
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId) &&
CommonService.GetThisUnitId() != Const.CncecFccId)
{
MenuId = Const.SafePersonQualityMenuId;
this.panelLeftRegion.Hidden = true;
////权限按钮方法
this.GetButtonPower();
}
if (string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
{
btnMenuEdit.Hidden = true;
btnMenuDelete.Hidden = true;
}
}
}
#endregion
#region GV绑定数据
protected void changeTree(object sender, EventArgs e)
{
this.ProjectId = this.ucTree.ProjectId;
this.BindGrid();
}
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
string strSql = @"SELECT PhysicalExamination.FileId,PhysicalExamination.FileCode,PhysicalExamination.FileName,CompileManUser.UserName AS CompileManName,PhysicalExamination.CompileDate,Project.ProjectName,Project.ProjectCode"
+ @" ,(CASE WHEN PhysicalExamination.States = " + BLL.Const.State_0 + " OR PhysicalExamination.States IS NULL THEN '待['+OperateUser.UserName+']提交' WHEN PhysicalExamination.States = " + BLL.Const.State_2 + " THEN '审核/审批完成' ELSE '待['+OperateUser.UserName+']办理' END) AS FlowOperateName"
+ @" FROM OccupationHealth_PhysicalExamination AS PhysicalExamination"
+ @" LEFT JOIN Sys_FlowOperate AS FlowOperate ON PhysicalExamination.FileId=FlowOperate.DataId AND FlowOperate.IsClosed <> 1"
+ @" LEFT JOIN Sys_User AS OperateUser ON FlowOperate.OperaterId=OperateUser.UserId "
+ @" LEFT JOIN Sys_CodeRecords AS CodeRecords ON PhysicalExamination.FileId=CodeRecords.DataId "
+ @" LEFT JOIN Base_Project AS Project ON PhysicalExamination.ProjectId=Project.ProjectId "
+ @" LEFT JOIN Sys_User AS CompileManUser ON PhysicalExamination.CompileMan =CompileManUser.UserId WHERE 1=1 ";
List<SqlParameter> listStr = new List<SqlParameter>();
if (string.IsNullOrEmpty(this.CurrUser.LoginProjectId)) ///总部查看
{
strSql += " AND PhysicalExamination.States = @States"; ///状态为已完成
listStr.Add(new SqlParameter("@States", BLL.Const.State_2));
if (this.drpProject.SelectedValue != null && this.drpProject.SelectedValue != BLL.Const._Null)
var db = Funs.DB;
var query = (
from person in db.SitePerson_Person
join post in db.Base_WorkPost on person.WorkPostId equals post.WorkPostId into posts
from post in posts.DefaultIfEmpty()
join unit in db.Base_Unit on person.UnitId equals unit.UnitId into units
from unit in units.DefaultIfEmpty()
join edu in db.RealName_BasicData on person.EduLevel equals edu.DictCode into edus
from edu in edus.DefaultIfEmpty()
join project in db.Base_Project on person.ProjectId equals project.ProjectId into projects
from project in projects.DefaultIfEmpty()
join att in db.AttachFile on (person.PersonId + "#3") equals att.ToKeyId into atts
from att in atts.DefaultIfEmpty()
join teamGroup in db.ProjectData_TeamGroup on person.TeamGroupId equals teamGroup.TeamGroupId into teamGroups
from teamGroup in teamGroups.DefaultIfEmpty()
where person.ProjectId == this.ProjectId
&& att.AttachFileId != null
select new
{
strSql += " AND PhysicalExamination.ProjectId = @ProjectId";
listStr.Add(new SqlParameter("@ProjectId", this.drpProject.SelectedValue));
person.ProjectId,
person.UnitId,
person.PersonId,
person.PersonName,
person.Birthday,
Sex = person.Sex == "1" ? "男" : person.Sex == "2" ? "女" : "",
edu.DictName,
unit.UnitName,
post.WorkPostName,
person.Major,
person.SafeWorkingYears,
person.WorkingYears,
person.InTime,
person.IsUsed,
IsUsedName = person.IsUsed == true ? "是" : "否",
person.OutTime,
ProjectUnitId = project.UnitId,
project.ShortName,
TeamGroupName = teamGroup.TeamGroupName,
}
).Distinct();
if (!string.IsNullOrEmpty(ProjectId) && ProjectId != Const._Null)
{
query = query.Where(e => e.ProjectId == ProjectId);
}
else
{
if (this.ucTree.UnitId != CommonService.GetThisUnitId())
{
query = query.Where(e => e.ProjectUnitId == this.ucTree.UnitId).OrderBy(e => e.ShortName)
.ThenBy(e => e.UnitId);
}
}
else //现场查看
{
strSql += " AND PhysicalExamination.ProjectId = @ProjectId";
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
}
if (!string.IsNullOrEmpty(this.txtFileCode.Text.Trim()))
{
strSql += " AND FileCode LIKE @FileCode";
listStr.Add(new SqlParameter("@FileCode", "%" + this.txtFileCode.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.txtFileName.Text.Trim()))
{
strSql += " AND PhysicalExamination.FileName LIKE @FileName";
listStr.Add(new SqlParameter("@FileName", "%" + this.txtFileName.Text.Trim() + "%"));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.RecordCount = tb.Rows.Count;
tb = GetFilteredTable(Grid1.FilteredData, tb);
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
// 添加计数的序号
var groupedQuery = query.ToList().GroupBy(p => p.PersonId).SelectMany((group, index) =>
group.Select((person, personIndex) => new
{
Index = index + 1,
person.PersonId,
person.PersonName,
person.Birthday,
person.Sex,
person.DictName,
person.UnitName,
person.WorkPostName,
person.Major,
person.SafeWorkingYears,
person.WorkingYears,
person.InTime,
person.IsUsed,
person.IsUsedName,
person.OutTime,
person.ShortName,
person.TeamGroupName
})).ToList();
this.Grid1.RecordCount = groupedQuery.Select(p => p.PersonId).Distinct().Count();
this.lbAllPersonNum.Text = "合计:共" + groupedQuery
.Select(g => g.Index)
.DefaultIfEmpty(0) // 当集合为空时提供默认值0
.Max()
+ "人";
var table = groupedQuery.OrderBy(p => p.Index).Skip(this.Grid1.PageIndex * this.Grid1.PageSize)
.Take(this.Grid1.PageSize).ToList();
this.Grid1.DataSource = table;
this.Grid1.DataBind();
}
#region
/// <summary>
/// 改变索引事件
/// </summary>
@@ -95,7 +184,7 @@ namespace FineUIPro.Web.HSSE.OccupationHealth
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
this.BindGrid();
}
/// <summary>
@@ -106,7 +195,7 @@ namespace FineUIPro.Web.HSSE.OccupationHealth
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue);
BindGrid();
this.BindGrid();
}
/// <summary>
@@ -118,10 +207,11 @@ namespace FineUIPro.Web.HSSE.OccupationHealth
{
this.BindGrid();
}
#endregion
#endregion
#region
/// <summary>
/// 查询
/// </summary>
@@ -131,9 +221,21 @@ namespace FineUIPro.Web.HSSE.OccupationHealth
{
this.BindGrid();
}
/// <summary>
/// 关闭导入弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 双击事件
/// </summary>
@@ -164,50 +266,30 @@ namespace FineUIPro.Web.HSSE.OccupationHealth
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string id = Grid1.SelectedRowID;
var OccupationHealth = BLL.PhysicalExaminationService.GetPhysicalExaminationById(id);
if (OccupationHealth != null)
string id = Grid1.SelectedRow.DataKeys[0].ToString();
var person = BLL.PersonService.GetPersonById(id);
if (person != null)
{
if (this.btnMenuEdit.Hidden) ////双击事件 编辑权限有:编辑页面,无:查看页面 或者状态是完成时查看页面
if (!string.IsNullOrEmpty(ProjectId))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PhysicalExaminationView.aspx?FileId={0}", id, "查看 - ")));
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format(
"PhysicalExaminationEdit.aspx?ProjectId={0}&&Type={1}&&PersonId={2}&&UnitId={3}", this.ProjectId, "0",
id, ucTree.UnitId, "编辑 - ")));
}
else
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PhysicalExaminationEdit.aspx?FileId={0}", id, "编辑 - ")));
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format(
"PhysicalExaminationEdit.aspx?ProjectId={0}&&Type={1}&&PersonId={2}&&UnitId={3}&&CompanyEdit={4}",
this.ProjectId, "0", id, ucTree.UnitId, 1, "编辑 - ")));
}
}
}
#endregion
#region
/// <summary>
/// 右键删除事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length > 0)
{
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
var getD = BLL.PhysicalExaminationService.GetPhysicalExaminationById(rowID);
if (getD != null)
{
BLL.LogService.AddSys_Log(this.CurrUser, getD.FileCode, getD.FileId, BLL.Const.ServerPhysicalExaminationMenuId, BLL.Const.BtnDelete);
BLL.PhysicalExaminationService.DeletePhysicalExaminationById(rowID);
}
}
this.BindGrid();
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
}
}
}
#endregion
#region
/// <summary>
/// 获取按钮权限
/// </summary>
@@ -215,22 +297,10 @@ namespace FineUIPro.Web.HSSE.OccupationHealth
/// <returns></returns>
private void GetButtonPower()
{
if (Request.Params["value"] == "0")
{
return;
}
string menuId = BLL.Const.ServerPhysicalExaminationMenuId;
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
{
menuId = BLL.Const.PhysicalExaminationMenuId;
}
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, menuId);
var buttonList =
BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, MenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
this.btnNew.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnModify))
{
this.btnMenuEdit.Hidden = false;
@@ -240,12 +310,8 @@ namespace FineUIPro.Web.HSSE.OccupationHealth
this.btnMenuDelete.Hidden = false;
}
}
else
{
this.drpProject.Hidden = false;
BLL.ProjectService.InitAllProjectDropDownList(this.drpProject, true);
}
}
#endregion
#region
@@ -257,7 +323,9 @@ namespace FineUIPro.Web.HSSE.OccupationHealth
{
Response.ClearContent();
string filename = Funs.GetNewFileName();
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("体检管理" + filename, System.Text.Encoding.UTF8) + ".xls");
Response.AddHeader("content-disposition",
"attachment; filename=" +
System.Web.HttpUtility.UrlEncode("职业健康体检" + filename, System.Text.Encoding.UTF8) + ".xls");
Response.ContentType = "application/excel";
Response.ContentEncoding = System.Text.Encoding.UTF8;
this.Grid1.PageSize = 500;
@@ -266,14 +334,12 @@ namespace FineUIPro.Web.HSSE.OccupationHealth
Response.End();
}
#pragma warning disable CS0108 // “PhysicalExamination.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
/// <summary>
/// 导出方法
/// </summary>
/// <param name="grid"></param>
/// <returns></returns>
private string GetGridTableHtml(Grid grid)
#pragma warning restore CS0108 // “PhysicalExamination.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
{
StringBuilder sb = new StringBuilder();
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
@@ -281,8 +347,12 @@ namespace FineUIPro.Web.HSSE.OccupationHealth
sb.Append("<tr>");
foreach (GridColumn column in grid.Columns)
{
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
if (column.ColumnID != "attWindow")
{
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
}
}
sb.Append("</tr>");
foreach (GridRow row in grid.Rows)
{
@@ -294,7 +364,11 @@ namespace FineUIPro.Web.HSSE.OccupationHealth
{
html = (row.FindControl("lblNumber") as AspNet.Label).Text;
}
sb.AppendFormat("<td>{0}</td>", html);
if (column.ColumnID != "attWindow")
{
sb.AppendFormat("<td>{0}</td>", html);
}
}
sb.Append("</tr>");
@@ -304,6 +378,88 @@ namespace FineUIPro.Web.HSSE.OccupationHealth
return sb.ToString();
}
#endregion
#endregion
#region
/// <summary>
/// 右键删除事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
this.DeleteData();
}
/// <summary>
/// 删除方法
/// </summary>
private void DeleteData()
{
if (Grid1.SelectedRowIndexArray.Length > 0)
{
bool isShow = false;
if (Grid1.SelectedRowIndexArray.Length == 1)
{
isShow = true;
}
int i = 0;
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
if (this.judgementDelete(rowID, isShow))
{
i++;
var getV = BLL.PersonService.GetPersonById(rowID);
if (getV != null)
{
BLL.LogService.AddSys_Log(this.CurrUser, getV.PersonName, getV.PersonId, MenuId,
BLL.Const.BtnDelete);
BLL.PersonService.DeletePerson(rowID);
}
}
}
BindGrid();
if (i > 0)
{
ShowNotify("删除数据成功!(表格数据已重新绑定)", MessageBoxIcon.Success);
}
}
}
/// <summary>
/// 判断是否可删除
/// </summary>
/// <param name="rowID"></param>
/// <param name="isShow"></param>
/// <returns></returns>
private bool judgementDelete(string rowID, bool isShow)
{
string content = string.Empty;
//var q = from x in Funs.DB.QualityAudit_PersonQuality where x.PersonId == rowID select x;
//if (q.Count() > 0)
//{
// content += "人员资质中已存在该人员,无法删除!";
//}
if (string.IsNullOrEmpty(content))
{
return true;
}
else
{
if (isShow)
{
Alert.ShowInTop(content);
}
return false;
}
}
#endregion
}
}