353 lines
12 KiB
C#
353 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using BLL;
|
|
|
|
namespace FineUIPro.Web.Customization.CNCCG.HSSE.Check
|
|
{
|
|
public partial class SafetyOfficerCheck : 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.ucTree.UnitId = this.CurrUser.UnitId;
|
|
this.ucTree.ProjectId = this.ProjectId;
|
|
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
{
|
|
this.panelLeftRegion.Hidden = true;
|
|
////权限按钮方法
|
|
this.GetButtonPower();
|
|
}
|
|
|
|
this.btnNew.OnClientClick = Window1.GetShowReference("SafetyOfficerCheckEdit.aspx") + "return false;";
|
|
if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
|
|
{
|
|
Grid1.PageSize = this.CurrUser.PageSize.Value;
|
|
}
|
|
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 公司级树加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void changeTree(object sender, EventArgs e)
|
|
{
|
|
this.ProjectId = this.ucTree.ProjectId;
|
|
this.BindGrid();
|
|
|
|
this.GetButtonPower();
|
|
if (string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
{
|
|
btnNew.Hidden = true;
|
|
}
|
|
}
|
|
|
|
#region 获取按钮权限
|
|
/// <summary>
|
|
/// 获取按钮权限
|
|
/// </summary>
|
|
/// <param name="button"></param>
|
|
/// <returns></returns>
|
|
private void GetButtonPower()
|
|
{
|
|
if (Request.Params["value"] == "0")
|
|
{
|
|
return;
|
|
}
|
|
var menuid = Const.Check_SafetyOfficerCheckMenuId;
|
|
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.UserId, menuid);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnAdd))
|
|
{
|
|
this.btnNew.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnModify))
|
|
{
|
|
this.btnMenuEdit.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnDelete))
|
|
{
|
|
this.btnMenuDelete.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 获取整改前图片(放于Img中)
|
|
/// </summary>
|
|
/// <param name="SafetyOfficerCheckId"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertImageUrlByImage(object SafetyOfficerCheckId)
|
|
{
|
|
string url = string.Empty;
|
|
string httpUrl = string.Empty;
|
|
var sysSet6 = (from x in Funs.DB.Sys_Set where x.SetName == "程序访问地址" select x).ToList().FirstOrDefault();
|
|
if (sysSet6 != null)
|
|
{
|
|
httpUrl = sysSet6.SetValue;
|
|
}
|
|
//httpUrl = "http://localhost:2372/";
|
|
if (SafetyOfficerCheckId != null)
|
|
{
|
|
var model = Funs.DB.Check_SafetyOfficerCheck.FirstOrDefault(x => x.SafetyOfficerCheckId == SafetyOfficerCheckId.ToString());
|
|
if (model != null)
|
|
{
|
|
url = BLL.UploadAttachmentService.ShowImage(httpUrl, model.ImageUrl);
|
|
}
|
|
}
|
|
return url;
|
|
}
|
|
|
|
#region 绑定数据
|
|
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
if (string.IsNullOrEmpty(this.ProjectId))
|
|
{
|
|
return;
|
|
}
|
|
string strSql = @"SELECT
|
|
CASE WHEN State='0' then '待提交' when State='1' then '待生成日常巡检' when State='2' then '已生成日常巡检' END
|
|
as StatesNr,F.State,F.CompileDate,F.SafetyOfficerCheckId,F.ImageUrl,F.HandleIdea,
|
|
CompileManUser.UserName as CompileManUser, rUser.UserName as rUser
|
|
FROM Check_SafetyOfficerCheck as F
|
|
LEFT JOIN Sys_User AS CompileManUser ON F.CompileMan =CompileManUser.UserId
|
|
LEFT JOIN Sys_User AS rUser ON F.ReceiveMan =rUser.UserId
|
|
left join Project_ProjectUser AS PUser on F.ReceiveMan=PUser.UserId
|
|
WHERE 1=1 ";
|
|
var userId = CurrUser.UserId;
|
|
if (!string.IsNullOrEmpty(ProjectId))
|
|
{
|
|
strSql += " and PUser.ProjectId='" + ProjectId + "' ";
|
|
}
|
|
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
//发送文件页面
|
|
//管理员可以看到所有
|
|
if (userId == Const.sysglyId || userId == Const.hfnbdId)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
//不是管理员只能看到自己编制的或接收人是自己的
|
|
strSql += " AND (CompileMan = @CompileMan or ReceiveMan=@ReceiveMan) ";
|
|
listStr.Add(new SqlParameter("@CompileMan", CurrUser.UserId));
|
|
listStr.Add(new SqlParameter("@ReceiveMan", CurrUser.UserId));
|
|
}
|
|
if (!string.IsNullOrEmpty(ckState.SelectedValue))
|
|
{
|
|
strSql += " AND F.State = @State";
|
|
listStr.Add(new SqlParameter("@State", ckState.SelectedValue));
|
|
}
|
|
strSql += " order by CompileDate ";
|
|
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();
|
|
}
|
|
#region 分页 排序
|
|
/// <summary>
|
|
/// 改变索引事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页下拉选择事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 右键删除事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var getV = Funs.DB.Check_SafetyOfficerCheck.FirstOrDefault(x => x.SafetyOfficerCheckId == rowID);
|
|
if (getV != null)
|
|
{
|
|
BLL.SafetyOfficerCheckService.Delete(rowID);
|
|
}
|
|
}
|
|
this.BindGrid();
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 生成日常巡检
|
|
protected void btnbtnMenuGenerate_Click(object sender, EventArgs e) {
|
|
|
|
string id = Grid1.SelectedRowID;
|
|
var model = Funs.DB.Check_SafetyOfficerCheck.FirstOrDefault(x => x.SafetyOfficerCheckId == id);
|
|
if (model!=null)
|
|
{
|
|
//判断是否有权限生成
|
|
if (model.State!="1")
|
|
{
|
|
ShowNotify("当前状态不是待生成,不允许该操作!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (model.ReceiveMan!=CurrUser.UserId)
|
|
{
|
|
ShowNotify("您不是当前接收人,无权限执行该操作!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
this.Window1.Title = "生成日常巡检";
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SafetyOfficerCheckView.aspx?SafetyOfficerCheckId={0}&type=1", id, "查看 - ")));
|
|
}
|
|
#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)
|
|
{
|
|
string id = Grid1.SelectedRowID;
|
|
var model = Funs.DB.Check_SafetyOfficerCheck.FirstOrDefault(x => x.SafetyOfficerCheckId == id);
|
|
if (model != null)
|
|
{
|
|
//判断是否有权限生成
|
|
if (model.State == "2")
|
|
{
|
|
ShowNotify("已生成日常巡检,不允许编辑操作!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
}
|
|
this.EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑数据方法
|
|
/// </summary>
|
|
private void EditData()
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
var model = Funs.DB.Check_SafetyOfficerCheck.FirstOrDefault(x => x.SafetyOfficerCheckId == id);
|
|
if (model != null)
|
|
{
|
|
var userId = CurrUser.UserId;
|
|
//待提交
|
|
if (model.State == "0" && (model.CompileMan==CurrUser.UserId || userId == Const.sysglyId || userId == Const.hfnbdId))
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SafetyOfficerCheckEdit.aspx?SafetyOfficerCheckId={0}", id, "编辑 - ")));
|
|
}
|
|
//否则是详情页
|
|
else
|
|
{
|
|
//否则是查看页面
|
|
this.Window1.Title = "详情";
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SafetyOfficerCheckView.aspx?SafetyOfficerCheckId={0}", id, "查看 - ")));
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |