学习园地

This commit is contained in:
2026-10-13 15:32:31 +08:00
parent ec60636947
commit 29b15d4b54
28 changed files with 3926 additions and 1 deletions
+32
View File
@@ -1881,6 +1881,10 @@
<Content Include="HSSE\EduTrain\AccidentCaseItemSave.aspx" />
<Content Include="HSSE\EduTrain\AccidentCaseItemSelectCloumn.aspx" />
<Content Include="HSSE\EduTrain\AccidentCaseSave.aspx" />
<Content Include="HSSE\EduTrain\StudyZoneItemIn.aspx" />
<Content Include="HSSE\EduTrain\StudyZoneItemSave.aspx" />
<Content Include="HSSE\EduTrain\StudyZoneSave.aspx" />
<Content Include="HSSE\EduTrain\StudyZone.aspx" />
<Content Include="HSSE\EduTrain\PlanEdit.aspx" />
<Content Include="HSSE\EduTrain\SelectCompanyTrainingItemProducePlan.aspx" />
<Content Include="HSSE\EduTrain\TaskNotice.aspx" />
@@ -12883,6 +12887,34 @@
<Compile Include="HSSE\EduTrain\AccidentCaseSave.aspx.designer.cs">
<DependentUpon>AccidentCaseSave.aspx</DependentUpon>
</Compile>
<Compile Include="HSSE\EduTrain\StudyZoneItemIn.aspx.cs">
<DependentUpon>StudyZoneItemIn.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="HSSE\EduTrain\StudyZoneItemIn.aspx.designer.cs">
<DependentUpon>StudyZoneItemIn.aspx</DependentUpon>
</Compile>
<Compile Include="HSSE\EduTrain\StudyZoneItemSave.aspx.cs">
<DependentUpon>StudyZoneItemSave.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="HSSE\EduTrain\StudyZoneItemSave.aspx.designer.cs">
<DependentUpon>StudyZoneItemSave.aspx</DependentUpon>
</Compile>
<Compile Include="HSSE\EduTrain\StudyZoneSave.aspx.cs">
<DependentUpon>StudyZoneSave.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="HSSE\EduTrain\StudyZoneSave.aspx.designer.cs">
<DependentUpon>StudyZoneSave.aspx</DependentUpon>
</Compile>
<Compile Include="HSSE\EduTrain\StudyZone.aspx.cs">
<DependentUpon>StudyZone.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="HSSE\EduTrain\StudyZone.aspx.designer.cs">
<DependentUpon>StudyZone.aspx</DependentUpon>
</Compile>
<Compile Include="HSSE\EduTrain\PlanEdit.aspx.cs">
<DependentUpon>PlanEdit.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -0,0 +1,174 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StudyZone.aspx.cs"
Inherits="FineUIPro.Web.HSSE.EduTrain.StudyZone" %>
<!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>
<link href="../../res/css/common.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<f:PageManager ID="PageManager1" AutoSizePanelID="Panel1" runat="server" />
<f:Panel ID="Panel1" runat="server" ShowBorder="false" ShowHeader="false" Layout="Region">
<Items>
<f:Panel runat="server" ID="panelLeftRegion" RegionPosition="Left" RegionSplit="true"
EnableCollapse="true" Width="300" Title="学习园地" TitleToolTip="学习园地" ShowBorder="true"
ShowHeader="false" AutoScroll="true" BodyPadding="5px" IconFont="ArrowCircleLeft">
<Items>
<f:Toolbar ID="Toolbar2" Position="Top" runat="server" ToolbarAlign="Right">
<Items>
<f:Button ID="btnNew" Icon="Add" runat="server" OnClick="btnNew_Click" Hidden="true">
</f:Button>
<f:Button ID="btnEdit" Icon="Pencil" runat="server" OnClick="btnEdit_Click" Hidden="true">
</f:Button>
<f:Button ID="btnDelete" Icon="Delete" ConfirmText="确定删除当前数据?" OnClick="btnDelete_Click"
runat="server" Hidden="true">
</f:Button>
</Items>
</f:Toolbar>
<f:Tree ID="trStudyZone" EnableCollapse="true" ShowHeader="true" Title="学习园地" MinHeight="400px"
OnNodeCommand="trStudyZone_NodeCommand" AutoLeafIdentification="true" runat="server"
EnableTextSelection="True">
</f:Tree>
</Items>
</f:Panel>
<f:Panel runat="server" ID="panelCenterRegion" RegionPosition="Center" ShowBorder="true"
Layout="VBox" ShowHeader="false" BodyPadding="5px" IconFont="PlusCircle" Title="学习材料明细"
TitleToolTip="学习材料明细" AutoScroll="true">
<Items>
<f:Grid ID="Grid1" Width="850px" ShowBorder="true" ShowHeader="false" EnableCollapse="true" ForceFit="true"
runat="server" BoxFlex="1" DataKeyNames="StudyZoneItemIdNum" DataIDField="StudyZoneItemIdNum"
AllowSorting="true" SortField="StudyZoneItemCode" OnRowCommand="Grid1_RowCommand"
SortDirection="DESC" OnSort="Grid1_Sort" AllowPaging="true" IsDatabasePaging="true"
PageSize="20" OnPageIndexChange="Grid1_PageIndexChange" EnableRowDoubleClickEvent="true"
OnRowDoubleClick="Grid1_RowDoubleClick" EnableTextSelection="True" EnableColumnLines="true">
<Toolbars>
<f:Toolbar ID="Toolbar3" Position="Top" runat="server">
<Items>
<%--<f:DropDownList ID="drpWorkPost" runat="server" Label="适用岗位" AutoSelectFirstItem="true" AutoPostBack="true" EnableEdit="true" OnSelectedIndexChanged="drp_SelectedIndexChanged"
LabelAlign="Right" LabelWidth="80px" Width="300px">
</f:DropDownList>--%>
<f:TextBox ID="txtStudyZoneItemCode" runat="server" Label="编号" EmptyText="输入查询教材编号"
AutoPostBack="true" OnTextChanged="TextBox_TextChanged" Width="250px" LabelWidth="80px"
LabelAlign="Right">
</f:TextBox>
<f:TextBox ID="txtStudyZoneItemName" runat="server" Label="名称" EmptyText="输入查询教材名称"
AutoPostBack="true" OnTextChanged="TextBox_TextChanged" Width="250px" LabelWidth="80px"
LabelAlign="Right">
</f:TextBox>
<f:ToolbarFill ID="ToolbarFill1" runat="server">
</f:ToolbarFill>
<f:Button ID="btnNewDetail" ToolTip="新增" Icon="Add" runat="server" OnClick="btnNewDetail_Click"
Hidden="true">
</f:Button>
<%--<f:Button ID="btnImport" ToolTip="导入" Icon="ApplicationGet" Hidden="true" runat="server"
OnClick="btnImport_Click">
</f:Button>--%>
<f:Button ID="btnOut" OnClick="btnOut_Click" runat="server" ToolTip="导出" Icon="FolderUp"
EnableAjax="false" DisableControlBeforePostBack="false">
</f:Button>
</Items>
</f:Toolbar>
</Toolbars>
<Columns>
<%-- <f:TemplateField ColumnID="tfNumber" Width="55px" HeaderText="序号" HeaderTextAlign="Center"
TextAlign="Center">
<ItemTemplate>
<asp:Label ID="lbNumber" runat="server" Text='<%# Grid1.PageIndex * Grid1.PageSize + Container.DataItemIndex + 1 %>'></asp:Label>
</ItemTemplate>
</f:TemplateField>--%>
<f:TemplateField Width="120px" HeaderText="编号" HeaderTextAlign="Center" TextAlign="Center"
SortField="StudyZoneItemCode" ColumnID="tfStudyZoneItemCode">
<ItemTemplate>
<asp:Label ID="lbStudyZoneItemCode" runat="server" Text='<%# Bind("StudyZoneItemCode") %>'
ToolTip='<%#Bind("StudyZoneItemCode") %>'></asp:Label>
</ItemTemplate>
</f:TemplateField>
<f:TemplateField Width="200px" HeaderText="名称" HeaderTextAlign="Center" TextAlign="Left"
SortField="StudyZoneItemName" ColumnID="tfStudyZoneItemName">
<ItemTemplate>
<asp:Label ID="lbStudyZoneItemName" runat="server" Text='<%# Bind("StudyZoneItemName") %>'
ToolTip='<%#Bind("StudyZoneItemName") %>'></asp:Label>
</ItemTemplate>
</f:TemplateField>
<%--<f:RenderField ColumnID="WorkPostNames" DataField="WorkPostNames" SortField="WorkPostNames"
Width="300px" FieldType="String" HeaderText="适合岗位" HeaderTextAlign="Center" TextAlign="left">
</f:RenderField>--%>
<%-- <f:TemplateField Width="120px" HeaderText="整理人" HeaderTextAlign="Center" TextAlign="Left" ColumnID="tfCompileMan"
SortField="CompileMan">
<ItemTemplate>
<asp:Label ID="lbCompileMan" runat="server" Text='<%# Bind("CompileMan") %>' ToolTip='<%#Bind("CompileMan") %>'>
</asp:Label>
</ItemTemplate>
</f:TemplateField>--%>
<f:TemplateField Width="100px" HeaderText="整理时间" HeaderTextAlign="Center" TextAlign="Center" ColumnID="tfCompileDate"
SortField="CompileDate">
<ItemTemplate>
<asp:Label ID="lbCompileDate" runat="server" Text='<%# Bind("CompileDate","{0:yyyy-MM-dd}") %>'
ToolTip='<%#Bind("CompileDate") %>'></asp:Label>
</ItemTemplate>
</f:TemplateField>
<%--<f:LinkButtonField ColumnID="AttachUrlName" DataTextField="AttachUrlName" DataToolTipField="AttachUrlName" HeaderText="附件"
CommandName="Attach" EnableAjax="false" HeaderTextAlign="Center" Width="120px">
</f:LinkButtonField>--%>
<f:BoundField runat="server" Hidden="true" ColumnID="hdUrl" DataField="AttachUrl"></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:DropDownList>
</PageItems>
</f:Grid>
</Items>
</f:Panel>
</Items>
</f:Panel>
<f:Window ID="Window1" Title="类别" Hidden="true" EnableIFrame="true" EnableMaximize="true"
Target="Parent" EnableResize="false" runat="server" OnClose="Window1_Close" IsModal="true"
Width="700px" Height="600px">
</f:Window>
<f:Window ID="Window2" Title="详情" Hidden="true" EnableIFrame="true" EnableMaximize="true"
Target="Parent" EnableResize="false" runat="server" OnClose="Window2_Close" IsModal="true"
Width="700px" Height="600px">
</f:Window>
<f:Window ID="Window3" Title="导入信息" Hidden="true" EnableIFrame="true" EnableMaximize="true"
Target="Parent" EnableResize="false" runat="server" OnClose="Window3_Close" IsModal="false"
CloseAction="HidePostBack" Width="1200px" Height="700px">
</f:Window>
<f:Window ID="WindowAtt" Title="弹出窗体" Hidden="true" EnableIFrame="true" EnableMaximize="true"
Target="Parent" EnableResize="false" runat="server" IsModal="true" Width="700px"
Height="500px">
</f:Window>
<f:Menu ID="Menu1" runat="server">
<f:MenuButton ID="btnMenuEdit" OnClick="btnMenuEdit_Click" EnablePostBack="true"
runat="server" Text="编辑" Hidden="true" Icon="Pencil">
</f:MenuButton>
<f:MenuButton ID="btnMenuDelete" OnClick="btnMenuDelete_Click" EnablePostBack="true"
Icon="Delete" ConfirmText="删除选中行?" ConfirmTarget="Parent" runat="server" Text="删除"
Hidden="true">
</f:MenuButton>
</f:Menu>
</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>
@@ -0,0 +1,573 @@
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using AspNet = System.Web.UI.WebControls;
namespace FineUIPro.Web.HSSE.EduTrain
{
public partial class StudyZone : PageBase
{
#region 加载
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Funs.DropDownPageSize(this.ddlPageSize);
this.GetButtonPower();
//WorkPostService.InitWorkPostDropDownList(drpWorkPost, true);
InitTreeMenu();
}
}
#endregion
#region 加载树
/// <summary>
/// 初始化树
/// </summary>
private void InitTreeMenu()
{
trStudyZone.Nodes.Clear();
trStudyZone.ShowBorder = false;
trStudyZone.ShowHeader = false;
trStudyZone.EnableIcons = true;
trStudyZone.AutoScroll = true;
trStudyZone.EnableSingleClickExpand = true;
TreeNode rootNode = new TreeNode
{
Text = "学习园地",
NodeID = "0",
Expanded = true
};
this.trStudyZone.Nodes.Add(rootNode);
BoundTree(rootNode.Nodes, "0");
}
private void BoundTree(TreeNodeCollection nodes, string menuId)
{
var dt = GetNewTraining(menuId);
if (dt.Count() > 0)
{
TreeNode tn = null;
foreach (var dr in dt)
{
tn = new TreeNode
{
Text = dr.StudyZoneName,
NodeID = dr.StudyZoneId,
EnableClickEvent = true,
ToolTip = dr.StudyZoneName
};
nodes.Add(tn);
BoundTree(tn.Nodes, dr.StudyZoneId);
}
}
}
/// <summary>
/// 得到菜单方法
/// </summary>
/// <param name="parentId"></param>
/// <returns></returns>
private List<Model.Training_StudyZone> GetNewTraining(string parentId)
{
return (from x in Funs.DB.Training_StudyZone where x.SupStudyZoneId == parentId orderby x.StudyZoneCode select x).ToList(); ;
}
#endregion
#region 增加、修改、删除学习园地类别
/// <summary>
/// 增加学习园地类别
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNew_Click(object sender, EventArgs e)
{
if (this.trStudyZone.SelectedNode != null)
{
Model.Training_StudyZone training = BLL.StudyZoneService.GetStudyZoneById(this.trStudyZone.SelectedNode.NodeID);
if ((training != null && training.IsEndLever == false) || this.trStudyZone.SelectedNode.NodeID == "0") //根节点或者非末级节点,可以增加
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("StudyZoneSave.aspx?SupStudyZoneId={0}", this.trStudyZone.SelectedNode.NodeID, "编辑 - ")));
}
else
{
ShowNotify("选择的项已是末级!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("请选择树节点!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 修改学习园地类别
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnEdit_Click(object sender, EventArgs e)
{
if (this.trStudyZone.SelectedNode != null)
{
if (this.trStudyZone.SelectedNode.NodeID != "0") //非根节点可以编辑
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("StudyZoneSave.aspx?StudyZoneId={0}", this.trStudyZone.SelectedNode.NodeID, "编辑 - ")));
}
else
{
ShowNotify("根节点无法编辑!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("请选择树节点!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 删除学习园地类别
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDelete_Click(object sender, EventArgs e)
{
if (this.trStudyZone.SelectedNode != null)
{
var q = BLL.StudyZoneService.GetStudyZoneById(this.trStudyZone.SelectedNode.NodeID);
if (q != null && BLL.StudyZoneService.IsDeleteStudyZone(this.trStudyZone.SelectedNode.NodeID))
{
BLL.StudyZoneService.DeleteStudyZone(this.trStudyZone.SelectedNode.NodeID);
InitTreeMenu();
}
else
{
ShowNotify("存在下级菜单或已增加资源数据或者为内置项,不允许删除!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("请选择删除项!", MessageBoxIcon.Warning);
}
}
#endregion
#region 树点击事件
/// <summary>
/// 树点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void trStudyZone_NodeCommand(object sender, FineUIPro.TreeCommandEventArgs e)
{
BindGrid();
}
#endregion
#region 下拉触发事件
/// <summary>
/// 适用岗位下拉触发事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drp_SelectedIndexChanged(object sender, EventArgs e)
{
this.BindGrid();
}
#endregion
#region 绑定数据
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
if (this.trStudyZone.SelectedNode != null && !string.IsNullOrEmpty(this.trStudyZone.SelectedNode.NodeID))
{
//string strSql = @"SELECT item.StudyZoneItemId,(item.StudyZoneItemId+'_'+CAST(row_number() over(order by item.StudyZoneItemCode) AS nvarchar(10))) AS StudyZoneItemIdNum,"
// + @" item.StudyZoneItemId,item.StudyZoneId,item.StudyZoneItemCode,item.StudyZoneItemName,--A.AttachUrl,"
// + @" item.CompileMan, item.CompileDate,--dbo.GetFileName(A.AttachUrl) AS AttachUrlName, "
// + @" (CASE WHEN WorkPostNames IS NULL THEN '通用' ELSE WorkPostNames END) AS WorkPostNames "
// + @" FROM dbo.Training_StudyZoneItem AS item"
// //+ @" LEFT JOIN (SELECT ToKeyId ,F1 as AttachUrl"
// //+ @" FROM AttachFile CROSS APPLY (SELECT * FROM dbo.f_splitstr(AttachUrl,',')) t"
// //+ @" WHERE LEN(F1) > 0) AS A ON A.ToKeyId=item.StudyZoneItemId "
// + @" WHERE item.StudyZoneId=@StudyZoneId";
string strSql = @"SELECT item.StudyZoneItemId,(item.StudyZoneItemId+'_'+CAST(row_number() over(order by item.StudyZoneItemCode) AS nvarchar(10))) AS StudyZoneItemIdNum,"
+ @" item.StudyZoneItemId,item.StudyZoneId,item.StudyZoneItemCode,item.StudyZoneItemName,"
+ @" item.CompileMan, item.CompileDate,"
+ @" (CASE WHEN WorkPostNames IS NULL THEN '通用' ELSE WorkPostNames END) AS WorkPostNames "
+ @" FROM dbo.Training_StudyZoneItem AS item"
+ @" WHERE item.StudyZoneId=@StudyZoneId";
List<SqlParameter> listStr = new List<SqlParameter>
{
new SqlParameter("@StudyZoneId", this.trStudyZone.SelectedNode.NodeID)
};
if (!string.IsNullOrEmpty(this.txtStudyZoneItemCode.Text.Trim()))
{
strSql += " AND StudyZoneItemCode LIKE @StudyZoneItemCode";
listStr.Add(new SqlParameter("@StudyZoneItemCode", "%" + this.txtStudyZoneItemCode.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.txtStudyZoneItemName.Text.Trim()))
{
strSql += " AND StudyZoneItemName LIKE @StudyZoneItemName";
listStr.Add(new SqlParameter("@StudyZoneItemName", "%" + this.txtStudyZoneItemName.Text.Trim() + "%"));
}
//if (!string.IsNullOrEmpty(this.drpWorkPost.SelectedValue) && this.drpWorkPost.SelectedValue != Const._Null)
//{
// strSql += " AND (WorkPostIds IS NULL OR WorkPostIds LIKE @WorkPostId)";
// listStr.Add(new SqlParameter("@WorkPostId", "%" + this.drpWorkPost.SelectedValue + "%"));
//}
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();
}
}
#endregion
#region 弹出窗关闭事件
protected void Window1_Close(object sender, EventArgs e)
{
InitTreeMenu();
}
protected void Window2_Close(object sender, EventArgs e)
{
BindGrid();
}
#endregion
#region 排序、分页
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
Grid1.PageIndex = e.NewPageIndex;
BindGrid();
}
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
Grid1.SortDirection = e.SortDirection;
Grid1.SortField = e.SortField;
BindGrid();
}
#endregion
#region 查询
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
#endregion
#region 增加、修改、删除明细信息
#region 新增明细
/// <summary>
/// 新增明细
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNewDetail_Click(object sender, EventArgs e)
{
if (this.trStudyZone.SelectedNode != null)
{
if (this.trStudyZone.SelectedNode.Nodes.Count == 0)
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("StudyZoneItemSave.aspx?StudyZoneId={0}", this.trStudyZone.SelectedNode.NodeID, "编辑 - ")));
}
else
{
ShowNotify("请选择末级节点!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("请选择树节点!", MessageBoxIcon.Warning);
}
}
#endregion
#region 编辑明细
protected void btnEditDetail_Click(object sender, EventArgs e)
{
this.EditData();
}
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
this.EditData();
}
/// <summary>
/// 右键编辑事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuEdit_Click(object sender, EventArgs e)
{
this.EditData();
}
/// <summary>
/// 编辑数据方法
/// </summary>
private void EditData()
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string companyTrainingItemId = Grid1.SelectedRowID;
companyTrainingItemId = companyTrainingItemId.Substring(0, companyTrainingItemId.IndexOf("_"));
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("StudyZoneItemSave.aspx?StudyZoneItemId={0}", companyTrainingItemId, "编辑 - ")));
}
#endregion
#region 删除明细
// 删除数据
protected void btnDeleteDetail_Click(object sender, EventArgs e)
{
this.DeleteData();
}
/// <summary>
/// 右键删除事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
this.DeleteData();
}
/// <summary>
/// 删除方法
/// </summary>
private void DeleteData()
{
if (Grid1.SelectedRowIndexArray.Length > 0)
{
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
rowID = rowID.Substring(0, rowID.IndexOf("_"));
var getD = BLL.StudyZoneItemService.GetStudyZoneItemById(rowID);
if (getD != null)
{
BLL.LogService.AddSys_Log(this.CurrUser, getD.StudyZoneItemCode, getD.StudyZoneItemId, BLL.Const.StudyZoneMenuId, BLL.Const.BtnDelete);
BLL.StudyZoneItemService.DeleteStudyZoneItemById(rowID);
}
}
BindGrid();
ShowNotify("删除数据成功!");
}
}
#endregion
#endregion
#region 按钮权限
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.StudyZoneMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
this.btnNew.Hidden = false;
//this.btnImport.Hidden = false;
this.btnNewDetail.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnModify))
{
this.btnEdit.Hidden = false;
this.btnMenuEdit.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnDelete))
{
this.btnDelete.Hidden = false;
this.btnMenuDelete.Hidden = false;
}
}
}
#endregion
#region 导入
/// <summary>
/// 导入按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("StudyZoneItemIn.aspx", "导入 - ")));
}
protected void Window3_Close(object sender, EventArgs e)
{
this.InitTreeMenu();
this.BindGrid();
}
#endregion
/// <summary>
/// 导出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOut_Click(object sender, EventArgs e)
{
Response.ClearContent();
string filename = Funs.GetNewFileName();
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("学习园地" + filename, System.Text.Encoding.UTF8) + ".xls");
Response.ContentType = "application/excel";
Response.ContentEncoding = System.Text.Encoding.UTF8;
this.Grid1.PageSize = Grid1.RecordCount;
BindGrid();
Response.Write(GetGridTableHtml(Grid1, 5));
Response.End();
}
#region 导出方法
/// <summary>
/// 导出方法
/// </summary>
/// <param name="grid"></param>
/// <returns></returns>
public static string GetGridTableHtml(Grid grid, int count)
{
StringBuilder sb = new StringBuilder();
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
sb.Append("<tr>");
foreach (GridColumn column in grid.Columns)
{
if (column.ColumnIndex < count)
{
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
}
}
sb.Append("</tr>");
foreach (GridRow row in grid.Rows)
{
sb.Append("<tr>");
foreach (GridColumn column in grid.Columns)
{
if (column.ColumnIndex < count)
{
string html = row.Values[column.ColumnIndex].ToString();
if (column.ColumnID == "tfNumber" && (row.FindControl("lbNumber") as AspNet.Label) != null)
{
html = (row.FindControl("lbNumber") as AspNet.Label).Text;
}
if (column.ColumnID == "tfStudyZoneItemCode" && (row.FindControl("lbStudyZoneItemCode") as AspNet.Label) != null)
{
html = (row.FindControl("lbStudyZoneItemCode") as AspNet.Label).Text;
}
if (column.ColumnID == "tfStudyZoneItemName" && (row.FindControl("lbStudyZoneItemName") as AspNet.Label) != null)
{
html = (row.FindControl("lbStudyZoneItemName") as AspNet.Label).Text;
}
if (column.ColumnID == "tfCompileMan" && (row.FindControl("lbCompileMan") as AspNet.Label) != null)
{
html = (row.FindControl("lbCompileMan") as AspNet.Label).Text;
}
if (column.ColumnID == "tfCompileDate" && (row.FindControl("lbCompileDate") as AspNet.Label) != null)
{
html = (row.FindControl("lbCompileDate") as AspNet.Label).Text;
}
sb.AppendFormat("<td>{0}</td>", html);
}
}
sb.Append("</tr>");
}
sb.Append("</table>");
return sb.ToString();
}
#endregion
/// <summary>
/// 行事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == "Attach")
{
string attUrl = this.Grid1.Rows[e.RowIndex].Values[this.Grid1.Columns.Count - 1].ToString();
try
{
string url = Funs.RootPath + attUrl;
FileInfo info = new FileInfo(url);
string savedName = Path.GetFileName(url);
if (!info.Exists || string.IsNullOrEmpty(savedName))
{
url = Funs.RootPath + "Images//Null.jpg";
info = new FileInfo(url);
}
if (Path.GetExtension(savedName) == ".mp4" || Path.GetExtension(savedName).ToLower() == ".mp4" || Path.GetExtension(savedName) == ".m4v")
{
string mpUrl = HttpUtility.UrlEncode(attUrl.Replace('\\', '/'));
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("~/AttachFile/player.aspx?url={0}", attUrl.Replace('\\', '/'), "播放 - "), "播放视频", 700, 560));
}
else
{
string fileName = Path.GetFileName(url);
long fileSize = info.Length;
System.Web.HttpContext.Current.Response.Clear();
//System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());
System.Web.HttpContext.Current.Response.TransmitFile(url, 0, fileSize);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
}
}
catch (Exception)
{
}
}
}
}
}
@@ -0,0 +1,287 @@
//------------------------------------------------------------------------------
// <自动生成>
// 此代码由工具生成。
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </自动生成>
//------------------------------------------------------------------------------
namespace FineUIPro.Web.HSSE.EduTrain
{
public partial class StudyZone
{
/// <summary>
/// form1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// PageManager1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.PageManager PageManager1;
/// <summary>
/// Panel1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Panel Panel1;
/// <summary>
/// panelLeftRegion 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Panel panelLeftRegion;
/// <summary>
/// Toolbar2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar2;
/// <summary>
/// btnNew 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnNew;
/// <summary>
/// btnEdit 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnEdit;
/// <summary>
/// btnDelete 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnDelete;
/// <summary>
/// trStudyZone 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Tree trStudyZone;
/// <summary>
/// panelCenterRegion 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Panel panelCenterRegion;
/// <summary>
/// Grid1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Grid Grid1;
/// <summary>
/// Toolbar3 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar3;
/// <summary>
/// txtStudyZoneItemCode 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextBox txtStudyZoneItemCode;
/// <summary>
/// txtStudyZoneItemName 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextBox txtStudyZoneItemName;
/// <summary>
/// ToolbarFill1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.ToolbarFill ToolbarFill1;
/// <summary>
/// btnNewDetail 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnNewDetail;
/// <summary>
/// btnOut 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnOut;
/// <summary>
/// lbStudyZoneItemCode 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.WebControls.Label lbStudyZoneItemCode;
/// <summary>
/// lbStudyZoneItemName 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.WebControls.Label lbStudyZoneItemName;
/// <summary>
/// lbCompileDate 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.WebControls.Label lbCompileDate;
/// <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>
/// Window1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Window Window1;
/// <summary>
/// Window2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Window Window2;
/// <summary>
/// Window3 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Window Window3;
/// <summary>
/// WindowAtt 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Window WindowAtt;
/// <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;
}
}
@@ -0,0 +1,86 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StudyZoneItemIn.aspx.cs" Inherits="FineUIPro.Web.HSSE.EduTrain.StudyZoneItemIn" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>导入学习园地资料</title>
<link href="../../res/css/common.css" rel="stylesheet" type="text/css" />
</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:Button ID="btnAudit" Icon="ApplicationEdit" runat="server" ToolTip="审核" ValidateForms="SimpleForm1"
OnClick="btnAudit_Click">
</f:Button>
<f:Button ID="btnSave" Icon="SystemSave" runat="server" ToolTip="保存" ValidateForms="SimpleForm1"
OnClick="btnSave_Click">
</f:Button>
<f:Button ID="btnDownLoad" runat="server" Icon="ApplicationGo" ToolTip="下载模板" OnClick="btnDownLoad_Click">
</f:Button>
</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="false" IsDatabasePaging="false" PageSize="10"
EnableRowDoubleClickEvent="true" AllowFilters="true" EnableTextSelection="True" Height="400">
<Columns>
<f:TemplateField ColumnID="tfPageIndex" Width="40px" 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="错误行号" Width="50px">
</f:BoundField>
<f:BoundField DataField="Column" HeaderText="错误列" Width="100px">
</f:BoundField>
<f:BoundField DataField="Reason" HeaderText="错误类型" MinWidth="220px">
</f:BoundField>
</Columns>
</f:Grid>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:HiddenField ID="hdFileName" runat="server">
</f:HiddenField>
<f:HiddenField ID="hdCheckResult" runat="server">
</f:HiddenField>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:Label ID="lblBottom" runat="server" Text="说明:1、导入模板为.xls后缀的EXCEL文件,黄色背景为必填项;
2、对于导入信息中重复记录自动过滤插入一条记录;
3、掌握程度为掌握、熟悉、了解;
4、适合岗位空时为通用,多岗位时用,隔开,多选答案时用,隔开;
5、数据导入完成,成功后自动返回,如果有不成功数据页面弹出提示框,列表显示导入成功数据。">
</f:Label>
</Items>
</f:FormRow>
</Rows>
</f:Form>
<f:Window ID="Window1" Title="导入信息" Hidden="true" EnableIFrame="true" EnableMaximize="true"
Target="Parent" EnableResize="false" runat="server" OnClose="Window1_Close" IsModal="false"
CloseAction="HidePostBack" Width="900px" Height="600px">
</f:Window>
</form>
</body>
</html>
@@ -0,0 +1,419 @@
using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.IO;
using System.Linq;
using System.Web.Util;
namespace FineUIPro.Web.HSSE.EduTrain
{
public partial class StudyZoneItemIn : PageBase
{
#region 定义变量
/// <summary>
/// 上传预设的虚拟路径
/// </summary>
private string initPath = Const.ExcelUrl;
/// <summary>
/// 导入集合
/// </summary>
public static List<Model.Training_StudyZoneItem> viewTrainingItems = new List<Model.Training_StudyZoneItem>();
/// <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.hdFileName.Text = string.Empty;
this.hdCheckResult.Text = string.Empty;
if (viewTrainingItems != null)
{
viewTrainingItems.Clear();
}
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 (viewTrainingItems != null)
{
viewTrainingItems.Clear();
}
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
{
viewTrainingItems.Clear();
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]);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 将Dataset的数据导入数据库
/// <summary>
/// 将Dataset的数据导入数据库
/// </summary>
/// <param name="pds">数据集</param>
/// <param name="Cols">数据集行数</param>
/// <returns></returns>
private bool AddDatasetToSQL(DataTable pds)
{
string result = string.Empty;
int ic, ir;
ic = pds.Columns.Count;
ir = pds.Rows.Count;
if (pds != null && ir > 0)
{
///教材库
var companyTrainingItems = from x in Funs.DB.Training_StudyZoneItem select x;
///类型
var trainings = from x in Funs.DB.Training_StudyZone select x;
///岗位
var workPosts = from x in Funs.DB.Base_WorkPost select x;
for (int i = 0; i < ir; i++)
{
Model.Training_StudyZoneItem newViewTrainingItem = new Model.Training_StudyZoneItem();
newViewTrainingItem.StudyZoneItemId = SQLHelper.GetNewID(typeof(Model.Training_StudyZoneItem));
//类型
string col1 = pds.Rows[i][0].ToString().Trim();
if (string.IsNullOrEmpty(col1))
{
errorInfos.Add(new ErrorInfo { Row = (i + 2).ToString(), Column = "教材类型", Reason = "此项为必填项!" });
}
else
{
var standard = trainings.FirstOrDefault(x => x.StudyZoneName == col1);
if (standard != null)
{
newViewTrainingItem.StudyZoneId = standard.StudyZoneId;
}
else
{
errorInfos.Add(new ErrorInfo { Row = (i + 2).ToString(), Column = "教材类别", Reason = $"不存在教材类别[{col1}]!" });
}
}
if (!string.IsNullOrWhiteSpace(newViewTrainingItem.StudyZoneId))
{
//教材编号
string col2 = pds.Rows[i][1].ToString().Trim();
//教材名称
string col3 = pds.Rows[i][2].ToString().Trim();
if (!string.IsNullOrWhiteSpace(col2))
{
var items = companyTrainingItems.FirstOrDefault(x => x.StudyZoneItemCode == col2);
if (items != null)
{
errorInfos.Add(new ErrorInfo { Row = (i + 2).ToString(), Column = "教材编号", Reason = $"[{col1}]已存在编号[{col2}]!" });
}
else
{
newViewTrainingItem.StudyZoneItemCode = col2;
}
}
else
{
errorInfos.Add(new ErrorInfo { Row = (i + 2).ToString(), Column = "教材编号", Reason = "不能为空!" });
}
if (!string.IsNullOrWhiteSpace(col3))
{
var item = companyTrainingItems.FirstOrDefault(x => x.StudyZoneItemName == col3);
if (item != null)
{
errorInfos.Add(new ErrorInfo { Row = (i + 2).ToString(), Column = "教材名称", Reason = $"[{col1}]已存在教材名称[{col3}]!" });
}
else
{
newViewTrainingItem.StudyZoneItemName = col3;
}
}
else
{
errorInfos.Add(new ErrorInfo { Row = (i + 2).ToString(), Column = "教材名称", Reason = "不能为空!" });
}
}
//适合岗位
string col4 = pds.Rows[i][3].ToString().Trim();
if (!string.IsNullOrEmpty(col4))
{
List<string> WorkPostSels = Funs.GetStrListByStr(col4, ',');
if (WorkPostSels.Count() > 0)
{
string ids = string.Empty;
foreach (var item in WorkPostSels)
{
string workItem = item.Trim();
var wp = workPosts.FirstOrDefault(x => x.WorkPostName == workItem);
if (wp != null)
{
ids += wp.WorkPostId + ",";
}
else
{
errorInfos.Add(new ErrorInfo { Row = (i + 2).ToString(), Column = "适合岗位", Reason = $"[{workItem}]不在岗位表中!" });
}
}
if (!string.IsNullOrEmpty(ids))
{
newViewTrainingItem.WorkPostNames = col4;
newViewTrainingItem.WorkPostIds = ids.Substring(0, ids.LastIndexOf(","));
}
}
}
//时长(分钟)
string col5 = pds.Rows[i][4].ToString().Trim();
if (!string.IsNullOrWhiteSpace(col5))
{
newViewTrainingItem.LearningTime = int.Parse(col5) * 60;
}
//掌握程度
string col6 = pds.Rows[i][5].ToString().Trim();
if (!string.IsNullOrWhiteSpace(col6))
{
newViewTrainingItem.Outcome = col6 == "了解" ? 2 : col6 == "熟悉" ? 1 : 0;
}
else
{
newViewTrainingItem.Outcome = 0;
}
newViewTrainingItem.CompileDate = DateTime.Now;
newViewTrainingItem.CompileMan = this.CurrUser.UserName;
///加入学习园地资料
viewTrainingItems.Add(newViewTrainingItem);
}
if (errorInfos.Any())
{
viewTrainingItems.Clear();
this.gvErrorInfo.DataSource = errorInfos;
this.gvErrorInfo.DataBind();
}
else
{
errorInfos.Clear();
if (!viewTrainingItems.Any())
{
Alert.ShowInTop("导入数据为空!", MessageBoxIcon.Warning);
}
else
{
ShowNotify("审核完成,请点击导入!", MessageBoxIcon.Success);
}
}
}
else
{
Alert.ShowInTop("导入数据为空!", MessageBoxIcon.Warning);
}
return true;
}
#endregion
#endregion
#region 保存
/// <summary>
/// 保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (!errorInfos.Any())
{
int a = viewTrainingItems.Count();
int insertCount = 0;
int updateCount = 0;
for (int i = 0; i < a; i++)
{
Model.Training_StudyZoneItem newModel = new Model.Training_StudyZoneItem
{
StudyZoneId = viewTrainingItems[i].StudyZoneId,
StudyZoneItemId = viewTrainingItems[i].StudyZoneItemId,
StudyZoneItemCode = viewTrainingItems[i].StudyZoneItemCode,
StudyZoneItemName = viewTrainingItems[i].StudyZoneItemName,
WorkPostIds = viewTrainingItems[i].WorkPostIds,
WorkPostNames = viewTrainingItems[i].WorkPostNames,
LearningTime = viewTrainingItems[i].LearningTime,
CompileDate = viewTrainingItems[i].CompileDate,
CompileMan = viewTrainingItems[i].CompileMan,
Outcome = viewTrainingItems[i].Outcome
};
BLL.StudyZoneItemService.AddStudyZoneItem(newModel);
}
string rootPath = Server.MapPath("~/");
string initFullPath = rootPath + initPath;
string filePath = initFullPath + this.hdFileName.Text;
if (filePath != string.Empty && File.Exists(filePath))
{
File.Delete(filePath);//删除上传的XLS文件
}
ShowNotify("导入完成!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
Alert.ShowInTop("请先将错误数据修正,再重新导入保存!", MessageBoxIcon.Warning);
}
}
#endregion
#region 关闭弹出窗口
/// <summary>
/// 关闭导入弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
if (Session["trainingItem"] != null)
{
viewTrainingItems = Session["trainingItem"] as List<Model.Training_StudyZoneItem>;
}
if (viewTrainingItems.Count > 0)
{
this.gvErrorInfo.Hidden = false;
this.gvErrorInfo.DataSource = viewTrainingItems;
this.gvErrorInfo.DataBind();
}
}
#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 filePath = Const.StudyZoneTemplateUrl;
string uploadfilepath = rootPath + filePath;
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
}
}
@@ -0,0 +1,143 @@
//------------------------------------------------------------------------------
// <自动生成>
// 此代码由工具生成。
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </自动生成>
//------------------------------------------------------------------------------
namespace FineUIPro.Web.HSSE.EduTrain
{
public partial class StudyZoneItemIn
{
/// <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>
/// btnAudit 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnAudit;
/// <summary>
/// btnSave 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnSave;
/// <summary>
/// btnDownLoad 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnDownLoad;
/// <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;
/// <summary>
/// hdFileName 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.HiddenField hdFileName;
/// <summary>
/// hdCheckResult 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.HiddenField hdCheckResult;
/// <summary>
/// lblBottom 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Label lblBottom;
/// <summary>
/// Window1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Window Window1;
}
}
@@ -0,0 +1,153 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StudyZoneItemSave.aspx.cs"
Inherits="FineUIPro.Web.HSSE.EduTrain.StudyZoneItemSave" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>编辑学习园地资料</title>
<link href="../../res/css/common.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<f:PageManager ID="PageManager1" AutoSizePanelID="SimpleForm1" runat="server" />
<f:Form ID="SimpleForm1" ShowBorder="false" ShowHeader="false" AutoScroll="true"
BodyPadding="10px" runat="server" RedStarPosition="BeforeText" LabelAlign="Right">
<Rows>
<f:FormRow>
<Items>
<f:TextBox ID="txtStudyZoneItemCode" runat="server" Label="编号" Required="true"
ShowRedStar="true" FocusOnPageLoad="true" MaxLength="50" LabelWidth="120px">
</f:TextBox>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:TextBox ID="txtStudyZoneItemName" runat="server" Label="名称" Required="true" LabelWidth="120px"
ShowRedStar="true" MaxLength="50" AutoPostBack="true" OnTextChanged="TextBox_TextChanged">
</f:TextBox>
</Items>
</f:FormRow>
<%--<f:FormRow>
<Items>
<f:DropDownBox runat="server" Label="适合岗位" ID="DropDownBox1" LabelWidth="120px"
DataControlID="RadioButtonList1" EnableMultiSelect="true">
<PopPanel>
<f:SimpleForm ID="SimpleForm2" BodyPadding="10px" runat="server" AutoScroll="true"
ShowBorder="True" ShowHeader="false" Hidden="true">
<Items>
<f:Label ID="Label1" runat="server" Text="请选择适合的岗位"></f:Label>
<f:CheckBoxList ID="RadioButtonList1" ColumnNumber="3" runat="server">
</f:CheckBoxList>
</Items>
</f:SimpleForm>
</PopPanel>
</f:DropDownBox>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:DropDownBox runat="server" ID="ddTestTraining" Label="考试题库" EnableMultiSelect="true" CustomData="true" LabelWidth="120px">
<PopPanel>
<f:Tree ID="treeTestTraining" ShowHeader="false" Hidden="true" runat="server" EnableCheckBox="true" CascadeCheck="true">
</f:Tree>
</PopPanel>
<Listeners>
<f:Listener Event="poppanelshow" Handler="onPopPanelShow" />
</Listeners>
</f:DropDownBox>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:NumberBox ID="txtLearningTime" Label="时长(分钟)" runat="server" DecimalPrecision="0" NoDecimal="true" NoNegative="true" LabelWidth="120px"></f:NumberBox>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:DropDownList ID="drpOutcome" Label="掌握程度" AutoSelectFirstItem="false" AutoPostBack="false" EnableSimulateTree="true" Required="true" ShowRedStar="true" runat="server" LabelWidth="120px">
</f:DropDownList>
</Items>
</f:FormRow>--%>
<f:FormRow>
<Items>
<f:TextBox ID="txtCompileMan" runat="server" Label="整理人" Readonly="true" MaxLength="50" LabelWidth="120px">
</f:TextBox>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:DatePicker runat="server" Label="整理时间" ID="txtCompileDate" LabelWidth="120px">
</f:DatePicker>
</Items>
</f:FormRow>
</Rows>
<Toolbars>
<f:Toolbar ID="Toolbar1" Position="Bottom" ToolbarAlign="Right" runat="server">
<Items>
<f:Label runat="server" ID="lbTemp">
</f:Label>
<f:Button ID="btnAttachUrl" Text="学习资料" ToolTip="学习资料上传及查看" Icon="TableCell" runat="server"
OnClick="btnUploadResources_Click" ValidateForms="SimpleForm1">
</f:Button>
<f:ToolbarFill ID="ToolbarFill1" runat="server">
</f:ToolbarFill>
<f:Button ID="btnSave" Icon="SystemSave" runat="server" ValidateForms="SimpleForm1"
OnClick="btnSave_Click" Hidden="true">
</f:Button>
<f:Button ID="btnClose" EnablePostBack="false" ToolTip="关闭" runat="server" Icon="SystemClose">
</f:Button>
<f:HiddenField ID="hdCompileMan" runat="server">
</f:HiddenField>
</Items>
</f:Toolbar>
</Toolbars>
</f:Form>
<f:Window ID="WindowAtt" Title="弹出窗体" Hidden="true" EnableIFrame="true" EnableMaximize="true"
Target="Parent" EnableResize="false" runat="server" IsModal="true" Width="700px"
Height="500px">
</f:Window>
</form>
</body>
<script>
<%-- var ddTestTraining = '<%= ddTestTraining.ClientID %>';
var treeTestTraining = '<%= treeTestTraining.ClientID %>';
function onPopPanelShow(event) {
var nodes = this.getValue();
F.noEvent(function () {
// 第二个参数true:是否递归调用子节点
F(treeTestTraining).checkNodes(nodes, true);
// 启用树控件的级联选择时,确保把树控件的选中值全部同步到下拉框
syncToDropDownBox();
});
}
// 将树控件的选中值同步到下拉框
function syncToDropDownBox() {
var values = [], texts = [];
var checkedNodes = F(treeTestTraining).getCheckedNodes(true);
$.each(checkedNodes, function (index, node) {
debugger;
values.push(node.id);
texts.push(node.text);
});
F(ddTestTraining).setValue(values, texts);
}
F.ready(function () {
F(treeTestTraining).on('nodecheck', function (event, nodeId, checked) {
// 加个延迟,等待复选框的级联选择完成
window.setTimeout(function () {
syncToDropDownBox();
});
});
});--%>
</script>
</html>
@@ -0,0 +1,286 @@
using System;
using System.Linq;
using Model;
using BLL;
using System.Collections.Generic;
using Microsoft.Office.Interop.Excel;
namespace FineUIPro.Web.HSSE.EduTrain
{
public partial class StudyZoneItemSave : PageBase
{
#region 定义变量
/// <summary>
/// 主键
/// </summary>
public string StudyZoneItemId
{
get
{
return (string)ViewState["StudyZoneItemId"];
}
set
{
ViewState["StudyZoneItemId"] = value;
}
}
/// <summary>
/// 主表主键
/// </summary>
public string StudyZoneId
{
get
{
return (string)ViewState["StudyZoneId"];
}
set
{
ViewState["StudyZoneId"] = value;
}
}
#endregion
#region 加载页面
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.GetButtonPower();
btnClose.OnClientClick = ActiveWindow.GetHideReference();
//BoundTree(treeTestTraining.Nodes, "0");
//BindEnumrableToDropDownList();
this.StudyZoneItemId = Request.QueryString["StudyZoneItemId"];
this.StudyZoneId = Request.QueryString["StudyZoneId"];
if (!string.IsNullOrEmpty(this.StudyZoneItemId))
{
var model = StudyZoneItemService.GetStudyZoneItemById(this.StudyZoneItemId);
if (model != null)
{
this.StudyZoneId = model.StudyZoneId;
txtStudyZoneItemCode.Text = model.StudyZoneItemCode;
txtStudyZoneItemName.Text = model.StudyZoneItemName;
txtCompileMan.Text = model.CompileMan;
hdCompileMan.Text = model.CompileMan;
// if (model.Outcome!=null)
// drpOutcome.SelectedValue = model.Outcome.ToString();
// if (!string.IsNullOrEmpty(model.TestTrainingIds))
// {
// ddTestTraining.Values = model.TestTrainingIds.Split(',');
// string text = "";
// var trains = Funs.DB.Training_TestTraining.ToList();
// foreach (var ids in ddTestTraining.Values)
// {
// var t = trains.FirstOrDefault(x => x.TrainingId == ids);
// if (t != null)
// {
// text += "[" + t.TrainingCode + "]" + t.TrainingName + ",";
// }
// }
// ddTestTraining.Text = text.TrimEnd(new char[] { ',' });
// }
// if (!string.IsNullOrEmpty(model.WorkPostIds))
// {
// string[] ids1 = model.WorkPostIds.Split(',');
// DropDownBox1.Values = ids1;
// }
// if (model.LearningTime.HasValue)
//{
// txtLearningTime.Text = (model.LearningTime.Value/60).ToString();
//}
if (model.CompileDate != null)
{
txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", model.CompileDate);
}
}
}
else
{
var cTraining = BLL.StudyZoneService.GetStudyZoneById(this.StudyZoneId);
if (cTraining != null)
{
txtCompileMan.Text = this.CurrUser.UserName;
hdCompileMan.Text = this.CurrUser.UserName;
//this.txtStudyZoneItemName.Text = cTraining.StudyZoneName;
this.txtStudyZoneItemCode.Text = SQLHelper.RunProcNewId("SpGetNewCode3", "Training_StudyZoneItem", "StudyZoneItemCode", cTraining.StudyZoneCode + "-");
txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
}
}
}
//private void BindEnumrableToDropDownList()
//{
// List<Model.Base_WorkPost> workPostList = BLL.WorkPostService.GetWorkPostList();
// RadioButtonList1.DataTextField = "WorkPostName";
// RadioButtonList1.DataValueField = "WorkPostId";
// RadioButtonList1.DataSource = workPostList;
// RadioButtonList1.DataBind();
// Enums.InitOutcomeDropDownList(drpOutcome, false);
//}
#endregion
//private List<Model.Training_TestTraining> GetNewTraining(string parentId)
//{
// return (from x in Funs.DB.Training_TestTraining
// where x.SupTrainingId == parentId
// orderby x.TrainingCode
// select x).ToList();
//}
//private void BoundTree(TreeNodeCollection nodes, string parentId)
//{
// var dt = GetNewTraining(parentId);
// if (dt.Count() > 0)
// {
// TreeNode tn = null;
// foreach (var dr in dt)
// {
// string name = dr.TrainingName;
// if (!string.IsNullOrEmpty(dr.TrainingCode))
// {
// name = "[" + dr.TrainingCode + "]" + dr.TrainingName;
// }
// tn = new TreeNode
// {
// Text = name,
// NodeID = dr.TrainingId,
// EnableClickEvent = true,
// ToolTip = dr.TrainingName
// };
// nodes.Add(tn);
// ///是否存在下级节点
// var sup = Funs.DB.Training_TestTraining.FirstOrDefault(x => x.SupTrainingId == tn.NodeID);
// if (sup != null)
// {
// BoundTree(tn.Nodes, tn.NodeID);
// }
// }
// }
//}
#region 保存
/// <summary>
/// 保存数据
/// </summary>
private void SaveData(bool isClose)
{
Model.Training_StudyZoneItem newModel = new Training_StudyZoneItem
{
StudyZoneItemCode = this.txtStudyZoneItemCode.Text.Trim(),
StudyZoneItemName = this.txtStudyZoneItemName.Text.Trim(),
CompileMan = hdCompileMan.Text.Trim()
};
// newModel.Outcome = int.Parse(drpOutcome.SelectedValue);
// if (!string.IsNullOrEmpty(DropDownBox1.Text))
// {
// newModel.WorkPostIds = String.Join(",", DropDownBox1.Values);
// newModel.WorkPostNames = String.Join(",", DropDownBox1.Texts);
// }
// if (ddTestTraining.Values != null && ddTestTraining.Values.Length > 0)
// {
// newModel.TestTrainingIds = string.Join(",", ddTestTraining.Values);
// }
// if (!string.IsNullOrEmpty(txtLearningTime.Text))
//{
// newModel.LearningTime = int.Parse(txtLearningTime.Text)*60;
//}
if (!string.IsNullOrEmpty(txtCompileDate.Text.Trim()))
{
newModel.CompileDate = Convert.ToDateTime(txtCompileDate.Text.Trim());
}
if (!string.IsNullOrEmpty(this.StudyZoneItemId))
{
newModel.StudyZoneItemId = this.StudyZoneItemId;
BLL.StudyZoneItemService.UpdateStudyZoneItem(newModel);
BLL.LogService.AddSys_Log(this.CurrUser, newModel.StudyZoneItemCode, newModel.StudyZoneItemId,BLL.Const.StudyZoneMenuId,BLL.Const.BtnModify);
}
else
{
newModel.StudyZoneId = this.StudyZoneId;
this.StudyZoneItemId = SQLHelper.GetNewID(typeof(Model.Training_StudyZoneItem));
newModel.StudyZoneItemId = this.StudyZoneItemId;
BLL.StudyZoneItemService.AddStudyZoneItem(newModel);
BLL.LogService.AddSys_Log(this.CurrUser, newModel.StudyZoneItemCode, newModel.StudyZoneItemId, BLL.Const.StudyZoneMenuId, BLL.Const.BtnAdd);
}
if (isClose)
{
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
}
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
SaveData(true);
}
#endregion
#region 验证教材名称是否存在
/// <summary>
/// 验证教材名称是否存在
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
var q = Funs.DB.Training_StudyZoneItem.FirstOrDefault(x => x.StudyZoneId == this.StudyZoneId && x.StudyZoneItemName == this.txtStudyZoneItemName.Text.Trim() && (x.StudyZoneItemId != this.StudyZoneItemId || (this.StudyZoneItemId == null && x.StudyZoneItemId != null)));
if (q != null)
{
ShowNotify("输入的教材名称已存在!", MessageBoxIcon.Warning);
}
}
#endregion
#region 上传附件资源
/// <summary>
/// 上传附件资源
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnUploadResources_Click(object sender, EventArgs e)
{
if (this.btnSave.Hidden)
{
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/StudyZone&menuId={1}&type=-1", StudyZoneItemId, BLL.Const.StudyZoneMenuId)));
}
else
{
if (string.IsNullOrEmpty(this.StudyZoneItemId))
{
SaveData(false);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/StudyZone&menuId={1}", StudyZoneItemId, BLL.Const.StudyZoneMenuId)));
}
}
#endregion
#region 按钮权限
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
if (Request.Params["value"] == "0")
{
return;
}
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.StudyZoneMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnSave))
{
this.btnSave.Hidden = false;
}
}
}
#endregion
}
}
@@ -0,0 +1,152 @@
//------------------------------------------------------------------------------
// <自动生成>
// 此代码由工具生成。
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </自动生成>
//------------------------------------------------------------------------------
namespace FineUIPro.Web.HSSE.EduTrain
{
public partial class StudyZoneItemSave
{
/// <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>
/// txtStudyZoneItemCode 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextBox txtStudyZoneItemCode;
/// <summary>
/// txtStudyZoneItemName 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextBox txtStudyZoneItemName;
/// <summary>
/// txtCompileMan 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextBox txtCompileMan;
/// <summary>
/// txtCompileDate 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.DatePicker txtCompileDate;
/// <summary>
/// Toolbar1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar1;
/// <summary>
/// lbTemp 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Label lbTemp;
/// <summary>
/// btnAttachUrl 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnAttachUrl;
/// <summary>
/// ToolbarFill1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.ToolbarFill ToolbarFill1;
/// <summary>
/// btnSave 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnSave;
/// <summary>
/// btnClose 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnClose;
/// <summary>
/// hdCompileMan 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.HiddenField hdCompileMan;
/// <summary>
/// WindowAtt 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Window WindowAtt;
}
}
@@ -0,0 +1,52 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StudyZoneSave.aspx.cs"
Inherits="FineUIPro.Web.HSSE.EduTrain.StudyZoneSave" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>编辑学习园地资料类别</title>
<link href="../../res/css/common.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<f:PageManager ID="PageManager1" AutoSizePanelID="SimpleForm1" runat="server" />
<f:Form ID="SimpleForm1" ShowBorder="false" ShowHeader="false" AutoScroll="true"
BodyPadding="10px" runat="server" RedStarPosition="BeforeText" LabelAlign="Right">
<Rows>
<f:FormRow>
<Items>
<f:TextBox ID="txtStudyZoneCode" runat="server" Label="编号" Required="true"
ShowRedStar="true" FocusOnPageLoad="true" MaxLength="50">
</f:TextBox>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:TextBox ID="txtStudyZoneName" runat="server" Label="名称" Required="true"
ShowRedStar="true" MaxLength="50" AutoPostBack="true" OnTextChanged="TextBox_TextChanged">
</f:TextBox>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:DropDownList ID="drpIsEndLever" Label="是否末级" AutoPostBack="false" EnableSimulateTree="true"
runat="server">
</f:DropDownList>
</Items>
</f:FormRow>
</Rows>
<Toolbars>
<f:Toolbar ID="Toolbar1" Position="Bottom" ToolbarAlign="Right" runat="server">
<Items>
<f:Button ID="btnSave" Icon="SystemSave" runat="server" ValidateForms="SimpleForm1"
OnClick="btnSave_Click" Hidden="true">
</f:Button>
<f:Button ID="btnClose" EnablePostBack="false" ToolTip="关闭" runat="server" Icon="SystemClose">
</f:Button>
</Items>
</f:Toolbar>
</Toolbars>
</f:Form>
</form>
</body>
</html>
@@ -0,0 +1,154 @@
using System;
using System.Linq;
using BLL;
namespace FineUIPro.Web.HSSE.EduTrain
{
public partial class StudyZoneSave : PageBase
{
#region 定义变量
/// <summary>
/// 主键
/// </summary>
public string StudyZoneId
{
get
{
return (string)ViewState["StudyZoneId"];
}
set
{
ViewState["StudyZoneId"] = value;
}
}
/// <summary>
/// 上级ID
/// </summary>
public string SupStudyZoneId
{
get
{
return (string)ViewState["SupStudyZoneId"];
}
set
{
ViewState["SupStudyZoneId"] = value;
}
}
#endregion
#region 加载
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.GetButtonPower();
btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.drpIsEndLever.DataTextField = "TypeName";
drpIsEndLever.DataValueField = "TypeId";
drpIsEndLever.DataSource = BLL.TrainingService.GetIsEndLeverList();
drpIsEndLever.DataBind();
this.StudyZoneId = Request.QueryString["StudyZoneId"];
this.SupStudyZoneId = Request.QueryString["SupStudyZoneId"];
if (!string.IsNullOrEmpty(StudyZoneId))
{
var q = BLL.StudyZoneService.GetStudyZoneById(StudyZoneId);
if (q != null)
{
txtStudyZoneCode.Text = q.StudyZoneCode;
txtStudyZoneName.Text = q.StudyZoneName;
if (q.IsEndLever == true)
{
this.drpIsEndLever.SelectedValue = "true";
}
else
{
this.drpIsEndLever.SelectedValue = "false";
}
}
}
}
}
#endregion
#region 保存
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
Model.Training_StudyZone model = new Model.Training_StudyZone();
model.StudyZoneCode = this.txtStudyZoneCode.Text.Trim();
model.StudyZoneName = this.txtStudyZoneName.Text.Trim();
model.IsEndLever = Convert.ToBoolean(drpIsEndLever.SelectedValue);
if (!string.IsNullOrEmpty(this.StudyZoneId))
{
Model.Training_StudyZone t = BLL.StudyZoneService.GetStudyZoneById(this.StudyZoneId);
if (t != null)
{
model.SupStudyZoneId = t.SupStudyZoneId;
}
model.StudyZoneId = this.StudyZoneId;
BLL.StudyZoneService.UpdateStudyZone(model);
}
else
{
model.SupStudyZoneId = this.SupStudyZoneId;
this.StudyZoneId = SQLHelper.GetNewID(typeof(Model.Training_StudyZone));
model.StudyZoneId = this.StudyZoneId;
BLL.StudyZoneService.AddStudyZone(model);
}
// 2. 关闭本窗体,然后刷新父窗体
// PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
// 2. 关闭本窗体,然后回发父窗体
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
//PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(trainingId) + ActiveWindow.GetHideReference());
}
#endregion
#region 验证学习园地资料名称是否存在
/// <summary>
/// 验证学习园地资料名称是否存在
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
var model = Funs.DB.Training_StudyZone.FirstOrDefault(x => x.SupStudyZoneId == this.SupStudyZoneId && x.StudyZoneName == this.txtStudyZoneName.Text.Trim() && (x.StudyZoneId != this.StudyZoneId || (this.StudyZoneId == null && x.StudyZoneId != null)));
if (model != null)
{
ShowNotify("输入的名称已存在!", MessageBoxIcon.Warning);
}
}
#endregion
#region 按钮权限
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.StudyZoneMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnSave))
{
this.btnSave.Hidden = false;
}
}
}
#endregion
}
}
@@ -0,0 +1,98 @@
//------------------------------------------------------------------------------
// <自动生成>
// 此代码由工具生成。
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </自动生成>
//------------------------------------------------------------------------------
namespace FineUIPro.Web.HSSE.EduTrain
{
public partial class StudyZoneSave
{
/// <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>
/// txtStudyZoneCode 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextBox txtStudyZoneCode;
/// <summary>
/// txtStudyZoneName 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextBox txtStudyZoneName;
/// <summary>
/// drpIsEndLever 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.DropDownList drpIsEndLever;
/// <summary>
/// Toolbar1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar1;
/// <summary>
/// btnSave 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnSave;
/// <summary>
/// btnClose 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnClose;
}
}