387 lines
14 KiB
C#
387 lines
14 KiB
C#
using BLL;
|
|
using FineUIPro.Web.DataShow;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
|
|
namespace FineUIPro.Web.HJGL.PersonManage
|
|
{
|
|
public partial class NDTPersonRegister : PageBase
|
|
{
|
|
#region 项目主键
|
|
/// <summary>
|
|
/// 项目主键
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
|
|
{
|
|
this.ProjectId = Request.Params["projectId"];
|
|
}
|
|
this.InitDropDownList();
|
|
this.ucTree.UnitId = this.CurrUser.UnitId;
|
|
this.ucTree.ProjectId = this.ProjectId;
|
|
if (!string.IsNullOrEmpty(this.ProjectId))
|
|
{
|
|
this.panelLeftRegion.Hidden = true;
|
|
////权限按钮方法
|
|
//this.GetButtonPower();
|
|
}
|
|
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void InitDropDownList()
|
|
{
|
|
var cUnit = BLL.UnitService.GetUnitByProjectIdUnitTypeList(this.ProjectId, BLL.Const.ProjectUnitType_5);
|
|
if (cUnit != null)
|
|
{
|
|
this.dpUnit.DataTextField = "UnitName";
|
|
this.dpUnit.DataValueField = "UnitId";
|
|
this.dpUnit.DataSource = cUnit;
|
|
this.dpUnit.DataBind();
|
|
Funs.FineUIPleaseSelect(dpUnit);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 公司级树加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void changeTree(object sender, EventArgs e)
|
|
{
|
|
this.ProjectId = this.ucTree.ProjectId;
|
|
this.InitDropDownList();
|
|
if (string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
{
|
|
btnNew.Hidden = true;
|
|
}
|
|
//this.GetButtonPower();
|
|
this.BindGrid();
|
|
}
|
|
|
|
|
|
#region 绑定数据
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
if (string.IsNullOrEmpty(this.ProjectId))
|
|
{
|
|
return;
|
|
}
|
|
string strSql = @"SELECT welder.WED_ID,
|
|
welder.WED_Code,
|
|
welder.WED_Name,
|
|
welder.WorkCode,
|
|
welder.EquipmentID,
|
|
welder.QueClass,
|
|
welder.WLimitDate,
|
|
welder.ProjectId,
|
|
welder.WederType,
|
|
welder.UnitName"
|
|
+ @" FROM View_PersonManageList AS welder"
|
|
+ @" WHERE welder.WederType ='2' AND welder.ProjectId=@projectId";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@projectId", this.ProjectId));
|
|
if (this.dpUnit.SelectedValue != BLL.Const._Null)
|
|
{
|
|
strSql += " AND welder.WED_Unit=@WED_Unit ";
|
|
listStr.Add(new SqlParameter("@WED_Unit", this.dpUnit.SelectedValue));
|
|
}
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
//tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
/// <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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 增加按钮事件
|
|
/// <summary>
|
|
/// 增加按钮事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
if (GetButtonPower(Const.BtnAdd))
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("NDTPersonRegisterEdit.aspx", "新增 - ")));
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 编辑
|
|
/// <summary>
|
|
/// 双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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 (GetButtonPower(Const.BtnModify))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("NDTPersonRegisterEdit.aspx?welderId={0}", Grid1.SelectedRowID, "编辑 - ")));
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 右键删除事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (GetButtonPower(Const.BtnDelete))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
string strShowNotify = string.Empty;
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var welder = BLL.WelderService.GetWelderById(rowID);
|
|
if (welder != null)
|
|
{
|
|
string cont = judgementDelete(rowID);
|
|
if (string.IsNullOrEmpty(cont))
|
|
{
|
|
BLL.WelderScoreService.DeleteWelderScoreBywed_id(rowID);
|
|
BLL.WeldMethodItemService.DeleteWeldMethodItem(rowID);
|
|
BLL.WelderItemService.DeleteItemByWenId(rowID);
|
|
BLL.PersonManageService.DeleteBSWelder(rowID);
|
|
}
|
|
else
|
|
{
|
|
strShowNotify += "无损检测人员登记" + ":" + welder.WED_Name + cont;
|
|
}
|
|
}
|
|
}
|
|
BindGrid();
|
|
if (!string.IsNullOrEmpty(strShowNotify))
|
|
{
|
|
Alert.ShowInTop(strShowNotify, MessageBoxIcon.Warning);
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
|
|
#region 判断是否可删除
|
|
/// <summary>
|
|
/// 判断是否可以删除
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private string judgementDelete(string id)
|
|
{
|
|
string content = string.Empty;
|
|
//if (Funs.DB.Pipeline_WeldJoint.FirstOrDefault(x => x.PipeAssembly1Id == id) != null)
|
|
//{
|
|
// content += "已在【焊口信息】中使用,不能删除!";
|
|
//}
|
|
|
|
return content;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 获取按钮权限
|
|
/// <summary>
|
|
/// 获取按钮权限
|
|
/// </summary>
|
|
/// <param name="button"></param>
|
|
/// <returns></returns>
|
|
private bool GetButtonPower(string button)
|
|
{
|
|
return BLL.CommonService.GetAllButtonPowerList(this.ProjectId, this.CurrUser.UserId, BLL.Const.HJGL_NDTPersonRegisterMenuId, button);
|
|
}
|
|
#endregion
|
|
|
|
|
|
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
object[] keys = Grid1.DataKeys[e.RowIndex];
|
|
string fileId = string.Empty;
|
|
if (keys == null)
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
fileId = keys[0].ToString();
|
|
}
|
|
if (e.CommandName == "attchUrl")
|
|
{
|
|
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/Solution&menuId={2}",
|
|
-1, fileId, Const.NDTPersonRegisterMenuId)));
|
|
|
|
|
|
}
|
|
}
|
|
protected void btnPrint_Click(object sender, EventArgs e)
|
|
{
|
|
// string reportId = this.tvControlItem.SelectedNode.NodeID;
|
|
// var trust = BLL.TrustManageEditService.GetCH_TrustByID(reportId);
|
|
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
|
keyValuePairs.Add("ProjectName", ProjectService.GetProjectNameByProjectId(this.ProjectId));
|
|
string strSql = @"SELECT welder.WED_ID,
|
|
welder.WED_Code,
|
|
welder.WED_Name,
|
|
welder.WorkCode,
|
|
welder.EquipmentID,
|
|
welder.QueClass,
|
|
welder.WLimitDate,
|
|
welder.ProjectId,
|
|
welder.WederType "
|
|
+ @" FROM View_PersonManageList AS welder"
|
|
+ @" WHERE welder.WederType ='2' AND welder.ProjectId=@projectId";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@projectId", this.ProjectId));
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
dt.TableName = "Table1";
|
|
BLL.Common.FastReportService.ResetData();
|
|
BLL.Common.FastReportService.AddFastreportTable(dt);
|
|
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
|
|
|
|
// Session["Table"] = dt;
|
|
// Session["CH_TrustID"] = reportId;
|
|
string initTemplatePath = "";
|
|
string rootPath = Server.MapPath("~/");
|
|
|
|
initTemplatePath = "File\\Fastreport\\无损检测人员登记表.frx";
|
|
|
|
|
|
if (File.Exists(rootPath + initTemplatePath))
|
|
{
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../TrustManage/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
|
|
|
|
|
|
}
|
|
}
|
|
|
|
protected void dpUnit_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
} |