1313 lines
52 KiB
C#
1313 lines
52 KiB
C#
using BLL;
|
||
using FineUIPro.Web.DataShow;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using AspNet = System.Web.UI.WebControls;
|
||
using Aspose.Words;
|
||
using System.IO;
|
||
using System.Threading;
|
||
using Model;
|
||
|
||
namespace FineUIPro.Web.HSSE.SitePerson
|
||
{
|
||
public partial class PersonList : PageBase
|
||
{
|
||
#region 定义项
|
||
/// <summary>
|
||
/// 人员主键
|
||
/// </summary>
|
||
public string PersonId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["PersonId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["PersonId"] = value;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 项目id
|
||
/// </summary>
|
||
public string ProjectId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["ProjectId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["ProjectId"] = value;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 加载页面
|
||
/// <summary>
|
||
/// 加载页面
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
Funs.DropDownPageSize(this.ddlPageSize);
|
||
this.ProjectId = this.CurrUser.LoginProjectId;
|
||
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
|
||
{
|
||
this.ProjectId = Request.Params["projectId"];
|
||
}
|
||
this.ucTree.UnitId = this.CurrUser.UnitId;
|
||
this.ucTree.ProjectId = this.ProjectId;
|
||
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
||
{
|
||
this.panelLeftRegion1.Hidden = true;
|
||
////权限按钮方法
|
||
this.GetButtonPower();
|
||
}
|
||
|
||
this.btnMenuDelete.OnClientClick = Grid1.GetNoSelectionAlertReference("请至少选择一项!");
|
||
this.btnMenuDelete.ConfirmText = String.Format("你确定要删除选中的 <b><script>{0}</script></b> 行数据吗?", Grid1.GetSelectedCountReference());
|
||
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
||
BLL.WorkPostService.InitWorkPostDropDownList(this.drpPost, true);
|
||
this.InitTreeMenu();//加载树
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 公司级树加载
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void changeTree(object sender, EventArgs e)
|
||
{
|
||
this.ProjectId = this.ucTree.ProjectId;
|
||
this.InitTreeMenu();
|
||
this.BindGrid();
|
||
this.GetButtonPower();
|
||
if (string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
||
{
|
||
btnNew.Hidden = true;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 加载树
|
||
/// </summary>
|
||
private void InitTreeMenu()
|
||
{
|
||
this.tvProjectAndUnit.Nodes.Clear();
|
||
var project = BLL.ProjectService.GetProjectByProjectId(this.ProjectId);
|
||
if (project != null)
|
||
{
|
||
var personLists = BLL.PersonService.GetPersonList(project.ProjectId);
|
||
TreeNode rootNode = new TreeNode();
|
||
rootNode = new TreeNode
|
||
{
|
||
Text = project.ProjectName,
|
||
NodeID = project.ProjectId
|
||
};
|
||
if (personLists.Count() > 0)
|
||
{
|
||
var personIn = personLists.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.IsUsed == true
|
||
&& x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime > DateTime.Now)).ToList();
|
||
rootNode.ToolTip = "当前项目人员总数:" + personLists.Count() + ";在场人员数:" + personIn.Count() + ";离场人员数:" + (personLists.Count() - personIn.Count());
|
||
}
|
||
else
|
||
{
|
||
rootNode.ToolTip = "当前项目人员总数:0";
|
||
}
|
||
rootNode.Expanded = true;
|
||
this.tvProjectAndUnit.Nodes.Add(rootNode);
|
||
GetUnitLists(rootNode.Nodes, this.ProjectId, personLists);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 加载单位
|
||
/// </summary>
|
||
/// <param name="nodes"></param>
|
||
/// <param name="parentId"></param>
|
||
private void GetUnitLists(TreeNodeCollection nodes, string parentId, List<Model.SitePerson_Person> personLists)
|
||
{
|
||
List<Model.Base_Unit> unitLists = BLL.UnitService.GetUnitByProjectIdList(parentId);
|
||
if (unitLists.Count() > 0)
|
||
{
|
||
if (BLL.ProjectUnitService.GetProjectUnitTypeByProjectIdUnitId(parentId, this.CurrUser.UnitId))
|
||
{
|
||
unitLists = unitLists.Where(x => x.UnitId == this.CurrUser.UnitId).ToList();
|
||
}
|
||
|
||
//添加其他单位/无单位人员
|
||
Model.Base_Unit otherUnit = new Model.Base_Unit
|
||
{
|
||
UnitId = "0",
|
||
UnitName = "其他"
|
||
};
|
||
unitLists.Add(otherUnit);
|
||
|
||
TreeNode newNode = null;
|
||
foreach (var q in unitLists)
|
||
{
|
||
newNode = new TreeNode
|
||
{
|
||
Text = q.UnitName,
|
||
NodeID = q.UnitId + "|" + parentId,
|
||
ToolTip = q.UnitName
|
||
};
|
||
if (personLists.Count() > 0)
|
||
{
|
||
var personUnitLists = personLists.Where(x => x.UnitId == q.UnitId);
|
||
if (q.UnitId == "0")
|
||
{
|
||
personUnitLists = personLists.Where(x => x.UnitId == null);
|
||
}
|
||
|
||
if (personUnitLists.Count() > 0)
|
||
{
|
||
var personIn = personUnitLists.Where(x => x.InTime <= System.DateTime.Now && x.IsUsed == true
|
||
&& (!x.OutTime.HasValue || x.OutTime >= System.DateTime.Now));
|
||
newNode.ToolTip = q.UnitName + "人员总数:" + personUnitLists.Count() + ";在场人员数:" + personIn.Count() + ";离场人员数:" + (personUnitLists.Count() - personIn.Count());
|
||
}
|
||
else
|
||
{
|
||
newNode.ToolTip = q.UnitName + "人员总数:0";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
newNode.ToolTip = q.UnitName + "人员总数:0";
|
||
}
|
||
newNode.EnableClickEvent = true;
|
||
nodes.Add(newNode);
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 绑定数据
|
||
/// </summary>
|
||
private void BindGrid()
|
||
{
|
||
if (string.IsNullOrEmpty(this.ProjectId))
|
||
{
|
||
return;
|
||
}
|
||
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
if (this.tvProjectAndUnit != null && !string.IsNullOrEmpty(this.tvProjectAndUnit.SelectedNodeID))
|
||
{
|
||
string id = this.tvProjectAndUnit.SelectedNodeID;
|
||
string unitId = string.Empty;
|
||
string projectId = string.Empty;
|
||
var str = id.Split('|');
|
||
if (str.Count() > 1)
|
||
{
|
||
unitId = str[0];
|
||
projectId = str[1];
|
||
}
|
||
|
||
string strSql = "select * from View_SitePerson_Person Where ProjectId=@ProjectId ";
|
||
List<SqlParameter> listStr = new List<SqlParameter>
|
||
{
|
||
new SqlParameter("@ProjectId", this.ProjectId)
|
||
};
|
||
if (!string.IsNullOrEmpty(unitId) && unitId != "0")
|
||
{
|
||
strSql += " AND UnitId =@UnitId ";
|
||
listStr.Add(new SqlParameter("@UnitId", unitId));
|
||
}
|
||
else
|
||
{
|
||
strSql += " AND UnitId IS NULL";
|
||
}
|
||
if (drpIsUsedTypeName.SelectedValue == "待审核")
|
||
{
|
||
strSql += " AND IsUsedType = @IsUsedType";
|
||
listStr.Add(new SqlParameter("@IsUsedType", "2"));
|
||
}
|
||
else if (drpIsUsedTypeName.SelectedValue == "在岗")
|
||
{
|
||
strSql += " AND IsUsedType = @IsUsedType";
|
||
listStr.Add(new SqlParameter("@IsUsedType", "1"));
|
||
}
|
||
else if (drpIsUsedTypeName.SelectedValue == "离岗")
|
||
{
|
||
strSql += " AND IsUsedType = @IsUsedType";
|
||
listStr.Add(new SqlParameter("@IsUsedType", "0"));
|
||
}
|
||
if (!string.IsNullOrEmpty(this.txtPersonName.Text.Trim()))
|
||
{
|
||
strSql += " AND PersonName LIKE @PersonName";
|
||
listStr.Add(new SqlParameter("@PersonName", "%" + this.txtPersonName.Text.Trim() + "%"));
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(this.txtCardNo.Text.Trim()))
|
||
{
|
||
strSql += " AND CardNo LIKE @CardNo";
|
||
listStr.Add(new SqlParameter("@CardNo", "%" + this.txtCardNo.Text.Trim() + "%"));
|
||
}
|
||
if (!string.IsNullOrEmpty(this.txtIdentityCard.Text.Trim()))
|
||
{
|
||
strSql += " AND IdentityCard LIKE @IdentityCard";
|
||
listStr.Add(new SqlParameter("@IdentityCard", "%" + this.txtIdentityCard.Text.Trim() + "%"));
|
||
}
|
||
if (!string.IsNullOrEmpty(this.drpTreamGroup.SelectedValue) && this.drpTreamGroup.SelectedValue != BLL.Const._Null)
|
||
{
|
||
strSql += " AND TeamGroupId = @TeamGroupId";
|
||
listStr.Add(new SqlParameter("@TeamGroupId", this.drpTreamGroup.SelectedValue));
|
||
}
|
||
|
||
if (this.drpPost.SelectedItemArray.Count() > 1 || (this.drpPost.SelectedValue != BLL.Const._Null && this.drpPost.SelectedItemArray.Count() == 1))
|
||
{
|
||
strSql += " AND (1=2 ";
|
||
int i = 0;
|
||
foreach (var item in this.drpPost.SelectedValueArray)
|
||
{
|
||
if (!string.IsNullOrEmpty(item) && item != BLL.Const._Null)
|
||
{
|
||
strSql += " OR WorkPostId = @WorkPostId" + i.ToString();
|
||
listStr.Add(new SqlParameter("@WorkPostId" + i.ToString(), item));
|
||
}
|
||
|
||
i++;
|
||
}
|
||
|
||
strSql += ")";
|
||
}
|
||
if (this.ckTrain.Checked)
|
||
{
|
||
strSql += " AND TrainCount =0";
|
||
}
|
||
if (this.ckIdCardInfoNotOK.Checked)
|
||
{
|
||
strSql += " AND (IdcardType is null or IdentityCard is null or PhotoUrl is null or (select count(*) from AttachFile where ToKeyId=PersonId+'#1')=0 or (select count(*) from AttachFile where ToKeyId=PersonId+'#5')=0)";
|
||
}
|
||
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
|
||
Grid1.RecordCount = tb.Rows.Count;
|
||
var table = this.GetPagedDataTable(Grid1, tb);
|
||
Grid1.DataSource = table;
|
||
Grid1.DataBind();
|
||
|
||
for (int i = 0; i < Grid1.Rows.Count; i++)
|
||
{
|
||
string personId = Grid1.Rows[i].DataKeys[0].ToString();
|
||
var person = BLL.PersonService.GetPersonById(personId);
|
||
|
||
if (person.IsUsedType=="2") //待审批
|
||
{
|
||
Grid1.Rows[i].RowCssClass = "Yellow";
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 点击TreeView
|
||
/// <summary>
|
||
/// 点击TreeView
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void tvProjectAndUnit_NodeCommand(object sender, TreeCommandEventArgs e)
|
||
{
|
||
this.drpTreamGroup.Items.Clear();
|
||
if (this.tvProjectAndUnit.SelectedNodeID.Contains("|"))
|
||
{
|
||
string id = this.tvProjectAndUnit.SelectedNodeID;
|
||
string unitId = string.Empty;
|
||
string projectId = string.Empty;
|
||
var str = id.Split('|');
|
||
if (str.Count() > 1)
|
||
{
|
||
unitId = str[0];
|
||
projectId = str[1];
|
||
}
|
||
BLL.TeamGroupService.InitTeamGroupProjectUnitDropDownList(this.drpTreamGroup, projectId, unitId, true);
|
||
|
||
BindGrid();
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 页索引改变事件
|
||
/// <summary>
|
||
/// 页索引改变事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||
{
|
||
Grid1.PageIndex = e.NewPageIndex;
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 排序
|
||
/// <summary>
|
||
/// 排序
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
||
{
|
||
Grid1.SortDirection = e.SortDirection;
|
||
Grid1.SortField = e.SortField;
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 分页选择下拉改变事件
|
||
/// <summary>
|
||
/// 分页选择下拉改变事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 增加按钮
|
||
/// <summary>
|
||
/// 增加按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnNew_Click(object sender, EventArgs e)
|
||
{
|
||
if (this.tvProjectAndUnit.SelectedNodeID.Contains("|"))
|
||
{
|
||
string id = this.tvProjectAndUnit.SelectedNodeID;
|
||
string[] str = id.Split('|');
|
||
if (str.Count() > 1)
|
||
{
|
||
string unitId = id.Split('|')[0];
|
||
string projectId = id.Split('|')[1];
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PersonListEdit.aspx?ProjectId={0}&&UnitId={1}", projectId, unitId, "编辑 - ")));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("请选择单位!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 编辑
|
||
/// <summary>
|
||
/// 右键编辑事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
||
{
|
||
this.EditData();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 编辑
|
||
/// </summary>
|
||
private void EditData()
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
this.PersonId = Grid1.SelectedRowID;
|
||
string id = this.tvProjectAndUnit.SelectedNodeID;
|
||
string[] str = id.Split('|');
|
||
if (str.Count() > 1)
|
||
{
|
||
string unitId = id.Split('|')[0];
|
||
string projectId = id.Split('|')[1];
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PersonListEdit.aspx?PersonId={0}&&ProjectId={1}&&UnitId={2}", this.PersonId, projectId, unitId, "编辑 - ")));
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Grid双击事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
||
{
|
||
this.EditData();
|
||
}
|
||
#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, BLL.Const.PersonListMenuId, BLL.Const.BtnDelete);
|
||
BLL.PersonService.DeletePerson(rowID);
|
||
}
|
||
}
|
||
}
|
||
//Project_HSSEData_HSSEService.StatisticalData(this.CurrUser.LoginProjectId, Project_HSSEData_HSSEService.HSSEDateType.ProjectInformation);
|
||
//Project_HSSEData_HSSEService.StatisticalData(this.CurrUser.LoginProjectId, Project_HSSEData_HSSEService.HSSEDateType.OfSafetySupervisors);
|
||
//Project_CQMSDataService.StatisticalData(this.CurrUser.LoginProjectId, Project_CQMSDataService.CQMSDateType.ManagerData);
|
||
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
|
||
|
||
#region 关闭弹出窗口
|
||
/// <summary>
|
||
/// 关闭弹出窗口
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 判断按钮权限
|
||
/// <summary>
|
||
/// 判断按钮权限
|
||
/// </summary>
|
||
private void GetButtonPower()
|
||
{
|
||
if (Request.Params["value"] == "0")
|
||
{
|
||
return;
|
||
}
|
||
var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.UserId, BLL.Const.PersonListMenuId);
|
||
if (buttonList.Count() > 0)
|
||
{
|
||
if (buttonList.Contains(BLL.Const.BtnAdd))
|
||
{
|
||
this.btnNew.Hidden = false;
|
||
this.btnImport.Hidden = false;
|
||
this.btnPersonOut.Hidden = false;
|
||
}
|
||
if (buttonList.Contains(BLL.Const.BtnModify))
|
||
{
|
||
this.btnMenuEdit.Hidden = false;
|
||
this.btnPersonUnit.Hidden = false;
|
||
}
|
||
if (buttonList.Contains(BLL.Const.BtnDelete))
|
||
{
|
||
this.btnMenuDelete.Hidden = false;
|
||
this.btnPersonUnit.Hidden = false;
|
||
}
|
||
this.btnApprove.Hidden = false;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 导入
|
||
/// <summary>
|
||
/// 导入按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnImport_Click(object sender, EventArgs e)
|
||
{
|
||
//if (this.tvProjectAndUnit.SelectedNodeID.Contains("|"))
|
||
//{
|
||
// string id = this.tvProjectAndUnit.SelectedNodeID;
|
||
// string unitId = string.Empty;
|
||
// string projectId = string.Empty;
|
||
// unitId = id.Split('|')[0];
|
||
// projectId = id.Split('|')[1];
|
||
|
||
//}
|
||
//else
|
||
//{
|
||
// Alert.ShowInTop("请选择单位!", MessageBoxIcon.Warning);
|
||
// return;
|
||
//}
|
||
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("PersonIn.aspx?ProjectId={0}", this.ProjectId, "导入 - ")));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 关闭导入弹出窗口
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Window2_Close(object sender, WindowCloseEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 导出按钮
|
||
/// 导出按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnOut_Click(object sender, EventArgs e)
|
||
{
|
||
Response.ClearContent();
|
||
string filename = Funs.GetNewFileName();
|
||
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 = this.;
|
||
BindGrid();
|
||
Response.Write(GetGridTableHtml(Grid1));
|
||
Response.End();
|
||
}
|
||
|
||
#pragma warning disable CS0108 // “PersonList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
|
||
/// <summary>
|
||
/// 导出方法
|
||
/// </summary>
|
||
/// <param name="grid"></param>
|
||
/// <returns></returns>
|
||
private string GetGridTableHtml(Grid grid)
|
||
#pragma warning restore CS0108 // “PersonList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
|
||
{
|
||
StringBuilder sb = new StringBuilder();
|
||
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
||
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
||
sb.Append("<tr>");
|
||
foreach (GridColumn column in grid.Columns)
|
||
{
|
||
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
||
}
|
||
sb.Append("</tr>");
|
||
foreach (GridRow row in grid.Rows)
|
||
{
|
||
sb.Append("<tr>");
|
||
foreach (GridColumn column in grid.Columns)
|
||
{
|
||
string html = row.Values[column.ColumnIndex].ToString();
|
||
if (column.ColumnID == "tfNumber")
|
||
{
|
||
html = (row.FindControl("labNumber") as AspNet.Label).Text;
|
||
}
|
||
if (column.ColumnID == "tfI")
|
||
{
|
||
html = (row.FindControl("lbI") as AspNet.Label).Text;
|
||
}
|
||
//sb.AppendFormat("<td>{0}</td>", html);
|
||
sb.AppendFormat("<td style='vnd.ms-excel.numberformat:@;width:140px;'>{0}</td>", html);
|
||
}
|
||
|
||
sb.Append("</tr>");
|
||
}
|
||
|
||
sb.Append("</table>");
|
||
|
||
return sb.ToString();
|
||
}
|
||
#endregion
|
||
|
||
#region 批量出场
|
||
/// <summary>
|
||
/// 批量出场按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnPersonOut_Click(object sender, EventArgs e)
|
||
{
|
||
PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("PersonOut.aspx?ProjectId={0}", this.ProjectId, "批量出场 - ")));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 批量单位转换
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnPersonUnit_Click(object sender, EventArgs e)
|
||
{
|
||
if (BLL.CommonService.IsMainUnitOrAdmin(this.CurrUser.UserId))
|
||
{
|
||
PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("PersonUnitRefresh.aspx", "批量单位转换 - ")));
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("非软件管理单位用户,不能调整人员单位!", MessageBoxIcon.Warning);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 关闭导入弹出窗口
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Window3_Close(object sender, WindowCloseEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
|
||
#region 批量审核
|
||
/// <summary>
|
||
/// 批量审核
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnApprove_Click(object sender, EventArgs e)
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
var ids = Grid1.SelectedRowIDArray;
|
||
foreach (var id in ids)
|
||
{
|
||
var person = PersonService.GetPersonById(id);
|
||
if (person.IsUsedType == "2")
|
||
{
|
||
person.IsUsedType = "1";
|
||
PersonService.UpdatePerson(person);
|
||
}
|
||
}
|
||
ShowNotify("操作完成!", MessageBoxIcon.Success);
|
||
}
|
||
#endregion
|
||
|
||
#region 查询
|
||
/// <summary>
|
||
/// 查询
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||
{
|
||
this.BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 批量生成二维码
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnQR_Click(object sender, EventArgs e)
|
||
{
|
||
var getPersons = from x in Funs.DB.SitePerson_Person
|
||
where x.ProjectId == this.ProjectId && x.IdentityCard != null && x.QRCodeAttachUrl == null
|
||
select x;
|
||
int num = 0;
|
||
if (getPersons.Count() > 0)
|
||
{
|
||
foreach (var item in getPersons)
|
||
{
|
||
string url = CreateQRCodeService.CreateCode_Simple("person$" + item.IdentityCard);
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
item.QRCodeAttachUrl = url;
|
||
Funs.DB.SubmitChanges();
|
||
num++;
|
||
}
|
||
}
|
||
}
|
||
ShowNotify("操作完成,新生成二维码" + num.ToString() + "条", MessageBoxIcon.Success);
|
||
}
|
||
/// <summary>
|
||
/// 年龄
|
||
/// </summary>
|
||
/// <param name="compileMan"></param>
|
||
/// <returns></returns>
|
||
protected string ConvertAge(object rirthday)
|
||
{
|
||
string age = string.Empty;
|
||
if (rirthday != null)
|
||
{
|
||
DateTime? bDate = Funs.GetNewDateTime(rirthday.ToString());
|
||
if (bDate.HasValue)
|
||
{
|
||
age = CommonService.CalculateAgeCorrect(bDate.Value).ToString();
|
||
}
|
||
}
|
||
return age;
|
||
}
|
||
|
||
protected void butExport_Click(object sender, EventArgs e)
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
var person = Funs.DB.View_SitePerson_Person.FirstOrDefault(x => x.PersonId == Grid1.SelectedRowID);
|
||
var personData = Funs.DB.SitePerson_Person.FirstOrDefault(x => x.PersonId == Grid1.SelectedRowID);
|
||
|
||
if (person != null)
|
||
{
|
||
string rootPath = Server.MapPath("~/");
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
|
||
if (person.WorkPostName == "电工")
|
||
{
|
||
initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(电工).doc";
|
||
}
|
||
// else if (person.WorkPostName == "电焊工")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(电焊工).doc";
|
||
// }
|
||
// else if (person.WorkPostName == "防水普工")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(防水普工).doc";
|
||
// }
|
||
// else if (person.WorkPostName == "钢筋工")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(钢筋工).doc";
|
||
// }
|
||
// else if (person.WorkPostName == "管理人员")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(管理人员).doc";
|
||
// }
|
||
// else if (person.WorkPostName == "架子工")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(架子工).doc";
|
||
// }
|
||
// else if (person.WorkPostName == "木工")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(木工).doc";
|
||
// }
|
||
// else if (person.WorkPostName == "普工")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(普工).doc";
|
||
// }
|
||
// else if (person.WorkPostName == "施工电梯司机")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(施工电梯司机).doc";
|
||
// }
|
||
// else if (person.WorkPostName == "水电工")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(水电工).doc";
|
||
// }
|
||
// else if (person.WorkPostName == "司索信号工")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(司索信号工).doc";
|
||
// }
|
||
// else if (person.WorkPostName == "塔吊司机")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(塔吊司机).doc";
|
||
// }
|
||
// else if (person.WorkPostName == "挖机司机")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(挖机司机).doc";
|
||
// }
|
||
// else if (person.WorkPostName == "瓦工")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(瓦工).doc";
|
||
// }
|
||
// else if (person.WorkPostName == "渣土车司机")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(渣土车司机).doc";
|
||
// }
|
||
// else if (person.WorkPostName == "桩基")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(桩基).doc";
|
||
// }
|
||
// else if (person.WorkPostName == "装配、灌浆工")
|
||
// {
|
||
// initTemplatePath = "File\\Word\\Person\\安全教育培训打印整套(装配、灌浆工).doc";
|
||
// }
|
||
else
|
||
{
|
||
Alert.ShowInTop("当前岗位类型不可导出!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
uploadfilepath = rootPath + initTemplatePath;
|
||
newUrl = uploadfilepath.Replace(".doc", person.PersonName + ".doc");
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
|
||
File.Copy(uploadfilepath, newUrl);
|
||
AsposeWordHelper helper = new AsposeWordHelper();
|
||
helper.OpenTempelte(newUrl); //打开模板文件
|
||
|
||
string projectName = Funs.DB.Base_Project.First(z => z.ProjectId == person.ProjectId).ProjectName;
|
||
string name = person.PersonName;
|
||
string time = DateTime.Now.ToString("yyyy-MM-dd");
|
||
string sex = string.IsNullOrEmpty(person.Sex) ? "" : person.Sex == "1" ? "男" : "女";
|
||
string InTime = person.InTime.HasValue ? string.Format("{0:yyyy-MM-dd}", person.InTime) : "";
|
||
string IdCardFront = AttachFileService.getFileUrl(person.PersonId + "#1");
|
||
string IdCardBack = AttachFileService.getFileUrl(person.PersonId + "#5");
|
||
if (!string.IsNullOrEmpty(IdCardFront))
|
||
{
|
||
helper.AddImage(rootPath + IdCardFront, "IdCardFront", 100, 100, 10, 20);
|
||
}
|
||
else
|
||
{
|
||
helper.AddImage(string.Empty, "IdCardFront", 100, 100, 10, 20);
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(IdCardBack))
|
||
{
|
||
helper.AddImage(rootPath + IdCardBack, "IdCardBack", 100, 100, 120, 20);
|
||
}
|
||
else
|
||
{
|
||
helper.AddImage(string.Empty, "IdCardBack", 100, 100, 10, 20);
|
||
}
|
||
|
||
var gTrainingTestRecord =
|
||
(from x in Funs.DB.Training_TestRecord
|
||
join TestPlan in Funs.DB.Training_TestPlan on x.TestPlanId equals TestPlan.TestPlanId into
|
||
gTestPlan
|
||
from TestPlan in gTestPlan.DefaultIfEmpty()
|
||
join user in Funs.DB.Sys_User on TestPlan.PlanManId equals user.UserId into gUser
|
||
from user in gUser.DefaultIfEmpty()
|
||
where x.TestManId == person.PersonId
|
||
orderby x.TestEndTime descending
|
||
select new
|
||
{
|
||
TestRecordId = x.TestRecordId,
|
||
TestStartTime = x.TestStartTime,
|
||
TestEndTime = x.TestEndTime,
|
||
Signature = x.Signature,
|
||
TestScores = x.TestScores,
|
||
PlanManName = user == null ? "" : user.UserName
|
||
}).FirstOrDefault();
|
||
|
||
string date1 = "";
|
||
string sign = "";
|
||
string sign1 = "";
|
||
string TestRecordId = "";
|
||
decimal? TestScores = null;
|
||
DateTime? TestStartTime = null;
|
||
DateTime? dateTime1 = null;
|
||
string Signature = "";
|
||
string unitName = "";
|
||
string workPostName = "";
|
||
string testName = "";
|
||
string IdCard = "";
|
||
int SValue = 0;
|
||
int SValueCount = 0;
|
||
int MValue = 0;
|
||
int MValueCount = 0;
|
||
int JValue = 0;
|
||
int JValueCount = 0;
|
||
Sys_TestRule sysTestRule = null;
|
||
IQueryable<Training_TestRecordItem> getTestItems = null;
|
||
List<Training_TestRecordItem> getSingleItem = new List<Training_TestRecordItem>();
|
||
List<Training_TestRecordItem> getMultipleItem = new List<Training_TestRecordItem>();
|
||
List<Training_TestRecordItem> getIsTrueItem = new List<Training_TestRecordItem>();
|
||
if (gTrainingTestRecord != null)
|
||
{
|
||
testName = person.PersonName;
|
||
IdCard = person.IdentityCard;
|
||
Signature = gTrainingTestRecord.Signature;
|
||
TestScores = gTrainingTestRecord.TestScores;
|
||
TestStartTime = gTrainingTestRecord.TestStartTime;
|
||
TestRecordId = gTrainingTestRecord.TestRecordId;
|
||
sign = gTrainingTestRecord.PlanManName;
|
||
sign1 = AttachFileService.getFileUrl(person.PersonId + "_1");
|
||
|
||
dateTime1 = gTrainingTestRecord.TestStartTime.Value;
|
||
|
||
unitName = BLL.UnitService.GetUnitNameByUnitId(person.UnitId);
|
||
workPostName = WorkPostService.getWorkPostNamesWorkPostIds(person.WorkPostId);
|
||
sysTestRule = Funs.DB.Sys_TestRule.FirstOrDefault();
|
||
getTestItems = from x in Funs.DB.Training_TestRecordItem
|
||
where x.TestRecordId == TestRecordId
|
||
select x;
|
||
getSingleItem = getTestItems.Where(x => x.TestType == "1").ToList();
|
||
SValue = sysTestRule.SValue; //每题分数
|
||
SValueCount = sysTestRule.SValue * getSingleItem.Count; //总分
|
||
|
||
getMultipleItem = getTestItems.Where(x => x.TestType == "2").ToList();
|
||
MValue = sysTestRule.MValue; //每题分数
|
||
MValueCount = sysTestRule.MValue * getMultipleItem.Count; //总分
|
||
|
||
getIsTrueItem = getTestItems.Where(x => x.TestType == "3").ToList();
|
||
JValue = sysTestRule.JValue; //每题分数
|
||
JValueCount = sysTestRule.JValue * getIsTrueItem.Count; //总分
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(sign1))
|
||
{
|
||
helper.AddImage(rootPath + sign1, "sign1", 50, 25, 15, 30);
|
||
helper.AddImage(rootPath + sign1, "sign1_1", 50, 25, 15, 30);
|
||
helper.AddImage(rootPath + sign1, "sign1_2", 50, 25, 15, 30);
|
||
}
|
||
else
|
||
{
|
||
helper.AddImage(string.Empty, "sign1", 0, 0, 0, 0);
|
||
helper.AddImage(string.Empty, "sign1_1", 0, 0, 0, 0);
|
||
helper.AddImage(string.Empty, "sign1_2", 0, 0, 0, 0);
|
||
}
|
||
|
||
// 构建格式化的字符串
|
||
date1 = dateTime1.HasValue
|
||
? $" {dateTime1.Value.Year} 年 {dateTime1.Value.Month:D2} 月 {dateTime1.Value.Day:D2} 日"
|
||
: "";
|
||
|
||
string sign2 = AttachFileService.getFileUrl(person.PersonId + "_2");
|
||
if (!string.IsNullOrEmpty(sign2))
|
||
{
|
||
helper.AddImage(rootPath + sign2, "sign2", 50, 25, 130, 0);
|
||
}
|
||
else
|
||
{
|
||
helper.AddImage(string.Empty, "sign2", 0, 0, 0, 0);
|
||
}
|
||
|
||
string date2 = personData.SignTime.HasValue
|
||
? $" {personData.SignTime.Value.Year} 年 {personData.SignTime.Value.Month:D2} 月 {personData.SignTime.Value.Day:D2} 日"
|
||
: "";
|
||
|
||
string IdentityCard = person.IdentityCard;
|
||
string Telephone = person.Telephone;
|
||
|
||
string year = person.InTime.HasValue ? person.InTime.Value.Year.ToString() : "";
|
||
string month = person.InTime.HasValue ? person.InTime.Value.Month.ToString() : "";
|
||
string day = person.InTime.HasValue ? person.InTime.Value.Day.ToString() : "";
|
||
|
||
string sign3 = AttachFileService.getFileUrl(person.PersonId + "_3");
|
||
if (!string.IsNullOrEmpty(sign3))
|
||
{
|
||
helper.AddImage(rootPath + sign3, "sign3", 50, 25, 350, 5);
|
||
}
|
||
else
|
||
{
|
||
helper.AddImage(string.Empty, "sign3", 0, 0, 0, 0);
|
||
}
|
||
|
||
string sign4 = AttachFileService.getFileUrl(person.PersonId + "_4");
|
||
if (!string.IsNullOrEmpty(sign4))
|
||
{
|
||
helper.AddImage(rootPath + sign4, "sign4", 50, 25, 100, 5);
|
||
}
|
||
else
|
||
{
|
||
helper.AddImage(string.Empty, "sign4", 0, 0, 0, 0);
|
||
}
|
||
|
||
string sign5 = AttachFileService.getFileUrl(person.PersonId + "_5");
|
||
if (!string.IsNullOrEmpty(sign5))
|
||
{
|
||
helper.AddImage(rootPath + sign5, "sign5", 50, 25, 320, 5);
|
||
}
|
||
else
|
||
{
|
||
helper.AddImage(string.Empty, "sign5", 0, 0, 0, 0);
|
||
}
|
||
|
||
#region 试卷
|
||
|
||
#region 单选
|
||
|
||
DataTable tableS = new DataTable("TableS");
|
||
tableS.Columns.Add("SProblem");
|
||
tableS.Columns.Add("SOption");
|
||
|
||
if (getSingleItem.Count > 0)
|
||
{
|
||
int num = 1;
|
||
foreach (var item in getSingleItem)
|
||
{
|
||
string Avstracts = item.Abstracts.Replace(" ", "").Replace(" ", "").Replace("(", "(")
|
||
.Replace(")", ")").Replace("()", "(" + item.SelectedItem + ")");
|
||
string SProblem = num + "、" + Avstracts + " 正确答案:" + item.AnswerItems;
|
||
string str = string.Empty;
|
||
if (!string.IsNullOrEmpty(item.AItem))
|
||
{
|
||
str += "A." + item.AItem;
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(item.BItem))
|
||
{
|
||
str += " B." + item.BItem;
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(item.CItem))
|
||
{
|
||
str += " C." + item.CItem;
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(item.DItem))
|
||
{
|
||
str += " D." + item.DItem;
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(item.EItem))
|
||
{
|
||
str += " E." + item.EItem;
|
||
}
|
||
|
||
string SOption = str;
|
||
tableS.Rows.Add(new object[] { SProblem, SOption });
|
||
num++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
tableS.Rows.Add(new object[] { "", "" });
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 多选
|
||
|
||
DataTable tableM = new DataTable("TableM");
|
||
tableM.Columns.Add("MProblem");
|
||
tableM.Columns.Add("MOption");
|
||
if (getMultipleItem.Count > 0)
|
||
{
|
||
int num = 1;
|
||
foreach (var item in getMultipleItem)
|
||
{
|
||
string Avstracts = item.Abstracts.Replace(" ", "").Replace(" ", "").Replace("(", "(")
|
||
.Replace(")", ")").Replace("()", "(" + item.SelectedItem + ")");
|
||
string MProblem = num + "、" + Avstracts + " 正确答案:" + item.AnswerItems;
|
||
string str = string.Empty;
|
||
if (!string.IsNullOrEmpty(item.AItem))
|
||
{
|
||
str += "A." + item.AItem;
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(item.BItem))
|
||
{
|
||
str += " B." + item.BItem;
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(item.CItem))
|
||
{
|
||
str += " ;C." + item.CItem;
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(item.DItem))
|
||
{
|
||
str += " ;D." + item.DItem;
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(item.EItem))
|
||
{
|
||
str += " ;E." + item.EItem;
|
||
}
|
||
|
||
string MOption = str;
|
||
tableM.Rows.Add(new object[] { MProblem, MOption });
|
||
num++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
tableM.Rows.Add(new object[] { "", "" });
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 判断
|
||
|
||
DataTable tableJ = new DataTable("TableJ");
|
||
tableJ.Columns.Add("data");
|
||
|
||
if (getIsTrueItem.Count > 0)
|
||
{
|
||
int num = 1;
|
||
foreach (var item in getIsTrueItem)
|
||
{
|
||
var Avstracts = item.Abstracts;
|
||
if (Avstracts.IndexOf("(") > -1)
|
||
{
|
||
Avstracts = Avstracts.Replace("(", "(" + item.SelectedItem == "(A" ? "(√" : "(×");
|
||
}
|
||
else
|
||
{
|
||
if (Avstracts.IndexOf("(") > -1)
|
||
Avstracts = Avstracts.Replace("(", "(" + item.SelectedItem == "(A" ? "(√" : "(×");
|
||
}
|
||
|
||
string data = num + "、" + Avstracts + " 正确答案:" + (item.AnswerItems == "A" ? "√" : "×");
|
||
tableJ.Rows.Add(new object[] { data });
|
||
num++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
tableJ.Rows.Add(new object[] { "" });
|
||
}
|
||
|
||
#endregion
|
||
|
||
helper.WriteTable(tableS); //集合赋值遍历
|
||
helper.WriteTable(tableM); //集合赋值遍历
|
||
helper.WriteTable(tableJ); //集合赋值遍历
|
||
|
||
//考试抓拍照片
|
||
var attachFile = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == TestRecordId);
|
||
if (attachFile != null && !string.IsNullOrEmpty(attachFile.AttachUrl))
|
||
{
|
||
List<string> listUrl = Funs.GetStrListByStr(attachFile.AttachUrl, ',');
|
||
int count = listUrl.Count();
|
||
if (count > 0)
|
||
{
|
||
helper.AddImage(rootPath + listUrl[0], "imgStr1", 70, 70, 10, 10);
|
||
if (count >= 2)
|
||
{
|
||
int cout2 = count / 2;
|
||
helper.AddImage(rootPath + listUrl[cout2], "imgStr2", 70, 70, 10, 10);
|
||
}
|
||
else
|
||
{
|
||
helper.AddImage(string.Empty, "imgStr2", 0, 0, 0, 0);
|
||
}
|
||
|
||
helper.AddImage(rootPath + listUrl[count - 1], "imgStr3", 70, 70, 10, 10);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
helper.AddImage(string.Empty, "imgStr1", 0, 0, 0, 0);
|
||
helper.AddImage(string.Empty, "imgStr2", 0, 0, 0, 0);
|
||
helper.AddImage(string.Empty, "imgStr3", 0, 0, 0, 0);
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
string[] fieldNames = { };
|
||
object[] fieldValues = { };
|
||
if (!string.IsNullOrEmpty(Signature))
|
||
{
|
||
helper.AddImage(rootPath + Signature, "testName", 50, 25, 10, 5);
|
||
fieldNames = new[]
|
||
{
|
||
"projectName", "name", "time", "sex", "InTime", "sign",
|
||
"date1", "date2", "IdentityCard", "Telephone", "year", "month", "day",
|
||
"unitName", "workPostName", "TestStartTime","IdCard", "TestScores", "SValue", "SValueCount", "MValue",
|
||
"MValueCount", "JValue", "JValueCount"
|
||
};
|
||
|
||
fieldValues = new object[]
|
||
{
|
||
projectName, name, time, sex, InTime, sign, date1, date2,
|
||
IdentityCard, Telephone, year, month, day,
|
||
unitName, workPostName, TestStartTime,IdCard, TestScores, SValue, SValueCount, MValue, MValueCount,
|
||
JValue, JValueCount
|
||
};
|
||
}
|
||
else
|
||
{
|
||
fieldNames = new[]
|
||
{
|
||
"projectName", "name", "time", "sex", "InTime", "sign",
|
||
"date1", "date2", "IdentityCard", "Telephone", "year", "month", "day",
|
||
"unitName", "workPostName", "TestStartTime", "testName", "IdCard", "TestScores", "SValue", "SValueCount",
|
||
"MValue", "MValueCount", "JValue", "JValueCount"
|
||
};
|
||
|
||
fieldValues = new object[]
|
||
{
|
||
projectName, name, time, sex, InTime, sign, date1, date2,
|
||
IdentityCard, Telephone, year, month, day,
|
||
unitName, workPostName, TestStartTime, testName, IdCard, TestScores, SValue, SValueCount,
|
||
MValue, MValueCount, JValue, JValueCount
|
||
};
|
||
}
|
||
|
||
helper.Executefield(fieldNames, fieldValues); //域赋值
|
||
helper.SaveDoc(newUrl); //文件保存,保存为doc
|
||
|
||
// 验证文件是否存在
|
||
if (!File.Exists(newUrl))
|
||
{
|
||
throw new Exception("文件不存在: " + newUrl);
|
||
}
|
||
|
||
string fileName = Path.GetFileName(newUrl);
|
||
FileInfo info = new FileInfo(newUrl);
|
||
long fileSize = info.Length;
|
||
Response.Clear();
|
||
Response.ContentType = "application/x-zip-compressed";
|
||
Response.AddHeader("Content-Disposition",
|
||
"attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||
Response.AddHeader("Content-Length", fileSize.ToString());
|
||
Response.TransmitFile(newUrl, 0, fileSize);
|
||
Response.Flush();
|
||
Response.Close();
|
||
File.Delete(newUrl);
|
||
}
|
||
}
|
||
}
|
||
|
||
} |