314 lines
11 KiB
C#
314 lines
11 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using BLL;
|
|
|
|
namespace FineUIPro.Web.common.ProjectSet
|
|
{
|
|
public partial class WorkArea : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
InitTreeMenu();//加载树
|
|
}
|
|
}
|
|
|
|
#region 数据绑定
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT WorkArea.ProjectId, WorkArea.WorkAreaId,WorkArea.WorkAreaCode,WorkArea.WorkAreaName,WorkArea.UnitId,Unit.UnitName,WorkArea.SupervisorUnitId,SupervisorUnit.UnitName AS SupervisorUnitName,WorkArea.InstallationId,Installation.InstallationName,WorkArea.Def"
|
|
+ @" FROM Project_WorkArea AS WorkArea "
|
|
+ @" LEFT JOIN Project_Installation AS Installation ON WorkArea.InstallationId=Installation.InstallationId "
|
|
+ @" LEFT JOIN Base_Unit AS Unit ON WorkArea.UnitId=Unit.UnitId"
|
|
+ @" LEFT JOIN Base_Unit AS SupervisorUnit ON WorkArea.SupervisorUnitId=SupervisorUnit.UnitId WHERE WorkArea.ProjectId= @ProjectId";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", this.tvProject.SelectedNodeID));
|
|
if (!string.IsNullOrEmpty(this.txtWorkAreaCode.Text.Trim()))
|
|
{
|
|
strSql += " AND WorkArea.WorkAreaCode LIKE @WorkAreaCode";
|
|
listStr.Add(new SqlParameter("@WorkAreaCode", "%" + this.txtWorkAreaCode.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtWorkAreaName.Text.Trim()))
|
|
{
|
|
strSql += " AND WorkArea.WorkAreaName LIKE @WorkAreaName";
|
|
listStr.Add(new SqlParameter("@WorkAreaName", "%" + this.txtWorkAreaName.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>
|
|
/// 加载树
|
|
/// </summary>
|
|
private void InitTreeMenu()
|
|
{
|
|
this.tvProject.Nodes.Clear();
|
|
TreeNode rootNode = new TreeNode();
|
|
rootNode.Text = "项目";
|
|
rootNode.NodeID = "0";
|
|
rootNode.Expanded = true;
|
|
this.tvProject.Nodes.Add(rootNode);
|
|
BoundTree(rootNode.Nodes);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加项目
|
|
/// </summary>
|
|
/// <param name="nodes"></param>
|
|
/// <param name="parentId"></param>
|
|
/// <param name="type"></param>
|
|
private void BoundTree(TreeNodeCollection nodes)
|
|
{
|
|
List<Model.Base_Project> projectLists = (from x in Funs.DB.Base_Project orderby x.ProjectCode select x).ToList();
|
|
if (projectLists.Count() > 0)
|
|
{
|
|
TreeNode tn = null;
|
|
foreach (var q in projectLists)
|
|
{
|
|
tn = new TreeNode();
|
|
tn.Text = "[" + q.ProjectCode + "]" + q.ProjectName;
|
|
tn.NodeID = q.ProjectId;
|
|
tn.ToolTip = "[" + q.ProjectCode + "]" + q.ProjectName;
|
|
tn.EnableClickEvent = true;
|
|
nodes.Add(tn);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 点击TreeView
|
|
/// <summary>
|
|
/// 点击TreeView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvProject_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 分页排序
|
|
#region 页索引改变事件
|
|
/// <summary>
|
|
/// 页索引改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
Grid1.PageIndex = e.NewPageIndex;
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 排序
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, 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 ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 施工区域 维护事件
|
|
/// <summary>
|
|
/// Grid双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectWorkAreaMenuId, BLL.Const.BtnModify))
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WorkAreaEdit.aspx?projectId={0}&workAreaId={1}", tvProject.SelectedNodeID, Grid1.SelectedRowID, "编辑 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
/// <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.ProjectWorkAreaMenuId, Const.BtnAdd))
|
|
{
|
|
var project = BLL.Base_ProjectService.GetProjectByProjectId(tvProject.SelectedNodeID);
|
|
if (project != null)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WorkAreaEdit.aspx?projectId={0}", tvProject.SelectedNodeID, "新增 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("请先选择项目!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
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.ProjectWorkAreaMenuId, BLL.Const.BtnModify))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WorkAreaEdit.aspx?workAreaId={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.ProjectWorkAreaMenuId, 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.Project_WorkAreaService.DeleteWorkArea(rowID);
|
|
BLL.Sys_LogService.AddLog(Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除施工区域信息");
|
|
}
|
|
}
|
|
|
|
Alert.ShowInTop("删除成功!", MessageBoxIcon.Success);
|
|
this.BindGrid();
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 关闭弹出窗口及刷新页面
|
|
/// <summary>
|
|
/// 关闭弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(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_IsoInfoService.GetIsoInfoByBawId(id) > 0)
|
|
{
|
|
content = "管线中已经使用了该区域,不能删除!";
|
|
}
|
|
if (BLL.Base_TeamGroupService.GetTeamGroupCountByworkAreaId(id) > 0)
|
|
{
|
|
content = "班组中已经使用了该区域,不能删除!";
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(content))
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
if (isShow)
|
|
{
|
|
Alert.ShowInTop(content, MessageBoxIcon.Error);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |