提交代码
This commit is contained in:
@@ -7,7 +7,13 @@ using System.Data;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using static FineUIPro.Web.TestRun.Report.PreRunSchedule;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.SS.Util;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using System.IO;
|
||||
|
||||
namespace FineUIPro.Web.TestRun.Report
|
||||
{
|
||||
@@ -18,14 +24,15 @@ namespace FineUIPro.Web.TestRun.Report
|
||||
/// </summary>
|
||||
public string TreePreRunId { get { return (string)ViewState["TreePreRunId"]; } set { ViewState["TreePreRunId"] = value; } }
|
||||
/// <summary>
|
||||
/// 子系统主键
|
||||
/// 系统主键
|
||||
/// </summary>
|
||||
public string SsubSystemId { get { return (string)ViewState["SsubSystemId"]; } set { ViewState["SsubSystemId"] = value; } }
|
||||
public List<string> SystemIds { get { return (List<string>)ViewState["SystemIds"]; } set { ViewState["SystemIds"] = value; } }
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
if (SystemIds == null) SystemIds = new List<string>();
|
||||
this.InitTreeMenu();//加载树
|
||||
}
|
||||
}
|
||||
@@ -107,76 +114,203 @@ namespace FineUIPro.Web.TestRun.Report
|
||||
/// <param name="e"></param>
|
||||
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
||||
{
|
||||
var devices = new List<PreRun_SysDevice>();
|
||||
this.TreePreRunId = tvControlItem.SelectedNodeID != "0" ? tvControlItem.SelectedNodeID : string.Empty;
|
||||
if (!string.IsNullOrWhiteSpace(this.TreePreRunId))
|
||||
{
|
||||
var model = Funs.DB.PreRun_SysDevice.FirstOrDefault(x => x.PreRunId == this.TreePreRunId);
|
||||
if (model.PreRunLevel == 3)
|
||||
{
|
||||
this.SystemIds = new List<string>() { model.PreRunId };
|
||||
}
|
||||
else if (model.PreRunLevel == 2)
|
||||
{
|
||||
devices = Funs.DB.PreRun_SysDevice.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.PreRunLevel == 3 && x.ProcessesId == model.PreRunId).ToList();
|
||||
if (devices.Count > 0)
|
||||
{
|
||||
this.SystemIds = devices.ConvertAll(x => x.PreRunId);
|
||||
}
|
||||
}
|
||||
else if (model.PreRunLevel == 1)
|
||||
{
|
||||
devices = Funs.DB.PreRun_SysDevice.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.PreRunLevel == 3 && x.InstallationId == model.PreRunId).ToList();
|
||||
if (devices.Count > 0)
|
||||
{
|
||||
this.SystemIds = devices.ConvertAll(x => x.PreRunId);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
devices = Funs.DB.PreRun_SysDevice.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.PreRunLevel == 3).ToList();
|
||||
if (devices.Count > 0)
|
||||
{
|
||||
this.SystemIds = devices.ConvertAll(x => x.PreRunId);
|
||||
}
|
||||
}
|
||||
TestRunBrid();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 数据绑定
|
||||
#region 数据绑定/导出
|
||||
|
||||
/// <summary>
|
||||
/// 预试车绑定
|
||||
/// </summary>
|
||||
public void TestRunBrid()
|
||||
{
|
||||
var result = new List<ScheduleBridDto>();
|
||||
string strSql = "select a.WorkPackId,b.WorkPackName,b.Sort,SUM(case ISNULL(a.InspectIsClose,0) when 1 then 1 else 0 end) as ygbnum,SUM(case ISNULL(a.InspectIsClose,0) when 0 then 1 else 0 end) as wgbnum,COUNT(1) as allnum from TestRun_SubInspectTerm as a inner join TestRun_WorkPackage as b on a.WorkPackId=b.WorkPackId where 1=1 and a.ProjectId=@ProjectId ";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||||
string installationName = "-";
|
||||
string processesName = "-";
|
||||
string systemName = "-";
|
||||
string subsystemName = "-";
|
||||
string columnames = string.Empty;
|
||||
if (!string.IsNullOrWhiteSpace(this.TreePreRunId))
|
||||
var result = new List<TestRunScheduleDto>();
|
||||
if (this.SystemIds.Count > 0)
|
||||
{
|
||||
var model = Funs.DB.PreRun_SysDevice.FirstOrDefault(p => p.PreRunId == this.TreePreRunId);
|
||||
if (model.PreRunLevel == 1)
|
||||
{
|
||||
installationName = model.PreRunName;
|
||||
columnames = "a.InstallationId";
|
||||
}
|
||||
else if (model.PreRunLevel == 2)
|
||||
{
|
||||
processesName = model.PreRunName;
|
||||
columnames = "a.ProcessesId";
|
||||
}
|
||||
else if (model.PreRunLevel == 3)
|
||||
{
|
||||
systemName = model.PreRunName;
|
||||
columnames = "a.SystemId";
|
||||
}
|
||||
else if (model.PreRunLevel == 4)
|
||||
{
|
||||
subsystemName = model.PreRunName;
|
||||
columnames = "a.SubsystemId";
|
||||
}
|
||||
strSql += $"and {columnames}='{model.PreRunId}'";
|
||||
}
|
||||
strSql += "group by a.WorkPackId,b.WorkPackName,b.Sort order by b.Sort asc";
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
var dt = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
if (dt != null)
|
||||
{
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
result.Add(new ScheduleBridDto()
|
||||
{
|
||||
WorkPackId = item["WorkPackId"].ToString(),
|
||||
WorkName = item["WorkPackName"].ToString(),
|
||||
InstallationName = installationName,
|
||||
ProcessesName = processesName,
|
||||
SystemName = systemName,
|
||||
SubsystemName = subsystemName,
|
||||
AllNum = item["allnum"].ToString(),
|
||||
NoCloseNum = item["wgbnum"].ToString(),
|
||||
CloseNum = item["ygbnum"].ToString()
|
||||
});
|
||||
}
|
||||
result = GetTestRunSchedules();
|
||||
}
|
||||
|
||||
GridTestRun.DataSource = result;
|
||||
GridTestRun.DataBind();
|
||||
JObject summary = new JObject();
|
||||
summary.Add("WorkPackNum", result.Sum(x => x.WorkPackNum));
|
||||
summary.Add("WorkPackNoCloseNum", result.Sum(x => x.WorkPackNoCloseNum));
|
||||
summary.Add("WorkPackCloseNum", result.Sum(x => x.WorkPackCloseNum));
|
||||
summary.Add("InspectNum", result.Sum(x => x.InspectNum));
|
||||
summary.Add("InspectNoCloseNum", result.Sum(x => x.InspectNoCloseNum));
|
||||
summary.Add("InspectCloseNum", result.Sum(x => x.InspectCloseNum));
|
||||
GridTestRun.SummaryData = summary;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 试车导出
|
||||
/// </summary>
|
||||
protected void btnScExport_Click(object sender, EventArgs e)
|
||||
{
|
||||
string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
|
||||
//导出文件
|
||||
string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
|
||||
if (!Directory.Exists(filePath))
|
||||
{
|
||||
Directory.CreateDirectory(filePath);
|
||||
}
|
||||
string ReportFileName = filePath + "试车进度.xlsx";
|
||||
|
||||
var result = GetTestRunSchedules();
|
||||
|
||||
if (result.Count > 0)
|
||||
{
|
||||
XSSFWorkbook hssfworkbook = new XSSFWorkbook();
|
||||
XSSFSheet ws = (XSSFSheet)hssfworkbook.CreateSheet("试车进度");
|
||||
|
||||
#region 列宽
|
||||
|
||||
ws.SetColumnWidth(0, (30 * 256));
|
||||
ws.SetColumnWidth(1, (20 * 256));
|
||||
ws.SetColumnWidth(2, (20 * 256));
|
||||
ws.SetColumnWidth(3, (20 * 256));
|
||||
ws.SetColumnWidth(4, (20 * 256));
|
||||
ws.SetColumnWidth(5, (20 * 256));
|
||||
ws.SetColumnWidth(6, (20 * 256));
|
||||
ws.SetColumnWidth(7, (20 * 256));
|
||||
ws.SetColumnWidth(8, (20 * 256));
|
||||
ws.SetColumnWidth(9, (20 * 256));
|
||||
|
||||
#endregion
|
||||
|
||||
#region 样式
|
||||
//公共样式
|
||||
ICellStyle style = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 10.5, true);
|
||||
//公共样式加粗
|
||||
ICellStyle styleBold = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 10.5, true, true);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 头部
|
||||
|
||||
ws = ExcelCreateRowTitle(ws, hssfworkbook, style, 0, 0, 0, 9);
|
||||
//行1
|
||||
ws.GetRow(0).GetCell(0).CellStyle = styleBold;
|
||||
ws.GetRow(0).GetCell(0).SetCellValue("工作包名称");
|
||||
ws.GetRow(0).GetCell(1).CellStyle = styleBold;
|
||||
ws.GetRow(0).GetCell(1).SetCellValue("装置名称");
|
||||
ws.GetRow(0).GetCell(2).CellStyle = styleBold;
|
||||
ws.GetRow(0).GetCell(2).SetCellValue("工序名称");
|
||||
ws.GetRow(0).GetCell(3).CellStyle = styleBold;
|
||||
ws.GetRow(0).GetCell(3).SetCellValue("系统名称");
|
||||
ws.GetRow(0).GetCell(4).CellStyle = styleBold;
|
||||
ws.GetRow(0).GetCell(4).SetCellValue("工作包数量");
|
||||
ws.GetRow(0).GetCell(5).CellStyle = styleBold;
|
||||
ws.GetRow(0).GetCell(5).SetCellValue("工作包未关闭数量");
|
||||
ws.GetRow(0).GetCell(6).CellStyle = styleBold;
|
||||
ws.GetRow(0).GetCell(6).SetCellValue("工作包已关闭数量");
|
||||
ws.GetRow(0).GetCell(7).CellStyle = styleBold;
|
||||
ws.GetRow(0).GetCell(7).SetCellValue("检查表数量");
|
||||
ws.GetRow(0).GetCell(8).CellStyle = styleBold;
|
||||
ws.GetRow(0).GetCell(8).SetCellValue("检查表未关闭数量");
|
||||
ws.GetRow(0).GetCell(9).CellStyle = styleBold;
|
||||
ws.GetRow(0).GetCell(9).SetCellValue("检查表已关闭数量");
|
||||
|
||||
#endregion
|
||||
|
||||
#region 表格
|
||||
|
||||
var start = 1;
|
||||
var end = result.Count;
|
||||
ws = ExcelCreateRowTitle(ws, hssfworkbook, style, start, end, 0, 9);
|
||||
|
||||
//数据
|
||||
var dataIndex = 1;
|
||||
foreach (var item in result)
|
||||
{
|
||||
ws.GetRow(dataIndex).GetCell(0).SetCellValue(item.WorkPackName);
|
||||
ws.GetRow(dataIndex).GetCell(1).SetCellValue(item.InstallationName);
|
||||
ws.GetRow(dataIndex).GetCell(2).SetCellValue(item.ProcessesName);
|
||||
ws.GetRow(dataIndex).GetCell(3).SetCellValue(item.SystemName);
|
||||
ws.GetRow(dataIndex).GetCell(4).SetCellValue(item.WorkPackNum);
|
||||
ws.GetRow(dataIndex).GetCell(5).SetCellValue(item.WorkPackNoCloseNum);
|
||||
ws.GetRow(dataIndex).GetCell(6).SetCellValue(item.WorkPackCloseNum);
|
||||
ws.GetRow(dataIndex).GetCell(7).SetCellValue(item.InspectNum);
|
||||
ws.GetRow(dataIndex).GetCell(8).SetCellValue(item.InspectNoCloseNum);
|
||||
ws.GetRow(dataIndex).GetCell(9).SetCellValue(item.InspectCloseNum);
|
||||
dataIndex++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 尾部
|
||||
|
||||
ws = ExcelCreateRowTitle(ws, hssfworkbook, style, end + 1, end + 1, 0, 9);
|
||||
var region = new CellRangeAddress(end + 1, end + 1, 0, 3);
|
||||
ws.AddMergedRegion(region);
|
||||
ws.GetRow(end + 1).GetCell(0).SetCellValue("合计");
|
||||
ws.GetRow(end + 1).GetCell(4).SetCellValue(result.Count > 0 ? result.Sum(x => x.WorkPackNum).ToString() : "0");
|
||||
ws.GetRow(end + 1).GetCell(5).SetCellValue(result.Count > 0 ? result.Sum(x => x.WorkPackNoCloseNum).ToString() : "0");
|
||||
ws.GetRow(end + 1).GetCell(6).SetCellValue(result.Count > 0 ? result.Sum(x => x.WorkPackCloseNum).ToString() : "0");
|
||||
ws.GetRow(end + 1).GetCell(7).SetCellValue(result.Count > 0 ? result.Sum(x => x.InspectNum).ToString() : "0");
|
||||
ws.GetRow(end + 1).GetCell(8).SetCellValue(result.Count > 0 ? result.Sum(x => x.InspectNoCloseNum).ToString() : "0");
|
||||
ws.GetRow(end + 1).GetCell(9).SetCellValue(result.Count > 0 ? result.Sum(x => x.InspectCloseNum).ToString() : "0");
|
||||
|
||||
#endregion
|
||||
|
||||
ws.PrintSetup.Landscape = false;
|
||||
ws.PrintSetup.PaperSize = 9;
|
||||
ws.ForceFormulaRecalculation = true;
|
||||
using (FileStream filess = File.OpenWrite(ReportFileName))
|
||||
{
|
||||
hssfworkbook.Write(filess);
|
||||
}
|
||||
FileInfo filet = new FileInfo(ReportFileName);
|
||||
Response.Clear();
|
||||
Response.Charset = "GB2312";
|
||||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||||
// 添加头信息,为"文件下载/另存为"对话框指定默认文件名
|
||||
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode("试车进度.xlsx"));
|
||||
// 添加头信息,指定文件大小,让浏览器能够显示下载进度
|
||||
Response.AddHeader("Content-Length", filet.Length.ToString());
|
||||
// 指定返回的是一个不能被客户端读取的流,必须被下载
|
||||
Response.ContentType = "application/ms-excel";
|
||||
// 把文件流发送到客户端
|
||||
Response.WriteFile(filet.FullName);
|
||||
// 停止页面的执行
|
||||
Response.End();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -184,7 +318,48 @@ namespace FineUIPro.Web.TestRun.Report
|
||||
#region 私有方法
|
||||
|
||||
/// <summary>
|
||||
/// 试车统计实体
|
||||
/// 创建头部
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private XSSFSheet ExcelCreateRowTitle(XSSFSheet ws, XSSFWorkbook hssfworkbook, ICellStyle style, int sRows, int eRows, int cStart, int cEnd, float height = 21)
|
||||
{
|
||||
for (int i = sRows; i <= eRows; i++)
|
||||
{
|
||||
ws.CreateRow(i);
|
||||
ws.GetRow(i).HeightInPoints = height;
|
||||
for (int j = cStart; j <= cEnd; j++)
|
||||
{
|
||||
ws.GetRow(i).CreateCell(j);
|
||||
ws.GetRow(i).CreateCell(j).CellStyle = style;
|
||||
}
|
||||
}
|
||||
return ws;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建样式
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static ICellStyle SetExcelStyle(XSSFWorkbook wb, BorderStyle Bottom, BorderStyle Left, BorderStyle Right, BorderStyle Top, VerticalAlignment VerAig, HorizontalAlignment HorAig, double FontSize, bool WrapText = true, bool Bold = false, string FontName = "宋体")
|
||||
{
|
||||
ICellStyle style = wb.CreateCellStyle();
|
||||
style.BorderBottom = Bottom;
|
||||
style.BorderLeft = Left;
|
||||
style.BorderRight = Right;
|
||||
style.BorderTop = Top;
|
||||
style.VerticalAlignment = VerAig;
|
||||
style.Alignment = HorAig;
|
||||
IFont font = wb.CreateFont();
|
||||
font.FontHeightInPoints = FontSize;
|
||||
font.IsBold = Bold;
|
||||
font.FontName = FontName;
|
||||
style.SetFont(font);
|
||||
style.WrapText = WrapText;
|
||||
return style;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 试车统计实体(老)
|
||||
/// </summary>
|
||||
public class ScheduleBridDto
|
||||
{
|
||||
@@ -226,6 +401,171 @@ namespace FineUIPro.Web.TestRun.Report
|
||||
public string CloseNum { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取试车统计
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private List<TestRunScheduleDto> GetTestRunSchedules()
|
||||
{
|
||||
var list = new List<TestRunScheduleDto>();
|
||||
|
||||
string allStr = $"select b.WorkPackId,b.WorkPackName,COUNT(a.SystemId) as WorkPackNum from TestRun_SubSysWorkPackage as a inner join TestRun_WorkPackage as b on a.WorkPackId = b.WorkPackId where a.SystemId in ('{string.Join("','", this.SystemIds)}') group by b.WorkPackId,b.WorkPackName";
|
||||
var dt = SQLHelper.GetDataTableRunText(allStr);
|
||||
|
||||
string inspectStr = $"select a.WorkPackId,b.WorkPackName,b.Sort,SUM(case ISNULL(a.InspectIsClose, 0) when 1 then 1 else 0 end) as CloseNum,SUM(case ISNULL(a.InspectIsClose, 0) when 0 then 1 else 0 end) as NoCloseNum,COUNT(1) as AllNum from TestRun_SubInspectTerm as a inner join TestRun_WorkPackage as b on a.WorkPackId = b.WorkPackId where 1=1 and a.ProjectId = '{this.CurrUser.LoginProjectId}' group by a.WorkPackId,b.WorkPackName,b.Sort order by b.Sort asc";
|
||||
var inspectDt = SQLHelper.GetDataTableRunText(inspectStr);
|
||||
var inspectlist = DataTableToList<WorkPackageInspectDto>(inspectDt);
|
||||
|
||||
string deviceStr = $"select b.PreRunName as InstallationName,c.PreRunName as ProcessesName,d.PreRunName as SystemName from PreRun_SysDevice as a left join PreRun_SysDevice as b on b.PreRunId=ISNULL(a.InstallationId,a.PreRunId) left join PreRun_SysDevice as c on c.PreRunId=a.ProcessesId left join PreRun_SysDevice as d on d.PreRunId=a.SystemId where a.PreRunId='{this.TreePreRunId}'";
|
||||
var driveDt = SQLHelper.GetDataTableRunText(deviceStr);
|
||||
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
list = DataTableToList<TestRunScheduleDto>(dt);
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (inspectlist.Count(x => x.WorkPackId == item.WorkPackId) > 0)
|
||||
{
|
||||
var itemInspect = inspectlist.FirstOrDefault(x => x.WorkPackId == item.WorkPackId);
|
||||
item.InspectNum = itemInspect.AllNum;
|
||||
item.InspectCloseNum = itemInspect.CloseNum;
|
||||
item.InspectNoCloseNum = itemInspect.NoCloseNum;
|
||||
item.WorkPackCloseNum = itemInspect.CloseNum;
|
||||
item.WorkPackNoCloseNum = itemInspect.NoCloseNum;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.InspectNum = 0;
|
||||
item.InspectCloseNum = 0;
|
||||
item.InspectNoCloseNum = 0;
|
||||
item.WorkPackNoCloseNum = 0;
|
||||
item.WorkPackCloseNum = 0;
|
||||
}
|
||||
if (driveDt.Rows.Count > 0)
|
||||
{
|
||||
item.InstallationName = driveDt.Rows[0]["InstallationName"].ToString();
|
||||
item.ProcessesName = driveDt.Rows[0]["ProcessesName"].ToString();
|
||||
item.SystemName = driveDt.Rows[0]["SystemName"].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 试车统计实体
|
||||
/// </summary>
|
||||
public class TestRunScheduleDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 工作包主键
|
||||
/// </summary>
|
||||
public string WorkPackId { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包名称
|
||||
/// </summary>
|
||||
public string WorkPackName { get; set; }
|
||||
/// <summary>
|
||||
/// 装置名称
|
||||
/// </summary>
|
||||
public string InstallationName { get; set; }
|
||||
/// <summary>
|
||||
/// 工序名称
|
||||
/// </summary>
|
||||
public string ProcessesName { get; set; }
|
||||
/// <summary>
|
||||
/// 系统名称
|
||||
/// </summary>
|
||||
public string SystemName { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包数量
|
||||
/// </summary>
|
||||
public int WorkPackNum { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包未关闭数量
|
||||
/// </summary>
|
||||
public int WorkPackNoCloseNum { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包已关闭数量
|
||||
/// </summary>
|
||||
public int WorkPackCloseNum { get; set; }
|
||||
/// <summary>
|
||||
/// 检查表数量
|
||||
/// </summary>
|
||||
public int InspectNum { get; set; }
|
||||
/// <summary>
|
||||
/// 检查表未关闭数量
|
||||
/// </summary>
|
||||
public int InspectNoCloseNum { get; set; }
|
||||
/// <summary>
|
||||
/// 检查表已关闭数量
|
||||
/// </summary>
|
||||
public int InspectCloseNum { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 试车检查表实体
|
||||
/// </summary>
|
||||
public class WorkPackageInspectDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 工作包主键
|
||||
/// </summary>
|
||||
public string WorkPackId { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包名称
|
||||
/// </summary>
|
||||
public string WorkPackName { get; set; }
|
||||
/// <summary>
|
||||
/// 检查表数量
|
||||
/// </summary>
|
||||
public int AllNum { get; set; }
|
||||
/// <summary>
|
||||
/// 未关闭任务单数量
|
||||
/// </summary>
|
||||
public int NoCloseNum { get; set; }
|
||||
/// <summary>
|
||||
/// 已关闭任务单数量
|
||||
/// </summary>
|
||||
public int CloseNum { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 转换
|
||||
|
||||
/// <summary>
|
||||
/// DataTable转换List
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<T> DataTableToList<T>(DataTable table)
|
||||
{
|
||||
List<T> list = new List<T>();
|
||||
T t = default(T);
|
||||
PropertyInfo[] propertypes = null;
|
||||
string tempName = string.Empty;
|
||||
foreach (DataRow row in table.Rows)
|
||||
{
|
||||
t = Activator.CreateInstance<T>();
|
||||
propertypes = t.GetType().GetProperties();
|
||||
foreach (PropertyInfo pro in propertypes)
|
||||
{
|
||||
tempName = pro.Name;
|
||||
if (table.Columns.Contains(tempName))
|
||||
{
|
||||
object value = row[tempName];
|
||||
if (!value.ToString().Equals(""))
|
||||
{
|
||||
pro.SetValue(t, value, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
list.Add(t);
|
||||
}
|
||||
return list.Count == 0 ? new List<T>() : list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user