449 lines
18 KiB
C#
449 lines
18 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.CQMS.Foreign
|
|
{
|
|
public partial class ControlPointList : PageBase
|
|
{
|
|
#region 加载
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
GetButtonPower();
|
|
InitTreeMenu();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载树
|
|
/// <summary>
|
|
/// 加载树
|
|
/// </summary>
|
|
private void InitTreeMenu()
|
|
{
|
|
this.tvControlItem.Nodes.Clear();
|
|
this.tvControlItem.ShowBorder = false;
|
|
this.tvControlItem.ShowHeader = false;
|
|
this.tvControlItem.EnableIcons = true;
|
|
this.tvControlItem.AutoScroll = true;
|
|
this.tvControlItem.EnableSingleClickExpand = true;
|
|
|
|
var unitWorks = from x in Funs.DB.WBS_UnitWork where x.ProjectId == this.CurrUser.LoginProjectId orderby x.UnitWorkCode select x;
|
|
foreach (var item in unitWorks)
|
|
{
|
|
TreeNode rootNode1 = new TreeNode();
|
|
rootNode1.Text = item.UnitWorkName;
|
|
rootNode1.NodeID = item.UnitWorkId;
|
|
rootNode1.CommandName = "单位工程";
|
|
//rootNode1.EnableExpandEvent = true;
|
|
//rootNode1.EnableClickEvent = true;
|
|
this.tvControlItem.Nodes.Add(rootNode1);
|
|
|
|
var foreignCNProfessionals = from x in Funs.DB.WBS_ForeignCNProfessional orderby x.SortIndex select x;
|
|
foreach (var item2 in foreignCNProfessionals)
|
|
{
|
|
TreeNode rootNode2 = new TreeNode();
|
|
rootNode2.Text = item2.ProfessionalName;
|
|
rootNode2.NodeID = rootNode1.NodeID + "|" + item2.CNProfessionalId;
|
|
rootNode2.CommandName = "国外专业";
|
|
rootNode2.EnableExpandEvent = true;
|
|
rootNode2.EnableClickEvent = true;
|
|
rootNode1.Nodes.Add(rootNode2);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 点击树节点
|
|
/// <summary>
|
|
/// 点击树节点
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
string ids = this.tvControlItem.SelectedNodeID;
|
|
this.hdUnitWorkId.Text = ids.Split('|').ToList()[0];
|
|
this.hdCNProfessionalId.Text = ids.Split('|').ToList()[1];
|
|
BindGrid();
|
|
}
|
|
#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 txtName_TextChanged(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 数据绑定
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT ForeignBreakdownProject.BreakdownProjectId,
|
|
ForeignBreakdownProject.ProjectId,
|
|
ForeignBreakdownProject.UnitWorkId,
|
|
ForeignBreakdownProject.CNProfessionalId,
|
|
ForeignBreakdownProject.BreakdownCode,
|
|
ForeignBreakdownProject.BreakdownName,
|
|
ForeignBreakdownProject.BreakdownDef,
|
|
ForeignBreakdownProject.Remark,
|
|
ForeignBreakdownProject.ModelURL,
|
|
ForeignBreakdownProject.AttachUrl,
|
|
ForeignBreakdownProject.SortIndex,
|
|
ForeignBreakdownProject.IsSelected"
|
|
+ @" FROM WBS_ForeignBreakdownProject AS ForeignBreakdownProject "
|
|
+ @" WHERE ForeignBreakdownProject.ProjectId=@ProjectId"
|
|
+ @" AND ForeignBreakdownProject.UnitWorkId=@UnitWorkId"
|
|
+ @" AND ForeignBreakdownProject.CNProfessionalId=@CNProfessionalId";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
listStr.Add(new SqlParameter("@UnitWorkId", this.hdUnitWorkId.Text.Trim()));
|
|
listStr.Add(new SqlParameter("@CNProfessionalId", this.hdCNProfessionalId.Text.Trim()));
|
|
if (!string.IsNullOrEmpty(this.txtBreakdownName.Text.Trim()))
|
|
{
|
|
strSql += " AND ForeignBreakdownProject.BreakdownName LIKE @BreakdownName";
|
|
listStr.Add(new SqlParameter("@BreakdownName", "%" + this.txtBreakdownName.Text.Trim() + "%"));
|
|
}
|
|
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();
|
|
}
|
|
#endregion
|
|
|
|
#region 增加控制点项
|
|
/// <summary>
|
|
/// 增加控制点项
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.tvControlItem.SelectedNode != null && this.tvControlItem.SelectedNode.Nodes.Count == 0)
|
|
{
|
|
var breakdown = from x in Funs.DB.WBS_ForeignBreakdownProject
|
|
where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == this.hdUnitWorkId.Text.Trim()
|
|
select x;
|
|
if (breakdown.Count() > 0)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ControlPointListEdit.aspx?UnitWorkId={0}&&CNPrefessionalId={1}", this.hdUnitWorkId.Text.Trim(), this.hdCNProfessionalId.Text.Trim(), "编辑 - ")));
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("该装置下没有数据,请先提取数据!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择专业!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 编辑
|
|
/// <summary>
|
|
/// 编辑
|
|
/// </summary>
|
|
private void EditData()
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ControlPointListEdit.aspx?breakdownProjectId={0}&&UnitWorkId={1}&&CNPrefessionalId={2}", Grid1.SelectedRowID, this.hdUnitWorkId.Text.Trim(), this.hdCNProfessionalId.Text.Trim(), "编辑 - ")));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Grid行双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 右键修改
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuModify_Click(object sender, EventArgs e)
|
|
{
|
|
EditData();
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 右键删除
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDel_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var breakdown = BLL.ForeignBreakdownProjectService.GetForeignBreakdownProjectById(rowID);
|
|
if (breakdown != null)
|
|
{
|
|
BLL.ForeignBreakdownProjectService.DeleteForeignBreakdownProjectById(rowID);
|
|
}
|
|
}
|
|
BindGrid();
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var breakdown = BLL.ForeignBreakdownProjectService.GetForeignBreakdownProjectById(rowID);
|
|
if (breakdown != null)
|
|
{
|
|
breakdown.IsSelected = true;
|
|
BLL.ForeignBreakdownProjectService.UpdateForeignBreakdownProject(breakdown);
|
|
}
|
|
}
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 从总部提取该装置下所有专业控制点项
|
|
/// <summary>
|
|
/// 提取
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnExtract_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.tvControlItem.SelectedNode != null && this.tvControlItem.SelectedNode.Nodes.Count > 0)
|
|
{
|
|
var breakdown = from x in Funs.DB.WBS_ForeignBreakdownProject
|
|
where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == this.tvControlItem.SelectedNode.NodeID
|
|
select x;
|
|
if (breakdown.Count() == 0)
|
|
{
|
|
var foreignBreakdown = from x in Funs.DB.WBS_ForeignBreakdown orderby x.SortIndex select x;
|
|
if (foreignBreakdown.Count() > 0)
|
|
{
|
|
foreach (var q in foreignBreakdown)
|
|
{
|
|
Model.WBS_ForeignBreakdownProject newBreakdown = new Model.WBS_ForeignBreakdownProject();
|
|
string newKeyID = SQLHelper.GetNewID(typeof(Model.WBS_ForeignBreakdownProject));
|
|
newBreakdown.BreakdownProjectId = newKeyID;
|
|
newBreakdown.ProjectId = this.CurrUser.LoginProjectId;
|
|
newBreakdown.UnitWorkId = this.tvControlItem.SelectedNode.NodeID;
|
|
newBreakdown.CNProfessionalId = q.CNProfessionalId;
|
|
newBreakdown.BreakdownCode = q.BreakdownCode;
|
|
newBreakdown.BreakdownName = q.BreakdownName;
|
|
newBreakdown.BreakdownDef = q.BreakdownDef;
|
|
newBreakdown.ModelURL = q.ModelURL;
|
|
newBreakdown.Remark = q.Remark;
|
|
newBreakdown.SortIndex = q.SortIndex;
|
|
BLL.ForeignBreakdownProjectService.AddForeignBreakdownProject(newBreakdown);
|
|
}
|
|
ShowNotify("提取成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("已有数据,不能提取!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择单元!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 关闭弹出窗口
|
|
/// <summary>
|
|
/// 关闭弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region Grid行绑定事件
|
|
/// <summary>
|
|
/// 行绑定事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
|
|
{
|
|
List<int> lists = new List<int>();
|
|
for (int i = 0; i < this.Grid1.Rows.Count; i++)
|
|
{
|
|
//查看模板附件
|
|
System.Web.UI.WebControls.LinkButton lbtnFileUrl = ((System.Web.UI.WebControls.LinkButton)(this.Grid1.Rows[i].FindControl("lbtnFileUrl")));
|
|
if (!string.IsNullOrEmpty(lbtnFileUrl.CommandArgument.Trim()))
|
|
{
|
|
string url = lbtnFileUrl.CommandArgument.Replace('\\', '/');
|
|
lbtnFileUrl.Text = BLL.UploadAttachmentService.ShowAttachment("../", url);
|
|
}
|
|
|
|
string rowID = Grid1.DataKeys[i][0].ToString();
|
|
var breakdown = BLL.ForeignBreakdownProjectService.GetForeignBreakdownProjectById(rowID);
|
|
if (breakdown != null)
|
|
{
|
|
if (breakdown.IsSelected == true)
|
|
{
|
|
lists.Add(i);
|
|
}
|
|
}
|
|
}
|
|
Grid1.SelectedRowIndexArray = lists.ToArray();
|
|
}
|
|
#endregion
|
|
|
|
#region Grid行点击事件
|
|
/// <summary>
|
|
/// Grid行点击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
string breakdownProjectId = Grid1.DataKeys[e.RowIndex][0].ToString();
|
|
if (e.CommandName == "AttachUrl")//附件
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/Foreign/ControlPointList&menuId={1}", breakdownProjectId, BLL.Const.ControlPointListMenuId)));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 导出
|
|
/// <summary>
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("ForeignWBSOut.aspx", "导出 - ")));
|
|
}
|
|
#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.ControlPointListMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnAdd))
|
|
{
|
|
this.btnNew.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnModify))
|
|
{
|
|
this.Grid1.EnableRowDoubleClickEvent = true;
|
|
this.btnMenuModify.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnSave))
|
|
{
|
|
this.btnSave.Hidden = false;
|
|
this.btnExtract.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnDelete))
|
|
{
|
|
this.btnMenuDel.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |