20240305 开车HSE管理
This commit is contained in:
@@ -3,54 +3,92 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace FineUIPro.Web.TestRun.DriverHse
|
||||
{
|
||||
public partial class HseLicense : PageBase
|
||||
{
|
||||
#region 加载
|
||||
#region 加载页面
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
GetButtonPower();
|
||||
BindGrid();
|
||||
btnNew.OnClientClick = Window1.GetShowReference("HseLicenseEdit.aspx") + "return false;";
|
||||
BLL.UnitWorkService.InitUnitWorkDropDownList(this.drpUnitWorkId, this.CurrUser.LoginProjectId, true);
|
||||
InitTree();//加载类别树
|
||||
}
|
||||
}
|
||||
|
||||
#region 绑定资料库类别
|
||||
/// <summary>
|
||||
/// 绑定资料库树节点
|
||||
/// </summary>
|
||||
private void InitTree()
|
||||
{
|
||||
this.tvDataTypeInit.Nodes.Clear();
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = "作业类别";
|
||||
node.NodeID = "0";
|
||||
node.Expanded = true;
|
||||
this.tvDataTypeInit.Nodes.Add(node);
|
||||
var types = BLL.TestRunLicenseTypeService.GetTestRunLicenseTypeList();
|
||||
foreach (var q in types)
|
||||
{
|
||||
TreeNode newNode = new TreeNode();
|
||||
newNode.ToolTip = q.LicenseTypeName;
|
||||
newNode.Text = q.LicenseTypeName;
|
||||
newNode.NodeID = q.LicenseTypeId;
|
||||
newNode.EnableExpandEvent = true;
|
||||
newNode.EnableClickEvent = true;
|
||||
node.Nodes.Add(newNode);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region 树点击事件
|
||||
/// <summary>
|
||||
/// 资料库类别树点击事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void tvDataTypeInit_NodeCommand(object sender, TreeCommandEventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 数据绑定
|
||||
//加载列表
|
||||
/// <summary>
|
||||
/// 数据绑定
|
||||
/// </summary>
|
||||
public void BindGrid()
|
||||
{
|
||||
string strSql = @"SELECT driver.HseLicenseId,
|
||||
driver.ProjectId,
|
||||
driver.Code,
|
||||
driver.WorkArea,
|
||||
driver.WorkContents,
|
||||
driver.WorkDate,
|
||||
driver.UnitHead,
|
||||
driver.ApplyMan,
|
||||
driver.LicenseTypeId,
|
||||
driver.ApplyUnit,
|
||||
driver.WorkTicket,
|
||||
driver.WorkTicketCode,
|
||||
driver.Detection,
|
||||
driver.Guardian,
|
||||
driver.WorkEnd,
|
||||
driver.ApplyMan,
|
||||
driver.HeaderMan,
|
||||
driver.WorkAddress,
|
||||
driver.WorkContents,
|
||||
driver.Remark,
|
||||
driver.UnitWorkId,
|
||||
UnitWork.UnitWorkName"
|
||||
+ @" FROM DriverHse_HseLicense AS driver "
|
||||
+ @" LEFT JOIN WBS_UnitWork AS UnitWork ON UnitWork.UnitWorkId = driver.UnitWorkId WHERE driver.ProjectId=@projectId";
|
||||
TestRunLicenseType.LicenseTypeName"
|
||||
+ @" FROM DriverHse_HseLicense AS driver "
|
||||
+ @" LEFT JOIN Base_TestRunLicenseType AS TestRunLicenseType ON TestRunLicenseType.LicenseTypeId = driver.LicenseTypeId WHERE driver.ProjectId=@projectId";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId));
|
||||
if (!string.IsNullOrEmpty(this.drpUnitWorkId.SelectedValue) && this.drpUnitWorkId.SelectedValue != BLL.Const._Null)
|
||||
if (!string.IsNullOrEmpty(this.tvDataTypeInit.SelectedNodeID))
|
||||
{
|
||||
strSql += " AND driver.UnitWorkId=@unitWorkId";
|
||||
listStr.Add(new SqlParameter("@unitWorkId", this.drpUnitWorkId.SelectedValue));
|
||||
strSql += " AND driver.LicenseTypeId=@licenseTypeId";
|
||||
listStr.Add(new SqlParameter("@licenseTypeId", this.tvDataTypeInit.SelectedNodeID));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtCode.Text.Trim()))
|
||||
{
|
||||
strSql += " AND driver.Code like @code";
|
||||
listStr.Add(new SqlParameter("@code", "%" + this.txtCode.Text.Trim() + "%"));
|
||||
}
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
@@ -97,8 +135,12 @@ namespace FineUIPro.Web.TestRun.DriverHse
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 搜索
|
||||
//搜索按钮事件
|
||||
#region 查询
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSearch_Click(object sender, EventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
@@ -113,10 +155,96 @@ namespace FineUIPro.Web.TestRun.DriverHse
|
||||
/// <param name="e"></param>
|
||||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||||
{
|
||||
InitTree();
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 维护类别
|
||||
/// <summary>
|
||||
/// 增加类别
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnMenuAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
//string id = this.tvDataTypeInit.SelectedNodeID;
|
||||
//if (!string.IsNullOrEmpty(id))
|
||||
//{
|
||||
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("TestRunLicenseTypeEdit.aspx?type={1}", "add", "编辑 - ")));
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改类别
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnMenuModify2_Click(object sender, EventArgs e)
|
||||
{
|
||||
string id = this.tvDataTypeInit.SelectedNodeID;
|
||||
if (!string.IsNullOrEmpty(id) && id != "0")
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("TestRunLicenseTypeEdit.aspx?licenseTypeId={0}&type={1}", id, "edit", "编辑 - ")));
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop("请选择类别", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除类别
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnMenuDel2_Click(object sender, EventArgs e)
|
||||
{
|
||||
string id = this.tvDataTypeInit.SelectedNodeID;
|
||||
if (!string.IsNullOrEmpty(id) && id != "0")
|
||||
{
|
||||
Model.Base_TestRunLicenseType testRunLicenseType = BLL.TestRunLicenseTypeService.GetLicenseTypeById(id);
|
||||
if (testRunLicenseType != null)
|
||||
{
|
||||
BLL.TestRunLicenseTypeService.DeleteTestRunLicenseTypeById(id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop("请选择类别", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
InitTree();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 增加按钮
|
||||
/// <summary>
|
||||
/// 增加
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnNew_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.tvDataTypeInit.SelectedNode != null)
|
||||
{
|
||||
if (this.tvDataTypeInit.SelectedNodeID != "0")
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("HseLicenseEdit.aspx?licenseTypeId={0}", this.tvDataTypeInit.SelectedNode.NodeID, "新增 - ")));
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop("请选择类别!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop("请选择树节点!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑
|
||||
protected void btnMenuModify_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -143,11 +271,16 @@ namespace FineUIPro.Web.TestRun.DriverHse
|
||||
Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("HseLicenseEdit.aspx?id={0}", Grid1.SelectedRowID, "编辑 - ")));
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("HseLicenseEdit.aspx?hseLicenseId={0}", Grid1.SelectedRowID, "编辑 - ")));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除
|
||||
/// <summary>
|
||||
/// 右键删除
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnMenuDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length > 0)
|
||||
@@ -155,8 +288,8 @@ namespace FineUIPro.Web.TestRun.DriverHse
|
||||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||||
{
|
||||
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
||||
var info = BLL.HseLicenseService.GetHseLicenseById(rowID);
|
||||
if (info != null)
|
||||
var hseLicense = BLL.HseLicenseService.GetHseLicenseById(rowID);
|
||||
if (hseLicense != null)
|
||||
{
|
||||
BLL.HseLicenseService.DeleteHseLicenseById(rowID);
|
||||
}
|
||||
@@ -173,14 +306,14 @@ namespace FineUIPro.Web.TestRun.DriverHse
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
//protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
||||
//{
|
||||
//string id = Grid1.DataKeys[e.RowIndex][0].ToString();
|
||||
//if (e.CommandName == "AttachUrl")
|
||||
//{
|
||||
// PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/TestRun/DriverHse/HseLicense&menuId={1}", id, BLL.Const.HseLicenseMenuId)));
|
||||
//}
|
||||
//}
|
||||
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
||||
{
|
||||
string id = Grid1.DataKeys[e.RowIndex][0].ToString();
|
||||
if (e.CommandName == "AttachUrl")
|
||||
{
|
||||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/TestRun/DriverHse/HseLicense&menuId={1}", id, BLL.Const.HseLicenseMenuId)));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 权限设置
|
||||
@@ -194,19 +327,80 @@ namespace FineUIPro.Web.TestRun.DriverHse
|
||||
{
|
||||
if (buttonList.Contains(BLL.Const.BtnAdd))
|
||||
{
|
||||
this.btnDownLoad.Hidden = false;
|
||||
this.btnNew.Hidden = false;
|
||||
this.btnMenuAdd.Hidden = false;
|
||||
}
|
||||
if (buttonList.Contains(BLL.Const.BtnModify))
|
||||
{
|
||||
this.btnDownLoad.Hidden = false;
|
||||
this.btnMenuModify.Hidden = false;
|
||||
this.btnMenuModify2.Hidden = false;
|
||||
this.Grid1.EnableRowDoubleClickEvent = true;
|
||||
}
|
||||
if (buttonList.Contains(BLL.Const.BtnDelete))
|
||||
{
|
||||
this.btnMenuDel.Hidden = false;
|
||||
this.btnMenuDel2.Hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 下载模板
|
||||
protected void btnDownLoad_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.tvDataTypeInit.SelectedNode != null)
|
||||
{
|
||||
if (this.tvDataTypeInit.SelectedNodeID != "0")
|
||||
{
|
||||
Model.AttachFile attachFile = BLL.AttachFileService.GetAttachFile(this.tvDataTypeInit.SelectedNodeID, BLL.Const.HseLicenseMenuId);
|
||||
if (attachFile != null)
|
||||
{
|
||||
PageContext.RegisterStartupScript(Confirm.GetShowReference("是否确认下载作业类别模板?", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_OK"), PageManager1.GetCustomEventReference("Confirm_Cancel")));
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop("模板不存在,请先上传模板!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop("请选择类别!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop("请选择树节点!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载导入模板
|
||||
/// </summary>
|
||||
protected void PageManager1_CustomEvent(object sender, CustomEventArgs e)
|
||||
{
|
||||
if (e.EventArgument == "Confirm_OK")
|
||||
{
|
||||
string rootPath = Server.MapPath("~/");
|
||||
string initTemplatePath = string.Empty;
|
||||
string uploadfilepath = string.Empty;
|
||||
Model.AttachFile attachFile = BLL.AttachFileService.GetAttachFile(this.tvDataTypeInit.SelectedNodeID, BLL.Const.HseLicenseMenuId);
|
||||
|
||||
initTemplatePath = attachFile.AttachUrl;
|
||||
uploadfilepath = rootPath + initTemplatePath;
|
||||
string fileName = Path.GetFileName(initTemplatePath);
|
||||
FileInfo info = new FileInfo(uploadfilepath);
|
||||
long fileSize = info.Length;
|
||||
Response.Clear();
|
||||
Response.ContentType = "application/x-zip-compressed";
|
||||
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||||
Response.AddHeader("Content-Length", fileSize.ToString());
|
||||
Response.TransmitFile(uploadfilepath, 0, fileSize);
|
||||
Response.Flush();
|
||||
Response.Close();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user