275 lines
9.6 KiB
C#
275 lines
9.6 KiB
C#
using BLL;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.common.ProjectSet
|
|
{
|
|
public partial class Installation : PageBase
|
|
{
|
|
#region 页面加载
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.drpProjectId.DataTextField = "ProjectCode";
|
|
this.drpProjectId.DataValueField = "ProjectId";
|
|
this.drpProjectId.DataSource = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
|
|
this.drpProjectId.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpProjectId);
|
|
|
|
InitTreeMenu(); //加载树
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载树
|
|
private void InitTreeMenu()
|
|
{
|
|
this.trProjects.Nodes.Clear();
|
|
TreeNode rootNode = new TreeNode();
|
|
rootNode.Text = "项目";
|
|
rootNode.ToolTip = "项目";
|
|
rootNode.NodeID = "0";
|
|
rootNode.Expanded = true;
|
|
this.trProjects.Nodes.Add(rootNode);
|
|
|
|
List<Model.Base_Project> projects = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
|
|
if (this.drpProjectId.SelectedValue != null && this.drpProjectId.SelectedValue != "null")
|
|
{
|
|
projects = projects.Where(e => e.ProjectId == this.drpProjectId.SelectedValue).ToList();
|
|
}
|
|
foreach (var item in projects)
|
|
{
|
|
TreeNode rootProjectNode = new TreeNode();//定义根节点
|
|
rootProjectNode.Text = item.ProjectCode;
|
|
rootProjectNode.NodeID = item.ProjectId;
|
|
rootProjectNode.EnableClickEvent = true;
|
|
rootProjectNode.Expanded = true;
|
|
rootProjectNode.ToolTip = item.ProjectName;
|
|
rootNode.Nodes.Add(rootProjectNode);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 点击树
|
|
/// <summary>
|
|
/// Tree点击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void trWBS_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
if (this.trProjects.SelectedNodeID != "0")
|
|
{
|
|
BindGrid();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.InitTreeMenu();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnEdit_Click(object sender, EventArgs e)
|
|
{
|
|
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectInstallationMenuId, BLL.Const.BtnModify))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInParent("请至少选择一条记录!");
|
|
return;
|
|
}
|
|
string Id = Grid1.SelectedRowID;
|
|
PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("InstallationSave.aspx?installationId={0}&projectId={1}", Id, this.trProjects.SelectedNodeID, "编辑 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Grid行双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
btnEdit_Click(null, null);
|
|
}
|
|
|
|
#region 关闭弹出窗口
|
|
/// <summary>
|
|
/// 关闭弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window2_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
Alert.ShowInParent("删除成功!");
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window3_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 绑定数据
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = "select * from Project_Installation where ProjectId=@ProjectId";
|
|
SqlParameter[] parameter = new SqlParameter[]
|
|
{
|
|
new SqlParameter("@ProjectId",this.trProjects.SelectedNodeID),
|
|
};
|
|
DataTable table = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
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 (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectInstallationMenuId, BLL.Const.BtnAdd))
|
|
{
|
|
if (this.trProjects.SelectedNode != null && this.trProjects.SelectedNodeID != "0")
|
|
{
|
|
PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("InstallationSave.aspx?projectId={0}", this.trProjects.SelectedNodeID)));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("请先选择项目!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除装置
|
|
/// <summary>
|
|
/// 删除装置
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIDArray.Count() > 0)
|
|
{
|
|
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectInstallationMenuId, BLL.Const.BtnDelete))
|
|
{
|
|
//string installationId = Grid1.SelectedRowID;
|
|
int IndexId = Grid1.SelectedRowIndex;
|
|
Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(Grid1.SelectedRowID);
|
|
if (installation != null)
|
|
{
|
|
if (judgementDelete(Grid1.SelectedRowID))
|
|
{
|
|
// 临时删除选中行
|
|
Grid1.Rows.RemoveAt(IndexId);
|
|
BLL.Project_InstallationService.DeleteInstallation(Grid1.SelectedRowID);
|
|
BLL.Sys_LogService.AddLog(Const.System_1, this.trProjects.SelectedNodeID, this.CurrUser.UserId, "删除装置");
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInParent("此装置数据已删除!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInParent("请至少选择一条记录!");
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 判断是否可删除
|
|
/// <summary>
|
|
/// 判断是否可以删除
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private bool judgementDelete(string installationId)
|
|
{
|
|
string content = "";
|
|
|
|
var weldReportMain= (from x in Funs.DB.HJGL_BO_WeldReportMain
|
|
where x.InstallationId == installationId
|
|
orderby x.JOT_WeldDate
|
|
select x.JOT_WeldDate.Year+"年" + x.JOT_WeldDate.Month+"月").Distinct();
|
|
if (weldReportMain.Count() > 0)
|
|
{
|
|
string massge = "该装置下存在月份:";
|
|
foreach (var item in weldReportMain)
|
|
{
|
|
massge +="【" +item + "】";
|
|
}
|
|
content += massge + "的焊接日报!";
|
|
}
|
|
|
|
if (content == "")
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop(content, MessageBoxIcon.Warning);
|
|
return false;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |