20240423 综合管理导入

This commit is contained in:
毕文静 2024-04-23 16:41:21 +08:00
parent 5d9374cdd7
commit 22e86caec3
47 changed files with 4187 additions and 1269 deletions

View File

@ -0,0 +1,12 @@
alter table Comprehensive_TrainingRecords add RemarkCode nvarchar(50)
alter table Comprehensive_SiteVisaManagement add RemarkCode nvarchar(50)
alter table Comprehensive_DesignDetails add RemarCode nvarchar(50)
alter table Inspection_Test_Plan add RemarkCode nvarchar(50)
alter table Comprehensive_ReviewDrawings add RemarkCode nvarchar(50)
alter table Comprehensive_GeneralPlanApproval add RemarkCode nvarchar(50)
alter table Comprehensive_MajorPlanApproval add RemarkCode nvarchar(50)
alter table Comprehensive_SpecialEquipment add RemarkCode nvarchar(50)
alter table Comprehensive_PressurePipe add RemarkCode nvarchar(50)
alter table Comprehensive_QualityAccident add RemarkCode nvarchar(50)
go

View File

@ -141,6 +141,7 @@ namespace BLL
newDesignDetails.Status = designDetails.Status;
newDesignDetails.AuditMan = designDetails.AuditMan;
newDesignDetails.JoinPersonNum = designDetails.JoinPersonNum;
newDesignDetails.RemarCode = designDetails.RemarCode;
db.Comprehensive_DesignDetails.InsertOnSubmit(newDesignDetails);
db.SubmitChanges();

View File

@ -117,6 +117,7 @@ namespace BLL
newGeneralPlanApproval.CompileMan = generalPlanApproval.CompileMan;
newGeneralPlanApproval.CompileDate = generalPlanApproval.CompileDate;
newGeneralPlanApproval.UnitWorkId = generalPlanApproval.UnitWorkId;
newGeneralPlanApproval.RemarkCode = generalPlanApproval.RemarkCode;
db.Comprehensive_GeneralPlanApproval.InsertOnSubmit(newGeneralPlanApproval);
db.SubmitChanges();
}

View File

@ -135,6 +135,7 @@ namespace BLL
newSiteVisaManagement.AuditMan = siteVisaMangement.AuditMan;
newSiteVisaManagement.Remark = siteVisaMangement.Remark;
newSiteVisaManagement.Status = siteVisaMangement.Status;
newSiteVisaManagement.RemarkCode = siteVisaMangement.RemarkCode;
db.Comprehensive_SiteVisaManagement.InsertOnSubmit(newSiteVisaManagement);
db.SubmitChanges();
}

View File

@ -48,7 +48,8 @@ namespace BLL
TrainingAddress = trainingRecords.TrainingAddress,
Hours = trainingRecords.Hours,
KeynoteSpeaker = trainingRecords.KeynoteSpeaker,
Remark = trainingRecords.Remark
Remark = trainingRecords.Remark,
RemarkCode = trainingRecords.RemarkCode
};
Funs.DB.Comprehensive_TrainingRecords.InsertOnSubmit(newTraining);
Funs.DB.SubmitChanges();

View File

@ -3249,12 +3249,32 @@ namespace BLL
/// <summary>
/// 培训记录导入模板原始虚拟路径
/// </summary>
public const string CQMS_TrainingRecordsTemplateUrl= "File\\Excel\\DataIn\\培训记录导入模板.xlsx";
public const string CQMS_TrainingRecordsTemplateUrl= "File\\Excel\\DataIn\\培训记录导入模板.xls";
/// <summary>
/// 质量专项检查模板文件原始虚拟路径
/// </summary>
public const string JointCheckTempUrl = "File\\Excel\\CQMS\\质量专项检查模版.xlsx";
/// <summary>
/// 设计交底导入模板文件原始虚拟路径
/// </summary>
public const string DesignDetailsTemplateUrl = "File\\Excel\\DataIn\\设计交底导入模板.xls";
/// <summary>
/// 图纸会审记录导入模板文件原始虚拟路径
/// </summary>
public const string ReviewDrawingsTemplateUrl = "File\\Excel\\DataIn\\图纸会审记录导入模板.xls";
/// <summary>
/// 检验试验计划导入模板文件原始虚拟路径
/// </summary>
public const string InspectionTestPlanTemplateUrl = "File\\Excel\\DataIn\\检验试验计划导入模板.xls";
/// <summary>
/// 施工组织设计及施工方案导入模板文件原始虚拟路径
/// </summary>
public const string GeneralPlanApprovalTemplateUrl = "File\\Excel\\DataIn\\施工组织设计及施工方案导入模板.xls";
#endregion
#region

View File

@ -292,10 +292,13 @@ namespace FineUIPro.Web.CQMS.Comprehensive
}
string row12 = pds.Rows[i][12].ToString().Trim();
if (!string.IsNullOrEmpty(row12))
{
if (row12 != "是" && row12 != "否")
{
result += (i + 2).ToString() + "," + "是否需回复" + "," + "错误!" + "|";
}
}
string row13 = pds.Rows[i][13].ToString().Trim();
if (!string.IsNullOrEmpty(row13))
@ -602,7 +605,7 @@ namespace FineUIPro.Web.CQMS.Comprehensive
{
string rootPath = Server.MapPath("~/");
string uploadfilepath = rootPath + Const.CQMS_DataReceivingDocTempUrl;
string filePath = Const.NCRManagementDataInUrl;
string filePath = Const.CQMS_DataReceivingDocTempUrl;
string fileName = Path.GetFileName(filePath);
FileInfo info = new FileInfo(uploadfilepath);
long fileSize = info.Length;

View File

@ -27,6 +27,8 @@
<f:ToolbarFill runat="server"></f:ToolbarFill>
<f:Button ID="btnNew" Icon="Add" EnablePostBack="true" runat="server" OnClick="btnNew_Click" ToolTip="新增" Hidden="true">
</f:Button>
<f:Button ID="btnImport" ToolTip="导入" Hidden="true" Icon="PackageIn" runat="server" OnClick="btnImport_Click">
</f:Button>
</Items>
</f:Toolbar>
</Toolbars>
@ -92,6 +94,10 @@
<f:Window ID="Window1" Title="设计交底管理" Hidden="true" EnableIFrame="true" EnableMaximize="true"
Target="Parent" EnableResize="false" runat="server" IsModal="true" OnClose="Window1_Close"
Width="900px" Height="460px">
</f:Window>
<f:Window ID="Window2" Title="弹出窗体" Hidden="true" EnableIFrame="true" EnableMaximize="true"
Target="Top" EnableResize="false" runat="server" OnClose="Window1_Close" IsModal="true"
Width="700px" Height="560px">
</f:Window>
<f:Window ID="WindowAtt" Title="弹出窗体" Hidden="true" EnableIFrame="true"
EnableMaximize="true" Target="Parent" EnableResize="false" runat="server"

View File

@ -264,6 +264,10 @@ namespace FineUIPro.Web.Comprehensive
{
this.btnMenuDel.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnSave))
{
this.btnImport.Hidden = false;
}
}
}
#endregion
@ -296,5 +300,17 @@ namespace FineUIPro.Web.Comprehensive
return "编制";
}
#region
/// <summary>
/// 导入按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("DesignDetailsDataIn.aspx", "导入 - ")));
}
#endregion
}
}

View File

@ -7,12 +7,10 @@
// </自动生成>
//------------------------------------------------------------------------------
namespace FineUIPro.Web.Comprehensive
{
namespace FineUIPro.Web.Comprehensive {
public partial class DesignDetails
{
public partial class DesignDetails {
/// <summary>
/// form1 控件。
@ -86,6 +84,15 @@ namespace FineUIPro.Web.Comprehensive
/// </remarks>
protected global::FineUIPro.Button btnNew;
/// <summary>
/// btnImport 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnImport;
/// <summary>
/// lblPageIndex 控件。
/// </summary>
@ -158,6 +165,15 @@ namespace FineUIPro.Web.Comprehensive
/// </remarks>
protected global::FineUIPro.Window Window1;
/// <summary>
/// Window2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Window Window2;
/// <summary>
/// WindowAtt 控件。
/// </summary>

View File

@ -0,0 +1,68 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DesignDetailsDataIn.aspx.cs" Inherits="FineUIPro.Web.CQMS.Comprehensive.DesignDetailsDataIn" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>导入设计交底管理</title>
</head>
<body>
<form id="form1" runat="server">
<f:PageManager ID="PageManager1" AutoSizePanelID="SimpleForm1" runat="server" OnCustomEvent="PageManager1_CustomEvent" />
<f:Form ID="SimpleForm1" ShowBorder="false" ShowHeader="false" AutoScroll="true"
BodyPadding="10px" runat="server" RedStarPosition="BeforeText" LabelAlign="Right">
<Toolbars>
<f:Toolbar ID="Toolbar2" Position="Top" ToolbarAlign="Right" runat="server">
<Items>
<f:HiddenField ID="hdFileName" runat="server">
</f:HiddenField>
<f:Button ID="btnAudit" Icon="ApplicationEdit" runat="server" ToolTip="审核" ValidateForms="SimpleForm1"
OnClick="btnAudit_Click">
</f:Button>
<f:Button ID="btnImport" Icon="ApplicationGet" runat="server" ToolTip="导入" ValidateForms="SimpleForm1"
OnClick="btnImport_Click">
</f:Button>
<f:Button ID="btnDownLoad" runat="server" Icon="ApplicationGo" ToolTip="下载模板" OnClick="btnDownLoad_Click">
</f:Button>
<f:HiddenField ID="hdCheckResult" runat="server">
</f:HiddenField>
</Items>
</f:Toolbar>
</Toolbars>
<Rows>
<f:FormRow>
<Items>
<f:FileUpload runat="server" ID="fuAttachUrl" EmptyText="选择要导入的文件" Label="选择要导入的文件"
LabelWidth="150px">
</f:FileUpload>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:Grid ID="gvErrorInfo" ShowBorder="true" EnableAjax="false" ShowHeader="false" Title="设计交底管理" EnableCollapse="true"
runat="server" BoxFlex="1" AllowCellEditing="true" ClicksToEdit="2" AllowSorting="true"
SortDirection="DESC" EnableColumnLines="true" ForceFit="true" AllowPaging="true" IsDatabasePaging="true" PageSize="10"
EnableRowDoubleClickEvent="true" AllowFilters="true" EnableTextSelection="True">
<Columns>
<f:TemplateField ColumnID="tfPageIndex" Width="55px" HeaderText="序号" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:Label ID="lblPageIndex" runat="server" Text='<%# gvErrorInfo.PageIndex * gvErrorInfo.PageSize + Container.DataItemIndex + 1 %>'></asp:Label>
</ItemTemplate>
</f:TemplateField>
<f:BoundField DataField="Row" HeaderText="错误行号">
</f:BoundField>
<f:BoundField DataField="Column" HeaderText="错误列">
</f:BoundField>
<f:BoundField DataField="Reason" HeaderText="错误类型">
</f:BoundField>
</Columns>
</f:Grid>
</Items>
</f:FormRow>
</Rows>
</f:Form>
</form>
</body>
</html>

View File

@ -0,0 +1,484 @@
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.CQMS.Comprehensive
{
public partial class DesignDetailsDataIn : PageBase
{
#region
/// <summary>
/// 上传预设的虚拟路径
/// </summary>
private string initPath = Const.ExcelUrl;
/// <summary>
/// 错误集合
/// </summary>
public static List<Model.ErrorInfo> errorInfos = new List<Model.ErrorInfo>();
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.hdCheckResult.Text = string.Empty;
this.hdFileName.Text = string.Empty;
if (errorInfos != null)
{
errorInfos.Clear();
}
}
}
#endregion
#region
/// <summary>
/// 审核
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAudit_Click(object sender, EventArgs e)
{
try
{
if (this.fuAttachUrl.HasFile == false)
{
ShowNotify("请您选择Excel文件", MessageBoxIcon.Warning);
return;
}
string IsXls = Path.GetExtension(this.fuAttachUrl.FileName).ToString().Trim().ToLower();
if (IsXls != ".xls")
{
ShowNotify("只可以选择Excel文件", MessageBoxIcon.Warning);
return;
}
if (errorInfos != null)
{
errorInfos.Clear();
}
string rootPath = Server.MapPath("~/");
string initFullPath = rootPath + initPath;
if (!Directory.Exists(initFullPath))
{
Directory.CreateDirectory(initFullPath);
}
this.hdFileName.Text = BLL.Funs.GetNewFileName() + IsXls;
string filePath = initFullPath + this.hdFileName.Text;
this.fuAttachUrl.PostedFile.SaveAs(filePath);
ImportXlsToData(rootPath + initPath + this.hdFileName.Text);
}
catch (Exception ex)
{
ShowNotify("'" + ex.Message + "'", MessageBoxIcon.Warning);
}
}
#region Excel提取数据
/// <summary>
/// 从Excel提取数据--》Dataset
/// </summary>
/// <param name="filename">Excel文件路径名</param>
private void ImportXlsToData(string fileName)
{
try
{
string oleDBConnString = String.Empty;
oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
oleDBConnString += "Data Source=";
oleDBConnString += fileName;
oleDBConnString += ";Extended Properties=Excel 8.0;";
OleDbConnection oleDBConn = null;
OleDbDataAdapter oleAdMaster = null;
DataTable m_tableName = new DataTable();
DataSet ds = new DataSet();
oleDBConn = new OleDbConnection(oleDBConnString);
oleDBConn.Open();
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (m_tableName != null && m_tableName.Rows.Count > 0)
{
m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim();
}
string sqlMaster;
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
oleAdMaster.Fill(ds, "m_tableName");
oleAdMaster.Dispose();
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL(ds.Tables[0], 8);
hdCheckResult.Text = "1";
}
catch (Exception exc)
{
Response.Write(exc);
//return null;
// return dt;
}
finally
{
}
}
#endregion
#region Dataset的数据导入数据库
/// <summary>
/// 将Dataset的数据导入数据库
/// </summary>
/// <param name="pds">数据集</param>
/// <param name="Cols">数据集行数</param>
/// <returns></returns>
private bool AddDatasetToSQL(DataTable pds, int Cols)
{
string result = string.Empty;
int ic, ir;
ic = pds.Columns.Count;
if (ic < Cols)
{
ShowNotify("导入Excel格式错误Excel只有" + ic.ToString().Trim() + "列", MessageBoxIcon.Warning);
return false;
}
ir = pds.Rows.Count;
if (pds != null && ir > 0)
{
var oldViewInfos = from x in Funs.DB.Comprehensive_DesignDetails
where x.ProjectId == this.CurrUser.LoginProjectId
select x;
var units = from x in Funs.DB.Base_Unit
join y in Funs.DB.Project_ProjectUnit on x.UnitId equals y.UnitId
where y.ProjectId == this.CurrUser.LoginProjectId
select x;
var cns = from x in Funs.DB.Base_CNProfessional select x;
var unitWorks = from x in Funs.DB.WBS_UnitWork
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.SuperUnitWork == null
select x;
for (int i = 0; i < ir; i++)
{
string row0 = pds.Rows[i][0].ToString();
if (!string.IsNullOrEmpty(row0))
{
var cn = cns.Where(x => x.ProfessionalName == row0.Trim()).FirstOrDefault();
if (cn == null)
{
result += (i + 2).ToString() + "," + "专业名称" + "," + "[" + row0 + "]不存在!" + "|";
}
}
string row1 = pds.Rows[i][1].ToString();
if (string.IsNullOrEmpty(row1))
{
result += (i + 2).ToString() + "," + "编号" + "," + "此项为必填项!" + "|";
}
string row3 = pds.Rows[i][3].ToString();
if (!string.IsNullOrEmpty(row3))
{
try
{
DateTime date = Convert.ToDateTime(row3.Trim());
}
catch (Exception)
{
result += (i + 2).ToString() + "," + "交底日期" + "," + "[" + row3 + "]错误!" + "|";
}
}
string row4 = pds.Rows[i][4].ToString();
if (!string.IsNullOrEmpty(row4))
{
string[] reunit = row4.Split(',');
foreach (string unitWork in reunit)
{
var u = unitWorks.Where(x => x.UnitWorkName == unitWork.Trim()).FirstOrDefault();
if (u == null)
{
result += (i + 2).ToString() + "," + "单位工程名称" + "," + "[" + unitWork.Trim() + "]不存在!" + "|";
}
}
}
string row5 = pds.Rows[i][5].ToString();
if (!string.IsNullOrEmpty(row5))
{
string[] reunit = row5.Split(',');
foreach (string unit in reunit)
{
var u = units.Where(x => x.UnitName == unit.Trim()).FirstOrDefault();
if (u == null)
{
result += (i + 2).ToString() + "," + "参加单位" + "," + "[" + unit.Trim() + "]不存在!" + "|";
}
}
}
string row6 = pds.Rows[i][6].ToString();
if (!string.IsNullOrEmpty(row6))
{
try
{
int d = Convert.ToInt32(row6);
}
catch (Exception)
{
result += (i + 2).ToString() + "," + "参加人数" + "," + "[" + row3 + "]错误!" + "|";
}
}
string row7 = pds.Rows[i][7].ToString();
if (string.IsNullOrEmpty(row7))
{
result += (i + 2).ToString() + "," + "标志编号" + "," + "此项为必填项!" + "|";
}
}
if (!string.IsNullOrEmpty(result))
{
result = result.Substring(0, result.LastIndexOf("|"));
}
errorInfos.Clear();
if (!string.IsNullOrEmpty(result))
{
string results = result;
List<string> errorInfoList = results.Split('|').ToList();
foreach (var item in errorInfoList)
{
string[] errors = item.Split(',');
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = errors[0];
errorInfo.Column = errors[1];
errorInfo.Reason = errors[2];
errorInfos.Add(errorInfo);
}
if (errorInfos.Count > 0)
{
this.gvErrorInfo.DataSource = errorInfos;
this.gvErrorInfo.DataBind();
}
}
else
{
ShowNotify("审核完成,请点击导入!", MessageBoxIcon.Success);
}
}
else
{
ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
}
return true;
}
#endregion
#endregion
#region
/// <summary>
/// 导入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(hdCheckResult.Text))
{
if (errorInfos.Count <= 0)
{
string rootPath = Server.MapPath("~/");
ImportXlsToData2(rootPath + initPath + this.hdFileName.Text);
hdCheckResult.Text = string.Empty;
ShowNotify("导入成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
ShowNotify("请先将错误数据修正,再重新导入提交!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("请先审核要导入的文件!", MessageBoxIcon.Warning);
}
}
#region Excel提取数据
/// <summary>
/// 从Excel提取数据--》Dataset
/// </summary>
/// <param name="filename">Excel文件路径名</param>
private void ImportXlsToData2(string fileName)
{
try
{
string oleDBConnString = String.Empty;
oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
oleDBConnString += "Data Source=";
oleDBConnString += fileName;
oleDBConnString += ";Extended Properties=Excel 8.0;";
OleDbConnection oleDBConn = null;
OleDbDataAdapter oleAdMaster = null;
DataTable m_tableName = new DataTable();
DataSet ds = new DataSet();
oleDBConn = new OleDbConnection(oleDBConnString);
oleDBConn.Open();
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (m_tableName != null && m_tableName.Rows.Count > 0)
{
m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim();
}
string sqlMaster;
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
oleAdMaster.Fill(ds, "m_tableName");
oleAdMaster.Dispose();
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL2(ds.Tables[0], 8);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region Dataset的数据导入数据库
/// <summary>
/// 将Dataset的数据导入数据库
/// </summary>
/// <param name="pds">数据集</param>
/// <param name="Cols">数据集列数</param>
/// <returns></returns>
private bool AddDatasetToSQL2(DataTable pds, int Cols)
{
int ic, ir;
ic = pds.Columns.Count;
if (ic < Cols)
{
ShowNotify("导入Excel格式错误Excel只有" + ic.ToString().Trim() + "列", MessageBoxIcon.Warning);
}
string result = string.Empty;
ir = pds.Rows.Count;
if (pds != null && ir > 0)
{
var oldViewInfos = from x in Funs.DB.Comprehensive_DesignDetails
where x.ProjectId == this.CurrUser.LoginProjectId
select x;
var units = from x in Funs.DB.Base_Unit
join y in Funs.DB.Project_ProjectUnit on x.UnitId equals y.UnitId
where y.ProjectId == this.CurrUser.LoginProjectId
select x;
var cns = from x in Funs.DB.Base_CNProfessional select x;
var unitWorks = from x in Funs.DB.WBS_UnitWork
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.SuperUnitWork == null
select x;
for (int i = 0; i < ir; i++)
{
Model.Comprehensive_DesignDetails oldViewInfo = new Model.Comprehensive_DesignDetails();
string row0 = pds.Rows[i][0].ToString().Trim();
var cn = cns.Where(y => y.ProfessionalName == row0).FirstOrDefault();
oldViewInfo = oldViewInfos.Where(x => x.RemarCode == pds.Rows[i][7].ToString().Trim()
).FirstOrDefault();
if (oldViewInfo == null)
{
Model.Comprehensive_DesignDetails des = new Model.Comprehensive_DesignDetails();
des.DesignDetailsId = SQLHelper.GetNewID(typeof(Model.Comprehensive_DesignDetails));
des.ProjectId = this.CurrUser.LoginProjectId;
des.CNProfessionalId = cn.CNProfessionalId;
des.DesignDetailsCode = pds.Rows[i][1].ToString().Trim();
des.DetailsMan = pds.Rows[i][2].ToString().Trim();
des.DetailsDate = Funs.GetNewDateTime(pds.Rows[i][3].ToString().Trim());
if (!string.IsNullOrEmpty(pds.Rows[i][4].ToString().Trim()))
{
des.UnitWorkId = BLL.UnitWorkService.GetUnitWorkIdsByUnitWorkNames(this.CurrUser.LoginProjectId, pds.Rows[i][4].ToString().Trim());
}
if (!string.IsNullOrEmpty(pds.Rows[i][5].ToString().Trim()))
{
des.UnitName = BLL.UnitService.GetUnitIds(pds.Rows[i][5].ToString().Trim());
}
des.JoinPersonNum = Funs.GetNewInt(pds.Rows[i][6].ToString().Trim());
des.RemarCode = pds.Rows[i][7].ToString().Trim();
BLL.DesignDetailsService.AddDesignDetails(des);
}
}
}
else
{
ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
}
return true;
}
#endregion
#endregion
#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.DesignDetailsTemplateUrl;
string filePath = Const.DesignDetailsTemplateUrl;
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
}
}

View File

@ -0,0 +1,123 @@
//------------------------------------------------------------------------------
// <自动生成>
// 此代码由工具生成。
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </自动生成>
//------------------------------------------------------------------------------
namespace FineUIPro.Web.CQMS.Comprehensive {
public partial class DesignDetailsDataIn {
/// <summary>
/// form1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// PageManager1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.PageManager PageManager1;
/// <summary>
/// SimpleForm1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Form SimpleForm1;
/// <summary>
/// Toolbar2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar2;
/// <summary>
/// hdFileName 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.HiddenField hdFileName;
/// <summary>
/// btnAudit 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnAudit;
/// <summary>
/// btnImport 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnImport;
/// <summary>
/// btnDownLoad 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnDownLoad;
/// <summary>
/// hdCheckResult 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.HiddenField hdCheckResult;
/// <summary>
/// fuAttachUrl 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.FileUpload fuAttachUrl;
/// <summary>
/// gvErrorInfo 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Grid gvErrorInfo;
/// <summary>
/// lblPageIndex 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblPageIndex;
}
}

View File

@ -32,6 +32,8 @@
<f:ToolbarFill runat="server"></f:ToolbarFill>
<f:Button ID="btnNew" Icon="Add" EnablePostBack="true" runat="server" OnClick="btnNew_Click" ToolTip="新增" Hidden="true">
</f:Button>
<f:Button ID="btnImport" ToolTip="导入" Icon="PackageIn" runat="server" OnClick="btnImport_Click" Hidden="true">
</f:Button>
</Items>
</f:Toolbar>
</Toolbars>
@ -98,6 +100,10 @@
Target="Parent" EnableResize="false" runat="server" IsModal="true" OnClose="Window1_Close"
Width="900px" Height="420px">
</f:Window>
<f:Window ID="Window2" Title="弹出窗体" Hidden="true" EnableIFrame="true" EnableMaximize="true"
Target="Top" EnableResize="false" runat="server" OnClose="Window1_Close" IsModal="true"
Width="700px" Height="560px">
</f:Window>
<f:Menu ID="Menu1" runat="server">
<Items>
<f:MenuButton ID="btnMenuModify" EnablePostBack="true" runat="server" Text="修改" Icon="Pencil" OnClick="btnMenuModify_Click" Hidden="true">

View File

@ -252,8 +252,24 @@ namespace FineUIPro.Web.Comprehensive
{
this.btnMenuDel.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnSave))
{
this.btnImport.Hidden = false;
}
}
}
#endregion
#region
/// <summary>
/// 导入按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("GeneralPlanApprovalDataIn.aspx", "导入 - ")));
}
#endregion
}
}

View File

@ -102,6 +102,15 @@ namespace FineUIPro.Web.Comprehensive {
/// </remarks>
protected global::FineUIPro.Button btnNew;
/// <summary>
/// btnImport 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnImport;
/// <summary>
/// lblPageIndex 控件。
/// </summary>
@ -156,6 +165,15 @@ namespace FineUIPro.Web.Comprehensive {
/// </remarks>
protected global::FineUIPro.Window Window1;
/// <summary>
/// Window2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Window Window2;
/// <summary>
/// Menu1 控件。
/// </summary>

View File

@ -0,0 +1,68 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GeneralPlanApprovalDataIn.aspx.cs" Inherits="FineUIPro.Web.CQMS.Comprehensive.GeneralPlanApprovalDataIn" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>导入施工组织设计及施工方案</title>
</head>
<body>
<form id="form1" runat="server">
<f:PageManager ID="PageManager1" AutoSizePanelID="SimpleForm1" runat="server" OnCustomEvent="PageManager1_CustomEvent" />
<f:Form ID="SimpleForm1" ShowBorder="false" ShowHeader="false" AutoScroll="true"
BodyPadding="10px" runat="server" RedStarPosition="BeforeText" LabelAlign="Right">
<Toolbars>
<f:Toolbar ID="Toolbar2" Position="Top" ToolbarAlign="Right" runat="server">
<Items>
<f:HiddenField ID="hdFileName" runat="server">
</f:HiddenField>
<f:Button ID="btnAudit" Icon="ApplicationEdit" runat="server" ToolTip="审核" ValidateForms="SimpleForm1"
OnClick="btnAudit_Click">
</f:Button>
<f:Button ID="btnImport" Icon="ApplicationGet" runat="server" ToolTip="导入" ValidateForms="SimpleForm1"
OnClick="btnImport_Click">
</f:Button>
<f:Button ID="btnDownLoad" runat="server" Icon="ApplicationGo" ToolTip="下载模板" OnClick="btnDownLoad_Click">
</f:Button>
<f:HiddenField ID="hdCheckResult" runat="server">
</f:HiddenField>
</Items>
</f:Toolbar>
</Toolbars>
<Rows>
<f:FormRow>
<Items>
<f:FileUpload runat="server" ID="fuAttachUrl" EmptyText="选择要导入的文件" Label="选择要导入的文件"
LabelWidth="150px">
</f:FileUpload>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:Grid ID="gvErrorInfo" ShowBorder="true" EnableAjax="false" ShowHeader="false" Title="施工组织设计及施工方案" EnableCollapse="true"
runat="server" BoxFlex="1" AllowCellEditing="true" ClicksToEdit="2" AllowSorting="true"
SortDirection="DESC" EnableColumnLines="true" ForceFit="true" AllowPaging="true" IsDatabasePaging="true" PageSize="10"
EnableRowDoubleClickEvent="true" AllowFilters="true" EnableTextSelection="True">
<Columns>
<f:TemplateField ColumnID="tfPageIndex" Width="55px" HeaderText="序号" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:Label ID="lblPageIndex" runat="server" Text='<%# gvErrorInfo.PageIndex * gvErrorInfo.PageSize + Container.DataItemIndex + 1 %>'></asp:Label>
</ItemTemplate>
</f:TemplateField>
<f:BoundField DataField="Row" HeaderText="错误行号">
</f:BoundField>
<f:BoundField DataField="Column" HeaderText="错误列">
</f:BoundField>
<f:BoundField DataField="Reason" HeaderText="错误类型">
</f:BoundField>
</Columns>
</f:Grid>
</Items>
</f:FormRow>
</Rows>
</f:Form>
</form>
</body>
</html>

View File

@ -0,0 +1,476 @@
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.CQMS.Comprehensive
{
public partial class GeneralPlanApprovalDataIn : PageBase
{
#region
/// <summary>
/// 上传预设的虚拟路径
/// </summary>
private string initPath = Const.ExcelUrl;
/// <summary>
/// 错误集合
/// </summary>
public static List<Model.ErrorInfo> errorInfos = new List<Model.ErrorInfo>();
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.hdCheckResult.Text = string.Empty;
this.hdFileName.Text = string.Empty;
if (errorInfos != null)
{
errorInfos.Clear();
}
}
}
#endregion
#region
/// <summary>
/// 审核
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAudit_Click(object sender, EventArgs e)
{
try
{
if (this.fuAttachUrl.HasFile == false)
{
ShowNotify("请您选择Excel文件", MessageBoxIcon.Warning);
return;
}
string IsXls = Path.GetExtension(this.fuAttachUrl.FileName).ToString().Trim().ToLower();
if (IsXls != ".xls")
{
ShowNotify("只可以选择Excel文件", MessageBoxIcon.Warning);
return;
}
if (errorInfos != null)
{
errorInfos.Clear();
}
string rootPath = Server.MapPath("~/");
string initFullPath = rootPath + initPath;
if (!Directory.Exists(initFullPath))
{
Directory.CreateDirectory(initFullPath);
}
this.hdFileName.Text = BLL.Funs.GetNewFileName() + IsXls;
string filePath = initFullPath + this.hdFileName.Text;
this.fuAttachUrl.PostedFile.SaveAs(filePath);
ImportXlsToData(rootPath + initPath + this.hdFileName.Text);
}
catch (Exception ex)
{
ShowNotify("'" + ex.Message + "'", MessageBoxIcon.Warning);
}
}
#region Excel提取数据
/// <summary>
/// 从Excel提取数据--》Dataset
/// </summary>
/// <param name="filename">Excel文件路径名</param>
private void ImportXlsToData(string fileName)
{
try
{
string oleDBConnString = String.Empty;
oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
oleDBConnString += "Data Source=";
oleDBConnString += fileName;
oleDBConnString += ";Extended Properties=Excel 8.0;";
OleDbConnection oleDBConn = null;
OleDbDataAdapter oleAdMaster = null;
DataTable m_tableName = new DataTable();
DataSet ds = new DataSet();
oleDBConn = new OleDbConnection(oleDBConnString);
oleDBConn.Open();
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (m_tableName != null && m_tableName.Rows.Count > 0)
{
m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim();
}
string sqlMaster;
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
oleAdMaster.Fill(ds, "m_tableName");
oleAdMaster.Dispose();
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL(ds.Tables[0], 10);
hdCheckResult.Text = "1";
}
catch (Exception exc)
{
Response.Write(exc);
//return null;
// return dt;
}
finally
{
}
}
#endregion
#region Dataset的数据导入数据库
/// <summary>
/// 将Dataset的数据导入数据库
/// </summary>
/// <param name="pds">数据集</param>
/// <param name="Cols">数据集行数</param>
/// <returns></returns>
private bool AddDatasetToSQL(DataTable pds, int Cols)
{
string result = string.Empty;
int ic, ir;
ic = pds.Columns.Count;
if (ic < Cols)
{
ShowNotify("导入Excel格式错误Excel只有" + ic.ToString().Trim() + "列", MessageBoxIcon.Warning);
return false;
}
ir = pds.Rows.Count;
if (pds != null && ir > 0)
{
var oldViewInfos = from x in Funs.DB.Comprehensive_GeneralPlanApproval
where x.ProjectId == this.CurrUser.LoginProjectId
select x;
var units = from x in Funs.DB.Base_Unit
join y in Funs.DB.Project_ProjectUnit on x.UnitId equals y.UnitId
where y.ProjectId == this.CurrUser.LoginProjectId
select x;
var cns = from x in Funs.DB.Base_CNProfessional select x;
var unitWorks = from x in Funs.DB.WBS_UnitWork
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.SuperUnitWork == null
select x;
for (int i = 0; i < ir; i++)
{
string row0 = pds.Rows[i][0].ToString();
if (string.IsNullOrEmpty(row0))
{
result += (i + 2).ToString() + "," + "报批单位" + "," + "此项为必填项!" + "|";
}
else
{
var unit = units.Where(x => x.UnitName == row0.Trim()).FirstOrDefault();
if (unit == null)
{
result += (i + 2).ToString() + "," + "报批单位" + "," + "[" + row0 + "]不存在!" + "|";
}
}
string row1 = pds.Rows[i][1].ToString();
if (!string.IsNullOrEmpty(row1))
{
var cn = cns.Where(x => x.ProfessionalName == row1.Trim()).FirstOrDefault();
if (cn == null)
{
result += (i + 2).ToString() + "," + "专业名称" + "," + "[" + row1 + "]不存在!" + "|";
}
}
else
{
result += (i + 2).ToString() + "," + "专业名称" + "," + "此项为必填项!" + "|";
}
string row2 = pds.Rows[i][2].ToString();
if (!string.IsNullOrEmpty(row2))
{
string[] reunit = row2.Split(',');
foreach (string unitWork in reunit)
{
var u = unitWorks.Where(x => x.UnitWorkName == unitWork.Trim()).FirstOrDefault();
if (u == null)
{
result += (i + 2).ToString() + "," + "单位工程名称" + "," + "[" + unitWork.Trim() + "]不存在!" + "|";
}
}
}
string row3 = pds.Rows[i][3].ToString();
if (string.IsNullOrEmpty(row3))
{
result += (i + 2).ToString() + "," + "编号" + "," + "此项为必填项!" + "|";
}
string row5 = pds.Rows[i][5].ToString();
if (!string.IsNullOrEmpty(row5))
{
try
{
DateTime date = Convert.ToDateTime(row5.Trim());
}
catch (Exception)
{
result += (i + 2).ToString() + "," + "审批日期" + "," + "[" + row5 + "]错误!" + "|";
}
}
string row9 = pds.Rows[i][9].ToString();
if (string.IsNullOrEmpty(row9))
{
result += (i + 2).ToString() + "," + "标志编号" + "," + "此项为必填项!" + "|";
}
}
if (!string.IsNullOrEmpty(result))
{
result = result.Substring(0, result.LastIndexOf("|"));
}
errorInfos.Clear();
if (!string.IsNullOrEmpty(result))
{
string results = result;
List<string> errorInfoList = results.Split('|').ToList();
foreach (var item in errorInfoList)
{
string[] errors = item.Split(',');
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = errors[0];
errorInfo.Column = errors[1];
errorInfo.Reason = errors[2];
errorInfos.Add(errorInfo);
}
if (errorInfos.Count > 0)
{
this.gvErrorInfo.DataSource = errorInfos;
this.gvErrorInfo.DataBind();
}
}
else
{
ShowNotify("审核完成,请点击导入!", MessageBoxIcon.Success);
}
}
else
{
ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
}
return true;
}
#endregion
#endregion
#region
/// <summary>
/// 导入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(hdCheckResult.Text))
{
if (errorInfos.Count <= 0)
{
string rootPath = Server.MapPath("~/");
ImportXlsToData2(rootPath + initPath + this.hdFileName.Text);
hdCheckResult.Text = string.Empty;
ShowNotify("导入成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
ShowNotify("请先将错误数据修正,再重新导入提交!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("请先审核要导入的文件!", MessageBoxIcon.Warning);
}
}
#region Excel提取数据
/// <summary>
/// 从Excel提取数据--》Dataset
/// </summary>
/// <param name="filename">Excel文件路径名</param>
private void ImportXlsToData2(string fileName)
{
try
{
string oleDBConnString = String.Empty;
oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
oleDBConnString += "Data Source=";
oleDBConnString += fileName;
oleDBConnString += ";Extended Properties=Excel 8.0;";
OleDbConnection oleDBConn = null;
OleDbDataAdapter oleAdMaster = null;
DataTable m_tableName = new DataTable();
DataSet ds = new DataSet();
oleDBConn = new OleDbConnection(oleDBConnString);
oleDBConn.Open();
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (m_tableName != null && m_tableName.Rows.Count > 0)
{
m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim();
}
string sqlMaster;
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
oleAdMaster.Fill(ds, "m_tableName");
oleAdMaster.Dispose();
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL2(ds.Tables[0], 10);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region Dataset的数据导入数据库
/// <summary>
/// 将Dataset的数据导入数据库
/// </summary>
/// <param name="pds">数据集</param>
/// <param name="Cols">数据集列数</param>
/// <returns></returns>
private bool AddDatasetToSQL2(DataTable pds, int Cols)
{
int ic, ir;
ic = pds.Columns.Count;
if (ic < Cols)
{
ShowNotify("导入Excel格式错误Excel只有" + ic.ToString().Trim() + "列", MessageBoxIcon.Warning);
}
string result = string.Empty;
ir = pds.Rows.Count;
if (pds != null && ir > 0)
{
var oldViewInfos = from x in Funs.DB.Comprehensive_GeneralPlanApproval
where x.ProjectId == this.CurrUser.LoginProjectId
select x;
var units = from x in Funs.DB.Base_Unit
join y in Funs.DB.Project_ProjectUnit on x.UnitId equals y.UnitId
where y.ProjectId == this.CurrUser.LoginProjectId
select x;
var cns = from x in Funs.DB.Base_CNProfessional select x;
var unitWorks = from x in Funs.DB.WBS_UnitWork
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.SuperUnitWork == null
select x;
for (int i = 0; i < ir; i++)
{
Model.Comprehensive_GeneralPlanApproval oldViewInfo = new Model.Comprehensive_GeneralPlanApproval();
string row0 = pds.Rows[i][0].ToString().Trim();
string row1 = pds.Rows[i][1].ToString().Trim();
var cn = cns.Where(y => y.ProfessionalName == row1).FirstOrDefault();
oldViewInfo = oldViewInfos.Where(x => x.RemarkCode == pds.Rows[i][9].ToString().Trim()
).FirstOrDefault();
if (oldViewInfo == null)
{
Model.Comprehensive_GeneralPlanApproval des = new Model.Comprehensive_GeneralPlanApproval();
des.GeneralPlanApprovalId = SQLHelper.GetNewID(typeof(Model.Comprehensive_GeneralPlanApproval));
des.ProjectId = this.CurrUser.LoginProjectId;
des.UnitId = units.Where(x => x.UnitName == row0.Trim()).FirstOrDefault().UnitId;
des.CNProfessionalId = cn.CNProfessionalId;
if (!string.IsNullOrEmpty(pds.Rows[i][2].ToString().Trim()))
{
des.UnitWorkId = BLL.UnitWorkService.GetUnitWorkIdsByUnitWorkNames(this.CurrUser.LoginProjectId, pds.Rows[i][2].ToString().Trim());
}
des.PlanCode = pds.Rows[i][3].ToString().Trim();
des.PlanName = pds.Rows[i][4].ToString().Trim();
des.ApprovalDate = Funs.GetNewDateTime(pds.Rows[i][5].ToString().Trim());
des.AuditMan = pds.Rows[i][6].ToString().Trim();
des.ApprovalMan = pds.Rows[i][7].ToString().Trim();
des.ImplementationDeviation = pds.Rows[i][8].ToString().Trim();
des.RemarkCode = pds.Rows[i][9].ToString().Trim();
des.CompileMan = this.CurrUser.UserId;
des.CompileDate = DateTime.Now;
BLL.GeneralPlanApprovalService.AddGeneralPlanApproval(des);
}
}
}
else
{
ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
}
return true;
}
#endregion
#endregion
#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.GeneralPlanApprovalTemplateUrl;
string filePath = Const.GeneralPlanApprovalTemplateUrl;
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
}
}

View File

@ -0,0 +1,123 @@
//------------------------------------------------------------------------------
// <自动生成>
// 此代码由工具生成。
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </自动生成>
//------------------------------------------------------------------------------
namespace FineUIPro.Web.CQMS.Comprehensive {
public partial class GeneralPlanApprovalDataIn {
/// <summary>
/// form1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// PageManager1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.PageManager PageManager1;
/// <summary>
/// SimpleForm1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Form SimpleForm1;
/// <summary>
/// Toolbar2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar2;
/// <summary>
/// hdFileName 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.HiddenField hdFileName;
/// <summary>
/// btnAudit 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnAudit;
/// <summary>
/// btnImport 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnImport;
/// <summary>
/// btnDownLoad 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnDownLoad;
/// <summary>
/// hdCheckResult 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.HiddenField hdCheckResult;
/// <summary>
/// fuAttachUrl 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.FileUpload fuAttachUrl;
/// <summary>
/// gvErrorInfo 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Grid gvErrorInfo;
/// <summary>
/// lblPageIndex 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblPageIndex;
}
}

View File

@ -33,6 +33,8 @@
<f:ToolbarFill runat="server"></f:ToolbarFill>
<f:Button ID="btnNew" Icon="Add" EnablePostBack="true" runat="server" OnClick="btnNew_Click" ToolTip="新增" Hidden="true">
</f:Button>
<f:Button ID="btnImport" ToolTip="导入" Hidden="true" Icon="PackageIn" runat="server" OnClick="btnImport_Click">
</f:Button>
</Items>
</f:Toolbar>
</Toolbars>
@ -98,6 +100,10 @@
Target="Parent" EnableResize="false" runat="server" IsModal="true" OnClose="Window1_Close"
Width="900px" Height="460px">
</f:Window>
<f:Window ID="Window2" Title="导入检验试验计划" Hidden="true" EnableIFrame="true" EnableMaximize="true"
Target="Parent" EnableResize="false" runat="server" IsModal="true" OnClose="Window1_Close"
Width="700px" Height="460px">
</f:Window>
<f:Menu ID="Menu1" runat="server">
<Items>
<f:MenuButton ID="btnMenuModify" EnablePostBack="true" runat="server" Text="修改" Icon="Pencil" OnClick="btnMenuModify_Click" Hidden="true">

View File

@ -95,6 +95,10 @@ namespace FineUIPro.Web.CQMS.Comprehensive
{
this.btnMenuDel.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnSave))
{
this.btnImport.Hidden = false;
}
}
}
#endregion
@ -222,6 +226,16 @@ namespace FineUIPro.Web.CQMS.Comprehensive
}
#endregion
#region
/// <summary>
/// 导入按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("InspectionTestPlanDataIn.aspx", "导入 - ")));
}
#endregion
}
}

View File

@ -7,12 +7,10 @@
// </自动生成>
//------------------------------------------------------------------------------
namespace FineUIPro.Web.CQMS.Comprehensive
{
namespace FineUIPro.Web.CQMS.Comprehensive {
public partial class InspectionTestPlan
{
public partial class InspectionTestPlan {
/// <summary>
/// form1 控件。
@ -104,6 +102,15 @@ namespace FineUIPro.Web.CQMS.Comprehensive
/// </remarks>
protected global::FineUIPro.Button btnNew;
/// <summary>
/// btnImport 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnImport;
/// <summary>
/// lblPageIndex 控件。
/// </summary>
@ -149,6 +156,15 @@ namespace FineUIPro.Web.CQMS.Comprehensive
/// </remarks>
protected global::FineUIPro.Window Window1;
/// <summary>
/// Window2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Window Window2;
/// <summary>
/// Menu1 控件。
/// </summary>

View File

@ -0,0 +1,68 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="InspectionTestPlanDataIn.aspx.cs" Inherits="FineUIPro.Web.CQMS.Comprehensive.InspectionTestPlanDataIn" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>导入检验试验计划</title>
</head>
<body>
<form id="form1" runat="server">
<f:PageManager ID="PageManager1" AutoSizePanelID="SimpleForm1" runat="server" OnCustomEvent="PageManager1_CustomEvent" />
<f:Form ID="SimpleForm1" ShowBorder="false" ShowHeader="false" AutoScroll="true"
BodyPadding="10px" runat="server" RedStarPosition="BeforeText" LabelAlign="Right">
<Toolbars>
<f:Toolbar ID="Toolbar2" Position="Top" ToolbarAlign="Right" runat="server">
<Items>
<f:HiddenField ID="hdFileName" runat="server">
</f:HiddenField>
<f:Button ID="btnAudit" Icon="ApplicationEdit" runat="server" ToolTip="审核" ValidateForms="SimpleForm1"
OnClick="btnAudit_Click">
</f:Button>
<f:Button ID="btnImport" Icon="ApplicationGet" runat="server" ToolTip="导入" ValidateForms="SimpleForm1"
OnClick="btnImport_Click">
</f:Button>
<f:Button ID="btnDownLoad" runat="server" Icon="ApplicationGo" ToolTip="下载模板" OnClick="btnDownLoad_Click">
</f:Button>
<f:HiddenField ID="hdCheckResult" runat="server">
</f:HiddenField>
</Items>
</f:Toolbar>
</Toolbars>
<Rows>
<f:FormRow>
<Items>
<f:FileUpload runat="server" ID="fuAttachUrl" EmptyText="选择要导入的文件" Label="选择要导入的文件"
LabelWidth="150px">
</f:FileUpload>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:Grid ID="gvErrorInfo" ShowBorder="true" EnableAjax="false" ShowHeader="false" Title="检验试验计划" EnableCollapse="true"
runat="server" BoxFlex="1" AllowCellEditing="true" ClicksToEdit="2" AllowSorting="true"
SortDirection="DESC" EnableColumnLines="true" ForceFit="true" AllowPaging="true" IsDatabasePaging="true" PageSize="10"
EnableRowDoubleClickEvent="true" AllowFilters="true" EnableTextSelection="True">
<Columns>
<f:TemplateField ColumnID="tfPageIndex" Width="55px" HeaderText="序号" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:Label ID="lblPageIndex" runat="server" Text='<%# gvErrorInfo.PageIndex * gvErrorInfo.PageSize + Container.DataItemIndex + 1 %>'></asp:Label>
</ItemTemplate>
</f:TemplateField>
<f:BoundField DataField="Row" HeaderText="错误行号">
</f:BoundField>
<f:BoundField DataField="Column" HeaderText="错误列">
</f:BoundField>
<f:BoundField DataField="Reason" HeaderText="错误类型">
</f:BoundField>
</Columns>
</f:Grid>
</Items>
</f:FormRow>
</Rows>
</f:Form>
</form>
</body>
</html>

View File

@ -0,0 +1,441 @@
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.CQMS.Comprehensive
{
public partial class InspectionTestPlanDataIn : PageBase
{
#region
/// <summary>
/// 上传预设的虚拟路径
/// </summary>
private string initPath = Const.ExcelUrl;
/// <summary>
/// 错误集合
/// </summary>
public static List<Model.ErrorInfo> errorInfos = new List<Model.ErrorInfo>();
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.hdCheckResult.Text = string.Empty;
this.hdFileName.Text = string.Empty;
if (errorInfos != null)
{
errorInfos.Clear();
}
}
}
#endregion
#region
/// <summary>
/// 审核
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAudit_Click(object sender, EventArgs e)
{
try
{
if (this.fuAttachUrl.HasFile == false)
{
ShowNotify("请您选择Excel文件", MessageBoxIcon.Warning);
return;
}
string IsXls = Path.GetExtension(this.fuAttachUrl.FileName).ToString().Trim().ToLower();
if (IsXls != ".xls")
{
ShowNotify("只可以选择Excel文件", MessageBoxIcon.Warning);
return;
}
if (errorInfos != null)
{
errorInfos.Clear();
}
string rootPath = Server.MapPath("~/");
string initFullPath = rootPath + initPath;
if (!Directory.Exists(initFullPath))
{
Directory.CreateDirectory(initFullPath);
}
this.hdFileName.Text = BLL.Funs.GetNewFileName() + IsXls;
string filePath = initFullPath + this.hdFileName.Text;
this.fuAttachUrl.PostedFile.SaveAs(filePath);
ImportXlsToData(rootPath + initPath + this.hdFileName.Text);
}
catch (Exception ex)
{
ShowNotify("'" + ex.Message + "'", MessageBoxIcon.Warning);
}
}
#region Excel提取数据
/// <summary>
/// 从Excel提取数据--》Dataset
/// </summary>
/// <param name="filename">Excel文件路径名</param>
private void ImportXlsToData(string fileName)
{
try
{
string oleDBConnString = String.Empty;
oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
oleDBConnString += "Data Source=";
oleDBConnString += fileName;
oleDBConnString += ";Extended Properties=Excel 8.0;";
OleDbConnection oleDBConn = null;
OleDbDataAdapter oleAdMaster = null;
DataTable m_tableName = new DataTable();
DataSet ds = new DataSet();
oleDBConn = new OleDbConnection(oleDBConnString);
oleDBConn.Open();
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (m_tableName != null && m_tableName.Rows.Count > 0)
{
m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim();
}
string sqlMaster;
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
oleAdMaster.Fill(ds, "m_tableName");
oleAdMaster.Dispose();
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL(ds.Tables[0], 8);
hdCheckResult.Text = "1";
}
catch (Exception exc)
{
Response.Write(exc);
//return null;
// return dt;
}
finally
{
}
}
#endregion
#region Dataset的数据导入数据库
/// <summary>
/// 将Dataset的数据导入数据库
/// </summary>
/// <param name="pds">数据集</param>
/// <param name="Cols">数据集行数</param>
/// <returns></returns>
private bool AddDatasetToSQL(DataTable pds, int Cols)
{
string result = string.Empty;
int ic, ir;
ic = pds.Columns.Count;
if (ic < Cols)
{
ShowNotify("导入Excel格式错误Excel只有" + ic.ToString().Trim() + "列", MessageBoxIcon.Warning);
return false;
}
ir = pds.Rows.Count;
if (pds != null && ir > 0)
{
var units = from x in Funs.DB.Base_Unit
join y in Funs.DB.Project_ProjectUnit on x.UnitId equals y.UnitId
where y.ProjectId == this.CurrUser.LoginProjectId
select x;
var cns = from x in Funs.DB.Base_CNProfessional select x;
for (int i = 0; i < ir; i++)
{
string row0 = pds.Rows[i][0].ToString().Trim();
if (!string.IsNullOrEmpty(row0))
{
var u = units.Where(x => x.UnitName == row0).FirstOrDefault();
if (u == null)
{
result += (i + 2).ToString() + "," + "报批单位" + "," + "[" + row0 + "]不存在!" + "|";
}
}
else
{
result += (i + 2).ToString() + "," + "报批单位" + "," + "此项为必填项!" + "|";
}
string row1 = pds.Rows[i][1].ToString().Trim();
if (!string.IsNullOrEmpty(row1))
{
var cn = cns.Where(x => x.ProfessionalName == row1.Trim()).FirstOrDefault();
if (cn == null)
{
result += (i + 2).ToString() + "," + "专业名称" + "," + "[" + row1 + "]不存在!" + "|";
}
}
string row2 = pds.Rows[i][2].ToString();
if (string.IsNullOrEmpty(row2))
{
result += (i + 2).ToString() + "," + "编号" + "," + "此项为必填项!" + "|";
}
string row4 = pds.Rows[i][4].ToString();
if (!string.IsNullOrEmpty(row4))
{
try
{
DateTime date = Convert.ToDateTime(row4.Trim());
}
catch (Exception)
{
result += (i + 2).ToString() + "," + "审批日期" + "," + "[" + row4 + "]错误!" + "|";
}
}
string row7 = pds.Rows[i][7].ToString();
if (string.IsNullOrEmpty(row7))
{
result += (i + 2).ToString() + "," + "标志编号" + "," + "此项为必填项!" + "|";
}
}
if (!string.IsNullOrEmpty(result))
{
result = result.Substring(0, result.LastIndexOf("|"));
}
errorInfos.Clear();
if (!string.IsNullOrEmpty(result))
{
string results = result;
List<string> errorInfoList = results.Split('|').ToList();
foreach (var item in errorInfoList)
{
string[] errors = item.Split(',');
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = errors[0];
errorInfo.Column = errors[1];
errorInfo.Reason = errors[2];
errorInfos.Add(errorInfo);
}
if (errorInfos.Count > 0)
{
this.gvErrorInfo.DataSource = errorInfos;
this.gvErrorInfo.DataBind();
}
}
else
{
ShowNotify("审核完成,请点击导入!", MessageBoxIcon.Success);
}
}
else
{
ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
}
return true;
}
#endregion
#endregion
#region
/// <summary>
/// 导入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(hdCheckResult.Text))
{
if (errorInfos.Count <= 0)
{
string rootPath = Server.MapPath("~/");
ImportXlsToData2(rootPath + initPath + this.hdFileName.Text);
hdCheckResult.Text = string.Empty;
ShowNotify("导入成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
ShowNotify("请先将错误数据修正,再重新导入提交!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("请先审核要导入的文件!", MessageBoxIcon.Warning);
}
}
#region Excel提取数据
/// <summary>
/// 从Excel提取数据--》Dataset
/// </summary>
/// <param name="filename">Excel文件路径名</param>
private void ImportXlsToData2(string fileName)
{
try
{
string oleDBConnString = String.Empty;
oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
oleDBConnString += "Data Source=";
oleDBConnString += fileName;
oleDBConnString += ";Extended Properties=Excel 8.0;";
OleDbConnection oleDBConn = null;
OleDbDataAdapter oleAdMaster = null;
DataTable m_tableName = new DataTable();
DataSet ds = new DataSet();
oleDBConn = new OleDbConnection(oleDBConnString);
oleDBConn.Open();
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (m_tableName != null && m_tableName.Rows.Count > 0)
{
m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim();
}
string sqlMaster;
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
oleAdMaster.Fill(ds, "m_tableName");
oleAdMaster.Dispose();
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL2(ds.Tables[0], 8);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region Dataset的数据导入数据库
/// <summary>
/// 将Dataset的数据导入数据库
/// </summary>
/// <param name="pds">数据集</param>
/// <param name="Cols">数据集列数</param>
/// <returns></returns>
private bool AddDatasetToSQL2(DataTable pds, int Cols)
{
int ic, ir;
ic = pds.Columns.Count;
if (ic < Cols)
{
ShowNotify("导入Excel格式错误Excel只有" + ic.ToString().Trim() + "列", MessageBoxIcon.Warning);
}
ir = pds.Rows.Count;
if (pds != null && ir > 0)
{
var units = from x in Funs.DB.Base_Unit
join y in Funs.DB.Project_ProjectUnit on x.UnitId equals y.UnitId
where y.ProjectId == this.CurrUser.LoginProjectId
select x;
var cns = from x in Funs.DB.Base_CNProfessional select x;
var oldViewInfos = from x in Funs.DB.Inspection_Test_Plan
where x.ProjectId == this.CurrUser.LoginProjectId
select x;
for (int i = 0; i < ir; i++)
{
var oldViewInfo = oldViewInfos.Where(x => x.RemarkCode == pds.Rows[i][7].ToString().Trim()).FirstOrDefault();
if (oldViewInfo == null)
{
Model.Inspection_Test_Plan Ins = new Model.Inspection_Test_Plan();
Ins.Id = SQLHelper.GetNewID(typeof(Model.Inspection_Test_Plan));
Ins.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(pds.Rows[i][0].ToString().Trim()))
{
Ins.UnitId = units.FirstOrDefault(e => e.UnitName == pds.Rows[i][0].ToString().Trim()).UnitId;
}
if (!string.IsNullOrEmpty(pds.Rows[i][1].ToString().Trim()))
{
Ins.CNProfessionalId = cns.FirstOrDefault(e => e.ProfessionalName == pds.Rows[i][1].ToString().Trim()).CNProfessionalId;
}
Ins.PlanCode = pds.Rows[i][2].ToString().Trim();
Ins.PlanName = pds.Rows[i][3].ToString().Trim();
Ins.ApprovalDate = Funs.GetNewDateTime(pds.Rows[i][4].ToString().Trim());
Ins.AuditMan = pds.Rows[i][5].ToString().Trim();
Ins.ApprovalMan= pds.Rows[i][6].ToString().Trim();
Ins.RemarkCode= pds.Rows[i][7].ToString().Trim();
Ins.CreateMan = this.CurrUser.UserId;
Ins.CreateDate = DateTime.Now;
BLL.InspectionTestPlanService.Insert(Ins);
}
}
}
else
{
ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
}
return true;
}
#endregion
#endregion
#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.InspectionTestPlanTemplateUrl;
string filePath = Const.InspectionTestPlanTemplateUrl;
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
}
}

View File

@ -0,0 +1,123 @@
//------------------------------------------------------------------------------
// <自动生成>
// 此代码由工具生成。
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </自动生成>
//------------------------------------------------------------------------------
namespace FineUIPro.Web.CQMS.Comprehensive {
public partial class InspectionTestPlanDataIn {
/// <summary>
/// form1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// PageManager1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.PageManager PageManager1;
/// <summary>
/// SimpleForm1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Form SimpleForm1;
/// <summary>
/// Toolbar2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar2;
/// <summary>
/// hdFileName 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.HiddenField hdFileName;
/// <summary>
/// btnAudit 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnAudit;
/// <summary>
/// btnImport 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnImport;
/// <summary>
/// btnDownLoad 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnDownLoad;
/// <summary>
/// hdCheckResult 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.HiddenField hdCheckResult;
/// <summary>
/// fuAttachUrl 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.FileUpload fuAttachUrl;
/// <summary>
/// gvErrorInfo 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Grid gvErrorInfo;
/// <summary>
/// lblPageIndex 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblPageIndex;
}
}

View File

@ -29,6 +29,8 @@
<f:ToolbarFill runat="server"></f:ToolbarFill>
<f:Button ID="btnNew" Icon="Add" ToolTip="新增" Hidden="true" EnablePostBack="true" runat="server" OnClick="btnNew_Click">
</f:Button>
<f:Button ID="btnImport" ToolTip="导入" Icon="PackageIn" runat="server" OnClick="btnImport_Click" Hidden="true">
</f:Button>
</Items>
</f:Toolbar>

View File

@ -92,7 +92,7 @@ namespace FineUIPro.Web.CQMS.Comprehensive
}
if (buttonList.Contains(BLL.Const.BtnSave))
{
//this.btnImport.Hidden = false;
this.btnImport.Hidden = false;
}
}
}
@ -311,5 +311,19 @@ namespace FineUIPro.Web.CQMS.Comprehensive
return "编制";
}
#region
/// <summary>
/// 导入按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("ReviewDrawingsDataIn.aspx", "导入 - ")));
}
#endregion
}
}

View File

@ -7,12 +7,10 @@
// </自动生成>
//------------------------------------------------------------------------------
namespace FineUIPro.Web.CQMS.Comprehensive
{
namespace FineUIPro.Web.CQMS.Comprehensive {
public partial class ReviewDrawings
{
public partial class ReviewDrawings {
/// <summary>
/// form1 控件。
@ -95,6 +93,15 @@ namespace FineUIPro.Web.CQMS.Comprehensive
/// </remarks>
protected global::FineUIPro.Button btnNew;
/// <summary>
/// btnImport 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnImport;
/// <summary>
/// lblPageIndex 控件。
/// </summary>

View File

@ -0,0 +1,68 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReviewDrawingsDataIn.aspx.cs" Inherits="FineUIPro.Web.CQMS.Comprehensive.ReviewDrawingsDataIn" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>导入图纸会审记录</title>
</head>
<body>
<form id="form1" runat="server">
<f:PageManager ID="PageManager1" AutoSizePanelID="SimpleForm1" runat="server" OnCustomEvent="PageManager1_CustomEvent" />
<f:Form ID="SimpleForm1" ShowBorder="false" ShowHeader="false" AutoScroll="true"
BodyPadding="10px" runat="server" RedStarPosition="BeforeText" LabelAlign="Right">
<Toolbars>
<f:Toolbar ID="Toolbar2" Position="Top" ToolbarAlign="Right" runat="server">
<Items>
<f:HiddenField ID="hdFileName" runat="server">
</f:HiddenField>
<f:Button ID="btnAudit" Icon="ApplicationEdit" runat="server" ToolTip="审核" ValidateForms="SimpleForm1"
OnClick="btnAudit_Click">
</f:Button>
<f:Button ID="btnImport" Icon="ApplicationGet" runat="server" ToolTip="导入" ValidateForms="SimpleForm1"
OnClick="btnImport_Click">
</f:Button>
<f:Button ID="btnDownLoad" runat="server" Icon="ApplicationGo" ToolTip="下载模板" OnClick="btnDownLoad_Click">
</f:Button>
<f:HiddenField ID="hdCheckResult" runat="server">
</f:HiddenField>
</Items>
</f:Toolbar>
</Toolbars>
<Rows>
<f:FormRow>
<Items>
<f:FileUpload runat="server" ID="fuAttachUrl" EmptyText="选择要导入的文件" Label="选择要导入的文件"
LabelWidth="150px">
</f:FileUpload>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:Grid ID="gvErrorInfo" ShowBorder="true" EnableAjax="false" ShowHeader="false" Title="图纸会审记录" EnableCollapse="true"
runat="server" BoxFlex="1" AllowCellEditing="true" ClicksToEdit="2" AllowSorting="true"
SortDirection="DESC" EnableColumnLines="true" ForceFit="true" AllowPaging="true" IsDatabasePaging="true" PageSize="10"
EnableRowDoubleClickEvent="true" AllowFilters="true" EnableTextSelection="True">
<Columns>
<f:TemplateField ColumnID="tfPageIndex" Width="55px" HeaderText="序号" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:Label ID="lblPageIndex" runat="server" Text='<%# gvErrorInfo.PageIndex * gvErrorInfo.PageSize + Container.DataItemIndex + 1 %>'></asp:Label>
</ItemTemplate>
</f:TemplateField>
<f:BoundField DataField="Row" HeaderText="错误行号">
</f:BoundField>
<f:BoundField DataField="Column" HeaderText="错误列">
</f:BoundField>
<f:BoundField DataField="Reason" HeaderText="错误类型">
</f:BoundField>
</Columns>
</f:Grid>
</Items>
</f:FormRow>
</Rows>
</f:Form>
</form>
</body>
</html>

View File

@ -0,0 +1,483 @@
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.CQMS.Comprehensive
{
public partial class ReviewDrawingsDataIn : PageBase
{
#region
/// <summary>
/// 上传预设的虚拟路径
/// </summary>
private string initPath = Const.ExcelUrl;
/// <summary>
/// 错误集合
/// </summary>
public static List<Model.ErrorInfo> errorInfos = new List<Model.ErrorInfo>();
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.hdCheckResult.Text = string.Empty;
this.hdFileName.Text = string.Empty;
if (errorInfos != null)
{
errorInfos.Clear();
}
}
}
#endregion
#region
/// <summary>
/// 审核
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAudit_Click(object sender, EventArgs e)
{
try
{
if (this.fuAttachUrl.HasFile == false)
{
ShowNotify("请您选择Excel文件", MessageBoxIcon.Warning);
return;
}
string IsXls = Path.GetExtension(this.fuAttachUrl.FileName).ToString().Trim().ToLower();
if (IsXls != ".xls")
{
ShowNotify("只可以选择Excel文件", MessageBoxIcon.Warning);
return;
}
if (errorInfos != null)
{
errorInfos.Clear();
}
string rootPath = Server.MapPath("~/");
string initFullPath = rootPath + initPath;
if (!Directory.Exists(initFullPath))
{
Directory.CreateDirectory(initFullPath);
}
this.hdFileName.Text = BLL.Funs.GetNewFileName() + IsXls;
string filePath = initFullPath + this.hdFileName.Text;
this.fuAttachUrl.PostedFile.SaveAs(filePath);
ImportXlsToData(rootPath + initPath + this.hdFileName.Text);
}
catch (Exception ex)
{
ShowNotify("'" + ex.Message + "'", MessageBoxIcon.Warning);
}
}
#region Excel提取数据
/// <summary>
/// 从Excel提取数据--》Dataset
/// </summary>
/// <param name="filename">Excel文件路径名</param>
private void ImportXlsToData(string fileName)
{
try
{
string oleDBConnString = String.Empty;
oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
oleDBConnString += "Data Source=";
oleDBConnString += fileName;
oleDBConnString += ";Extended Properties=Excel 8.0;";
OleDbConnection oleDBConn = null;
OleDbDataAdapter oleAdMaster = null;
DataTable m_tableName = new DataTable();
DataSet ds = new DataSet();
oleDBConn = new OleDbConnection(oleDBConnString);
oleDBConn.Open();
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (m_tableName != null && m_tableName.Rows.Count > 0)
{
m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim();
}
string sqlMaster;
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
oleAdMaster.Fill(ds, "m_tableName");
oleAdMaster.Dispose();
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL(ds.Tables[0], 7);
hdCheckResult.Text = "1";
}
catch (Exception exc)
{
Response.Write(exc);
//return null;
// return dt;
}
finally
{
}
}
#endregion
#region Dataset的数据导入数据库
/// <summary>
/// 将Dataset的数据导入数据库
/// </summary>
/// <param name="pds">数据集</param>
/// <param name="Cols">数据集行数</param>
/// <returns></returns>
private bool AddDatasetToSQL(DataTable pds, int Cols)
{
string result = string.Empty;
int ic, ir;
ic = pds.Columns.Count;
if (ic < Cols)
{
ShowNotify("导入Excel格式错误Excel只有" + ic.ToString().Trim() + "列", MessageBoxIcon.Warning);
return false;
}
ir = pds.Rows.Count;
if (pds != null && ir > 0)
{
var oldViewInfos = from x in Funs.DB.Comprehensive_ReviewDrawings
where x.ProjectId == this.CurrUser.LoginProjectId
select x;
var units = from x in Funs.DB.Base_Unit
join y in Funs.DB.Project_ProjectUnit on x.UnitId equals y.UnitId
where y.ProjectId == this.CurrUser.LoginProjectId
select x;
var cns = from x in Funs.DB.Base_CNProfessional select x;
var unitWorks = from x in Funs.DB.WBS_UnitWork
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.SuperUnitWork == null
select x;
for (int i = 0; i < ir; i++)
{
string row0 = pds.Rows[i][0].ToString();
if (string.IsNullOrEmpty(row0))
{
result += (i + 2).ToString() + "," + "专业名称" + "," + "此项为必填项!" + "|";
}
else
{
var cn = cns.Where(x => x.ProfessionalName == row0.Trim()).FirstOrDefault();
if (cn == null)
{
result += (i + 2).ToString() + "," + "专业名称" + "," + "[" + row0 + "]不存在!" + "|";
}
}
string row1 = pds.Rows[i][1].ToString();
if (string.IsNullOrEmpty(row1))
{
result += (i + 2).ToString() + "," + "编号" + "," + "此项为必填项!" + "|";
}
string row2 = pds.Rows[i][2].ToString();
if (!string.IsNullOrEmpty(row2))
{
string[] reunit = row2.Split(',');
foreach (string unitWork in reunit)
{
var u = unitWorks.Where(x => x.UnitWorkName == unitWork.Trim()).FirstOrDefault();
if (u == null)
{
result += (i + 2).ToString() + "," + "单位工程名称" + "," + "[" + unitWork.Trim() + "]不存在!" + "|";
}
}
}
string row3 = pds.Rows[i][3].ToString();
if (!string.IsNullOrEmpty(row3))
{
try
{
DateTime date = Convert.ToDateTime(row3.Trim());
}
catch (Exception)
{
result += (i + 2).ToString() + "," + "图纸会审日期" + "," + "[" + row3 + "]错误!" + "|";
}
}
else
{
result += (i + 2).ToString() + "," + "图纸会审日期" + "," + "此项为必填项!" + "|";
}
string row4 = pds.Rows[i][4].ToString();
if (!string.IsNullOrEmpty(row4))
{
string[] reunit = row4.Split(',');
foreach (string unit in reunit)
{
var u = units.Where(x => x.UnitName == unit.Trim()).FirstOrDefault();
if (u == null)
{
result += (i + 2).ToString() + "," + "参加单位" + "," + "[" + unit.Trim() + "]不存在!" + "|";
}
}
}
string row6 = pds.Rows[i][6].ToString();
if (string.IsNullOrEmpty(row6))
{
result += (i + 2).ToString() + "," + "标志编号" + "," + "此项为必填项!" + "|";
}
}
if (!string.IsNullOrEmpty(result))
{
result = result.Substring(0, result.LastIndexOf("|"));
}
errorInfos.Clear();
if (!string.IsNullOrEmpty(result))
{
string results = result;
List<string> errorInfoList = results.Split('|').ToList();
foreach (var item in errorInfoList)
{
string[] errors = item.Split(',');
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = errors[0];
errorInfo.Column = errors[1];
errorInfo.Reason = errors[2];
errorInfos.Add(errorInfo);
}
if (errorInfos.Count > 0)
{
this.gvErrorInfo.DataSource = errorInfos;
this.gvErrorInfo.DataBind();
}
}
else
{
ShowNotify("审核完成,请点击导入!", MessageBoxIcon.Success);
}
}
else
{
ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
}
return true;
}
#endregion
#endregion
#region
/// <summary>
/// 导入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(hdCheckResult.Text))
{
if (errorInfos.Count <= 0)
{
string rootPath = Server.MapPath("~/");
ImportXlsToData2(rootPath + initPath + this.hdFileName.Text);
hdCheckResult.Text = string.Empty;
ShowNotify("导入成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
ShowNotify("请先将错误数据修正,再重新导入提交!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("请先审核要导入的文件!", MessageBoxIcon.Warning);
}
}
#region Excel提取数据
/// <summary>
/// 从Excel提取数据--》Dataset
/// </summary>
/// <param name="filename">Excel文件路径名</param>
private void ImportXlsToData2(string fileName)
{
try
{
string oleDBConnString = String.Empty;
oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
oleDBConnString += "Data Source=";
oleDBConnString += fileName;
oleDBConnString += ";Extended Properties=Excel 8.0;";
OleDbConnection oleDBConn = null;
OleDbDataAdapter oleAdMaster = null;
DataTable m_tableName = new DataTable();
DataSet ds = new DataSet();
oleDBConn = new OleDbConnection(oleDBConnString);
oleDBConn.Open();
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (m_tableName != null && m_tableName.Rows.Count > 0)
{
m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim();
}
string sqlMaster;
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
oleAdMaster.Fill(ds, "m_tableName");
oleAdMaster.Dispose();
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL2(ds.Tables[0], 7);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region Dataset的数据导入数据库
/// <summary>
/// 将Dataset的数据导入数据库
/// </summary>
/// <param name="pds">数据集</param>
/// <param name="Cols">数据集列数</param>
/// <returns></returns>
private bool AddDatasetToSQL2(DataTable pds, int Cols)
{
int ic, ir;
ic = pds.Columns.Count;
if (ic < Cols)
{
ShowNotify("导入Excel格式错误Excel只有" + ic.ToString().Trim() + "列", MessageBoxIcon.Warning);
}
string result = string.Empty;
ir = pds.Rows.Count;
if (pds != null && ir > 0)
{
var oldViewInfos = from x in Funs.DB.Comprehensive_ReviewDrawings
where x.ProjectId == this.CurrUser.LoginProjectId
select x;
var units = from x in Funs.DB.Base_Unit
join y in Funs.DB.Project_ProjectUnit on x.UnitId equals y.UnitId
where y.ProjectId == this.CurrUser.LoginProjectId
select x;
var cns = from x in Funs.DB.Base_CNProfessional select x;
var unitWorks = from x in Funs.DB.WBS_UnitWork
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.SuperUnitWork == null
select x;
for (int i = 0; i < ir; i++)
{
Model.Comprehensive_ReviewDrawings oldViewInfo = new Model.Comprehensive_ReviewDrawings();
string row0 = pds.Rows[i][0].ToString().Trim();
var cn = cns.Where(y => y.ProfessionalName == row0).FirstOrDefault();
oldViewInfo = oldViewInfos.Where(x => x.RemarkCode == pds.Rows[i][6].ToString().Trim()
).FirstOrDefault();
if (oldViewInfo == null)
{
Model.Comprehensive_ReviewDrawings des = new Model.Comprehensive_ReviewDrawings();
des.Id = SQLHelper.GetNewID(typeof(Model.Comprehensive_ReviewDrawings));
des.ProjectId = this.CurrUser.LoginProjectId;
des.CNProfessionalId = cn.CNProfessionalId;
des.DraCode = pds.Rows[i][1].ToString().Trim();
if (!string.IsNullOrEmpty(pds.Rows[i][2].ToString().Trim()))
{
des.UnitWorkId = BLL.UnitWorkService.GetUnitWorkIdsByUnitWorkNames(this.CurrUser.LoginProjectId, pds.Rows[i][2].ToString().Trim());
}
if (!string.IsNullOrEmpty(pds.Rows[i][3].ToString().Trim()))
{
des.ReviewDate = Convert.ToDateTime(pds.Rows[i][3].ToString().Trim());
}
if (!string.IsNullOrEmpty(pds.Rows[i][4].ToString().Trim()))
{
des.ReceiveUnits = BLL.UnitService.GetUnitIds(pds.Rows[i][4].ToString().Trim());
}
des.Remarks = pds.Rows[i][5].ToString().Trim();
des.RemarkCode = pds.Rows[i][6].ToString().Trim();
des.CreateMan = this.CurrUser.UserId;
des.CreateDate = DateTime.Now;
des.Status = BLL.Const.Comprehensive_Compile;
BLL.ReviewDrawingsService.Insert(des);
}
}
}
else
{
ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
}
return true;
}
#endregion
#endregion
#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.ReviewDrawingsTemplateUrl;
string filePath = Const.ReviewDrawingsTemplateUrl;
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
}
}

View File

@ -0,0 +1,123 @@
//------------------------------------------------------------------------------
// <自动生成>
// 此代码由工具生成。
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </自动生成>
//------------------------------------------------------------------------------
namespace FineUIPro.Web.CQMS.Comprehensive {
public partial class ReviewDrawingsDataIn {
/// <summary>
/// form1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// PageManager1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.PageManager PageManager1;
/// <summary>
/// SimpleForm1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Form SimpleForm1;
/// <summary>
/// Toolbar2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar2;
/// <summary>
/// hdFileName 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.HiddenField hdFileName;
/// <summary>
/// btnAudit 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnAudit;
/// <summary>
/// btnImport 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnImport;
/// <summary>
/// btnDownLoad 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnDownLoad;
/// <summary>
/// hdCheckResult 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.HiddenField hdCheckResult;
/// <summary>
/// fuAttachUrl 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.FileUpload fuAttachUrl;
/// <summary>
/// gvErrorInfo 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Grid gvErrorInfo;
/// <summary>
/// lblPageIndex 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblPageIndex;
}
}

View File

@ -126,7 +126,7 @@ namespace FineUIPro.Web.CQMS.Comprehensive
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL(ds.Tables[0], 10);
AddDatasetToSQL(ds.Tables[0], 11);
hdCheckResult.Text = "1";
}
catch (Exception exc)
@ -166,7 +166,7 @@ namespace FineUIPro.Web.CQMS.Comprehensive
join y in Funs.DB.Project_ProjectUnit on x.UnitId equals y.UnitId
where y.ProjectId == this.CurrUser.LoginProjectId && (y.UnitType == Const.ProjectUnitType_1 || y.UnitType == Const.ProjectUnitType_2)
select x;
var ins = from x in Funs.DB.WBS_UnitWork where x.ProjectId == this.CurrUser.LoginProjectId select x;
var ins = from x in Funs.DB.WBS_UnitWork where x.ProjectId == this.CurrUser.LoginProjectId && x.SuperUnitWork == null orderby x.UnitWorkCode select x;
var cns = from x in Funs.DB.Base_CNProfessional select x;
for (int i = 0; i < ir; i++)
@ -212,7 +212,7 @@ namespace FineUIPro.Web.CQMS.Comprehensive
var in1 = ins.Where(x => x.UnitWorkName == row4.Trim()).FirstOrDefault();
if (in1 == null)
{
result += (i + 2).ToString() + "," + "装置" + "," + "[" + row4 + "]不存在!" + "|";
result += (i + 2).ToString() + "," + "单位工程" + "," + "[" + row4 + "]不存在!" + "|";
}
}
@ -238,6 +238,12 @@ namespace FineUIPro.Web.CQMS.Comprehensive
result += (i + 2).ToString() + "," + "签证时间" + "," + "[" + row6 + "]错误!" + "|";
}
}
string row10 = pds.Rows[i][10].ToString();
if (string.IsNullOrEmpty(row10))
{
result += (i + 2).ToString() + "," + "标志编号" + "," + "此项为必填项!" + "|";
}
}
if (!string.IsNullOrEmpty(result))
{
@ -343,7 +349,7 @@ namespace FineUIPro.Web.CQMS.Comprehensive
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL2(ds.Tables[0], 4);
AddDatasetToSQL2(ds.Tables[0], 11);
}
catch (Exception ex)
{
@ -377,13 +383,13 @@ namespace FineUIPro.Web.CQMS.Comprehensive
select x;
var cns = from x in Funs.DB.Base_CNProfessional select x;
var installations = from x in Funs.DB.WBS_UnitWork where x.ProjectId == this.CurrUser.LoginProjectId select x;
var ins = from x in Funs.DB.WBS_UnitWork where x.ProjectId == this.CurrUser.LoginProjectId && x.SuperUnitWork == null select x;
var oldViewInfos = from x in Funs.DB.Comprehensive_SiteVisaManagement
where x.ProjectId == this.CurrUser.LoginProjectId
select x;
for (int i = 0; i < ir; i++)
{
var oldViewInfo = oldViewInfos.Where(x => x.VisaCode == pds.Rows[i][1].ToString().Trim()).FirstOrDefault();
var oldViewInfo = oldViewInfos.Where(x => x.RemarkCode == pds.Rows[i][10].ToString().Trim()).FirstOrDefault();
if (oldViewInfo == null)
{
Model.Comprehensive_SiteVisaManagement Ins = new Model.Comprehensive_SiteVisaManagement();
@ -397,7 +403,7 @@ namespace FineUIPro.Web.CQMS.Comprehensive
Ins.ProcessingState = pds.Rows[i][3].ToString().Trim();
if (!string.IsNullOrEmpty(pds.Rows[i][4].ToString().Trim()))
{
Ins.UnitWorkId = Funs.DB.WBS_UnitWork.First(e => e.UnitWorkName == pds.Rows[i][4].ToString().Trim()).UnitWorkId;
Ins.UnitWorkId = ins.FirstOrDefault(x => x.UnitWorkName == pds.Rows[i][4].ToString().Trim()).UnitWorkId;
}
if (!string.IsNullOrEmpty(pds.Rows[i][5].ToString().Trim()))
{
@ -410,6 +416,7 @@ namespace FineUIPro.Web.CQMS.Comprehensive
Ins.SignMan = pds.Rows[i][7].ToString().Trim();
Ins.AuditMan = pds.Rows[i][8].ToString().Trim();
Ins.Remark = pds.Rows[i][9].ToString().Trim();
Ins.RemarkCode = pds.Rows[i][10].ToString().Trim();
Ins.CompileMan = this.CurrUser.UserId;
Ins.Status = BLL.Const.Comprehensive_Compile;
Ins.VisaId = SQLHelper.GetNewID();

View File

@ -6,162 +6,63 @@
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>导入培训记录</title>
<style type="text/css">
.f-grid-row.red {
background-color: LightCoral;
}
.Label {
font-size: larger;
font-weight: bold;
}
</style>
<style type="text/css">
/*定义父容器*/
.content {
width: 550px;
height: 30px;
background: #E4F1FB;
margin: 0 auto;
}
/*定义进度条*/
.box {
width: 0px;
height: 30px;
line-height: 30px;
text-align: center;
background: #3BAAE3;
color: #fff;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<f:PageManager ID="PageManager1" AutoSizePanelID="Panel1" runat="server" />
<f:HiddenField ID="id" ClientIDMode="Static" runat="server"></f:HiddenField>
<f:Panel ID="Panel1" runat="server" Margin="2px" BodyPadding="2px" ShowBorder="false"
ShowHeader="false" Layout="VBox" BoxConfigAlign="Stretch">
<f:PageManager ID="PageManager1" AutoSizePanelID="SimpleForm1" runat="server" OnCustomEvent="PageManager1_CustomEvent" />
<f:Form ID="SimpleForm1" ShowBorder="false" ShowHeader="false" AutoScroll="true"
BodyPadding="10px" runat="server" RedStarPosition="BeforeText" LabelAlign="Right">
<Toolbars>
<f:Toolbar ID="Toolbar1" Position="Top" runat="server" ToolbarAlign="Right">
<f:Toolbar ID="Toolbar2" Position="Top" ToolbarAlign="Right" runat="server">
<Items>
<f:HiddenField ID="hdfileName" runat="server"></f:HiddenField>
<f:FileUpload ID="FileExcel" runat="server" Label="数据文件" EmptyText="请上传EXCEl格式文件" Width="350px" LabelWidth="90px" LabelAlign="Right"></f:FileUpload>
<f:Button ID="imgbtnImport" runat="server" Text="上传" ToolTip="文件上传" OnClick="imgbtnImport_Click"></f:Button>
<f:ToolbarFill ID="ToolbarFill1" runat="server"></f:ToolbarFill>
<f:CheckBox ID="ckUpdate" runat="server" Text="更新导入"></f:CheckBox>
<f:Button ID="btnSave" runat="server" Text="保存" ToolTip="审核保存" Icon="SystemSave" OnClick="btnSave_Click"></f:Button>
<f:Button ID="btnRefresh" runat="server" ClientIDMode="Static" Text="刷新" Icon="SystemSave" OnClick="btnRefresh_Click" Hidden="true"></f:Button>
<f:Button ID="btnAllDelete" runat="server" Icon="Delete" Text="删除记录" ToolTip="删除当前人所有临时导入记录" ConfirmText="删除当前人所有临时导入记录?"
ConfirmTarget="Top" OnClick="btnAllDelete_Click">
<f:HiddenField ID="hdFileName" runat="server">
</f:HiddenField>
<f:Button ID="btnAudit" Icon="ApplicationEdit" runat="server" ToolTip="审核" ValidateForms="SimpleForm1"
OnClick="btnAudit_Click">
</f:Button>
<f:Button ID="btnOut" OnClick="btnOut_Click" runat="server" Text="导出" Icon="TableGo"
EnableAjax="false" DisableControlBeforePostBack="false">
<f:Button ID="btnImport" Icon="ApplicationGet" runat="server" ToolTip="导入" ValidateForms="SimpleForm1"
OnClick="btnImport_Click">
</f:Button>
<f:Button ID="imgbtnUpload" runat="server" Icon="DiskDownload" Text="模板下载" OnClick="imgbtnUpload_Click" EnableAjaxLoading="false"></f:Button>
<%--<f:Button ID="lkAchievements" runat="server" Icon="DiskDownload" Text="导入说明" OnClick="lkAchievements_Click" EnableAjaxLoading="false"></f:Button>--%>
</Items>
<Items>
<f:Button ID="btnDownLoad" runat="server" Icon="ApplicationGo" ToolTip="下载模板" OnClick="btnDownLoad_Click">
</f:Button>
<f:HiddenField ID="hdCheckResult" runat="server">
</f:HiddenField>
</Items>
</f:Toolbar>
</Toolbars>
<Rows>
<f:FormRow>
<Items>
<f:Grid ID="Grid1" ShowBorder="true" ShowHeader="false" Title="数据导入" EnableCollapse="true"
runat="server" BoxFlex="1" DataKeyNames="TempId" AllowCellEditing="true" PageSize="15" OnPageIndexChange="Grid1_PageIndexChange"
EnableColumnLines="true" ClicksToEdit="2" DataIDField="TempId" AllowSorting="true"
SortField="RowNo" SortDirection="ASC" OnSort="Grid1_Sort" AllowPaging="true" IsDatabasePaging="true"
EnableRowDoubleClickEvent="true" OnRowDoubleClick="Grid1_RowDoubleClick" EnableTextSelection="True">
<f:FileUpload runat="server" ID="fuAttachUrl" EmptyText="选择要导入的文件" Label="选择要导入的文件"
LabelWidth="150px">
</f:FileUpload>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:Grid ID="gvErrorInfo" ShowBorder="true" EnableAjax="false" ShowHeader="false" Title="培训记录" EnableCollapse="true"
runat="server" BoxFlex="1" AllowCellEditing="true" ClicksToEdit="2" AllowSorting="true"
SortDirection="DESC" EnableColumnLines="true" ForceFit="true" AllowPaging="true" IsDatabasePaging="true" PageSize="10"
EnableRowDoubleClickEvent="true" AllowFilters="true" EnableTextSelection="True">
<Columns>
<f:TemplateField ColumnID="tfPageIndex" Width="55px" HeaderText="序号" HeaderTextAlign="Center" TextAlign="Center"
EnableLock="true" Locked="False">
<ItemTemplate>
<asp:Label ID="lblPageIndex" runat="server" Text='<%# Grid1.PageIndex * Grid1.PageSize + Container.DataItemIndex + 1 %>'></asp:Label>
<asp:Label ID="lblPageIndex" runat="server" Text='<%# gvErrorInfo.PageIndex * gvErrorInfo.PageSize + Container.DataItemIndex + 1 %>'></asp:Label>
</ItemTemplate>
</f:TemplateField>
<f:RenderField Width="70px" HeaderText="行号" ColumnID="RowNo" DataField="RowNo" SortField="RowNo"
FieldType="String" HeaderTextAlign="Center" TextAlign="Center">
</f:RenderField>
<f:RenderField ColumnID="Value1" DataField="Value1" FieldType="String" HeaderText="培训内容" TextAlign="Center"
HeaderTextAlign="Center" Width="130px">
</f:RenderField>
<f:RenderField ColumnID="Value2" DataField="Value2" FieldType="String" HeaderText="专业" TextAlign="Center"
HeaderTextAlign="Center" Width="130px">
</f:RenderField>
<f:RenderField ColumnID="Value3" DataField="Value3" FieldType="String" HeaderText="培训对象" TextAlign="Center"
HeaderTextAlign="Center" Width="130px">
</f:RenderField>
<f:RenderField ColumnID="Value4" DataField="Value4" FieldType="String" HeaderText="培训地点" TextAlign="Center"
HeaderTextAlign="Center" Width="130px">
</f:RenderField>
<f:RenderField ColumnID="Value5" DataField="Value5" FieldType="String" HeaderText="课时(小时)" TextAlign="Center"
HeaderTextAlign="Center" Width="130px">
</f:RenderField>
<f:RenderField ColumnID="Value6" DataField="Value6" FieldType="String" HeaderText="主讲人" TextAlign="Center"
HeaderTextAlign="Center" Width="110px">
</f:RenderField>
<f:RenderField ColumnID="Value7" DataField="Value7" FieldType="String" HeaderText="备注" TextAlign="Center"
HeaderTextAlign="Center" Width="110px">
</f:RenderField>
<f:BoundField DataField="Row" HeaderText="错误行号">
</f:BoundField>
<f:BoundField DataField="Column" HeaderText="错误列">
</f:BoundField>
<f:BoundField DataField="Reason" HeaderText="错误类型">
</f:BoundField>
</Columns>
<Listeners>
<f:Listener Event="beforerowcontextmenu" Handler="onRowContextMenu" />
</Listeners>
<PageItems>
<f:ToolbarSeparator ID="ToolbarSeparator1" runat="server">
</f:ToolbarSeparator>
<f:ToolbarText ID="ToolbarText1" runat="server" Text="每页记录数:">
</f:ToolbarText>
<f:DropDownList runat="server" ID="ddlPageSize" Width="80px" AutoPostBack="true"
OnSelectedIndexChanged="ddlPageSize_SelectedIndexChanged">
<f:ListItem Text="10" Value="10" />
<f:ListItem Text="15" Value="15" Selected="true" />
<f:ListItem Text="20" Value="20" />
<f:ListItem Text="25" Value="25" />
</f:DropDownList>
<f:Label Label="错误记录数" runat="server" ID="lbDataCout" CssClass="Label" LabelAlign="right" LabelWidth="120px"></f:Label>
</PageItems>
</f:Grid>
</Items>
</f:Panel>
<f:Window ID="Window1" Title="数据信息" Hidden="true" EnableIFrame="true"
EnableMaximize="true" Target="Top" EnableResize="true" runat="server"
IsModal="true" Width="1200px" Height="600px">
</f:Window>
<f:Window ID="Window2" Hidden="true" runat="server" MinHeight="30px"
Target="Parent" ShowHeader="false" BodyPadding="0" Margin="0"
IsModal="true" Width="550px" Height="32px">
<Items>
<f:ContentPanel ShowBorder="false" Height="30px" ShowHeader="false" ID="ContentPanel3" runat="server">
<div class="content" id="content">
<div class="box" id="box"></div>
</div>
</f:ContentPanel>
</Items>
</f:Window>
<f:Menu ID="Menu1" ClientIDMode="Static" runat="server">
<f:MenuButton ID="btnMenuEdit" OnClick="btnMenuEdit_Click" EnablePostBack="true"
runat="server" Text="编辑" Icon="TableEdit">
</f:MenuButton>
<f:MenuButton ID="btnMenuDelete" OnClick="btnMenuDelete_Click" EnablePostBack="true"
ConfirmText="删除选中行?" ConfirmTarget="Top" runat="server" Text="删除" Icon="Delete">
</f:MenuButton>
</f:Menu>
<asp:ScriptManager ID="ScriptManager2" runat="server" EnablePageMethods="true">
<Scripts>
<asp:ScriptReference Path="~/res/DataInTable.js" />
</Scripts>
</asp:ScriptManager>
</f:FormRow>
</Rows>
</f:Form>
</form>
<script type="text/javascript">
var menuID = '<%= Menu1.ClientID %>';
// 返回false来阻止浏览器右键菜单
function onRowContextMenu(event, rowId) {
F(menuID).show(); //showAt(event.pageX, event.pageY);
return false;
}
function reloadGrid() {
__doPostBack(null, 'reloadGrid');
}
</script>
</body>
</html>

View File

@ -1,18 +1,17 @@
using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.IO;
using System.Linq;
using System.Threading;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.CQMS.Comprehensive
{
public partial class TrainingRecordsDataIn : PageBase
{
#region
#region
/// <summary>
/// 上传预设的虚拟路径
/// </summary>
@ -21,8 +20,7 @@ namespace FineUIPro.Web.CQMS.Comprehensive
/// <summary>
/// 错误集合
/// </summary>
public static string errorInfos = string.Empty;
public static List<Model.ErrorInfo> errorInfos = new List<Model.ErrorInfo>();
#endregion
#region
@ -35,212 +33,388 @@ namespace FineUIPro.Web.CQMS.Comprehensive
{
if (!IsPostBack)
{
if (percent == null)
this.hdCheckResult.Text = string.Empty;
this.hdFileName.Text = string.Empty;
if (errorInfos != null)
{
percent = new Dictionary<string, int>();
errorInfos.Clear();
}
this.id.Text = this.CurrUser.UserId;
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
// 绑定表格
this.BindGrid();
}
else if (GetRequestEventArgument() == "reloadGrid")
{
BindGrid();
}
}
#endregion
#region
#region
/// <summary>
/// 绑定数据
/// 审核
/// </summary>
private void BindGrid()
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAudit_Click(object sender, EventArgs e)
{
string strSql = @"SELECT TempId,ProjectId,UserId,Time,RowNo,ToopValue,Value1,Value2,Value3,Value4,Value5,Value6,Value7,Value8,Value9,Value10"
+ @" ,Value11,Value12,Value13,Value14,Value15,Value16,Value17,Value18,Value19,Value20,Value21,Value22,Value23,Value24,Value25,Value26,Value27,Value28,Value29,Value30"
+ @" ,Value31,Value32,Value33,Value34,Value35,Value36,Value37,Value38,Value39,Value40,Value41,Value42,Value43,Value44,Value45,Value46,Value47,Value48,Value49,Value50,ToopValue,Type"
+ @" FROM Sys_DataInTemp "
+ @" WHERE ProjectId=@ProjectId AND UserId=@UserId AND Type=@Type";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
listStr.Add(new SqlParameter("@UserId", this.CurrUser.UserId));
listStr.Add(new SqlParameter("@Type", "TrainingRecords"));//培训记录
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();
try
{
if (this.fuAttachUrl.HasFile == false)
{
ShowNotify("请您选择Excel文件", MessageBoxIcon.Warning);
return;
}
string IsXls = Path.GetExtension(this.fuAttachUrl.FileName).ToString().Trim().ToLower();
if (IsXls != ".xls")
{
ShowNotify("只可以选择Excel文件", MessageBoxIcon.Warning);
return;
}
if (errorInfos != null)
{
errorInfos.Clear();
}
string rootPath = Server.MapPath("~/");
string initFullPath = rootPath + initPath;
if (!Directory.Exists(initFullPath))
{
Directory.CreateDirectory(initFullPath);
}
var dataInTempAll = from x in Funs.DB.Sys_DataInTemp
where x.ProjectId == this.CurrUser.LoginProjectId && x.UserId == this.CurrUser.UserId && x.Type == "TrainingRecords"
this.hdFileName.Text = BLL.Funs.GetNewFileName() + IsXls;
string filePath = initFullPath + this.hdFileName.Text;
this.fuAttachUrl.PostedFile.SaveAs(filePath);
ImportXlsToData(rootPath + initPath + this.hdFileName.Text);
}
catch (Exception ex)
{
ShowNotify("'" + ex.Message + "'", MessageBoxIcon.Warning);
}
}
#region Excel提取数据
/// <summary>
/// 从Excel提取数据--》Dataset
/// </summary>
/// <param name="filename">Excel文件路径名</param>
private void ImportXlsToData(string fileName)
{
try
{
string oleDBConnString = String.Empty;
oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
oleDBConnString += "Data Source=";
oleDBConnString += fileName;
oleDBConnString += ";Extended Properties=Excel 8.0;";
OleDbConnection oleDBConn = null;
OleDbDataAdapter oleAdMaster = null;
DataTable m_tableName = new DataTable();
DataSet ds = new DataSet();
oleDBConn = new OleDbConnection(oleDBConnString);
oleDBConn.Open();
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (m_tableName != null && m_tableName.Rows.Count > 0)
{
m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim();
}
string sqlMaster;
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
oleAdMaster.Fill(ds, "m_tableName");
oleAdMaster.Dispose();
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL(ds.Tables[0], 8);
hdCheckResult.Text = "1";
}
catch (Exception exc)
{
Response.Write(exc);
//return null;
// return dt;
}
finally
{
}
}
#endregion
#region Dataset的数据导入数据库
/// <summary>
/// 将Dataset的数据导入数据库
/// </summary>
/// <param name="pds">数据集</param>
/// <param name="Cols">数据集行数</param>
/// <returns></returns>
private bool AddDatasetToSQL(DataTable pds, int Cols)
{
string result = string.Empty;
int ic, ir;
ic = pds.Columns.Count;
if (ic < Cols)
{
ShowNotify("导入Excel格式错误Excel只有" + ic.ToString().Trim() + "列", MessageBoxIcon.Warning);
return false;
}
ir = pds.Rows.Count;
if (pds != null && ir > 0)
{
var oldViewInfos = from x in Funs.DB.Comprehensive_TrainingRecords
where x.ProjectId == this.CurrUser.LoginProjectId
select x;
for (int i = 0; i < Grid1.Rows.Count; i++)
{
var dataInTemp = dataInTempAll.FirstOrDefault(x => x.TempId == Grid1.Rows[i].DataKeys[0].ToString());
if (dataInTemp != null)
{
if (!string.IsNullOrEmpty(dataInTemp.ToopValue))
{
Grid1.Rows[i].RowCssClass = "red";
}
}
}
var errData = from x in dataInTempAll where x.ToopValue != null select x;
this.lbDataCout.Text = errData.Count().ToString();
}
#endregion
#region
/// <summary>
/// Grid行双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
var cns = from x in Funs.DB.Base_CNProfessional select x;
for (int i = 0; i < ir; i++)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
string row0 = pds.Rows[i][0].ToString();
if (string.IsNullOrEmpty(row0))
{
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
return;
result += (i + 2).ToString() + "," + "培训内容" + "," + "此项为必填项!" + "|";
}
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.TrainingRecordsMenuId, Const.BtnSave))
string row1 = pds.Rows[i][1].ToString();
if (string.IsNullOrEmpty(row1))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("TrainingRecordsDataInEdit.aspx?TempId={0}", Grid1.SelectedRowID, "维护 - ")));
result += (i + 2).ToString() + "," + "专业名称" + "," + "此项为必填项!" + "|";
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
var cn = cns.Where(x => x.ProfessionalName == row1.Trim()).FirstOrDefault();
if (cn == null)
{
result += (i + 2).ToString() + "," + "专业名称" + "," + "[" + row1 + "]不存在!" + "|";
}
}
string row2 = pds.Rows[i][2].ToString();
if (string.IsNullOrEmpty(row2))
{
result += (i + 2).ToString() + "," + "培训对象" + "," + "此项为必填项!" + "|";
}
string row3 = pds.Rows[i][3].ToString();
if (string.IsNullOrEmpty(row3))
{
result += (i + 2).ToString() + "," + "培训地点" + "," + "此项为必填项!" + "|";
}
string row4 = pds.Rows[i][4].ToString();
if (!string.IsNullOrEmpty(row4))
{
try
{
decimal d = Convert.ToDecimal(row4.Trim());
}
catch (Exception)
{
result += (i + 2).ToString() + "," + "课时(小时)" + "," + "[" + row4 + "]错误!" + "|";
}
}
string row7 = pds.Rows[i][7].ToString();
if (string.IsNullOrEmpty(row7))
{
result += (i + 2).ToString() + "," + "标志编号" + "," + "此项为必填项!" + "|";
}
}
if (!string.IsNullOrEmpty(result))
{
result = result.Substring(0, result.LastIndexOf("|"));
}
errorInfos.Clear();
if (!string.IsNullOrEmpty(result))
{
string results = result;
List<string> errorInfoList = results.Split('|').ToList();
foreach (var item in errorInfoList)
{
string[] errors = item.Split(',');
Model.ErrorInfo errorInfo = new Model.ErrorInfo();
errorInfo.Row = errors[0];
errorInfo.Column = errors[1];
errorInfo.Reason = errors[2];
errorInfos.Add(errorInfo);
}
if (errorInfos.Count > 0)
{
this.gvErrorInfo.DataSource = errorInfos;
this.gvErrorInfo.DataBind();
}
}
else
{
ShowNotify("审核完成,请点击导入!", MessageBoxIcon.Success);
}
}
else
{
ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
}
return true;
}
#endregion
#endregion
#region
/// <summary>
/// 导入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(hdCheckResult.Text))
{
if (errorInfos.Count <= 0)
{
string rootPath = Server.MapPath("~/");
ImportXlsToData2(rootPath + initPath + this.hdFileName.Text);
hdCheckResult.Text = string.Empty;
ShowNotify("导入成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
ShowNotify("请先将错误数据修正,再重新导入提交!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("请先审核要导入的文件!", MessageBoxIcon.Warning);
}
}
#region Excel提取数据
/// <summary>
/// 从Excel提取数据--》Dataset
/// </summary>
/// <param name="filename">Excel文件路径名</param>
private void ImportXlsToData2(string fileName)
{
try
{
string oleDBConnString = String.Empty;
oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
oleDBConnString += "Data Source=";
oleDBConnString += fileName;
oleDBConnString += ";Extended Properties=Excel 8.0;";
OleDbConnection oleDBConn = null;
OleDbDataAdapter oleAdMaster = null;
DataTable m_tableName = new DataTable();
DataSet ds = new DataSet();
oleDBConn = new OleDbConnection(oleDBConnString);
oleDBConn.Open();
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (m_tableName != null && m_tableName.Rows.Count > 0)
{
m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim();
}
string sqlMaster;
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
oleAdMaster.Fill(ds, "m_tableName");
oleAdMaster.Dispose();
oleDBConn.Close();
oleDBConn.Dispose();
AddDatasetToSQL2(ds.Tables[0], 8);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region
#region Dataset的数据导入数据库
/// <summary>
/// 导入信息编辑
/// 将Dataset的数据导入数据库
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuEdit_Click(object sender, EventArgs e)
/// <param name="pds">数据集</param>
/// <param name="Cols">数据集列数</param>
/// <returns></returns>
private bool AddDatasetToSQL2(DataTable pds, int Cols)
{
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.TrainingRecordsMenuId, BLL.Const.BtnSave))
int ic, ir;
ic = pds.Columns.Count;
if (ic < Cols)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
ShowNotify("导入Excel格式错误Excel只有" + ic.ToString().Trim() + "列", MessageBoxIcon.Warning);
}
string result = string.Empty;
ir = pds.Rows.Count;
if (pds != null && ir > 0)
{
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
return;
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("TrainingRecordsDataInEdit.aspx?TempId={0}", Grid1.SelectedRowID, "维护 - ")));
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
var oldViewInfos = from x in Funs.DB.Comprehensive_TrainingRecords
where x.ProjectId == this.CurrUser.LoginProjectId
select x;
/// <summary>
/// 删除按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
var cns = from x in Funs.DB.Base_CNProfessional select x;
for (int i = 0; i < ir; i++)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.TrainingRecordsMenuId, Const.BtnSave))
Model.Comprehensive_TrainingRecords oldViewInfo = new Model.Comprehensive_TrainingRecords();
string row1 = pds.Rows[i][1].ToString().Trim();
var cn = cns.Where(y => y.ProfessionalName == row1).FirstOrDefault();
oldViewInfo = oldViewInfos.Where(x => x.RemarkCode == pds.Rows[i][7].ToString().Trim()
).FirstOrDefault();
if (oldViewInfo == null)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
Model.Comprehensive_TrainingRecords des = new Model.Comprehensive_TrainingRecords();
des.TrainingRecordsId = SQLHelper.GetNewID(typeof(Model.Comprehensive_TrainingRecords));
des.ProjectId = this.CurrUser.LoginProjectId;
des.TrainingContents = pds.Rows[i][0].ToString().Trim();
des.CNProfessionalId = cn.CNProfessionalId;
des.TrainingObject = pds.Rows[i][2].ToString().Trim();
des.TrainingAddress = pds.Rows[i][3].ToString().Trim();
if (!string.IsNullOrEmpty(pds.Rows[i][4].ToString().Trim()))
{
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
return;
des.Hours = Convert.ToDecimal(pds.Rows[i][4].ToString().Trim());
}
des.KeynoteSpeaker = pds.Rows[i][5].ToString().Trim();
des.Remark = pds.Rows[i][6].ToString().Trim();
des.RemarkCode = pds.Rows[i][7].ToString().Trim();
BLL.TrainingRecordsService.AddTrainingRecords(des);
}
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
BLL.Sys_DataTempService.DeleteDataInTempByDataInTempID(rowID);
}
ShowNotify("删除成功!", MessageBoxIcon.Success);
this.BindGrid();
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
}
return true;
}
#endregion
#region
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
/// <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();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 删除所有数据事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAllDelete_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.TrainingRecordsMenuId, Const.BtnSave))
{
//先删除临时表中 该人员以前导入的数据
BLL.Sys_DataTempService.DeleteDataInTempByProjectIdUserId(this.CurrUser.LoginProjectId, this.CurrUser.UserId, "TrainingRecords");
this.BindGrid();
ShowNotify("删除成功!", MessageBoxIcon.Success);
this.lbDataCout.Text = string.Empty;
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#region
/// <summary>
/// 下载模板
/// 下载模板按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void imgbtnUpload_Click(object sender, EventArgs e)
protected void btnDownLoad_Click(object sender, EventArgs e)
{
this.TemplateUpload(BLL.Const.CQMS_TrainingRecordsTemplateUrl);
PageContext.RegisterStartupScript(Confirm.GetShowReference("确定下载导入模板吗?", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_OK"), PageManager1.GetCustomEventReference("Confirm_Cancel")));
}
protected void TemplateUpload(string initTemplatePath)
/// <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 + initTemplatePath;
string uploadfilepath = rootPath + Const.CQMS_TrainingRecordsTemplateUrl;
string filePath = Const.CQMS_TrainingRecordsTemplateUrl;
string fileName = Path.GetFileName(filePath);
FileInfo info = new FileInfo(uploadfilepath);
@ -253,268 +427,6 @@ namespace FineUIPro.Web.CQMS.Comprehensive
Response.TransmitFile(uploadfilepath, 0, fileSize);
Response.End();
}
/// <summary>
/// 导入说明
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
//protected void lkAchievements_Click(object sender, EventArgs e)
//{
// this.TemplateUpload(Const.CQMS_DataReceivingDocTempUrl);
//}
#endregion
#region
public static Dictionary<string, int> percent { get; set; }
public static Dictionary<string, string> url { get; set; }
[System.Web.Services.WebMethod]
public static int getPercent(string id)
{
return percent[id];
}
#endregion
#region
/// <summary>
/// 文件上传
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void imgbtnImport_Click(object sender, EventArgs e)
{
try
{
if (this.FileExcel.HasFile == false)
{
ShowNotify("请选择Excel文件!", MessageBoxIcon.Warning);
return;
}
string IsXls = Path.GetExtension(this.FileExcel.FileName).ToString().Trim().ToLower();
if (IsXls != ".xls" && IsXls != ".xlsx")
{
ShowNotify("只能选择Excel文件!", MessageBoxIcon.Warning);
return;
}
string rootPath = Server.MapPath("~/");
string initFullPath = rootPath + initPath;
if (!Directory.Exists(initFullPath))
{
Directory.CreateDirectory(initFullPath);
}
//指定上传文件名称
this.hdfileName.Text = BLL.Funs.GetNewFileName() + IsXls;
//上传文件路径
string filePath = initFullPath + this.hdfileName.Text;
//文件上传服务器
this.FileExcel.PostedFile.SaveAs(filePath);
//文件上传服务器后的名称
string fileName = rootPath + initPath + this.hdfileName.Text;
//读取Excel
DataSet ds = NPOIHelper.ExcelToDataSet(fileName, out errorInfos, true);
//验证Excel读取是否有误
if (!string.IsNullOrEmpty(errorInfos))
{
ShowNotify(errorInfos, MessageBoxIcon.Warning);
return;
}
if (ds.Tables.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
Sys_DataInTemp newDataInTemp = new Sys_DataInTemp();
newDataInTemp.TempId = SQLHelper.GetNewID(typeof(Model.Sys_DataInTemp));
newDataInTemp.ProjectId = this.CurrUser.LoginProjectId;
newDataInTemp.UserId = this.CurrUser.UserId;
newDataInTemp.Time = System.DateTime.Now;
newDataInTemp.Type = "TrainingRecords";
newDataInTemp.RowNo = i + 2;
newDataInTemp.Value1 = ds.Tables[0].Rows[i]["培训内容"].ToString().Trim();
newDataInTemp.Value2 = ds.Tables[0].Rows[i]["专业"].ToString().Trim();
newDataInTemp.Value3 = ds.Tables[0].Rows[i]["培训对象"].ToString().Trim();
newDataInTemp.Value4 = ds.Tables[0].Rows[i]["培训地点"].ToString().Trim();
newDataInTemp.Value5 = ds.Tables[0].Rows[i]["课时(小时)"].ToString().Trim();
newDataInTemp.Value6 = ds.Tables[0].Rows[i]["主讲人"].ToString().Trim();
newDataInTemp.Value7 = ds.Tables[0].Rows[i]["备注"].ToString().Trim();
BLL.Sys_DataTempService.AddDataInTemp(newDataInTemp);
}
this.BindGrid();
ShowNotify("数据已导入临时表!", MessageBoxIcon.Success);
}
else
{
ShowNotify("无数据!", MessageBoxIcon.Warning);
return;
}
}
catch (Exception ex)
{
Alert.ShowInTop("'" + ex.Message + "'", MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
/// 保存审核事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
Thread t = new Thread(new ThreadStart(() => { btnSaveMethod(this.CurrUser.LoginProjectId, this.CurrUser.UserId); }));
t.Start();
if (percent.ContainsKey(this.CurrUser.UserId))
{
percent[CurrUser.UserId] = 0;
}
else
{
percent.Add(CurrUser.UserId, 0);
}
PageContext.RegisterStartupScript("printX()");
}
protected void btnRefresh_Click(object sender, EventArgs e)
{
this.BindGrid();
}
protected void btnSaveMethod(string LoginProjectId, string UserId)
{
var cNProfessionals = from x in Funs.DB.Base_CNProfessional select x;//专业
var dataInTemp = from x in Funs.DB.Sys_DataInTemp
where x.ProjectId == LoginProjectId && x.UserId == UserId && x.Type == "TrainingRecords"
select x;
int okCount = 0;
int i = 0;
int ir = dataInTemp.Count();
string erreMessage = "";
foreach (var tempData in dataInTemp)
{
if (tempData != null)
{
i++;
percent[UserId] = (int)(100 * i / ir);
string errInfo = string.Empty;
var isExitValue = Funs.DB.Comprehensive_TrainingRecords.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.TrainingContents == tempData.Value1
&& x.CNProfessionalId == tempData.Value2);
if (isExitValue == null || this.ckUpdate.Checked)
{
Model.Comprehensive_TrainingRecords newData = new Model.Comprehensive_TrainingRecords();
if (!string.IsNullOrEmpty(tempData.Value1.Trim()))
{
newData.TrainingContents = tempData.Value1.Trim();
}
else
{
errInfo += "培训内容为必填项;";
}
if (!string.IsNullOrEmpty(tempData.Value2.Trim()))
{
var professional = cNProfessionals.FirstOrDefault(e => e.ProfessionalName == tempData.Value2.Trim());
if (professional != null)
{
newData.CNProfessionalId = professional.CNProfessionalId;
}
else
{
errInfo += "专业不存在;";
}
}
else
{
errInfo += "专业为必填项;";
}
if (!string.IsNullOrEmpty(tempData.Value3.Trim()))
{
newData.TrainingObject = tempData.Value3.Trim();
}
else
{
errInfo += "培训对象为必填项;";
}
if (!string.IsNullOrEmpty(tempData.Value4.Trim()))
{
newData.TrainingAddress = tempData.Value4.Trim();
}
else
{
errInfo += "培训地点为必填项;";
}
if (!string.IsNullOrEmpty(tempData.Value5.Trim()))
{
try
{
newData.Hours = Funs.GetNewDecimal(tempData.Value5.Trim());
}
catch (Exception)
{
errInfo += "课时(小时)格式错误;";
}
}
if (!string.IsNullOrEmpty(tempData.Value6.Trim()))
{
newData.KeynoteSpeaker = tempData.Value6.Trim();
}
if (!string.IsNullOrEmpty(tempData.Value7.Trim()))
{
newData.Remark = tempData.Value7.Trim();
}
if (string.IsNullOrEmpty(errInfo)) ////所有信息正确的话 这插入管线焊口
{
newData.ProjectId = this.CurrUser.LoginProjectId;
var data = BLL.TrainingRecordsService.GetTrainingRecordsByName(newData.TrainingContents, newData.CNProfessionalId);
if (data == null)
{
newData.TrainingRecordsId = SQLHelper.GetNewID(typeof(Model.Comprehensive_TrainingRecords));
BLL.TrainingRecordsService.AddTrainingRecords(newData);
}
else
{
newData.TrainingRecordsId = data.TrainingRecordsId;
BLL.TrainingRecordsService.UpdateTrainingRecords(newData);
}
BLL.Sys_DataTempService.DeleteDataInTempByDataInTempID(tempData.TempId);
okCount++;
}
}
else
{
errInfo = "该条记录已存在于培训记录表中。";
}
if (!string.IsNullOrEmpty(errInfo))
{
tempData.ToopValue = errInfo;
BLL.Sys_DataTempService.UpdateDataInTemp(tempData);
erreMessage += errInfo + ";";
}
}
}
}
#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) + ".xlsx");
Response.ContentType = "application/excel";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Write(GetGridTableHtml(Grid1));
Response.End();
}
#endregion
}

View File

@ -31,130 +31,85 @@ namespace FineUIPro.Web.CQMS.Comprehensive {
protected global::FineUIPro.PageManager PageManager1;
/// <summary>
/// id 控件。
/// SimpleForm1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.HiddenField id;
protected global::FineUIPro.Form SimpleForm1;
/// <summary>
/// Panel1 控件。
/// Toolbar2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Panel Panel1;
protected global::FineUIPro.Toolbar Toolbar2;
/// <summary>
/// Toolbar1 控件。
/// hdFileName 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar1;
protected global::FineUIPro.HiddenField hdFileName;
/// <summary>
/// hdfileName 控件。
/// btnAudit 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.HiddenField hdfileName;
protected global::FineUIPro.Button btnAudit;
/// <summary>
/// FileExcel 控件。
/// btnImport 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.FileUpload FileExcel;
protected global::FineUIPro.Button btnImport;
/// <summary>
/// imgbtnImport 控件。
/// btnDownLoad 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button imgbtnImport;
protected global::FineUIPro.Button btnDownLoad;
/// <summary>
/// ToolbarFill1 控件。
/// hdCheckResult 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.ToolbarFill ToolbarFill1;
protected global::FineUIPro.HiddenField hdCheckResult;
/// <summary>
/// ckUpdate 控件。
/// fuAttachUrl 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.CheckBox ckUpdate;
protected global::FineUIPro.FileUpload fuAttachUrl;
/// <summary>
/// btnSave 控件。
/// gvErrorInfo 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnSave;
/// <summary>
/// btnRefresh 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnRefresh;
/// <summary>
/// btnAllDelete 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnAllDelete;
/// <summary>
/// btnOut 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnOut;
/// <summary>
/// imgbtnUpload 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button imgbtnUpload;
/// <summary>
/// Grid1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Grid Grid1;
protected global::FineUIPro.Grid gvErrorInfo;
/// <summary>
/// lblPageIndex 控件。
@ -164,104 +119,5 @@ namespace FineUIPro.Web.CQMS.Comprehensive {
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblPageIndex;
/// <summary>
/// ToolbarSeparator1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.ToolbarSeparator ToolbarSeparator1;
/// <summary>
/// ToolbarText1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.ToolbarText ToolbarText1;
/// <summary>
/// ddlPageSize 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.DropDownList ddlPageSize;
/// <summary>
/// lbDataCout 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Label lbDataCout;
/// <summary>
/// Window1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Window Window1;
/// <summary>
/// Window2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Window Window2;
/// <summary>
/// ContentPanel3 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.ContentPanel ContentPanel3;
/// <summary>
/// Menu1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Menu Menu1;
/// <summary>
/// btnMenuEdit 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.MenuButton btnMenuEdit;
/// <summary>
/// btnMenuDelete 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.MenuButton btnMenuDelete;
/// <summary>
/// ScriptManager2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.ScriptManager ScriptManager2;
}
}

View File

@ -436,12 +436,14 @@
<Content Include="CQMS\Comprehensive\DesignChangeOrderEdit.aspx" />
<Content Include="CQMS\Comprehensive\DesignDetails.aspx" />
<Content Include="CQMS\Comprehensive\DesignDetailsApprove.aspx" />
<Content Include="CQMS\Comprehensive\DesignDetailsDataIn.aspx" />
<Content Include="CQMS\Comprehensive\DesignDetailsEdit.aspx" />
<Content Include="CQMS\Comprehensive\DesignDrawings.aspx" />
<Content Include="CQMS\Comprehensive\DesignDrawingsApprove.aspx" />
<Content Include="CQMS\Comprehensive\DesignDrawingsDataIn.aspx" />
<Content Include="CQMS\Comprehensive\DesignDrawingsEdit.aspx" />
<Content Include="CQMS\Comprehensive\GeneralPlanApproval.aspx" />
<Content Include="CQMS\Comprehensive\GeneralPlanApprovalDataIn.aspx" />
<Content Include="CQMS\Comprehensive\GeneralPlanApprovalEdit.aspx" />
<Content Include="CQMS\Comprehensive\InspectionEquipment.aspx" />
<Content Include="CQMS\Comprehensive\InspectionEquipmentApprove.aspx" />
@ -456,6 +458,7 @@
<Content Include="CQMS\Comprehensive\InspectionPersonDataIn.aspx" />
<Content Include="CQMS\Comprehensive\InspectionPersonEdit.aspx" />
<Content Include="CQMS\Comprehensive\InspectionTestPlan.aspx" />
<Content Include="CQMS\Comprehensive\InspectionTestPlanDataIn.aspx" />
<Content Include="CQMS\Comprehensive\InspectionTestPlanEdit.aspx" />
<Content Include="CQMS\Comprehensive\MajorPlanApproval.aspx" />
<Content Include="CQMS\Comprehensive\MajorPlanApprovalEdit.aspx" />
@ -471,6 +474,7 @@
<Content Include="CQMS\Comprehensive\QualityAccidentApprove.aspx" />
<Content Include="CQMS\Comprehensive\QualityAccidentEdit.aspx" />
<Content Include="CQMS\Comprehensive\ReviewDrawings.aspx" />
<Content Include="CQMS\Comprehensive\ReviewDrawingsDataIn.aspx" />
<Content Include="CQMS\Comprehensive\ReviewDrawingsEdit.aspx" />
<Content Include="CQMS\Comprehensive\SiteVisaManagement.aspx" />
<Content Include="CQMS\Comprehensive\SiteVisaManagementApprove.aspx" />
@ -7430,6 +7434,13 @@
<Compile Include="CQMS\Comprehensive\DesignDetailsApprove.aspx.designer.cs">
<DependentUpon>DesignDetailsApprove.aspx</DependentUpon>
</Compile>
<Compile Include="CQMS\Comprehensive\DesignDetailsDataIn.aspx.cs">
<DependentUpon>DesignDetailsDataIn.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="CQMS\Comprehensive\DesignDetailsDataIn.aspx.designer.cs">
<DependentUpon>DesignDetailsDataIn.aspx</DependentUpon>
</Compile>
<Compile Include="CQMS\Comprehensive\DesignDetailsEdit.aspx.cs">
<DependentUpon>DesignDetailsEdit.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@ -7472,6 +7483,13 @@
<Compile Include="CQMS\Comprehensive\GeneralPlanApproval.aspx.designer.cs">
<DependentUpon>GeneralPlanApproval.aspx</DependentUpon>
</Compile>
<Compile Include="CQMS\Comprehensive\GeneralPlanApprovalDataIn.aspx.cs">
<DependentUpon>GeneralPlanApprovalDataIn.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="CQMS\Comprehensive\GeneralPlanApprovalDataIn.aspx.designer.cs">
<DependentUpon>GeneralPlanApprovalDataIn.aspx</DependentUpon>
</Compile>
<Compile Include="CQMS\Comprehensive\GeneralPlanApprovalEdit.aspx.cs">
<DependentUpon>GeneralPlanApprovalEdit.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@ -7570,6 +7588,13 @@
<Compile Include="CQMS\Comprehensive\InspectionTestPlan.aspx.designer.cs">
<DependentUpon>InspectionTestPlan.aspx</DependentUpon>
</Compile>
<Compile Include="CQMS\Comprehensive\InspectionTestPlanDataIn.aspx.cs">
<DependentUpon>InspectionTestPlanDataIn.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="CQMS\Comprehensive\InspectionTestPlanDataIn.aspx.designer.cs">
<DependentUpon>InspectionTestPlanDataIn.aspx</DependentUpon>
</Compile>
<Compile Include="CQMS\Comprehensive\InspectionTestPlanEdit.aspx.cs">
<DependentUpon>InspectionTestPlanEdit.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@ -7675,6 +7700,13 @@
<Compile Include="CQMS\Comprehensive\ReviewDrawings.aspx.designer.cs">
<DependentUpon>ReviewDrawings.aspx</DependentUpon>
</Compile>
<Compile Include="CQMS\Comprehensive\ReviewDrawingsDataIn.aspx.cs">
<DependentUpon>ReviewDrawingsDataIn.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="CQMS\Comprehensive\ReviewDrawingsDataIn.aspx.designer.cs">
<DependentUpon>ReviewDrawingsDataIn.aspx</DependentUpon>
</Compile>
<Compile Include="CQMS\Comprehensive\ReviewDrawingsEdit.aspx.cs">
<DependentUpon>ReviewDrawingsEdit.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
<UseIISExpress>true</UseIISExpress>
<Use64BitIISExpress>false</Use64BitIISExpress>
<IISExpressSSLPort />

View File

@ -12,7 +12,7 @@
<appSettings>
<!--连接字符串-->
<!--<add key="ConnectionString" value="Server=.;Database=SGGLDB_WH;Integrated Security=False;User ID=sa;Password=1111;MultipleActiveResultSets=true;Connect Timeout=1200"/>-->
<add key="ConnectionString" value="Server=.;Database=SGGLDB_WH;Integrated Security=False;User ID=sa;Password=1111;MultipleActiveResultSets=true;Connect Timeout=1200"/>
<add key="ConnectionString" value="Server=.\SQL2012;Database=SGGLDB_WH;Integrated Security=False;User ID=sa;Password=1111;MultipleActiveResultSets=true;Connect Timeout=1200"/>
<!--系统名称-->
<add key="SystemName" value="智慧施工管理信息系统V1.0"/>
<add key="ChartImageHandler" value="storage=file;timeout=20;url=~/Images/;"/>
@ -77,7 +77,7 @@
<add verb="GET" path="res.axd" type="FineUIPro.ResourceHandler, FineUIPro" validate="false"/>
<add path="ChartImg.axd" verb="GET,POST,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<compilation debug="false" targetFramework="4.6.1"/>
<compilation debug="true" targetFramework="4.6.1"/>
<httpRuntime requestValidationMode="2.0" maxRequestLength="2147483647" executionTimeout="36000"/>
<authentication mode="Forms">
<forms loginUrl="Login.aspx" name="PUBLISHERCOOKIE" protection="All" timeout="1440" path="/"/>

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
<UseIISExpress>true</UseIISExpress>
<Use64BitIISExpress />
<IISExpressSSLPort />