232 lines
8.5 KiB
C#
232 lines
8.5 KiB
C#
|
using BLL;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Data;
|
|||
|
using System.Data.SqlClient;
|
|||
|
|
|||
|
namespace FineUIPro.Web.CQMS.WBS.Control
|
|||
|
{
|
|||
|
public partial class DivisionSubProjectsNew : PageBase
|
|||
|
{
|
|||
|
#region 加载页面
|
|||
|
/// <summary>
|
|||
|
/// 加载页面
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
GetButtonPower();
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 数据绑定
|
|||
|
/// </summary>
|
|||
|
public void BindGrid()
|
|||
|
{
|
|||
|
string strSql = @"select * from(select a.DivisionId,a.ProjectId,a.ParentId,a.DivisionLevel,a.BranchEngineeringCode,a.BranchEngineeringName,a.SubBranchEngineeringName,a.ProEngineeringCode,a.ProEngineeringName,a.ProEngineeringNum,a.Remark,a.AddUser,a.OperateTime,a.Sort,a.Status from Division_SubProjects as a where isnull(a.ProjectId,'')='' ";
|
|||
|
string strSql1 = @"select a.DivisionId,a.ProjectId,a.ParentId,a.DivisionLevel,a.BranchEngineeringCode,a.BranchEngineeringName,a.SubBranchEngineeringName,a.ProEngineeringCode,a.ProEngineeringName,a.ProEngineeringNum,a.Remark,a.AddUser,a.OperateTime,a.Sort,a.Status from Division_SubProjects as a inner join Base_Project as b on a.ProjectId=b.ProjectId where a.ProjectId=@ProjectId ";
|
|||
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|||
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|||
|
SqlParameter[] parameter = listStr.ToArray();
|
|||
|
var zxsql = strSql + " union all " + strSql1 + " ) as t order by t.BranchEngineeringCode,t.Sort,t.DivisionLevel,t.ProEngineeringNum asc";
|
|||
|
DataTable tb = SQLHelper.GetDataTableRunText(zxsql, parameter);
|
|||
|
Grid1.DataSource = tb;
|
|||
|
Grid1.DataBind();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 删除
|
|||
|
/// <summary>
|
|||
|
/// 行点击 事件
|
|||
|
/// </summary>
|
|||
|
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
|||
|
{
|
|||
|
if (e.CommandName == "Delete")
|
|||
|
{
|
|||
|
string rowID = e.RowID;
|
|||
|
if (!string.IsNullOrEmpty(rowID))
|
|||
|
{
|
|||
|
BLL.SubProjectsService.DeleteSubProjectsById(rowID);
|
|||
|
BindGrid();
|
|||
|
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 删除
|
|||
|
/// </summary>
|
|||
|
protected void btnDelete_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|||
|
{
|
|||
|
Alert.ShowInTop("至少选择一条数据!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|||
|
{
|
|||
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|||
|
if (!string.IsNullOrEmpty(rowID))
|
|||
|
{
|
|||
|
BLL.SubProjectsService.DeleteSubProjectsById(rowID);
|
|||
|
}
|
|||
|
}
|
|||
|
BindGrid();
|
|||
|
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 新增
|
|||
|
/// <summary>
|
|||
|
/// 新增分部工程
|
|||
|
/// </summary>
|
|||
|
protected void btnAdd_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DivisionSubProjectsNewEdit.aspx?type=1", "新增 - ")));
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 新增分项工程
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnParentAdd_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|||
|
{
|
|||
|
Alert.ShowInTop("请选择一条数据!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
var sub = BLL.SubProjectsService.GetSubProjectsById(this.Grid1.SelectedRowID);
|
|||
|
if (sub!=null)
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(sub.ProEngineeringName))
|
|||
|
{
|
|||
|
Alert.ShowInTop("分项工程下不能新增!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DivisionSubProjectsNewEdit.aspx?ParentId={0}&&type=2", this.Grid1.SelectedRowID, "新增分项工程 - ")));
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 编辑
|
|||
|
/// <summary>
|
|||
|
/// 编辑
|
|||
|
/// </summary>
|
|||
|
protected void btnEdit_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|||
|
{
|
|||
|
Alert.ShowInTop("请选择一条数据!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
var rowId = this.Grid1.SelectedRowID;
|
|||
|
var division = BLL.SubProjectsService.GetSubProjectsById(rowId);
|
|||
|
if (division != null)
|
|||
|
{
|
|||
|
string type = string.Empty;
|
|||
|
if (!string.IsNullOrEmpty(division.SubBranchEngineeringName))
|
|||
|
{
|
|||
|
type = "1";//子分部工程
|
|||
|
}
|
|||
|
else if (!string.IsNullOrEmpty(division.ProEngineeringName))
|
|||
|
{
|
|||
|
type = "2";//分项工程
|
|||
|
}
|
|||
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DivisionSubProjectsNewEdit.aspx?DivisionId={0}&ParentId={1}&type={2}", rowId, division.ParentId, type, "新增分项工程 - ")));
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 关闭弹出窗口
|
|||
|
/// <summary>
|
|||
|
/// 关闭
|
|||
|
/// </summary>
|
|||
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|||
|
{
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 右击新增子单位工程
|
|||
|
/// <summary>
|
|||
|
/// 右击新增子单位工程
|
|||
|
/// </summary>
|
|||
|
protected void btnMenuParentAdd_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|||
|
{
|
|||
|
Alert.ShowInTop("请选择一条数据!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DivisionSubProjectsNewEdit.aspx?ParentId={0}&&type=1", this.Grid1.SelectedRowID, "新增子分部工程 - ")));
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 行选择事件
|
|||
|
/// <summary>
|
|||
|
/// 行选择事件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Grid1_RowSelect(object sender, GridRowSelectEventArgs e)
|
|||
|
{
|
|||
|
string rowid = e.RowID.ToString();
|
|||
|
if (!string.IsNullOrEmpty(rowid))
|
|||
|
{
|
|||
|
var sub = BLL.SubProjectsService.GetSubProjectsById(rowid);
|
|||
|
if (sub != null)
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(sub.ParentId))
|
|||
|
{
|
|||
|
this.btnMenuParentAdd.Hidden = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.btnMenuParentAdd.Hidden = false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 获取按钮权限
|
|||
|
/// <summary>
|
|||
|
/// 获取按钮权限
|
|||
|
/// </summary>
|
|||
|
/// <param name="button"></param>
|
|||
|
/// <returns></returns>
|
|||
|
private void GetButtonPower()
|
|||
|
{
|
|||
|
if (Request.Params["value"] == "0")
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.DivisionSubProjectsMenuId);
|
|||
|
if (buttonList.Count > 0)
|
|||
|
{
|
|||
|
if (buttonList.Contains(BLL.Const.BtnAdd))
|
|||
|
{
|
|||
|
this.btnAdd.Hidden = false;
|
|||
|
this.btnMenuParentAdd.Hidden = false;
|
|||
|
this.btnParentAdd.Hidden = false;
|
|||
|
}
|
|||
|
if (buttonList.Contains(BLL.Const.BtnModify))
|
|||
|
{
|
|||
|
this.btnEdit.Hidden = false;
|
|||
|
}
|
|||
|
if (buttonList.Contains(BLL.Const.BtnDelete))
|
|||
|
{
|
|||
|
this.btnDelete.Hidden = false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|