SGGL_SHJ/SGGL/FineUIPro.Web/HJGL/PreDesign/YardPlanning.aspx.cs

440 lines
16 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web.UI.DataVisualization.Charting;
namespace FineUIPro.Web.HJGL.PreDesign
{
public partial class YardPlanning : 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.GetButtonPower();
this.InitTreeMenu();
Bind();
}
}
private void Bind()
{
if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID))
{
var unit = HJGL_YardPlanningService.GetHJGL_YardPlanningByProjectId(this.CurrUser.LoginProjectId, tvControlItem.SelectedNodeID);
this.imgPhoto.ImageUrl = null;
if (unit != null)
{
this.imgPhoto.ImageUrl = "~/" + unit.FlowChartPic;
}
}
}
#region --
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode1 = new TreeNode();
rootNode1.NodeID = "1";
rootNode1.Text = "建筑工程";
rootNode1.CommandName = "建筑工程";
rootNode1.Selectable = false;
this.tvControlItem.Nodes.Add(rootNode1);
TreeNode rootNode2 = new TreeNode();
rootNode2.NodeID = "2";
rootNode2.Text = "安装工程";
rootNode2.CommandName = "安装工程";
rootNode2.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode2);
var pUnits = (from x in Funs.DB.Project_ProjectUnit where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList();
// 获取当前用户所在单位
var currUnit = pUnits.FirstOrDefault(x => x.UnitId == this.CurrUser.UnitId);
var unitWorkList = (from x in Funs.DB.WBS_UnitWork
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.SuperUnitWork == null && x.UnitId != null && x.ProjectType != null
select x).ToList();
List<Model.WBS_UnitWork> unitWork1 = null;
List<Model.WBS_UnitWork> unitWork2 = null;
// 当前为施工单位,只能操作本单位的数据
if (currUnit != null && currUnit.UnitType == Const.ProjectUnitType_2)
{
unitWork1 = (from x in unitWorkList
where x.UnitId == this.CurrUser.UnitId && x.ProjectType == "1"
select x).ToList();
unitWork2 = (from x in unitWorkList
where x.UnitId == this.CurrUser.UnitId && x.ProjectType == "2"
select x).ToList();
}
else
{
unitWork1 = (from x in unitWorkList where x.ProjectType == "1" select x).ToList();
unitWork2 = (from x in unitWorkList where x.ProjectType == "2" select x).ToList();
}
if (unitWork1.Count() > 0)
{
foreach (var q in unitWork1)
{
int a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId select x).Count();
var u = BLL.UnitService.GetUnitByUnitId(q.UnitId);
TreeNode tn1 = new TreeNode();
tn1.NodeID = q.UnitWorkId;
tn1.Text = q.UnitWorkName + "【" + a.ToString() + "】" + "管线";
tn1.ToolTip = "施工单位:" + u.UnitName;
tn1.EnableClickEvent = true;
rootNode1.Nodes.Add(tn1);
}
}
if (unitWork2.Count() > 0)
{
foreach (var q in unitWork2)
{
int a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId select x).Count();
var u = BLL.UnitService.GetUnitByUnitId(q.UnitId);
TreeNode tn2 = new TreeNode();
tn2.NodeID = q.UnitWorkId;
// tn2.Text = q.UnitWorkName + "【" + a.ToString() + "】" + "管线";
tn2.Text = q.UnitWorkName ;
tn2.ToolTip = "施工单位:" + u.UnitName;
tn2.EnableClickEvent = true;
rootNode2.Nodes.Add(tn2);
}
}
}
#endregion
#region TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
this.Bind();
}
#endregion
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.PersonId, BLL.Const.HJGL_YardPlanningMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
this.btnNewItem.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnDelete))
{
this.btnDeleteItem.Hidden = false;
}
}
}
#endregion
/// <summary>
/// 删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDelete_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID))
{
var model = HJGL_YardPlanningService.GetHJGL_YardPlanningByProjectId(this.CurrUser.LoginProjectId, tvControlItem.SelectedNodeID);
if (model != null)
{
HJGL_YardPlanningService.DeleteHJGL_YardPlanningById(model.YardPlanningId);
}
this.imgPhoto.ImageUrl = null;
}
else
{
Alert.ShowInTop("请选择一个主项!", MessageBoxIcon.Warning);
}
}
protected void filePhoto_FileSelected(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID))
{
if (filePhoto.HasFile)
{
string rootUrl = ConfigurationManager.AppSettings["localRoot"];
if (string.IsNullOrEmpty(rootUrl))
{
rootUrl = Funs.RootPath;
}
string fileName = filePhoto.ShortFileName;
if (!ValidateFileType(fileName))
{
// 清空文件上传控件
filePhoto.Reset();
ShowNotify("无效的文件类型!");
return;
}
fileName = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_");
fileName = DateTime.Now.Ticks.ToString() + "_" + fileName;
filePhoto.SaveAs(rootUrl + "/FileUpload/HJGL_YardPlanning/" + fileName);
imgPhoto.ImageUrl = "~/FileUpload/HJGL_YardPlanning/" + fileName;
HJGL_YardPlanningService.SavePic(this.CurrUser.LoginProjectId, tvControlItem.SelectedNodeID, "FileUpload/HJGL_YardPlanning/" + fileName);
// 清空文件上传组件(上传后要记着清空,否则点击提交表单时会再次上传!!)
filePhoto.Reset();
}
}
else
{
Alert.ShowInTop("请选择一个主项!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// Tree点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void trSafetyOrganization_NodeCommand(object sender, TreeCommandEventArgs e)
{
if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID))
{
var unit = HJGL_YardPlanningService.GetHJGL_YardPlanningByProjectId(this.CurrUser.LoginProjectId, tvControlItem.SelectedNodeID);
this.imgPhoto.ImageUrl = null;
if (unit != null)
{
this.imgPhoto.ImageUrl = "~/" + unit.FlowChartPic;
}
}
else
{
this.imgPhoto.ImageUrl = null;
}
}
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID))
{
var model = HJGL_YardPlanningService.GetHJGL_YardPlanningByProjectId(this.CurrUser.LoginProjectId, tvControlItem.SelectedNodeID);
if (model == null)
{
HJGL_YardPlanningService.SavePic(this.CurrUser.LoginProjectId, tvControlItem.SelectedNodeID, "");
model = HJGL_YardPlanningService.GetHJGL_YardPlanningByProjectId(this.CurrUser.LoginProjectId, tvControlItem.SelectedNodeID);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/HJGL_YardPlanning&menuId={1}", model.YardPlanningId, BLL.Const.HJGL_YardPlanningMenuId)));
}
else
{
Alert.ShowInTop("请选择一个主项!", MessageBoxIcon.Warning);
}
}
}
//public partial class EmergencyProcess : PageBase
//{
// /// <summary>
// /// 项目id
// /// </summary>
// public string ProjectId
// {
// get
// {
// return (string)ViewState["ProjectId"];
// }
// set
// {
// ViewState["ProjectId"] = value;
// }
// }
// #region 加载
// /// <summary>
// /// 加载页面
// /// </summary>
// /// <param name="sender"></param>
// /// <param name="e"></param>
// protected void Page_Load(object sender, EventArgs e)
// {
// if (!IsPostBack)
// {
// ////权限按钮方法
// this.GetButtonPower();
// this.ProjectId = this.CurrUser.LoginProjectId;
// if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.ProjectId)
// {
// this.ProjectId = Request.Params["projectId"];
// }
// // 绑定表格
// this.BindGrid();
// }
// }
// #endregion
// #region GV绑定数据
// /// <summary>
// /// 绑定数据
// /// </summary>
// void BindGrid()
// {
// var getEmergencys = (from x in Funs.DB.Emergency_EmergencyProcess
// where x.ProjectId == this.ProjectId
// select x).ToList();
// if (getEmergencys.Count() == 0)
// {
// var getEEmergencyProcessItems = from x in Funs.DB.Emergency_EmergencyProcess
// where x.ProjectId == null
// select x;
// foreach (var item in getEEmergencyProcessItems)
// {
// Model.Emergency_EmergencyProcess newItem = new Model.Emergency_EmergencyProcess
// {
// EmergencyProcessId = SQLHelper.GetNewID(),
// ProjectId = this.ProjectId,
// ProcessSteps = item.ProcessSteps,
// ProcessName = item.ProcessName,
// StepOperator = item.StepOperator,
// Remark = item.Remark,
// };
// Funs.DB.Emergency_EmergencyProcess.InsertOnSubmit(newItem);
// Funs.DB.SubmitChanges();
// getEmergencys.Add(item);
// }
// }
// Grid1.RecordCount = getEmergencys.Count();
// DataTable tb = this.GetPagedDataTable(Grid1, getEmergencys);
// Grid1.DataSource = tb;
// Grid1.DataBind();
// }
// #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)
// {
// this.EditData();
// }
// /// <summary>
// /// 编辑数据方法
// /// </summary>
// void EditData()
// {
// if (Grid1.SelectedRowIndexArray.Length == 0)
// {
// Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
// return;
// }
// PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("EmergencyProcessEdit.aspx?EmergencyProcessId={0}", Grid1.SelectedRowID, "详细 - ")));
// }
// #endregion
// #region 获取按钮权限
// /// <summary>
// /// 获取按钮权限
// /// </summary>
// /// <param name="button"></param>
// /// <returns></returns>
// void GetButtonPower()
// {
// if (Request.Params["value"] == "0")
// {
// return;
// }
// var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_YardPlanningMenuId);
// if (buttonList.Count() > 0)
// {
// if (buttonList.Contains(BLL.Const.BtnModify))
// {
// this.btnMenuEdit.Hidden = false;
// }
// }
// }
// #endregion
//}
}