416 lines
16 KiB
C#
416 lines
16 KiB
C#
namespace FineUIPro.Web.common.WelderManage
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Text;
|
|
using BLL;
|
|
using Newtonsoft.Json.Linq;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
|
|
public partial class WelderManage : PageBase
|
|
{
|
|
#region 加载页面
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
///所属单位
|
|
this.drpUnitS.DataTextField = "UnitName";
|
|
this.drpUnitS.DataValueField = "UnitId";
|
|
this.drpUnitS.DataSource = BLL.Base_UnitService.GetSubUnitList();
|
|
this.drpUnitS.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpUnitS);
|
|
|
|
if (Funs.SystemCode == "HJCLGL")
|
|
{
|
|
btnNew.Hidden = false;
|
|
}
|
|
else
|
|
{
|
|
|
|
btnNew.Hidden = true;
|
|
}
|
|
|
|
///班组
|
|
//this.drpEducationS.DataTextField = "EDU_Name";
|
|
//this.drpEducationS.DataValueField = "EDU_ID";
|
|
//this.drpEducationS.DataSource = BLL.HJGL_TeamGroupService.GetEducationList(this.CurrUser.LoginProjectId);
|
|
//this.drpEducationS.DataBind();
|
|
//Funs.FineUIPleaseSelect(this.drpEducationS);
|
|
|
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
// 绑定表格
|
|
BindGrid();
|
|
}
|
|
else if (GetRequestEventArgument() == "reloadGrid")
|
|
{
|
|
BindGrid();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 绑定数据
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT Welder.WED_ID,Welder.WED_Code,Welder.WED_Name,Welder.WED_Unit,
|
|
(Unit.UnitCode+'-'+Unit.UnitName) as UnitName,Welder.EDU_ID,Education.TeamGroupName,
|
|
(CASE WHEN Welder.WED_Sex = '2' THEN '女' ELSE '男' END) AS WED_Sex,
|
|
Welder.RecordDate, Welder.WED_Birthday,Welder.WED_WorkCode,Welder.WED_Class,
|
|
(CASE WHEN Welder.WED_IfOnGuard = 1 THEN '是' ELSE '否' END) AS WED_IfOnGuard,
|
|
Welder.WED_Remark,Welder.SignatureUrl
|
|
FROM HJGL_BS_Welder AS Welder
|
|
LEFT JOIN Base_Unit AS Unit ON Welder.WED_Unit = Unit.UnitId
|
|
LEFT JOIN Base_TeamGroup AS Education ON Welder.EDU_ID = Education.TeamGroupId
|
|
where 1=1";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
//listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
if (this.drpUnitS.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpUnitS.SelectedValue))
|
|
{
|
|
strSql += " AND Welder.WED_Unit = @WED_Unit";
|
|
listStr.Add(new SqlParameter("@WED_Unit", drpUnitS.SelectedValue));
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(this.txtNameS.Text.Trim()))
|
|
{
|
|
strSql += " AND Welder.WED_Name LIKE @WED_Name";
|
|
listStr.Add(new SqlParameter("@WED_Name", "%" + this.txtNameS.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtCodeS.Text.Trim()))
|
|
{
|
|
strSql += " AND Welder.WED_Code LIKE @WED_Code";
|
|
listStr.Add(new SqlParameter("@WED_Code", "%" + this.txtCodeS.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtWorkCodeS.Text.Trim()))
|
|
{
|
|
strSql += " AND Welder.WED_WorkCode LIKE @WED_WorkCode";
|
|
listStr.Add(new SqlParameter("@WED_WorkCode", "%" + this.txtWorkCodeS.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtClassS.Text.Trim()))
|
|
{
|
|
strSql += " AND Welder.WED_Class LIKE @WED_Class";
|
|
listStr.Add(new SqlParameter("@WED_Class", "%" + this.txtClassS.Text.Trim() + "%"));
|
|
}
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
// 2.获取当前分页数据
|
|
//var table = this.GetPagedDataTable(Grid1, tb1);
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
#region 双击事件
|
|
/// <summary>
|
|
/// Grid行双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PersonManageMenuId, Const.BtnAdd))
|
|
{
|
|
PageContext.RegisterStartupScript(WindowWelderSave.GetShowReference(String.Format("WelderSave.aspx?WED_ID={0}", Grid1.SelectedRowID, "维护 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 焊工
|
|
/// <summary>
|
|
/// 增加焊工
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PersonManageMenuId, Const.BtnAdd))
|
|
{
|
|
PageContext.RegisterStartupScript(WindowWelderSave.GetShowReference(String.Format("WelderSave.aspx?WED_ID={0}", String.Empty, "新增 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 焊工编辑
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
|
{
|
|
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_PersonManageMenuId, BLL.Const.BtnModify))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(WindowWelderSave.GetShowReference(String.Format("WelderSave.aspx?WED_ID={0}", Grid1.SelectedRowID, "维护 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PersonManageMenuId, Const.BtnDelete))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
bool isShow = true;
|
|
if (Grid1.SelectedRowIndexArray.Length > 1)
|
|
{
|
|
isShow = false;
|
|
}
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
if (judgementDelete(rowID, isShow))
|
|
{
|
|
BLL.HJGL_WelderQualifiedProjectService.DeleteWelderQualifiedProjectByWED_ID(rowID);
|
|
BLL.HJGL_PersonManageService.DeleteBSWelder(rowID);
|
|
BLL.Sys_LogService.AddLog(Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除焊工信息");
|
|
}
|
|
}
|
|
|
|
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
|
this.BindGrid();
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 分页 排序
|
|
/// <summary>
|
|
/// 分页
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
Grid1.PageIndex = e.NewPageIndex;
|
|
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)
|
|
{
|
|
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();
|
|
}
|
|
|
|
protected void drpUnitS_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 判断是否可删除
|
|
/// <summary>
|
|
/// 判断是否可以删除
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private bool judgementDelete(string id, bool isShow)
|
|
{
|
|
string content = string.Empty;
|
|
if (BLL.HJGL_PW_JointInfoService.GetJointInfoByCellWelder(id) > 0 || BLL.HJGL_PW_JointInfoService.GetJointInfoByFloorWelder(id) > 0 )
|
|
{
|
|
content = "焊口中已使用了该人员,不能删除!";
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(content))
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
if (isShow)
|
|
{
|
|
Alert.ShowInTop(content, MessageBoxIcon.Error);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 打印
|
|
/// <summary>
|
|
/// 打印合格焊工
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnPrint_Click(object sender, EventArgs e)
|
|
{
|
|
var project = BLL.Base_ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
|
|
if (project != null)
|
|
{
|
|
string varValue = project.ProjectName;
|
|
if (string.IsNullOrEmpty(varValue))
|
|
{
|
|
varValue = Microsoft.JScript.GlobalObject.escape(varValue.Replace("/", ","));
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", BLL.Const.HJGL_WelderRecordReportId, this.CurrUser.LoginProjectId, varValue, "打印 - ")));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 导入
|
|
/// <summary>
|
|
/// 导入
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnIn_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PersonManageMenuId, Const.BtnIn))
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WelderIn.aspx", "导入 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 弹出编辑窗口关闭事件
|
|
/// <summary>
|
|
/// 弹出编辑窗体关闭事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 导出按钮
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
Response.ClearContent();
|
|
string filename = Funs.GetNewFileName();
|
|
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("焊工信息" + filename, System.Text.Encoding.UTF8) + ".xls");
|
|
Response.ContentType = "application/excel";
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
Response.Write(GetGridTableHtml(Grid1));
|
|
Response.End();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出方法
|
|
/// </summary>
|
|
/// <param name="grid"></param>
|
|
/// <returns></returns>
|
|
private string GetGridTableHtml(Grid grid)
|
|
{
|
|
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>");
|
|
this.Grid1.PageSize = 10000;
|
|
BindGrid();
|
|
foreach (GridColumn column in grid.Columns)
|
|
{
|
|
if(column.HeaderText== "序号" || column.HeaderText == "单位" || column.HeaderText == "焊工代号" || column.HeaderText == "姓名")
|
|
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 == 0 || column.ColumnIndex == 1 || column.ColumnIndex == 2 || column.ColumnIndex == 3)
|
|
{
|
|
string html = row.Values[column.ColumnIndex].ToString();
|
|
if (column.ColumnID == "tfNumber")
|
|
{
|
|
html = (row.FindControl("lblNumber") as AspNet.Label).Text;
|
|
}
|
|
sb.AppendFormat("<td>{0}</td>", html);
|
|
}
|
|
}
|
|
|
|
sb.Append("</tr>");
|
|
}
|
|
|
|
sb.Append("</table>");
|
|
|
|
return sb.ToString();
|
|
}
|
|
#endregion
|
|
}
|
|
} |