630 lines
		
	
	
		
			28 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			630 lines
		
	
	
		
			28 KiB
		
	
	
	
		
			C#
		
	
	
	
using BLL;
 | 
						|
using Newtonsoft.Json.Linq;
 | 
						|
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
using System.Web.UI.WebControls;
 | 
						|
 | 
						|
namespace FineUIPro.Web.HJGL.HotProessManage
 | 
						|
{
 | 
						|
    public partial class HotProessManageEdit : PageBase
 | 
						|
    {
 | 
						|
        #region 定义项
 | 
						|
        /// <summary>
 | 
						|
        /// 热处理主键
 | 
						|
        /// </summary>
 | 
						|
        public string HotProessId
 | 
						|
        {
 | 
						|
            get
 | 
						|
            {
 | 
						|
                return (string)ViewState["HotProessId"];
 | 
						|
            }
 | 
						|
            set
 | 
						|
            {
 | 
						|
                ViewState["HotProessId"] = value;
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 热处理明细集合
 | 
						|
        /// </summary>
 | 
						|
        private static List<Model.View_HotProessItem> viewHotProessItems = new List<Model.View_HotProessItem>();
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 加载
 | 
						|
        /// <summary>
 | 
						|
        /// 加载页面
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void Page_Load(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (!IsPostBack)
 | 
						|
            {
 | 
						|
                //单位、装置
 | 
						|
                //if (BLL.UnitService.GetUnitByUnitId(this.CurrUser.UnitId) == null || BLL.UnitService.GetUnitByUnitId(this.CurrUser.UnitId).UnitTypeId == BLL.Const.ProjectUnitType_1)
 | 
						|
                //{
 | 
						|
                //    BLL.UnitService.InitUnitNameByUnitTypeDropDownList(this.drpUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true);
 | 
						|
                //    BLL.Project_InstallationService.InitInstallationDropDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, true);
 | 
						|
                //}
 | 
						|
                //else
 | 
						|
                //{
 | 
						|
                //    BLL.UnitService.InitSubUnitNameDownList(this.drpUnit, this.CurrUser.LoginProjectId, this.CurrUser.UnitId, true);
 | 
						|
                //    BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.CurrUser.UnitId, true);
 | 
						|
                //}
 | 
						|
                var pUnit = BLL.UnitService.GetUnitByProjectIdUnitTypeList(this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2);
 | 
						|
                if (pUnit != null)
 | 
						|
                {
 | 
						|
                    this.drpUnit.DataTextField = "UnitName";
 | 
						|
                    this.drpUnit.DataValueField = "UnitId";
 | 
						|
                    this.drpUnit.DataSource = pUnit;
 | 
						|
                    this.drpUnit.DataBind();
 | 
						|
                    this.drpUnit.SelectedValue = this.CurrUser.UnitId;
 | 
						|
 | 
						|
                    BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpUnit.SelectedValue, true);
 | 
						|
                    this.drpInstallationId.SelectedIndex = 0;
 | 
						|
                }
 | 
						|
 | 
						|
                BLL.UserService.InitUserDropDownList(this.drpTabler, this.CurrUser.LoginProjectId, true);//制单人
 | 
						|
 | 
						|
                this.txtReportDate.Text = string.Format("{0:yyyy-MM}", DateTime.Now);
 | 
						|
                this.txtProessDate.Text = string.Format("{0:yyyy-MM-dd}",DateTime.Now);
 | 
						|
                this.drpTabler.SelectedValue = this.CurrUser.UserId;
 | 
						|
 | 
						|
                InitTreeMenu();//加载树
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 加载树装置-单位-工作区
 | 
						|
        /// <summary>
 | 
						|
        /// 加载树
 | 
						|
        /// </summary>
 | 
						|
        private void InitTreeMenu()
 | 
						|
        {
 | 
						|
            if (!string.IsNullOrEmpty(this.txtReportDate.Text.Trim()))
 | 
						|
            {
 | 
						|
                DateTime? startTime = Funs.GetNewDateTime(this.txtReportDate.Text.Trim());
 | 
						|
                DateTime? endTime = startTime.HasValue ? startTime.Value.AddMonths(1) : System.DateTime.Now;
 | 
						|
 | 
						|
                this.tvControlItem.Nodes.Clear();
 | 
						|
                TreeNode rootNode = new TreeNode();
 | 
						|
                rootNode.Text = "单位-装置-月份";
 | 
						|
                rootNode.NodeID = "0";
 | 
						|
                rootNode.Expanded = true;
 | 
						|
                this.tvControlItem.Nodes.Add(rootNode);
 | 
						|
 | 
						|
                List<Model.Base_Unit> units = null;
 | 
						|
                var unit = Funs.DB.Project_ProjectUnit.FirstOrDefault(x=>x.UnitId==this.CurrUser.UnitId);
 | 
						|
                if (unit == null || unit.UnitType  == BLL.Const.ProjectUnitType_1)
 | 
						|
                {
 | 
						|
                    units = BLL.UnitService.GetUnitByProjectIdUnitTypeList(this.CurrUser.LoginProjectId, "2");
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    units = (from x in Funs.DB.Base_Unit where x.UnitId == this.CurrUser.UnitId select x).ToList();
 | 
						|
                }
 | 
						|
                List<Model.HotProess> hotProessLists = new List<Model.HotProess>(); ///热处理              
 | 
						|
                hotProessLists = (from x in Funs.DB.HotProess
 | 
						|
                                  where x.ProjectId == this.CurrUser.LoginProjectId && x.ProessDate >= startTime && x.ProessDate < endTime
 | 
						|
                                  select x).ToList();
 | 
						|
              
 | 
						|
                if (units != null)
 | 
						|
                {
 | 
						|
                    foreach (var item in units)
 | 
						|
                    {
 | 
						|
                        TreeNode rootUnitNode = new TreeNode();//定义根节点
 | 
						|
                        rootUnitNode.Text = item.UnitName;
 | 
						|
                        rootUnitNode.NodeID = item.UnitId;
 | 
						|
                        rootUnitNode.Expanded = true;
 | 
						|
                        rootUnitNode.ToolTip = "施工单位";
 | 
						|
                        rootNode.Nodes.Add(rootUnitNode);
 | 
						|
                        var lists = hotProessLists.Where(x => x.UnitId == item.UnitId).ToList();
 | 
						|
                        this.BindNodes(rootUnitNode, lists);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    Alert.ShowInTop("请先增加施工单位!", MessageBoxIcon.Warning);
 | 
						|
                    return;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                Alert.ShowInTop("请选择热处理月份!", MessageBoxIcon.Warning);
 | 
						|
                return;
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 绑定树节点
 | 
						|
        /// <summary>
 | 
						|
        ///  绑定树节点
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="node"></param>
 | 
						|
        private void BindNodes(TreeNode node, List<Model.HotProess> hotProessLists)
 | 
						|
        {
 | 
						|
            if (node.ToolTip == "施工单位")
 | 
						|
            {
 | 
						|
                var installId = (from x in hotProessLists select x.InstallationId).Distinct();
 | 
						|
                if (installId.Count() > 0)
 | 
						|
                {
 | 
						|
                    var install = from x in Funs.DB.Project_Installation where installId.Contains(x.InstallationId) orderby x.InstallationCode select x;
 | 
						|
                    foreach (var q in install)
 | 
						|
                    {
 | 
						|
                        TreeNode newNode = new TreeNode();
 | 
						|
                        newNode.Text = q.InstallationCode + q.InstallationName;
 | 
						|
                        newNode.NodeID = q.InstallationId + "|" + node.NodeID; ;
 | 
						|
                        newNode.ToolTip = "装置";
 | 
						|
                        newNode.Expanded = true;
 | 
						|
                        node.Nodes.Add(newNode);
 | 
						|
                        this.BindNodes(newNode, hotProessLists);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
            else if (node.ToolTip == "装置")
 | 
						|
            {
 | 
						|
                string installationId = Funs.GetStrListByStr(node.NodeID, '|')[0];
 | 
						|
                var hotListMonth = (from x in hotProessLists
 | 
						|
                                      where x.InstallationId == installationId && x.UnitId == node.ParentNode.NodeID
 | 
						|
                                      select string.Format("{0:yyyy-MM}", x.ProessDate)).Distinct();
 | 
						|
                foreach (var item in hotListMonth)
 | 
						|
                {
 | 
						|
                    TreeNode newNode = new TreeNode();
 | 
						|
                    newNode.Text = item;
 | 
						|
                    newNode.NodeID = item + "|" + node.NodeID; ;
 | 
						|
                    newNode.ToolTip = "月份";
 | 
						|
                    node.Nodes.Add(newNode);
 | 
						|
                    this.BindNodes(newNode, hotProessLists);
 | 
						|
                }
 | 
						|
            }
 | 
						|
            else if (node.ToolTip == "月份")
 | 
						|
            {
 | 
						|
                string installationId = Funs.GetStrListByStr(node.ParentNode.NodeID, '|')[0];
 | 
						|
                var days = (from x in hotProessLists
 | 
						|
                            where x.InstallationId == installationId && x.UnitId == node.ParentNode.ParentNode.NodeID
 | 
						|
                            orderby x.ProessDate descending
 | 
						|
                            select x.ProessDate).Distinct();
 | 
						|
                foreach (var item in days)
 | 
						|
                {
 | 
						|
                    TreeNode newNode = new TreeNode();
 | 
						|
                    newNode.Text = string.Format("{0:yyyy-MM-dd}", item);
 | 
						|
                    newNode.NodeID = item.ToString() + "|" + node.NodeID; ;
 | 
						|
                    newNode.ToolTip = "日期";
 | 
						|
                    node.Nodes.Add(newNode);
 | 
						|
                    this.BindNodes(newNode, hotProessLists);
 | 
						|
                }
 | 
						|
            }
 | 
						|
            else if (node.ToolTip == "日期")
 | 
						|
            {
 | 
						|
                string installationId = Funs.GetStrListByStr(node.ParentNode.ParentNode.NodeID, '|')[0];
 | 
						|
                var dReports = from x in hotProessLists
 | 
						|
                               where x.InstallationId == installationId && x.UnitId == node.ParentNode.ParentNode.ParentNode.NodeID
 | 
						|
                               && x.ProessDate == Funs.GetNewDateTime(node.Text)
 | 
						|
                               orderby x.HotProessNo descending
 | 
						|
                               select x;
 | 
						|
                foreach (var item in dReports)
 | 
						|
                {
 | 
						|
                    TreeNode newNode = new TreeNode();
 | 
						|
                    if (!string.IsNullOrEmpty(item.HotProessNo))
 | 
						|
                    {
 | 
						|
                        newNode.Text = item.HotProessNo;
 | 
						|
                    }
 | 
						|
                    else
 | 
						|
                    {
 | 
						|
                        newNode.Text = "未知";
 | 
						|
                    }
 | 
						|
                    newNode.NodeID = item.HotProessId;
 | 
						|
                    newNode.EnableClickEvent = true;
 | 
						|
                    node.Nodes.Add(newNode);
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 查询树节点
 | 
						|
        protected void Tree_TextChanged(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            this.InitTreeMenu();
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 点击树节点
 | 
						|
        /// <summary>
 | 
						|
        /// 点击树节点
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
 | 
						|
        {
 | 
						|
            viewHotProessItems = new List<Model.View_HotProessItem>();
 | 
						|
            this.HotProessId = this.tvControlItem.SelectedNodeID;
 | 
						|
            if (!string.IsNullOrEmpty(this.HotProessId))
 | 
						|
            {
 | 
						|
                Model.HotProess hotProess = BLL.HotProessManageEditService.GetHotProessByID(this.HotProessId);
 | 
						|
                if (hotProess != null)
 | 
						|
                {
 | 
						|
                    if (!string.IsNullOrEmpty(hotProess.UnitId))
 | 
						|
                    {
 | 
						|
                        this.drpUnit.SelectedValue = hotProess.UnitId;
 | 
						|
                    }
 | 
						|
                    if (!string.IsNullOrEmpty(hotProess.InstallationId))
 | 
						|
                    {
 | 
						|
                        this.drpInstallationId.SelectedValue = hotProess.InstallationId;
 | 
						|
                    }
 | 
						|
                    this.txtHotProessNo.Text = hotProess.HotProessNo;
 | 
						|
                    this.txtProessDate.Text = hotProess.ProessDate.HasValue ? string.Format("{0:yyyy-MM-dd}", hotProess.ProessDate) : string.Format("{0:yyyy-MM-dd}", DateTime.Now);
 | 
						|
                    this.txtProessMethod.Text = hotProess.ProessMethod;
 | 
						|
                    this.txtProessEquipment.Text = hotProess.ProessEquipment;
 | 
						|
                    if (!string.IsNullOrEmpty(hotProess.Tabler))
 | 
						|
                    {
 | 
						|
                        this.drpTabler.SelectedValue = hotProess.Tabler;
 | 
						|
                    }
 | 
						|
                    else
 | 
						|
                    {
 | 
						|
                        this.drpTabler.SelectedValue = this.CurrUser.UserId;
 | 
						|
                    }
 | 
						|
                    this.txtRemark.Text = hotProess.Remark;
 | 
						|
 | 
						|
                    viewHotProessItems.Clear();
 | 
						|
                    viewHotProessItems = BLL.HotProessManageEditService.GetHotProessItemByID(this.HotProessId);
 | 
						|
                    if (viewHotProessItems.Count > 0)
 | 
						|
                    {
 | 
						|
                        this.Grid1.DataSource = viewHotProessItems;
 | 
						|
                        this.Grid1.DataBind();
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                this.HotProessId = string.Empty;
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion        
 | 
						|
 | 
						|
        #region 增加
 | 
						|
        /// <summary>
 | 
						|
        /// 增加按钮
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnAdd_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (this.GetButtonPower(BLL.Const.BtnAdd))
 | 
						|
            {
 | 
						|
                this.drpUnit.SelectedIndex = 0;
 | 
						|
                this.drpInstallationId.SelectedIndex = 0;
 | 
						|
                this.txtHotProessNo.Text = string.Empty;
 | 
						|
                this.txtProessDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
 | 
						|
                this.txtProessMethod.Text = string.Empty;
 | 
						|
                this.txtProessEquipment.Text = string.Empty;
 | 
						|
                this.drpTabler.Text = this.CurrUser.UserId;
 | 
						|
                this.txtRemark.Text = string.Empty;
 | 
						|
 | 
						|
                this.HotProessId = string.Empty;
 | 
						|
                viewHotProessItems.Clear();
 | 
						|
                this.Grid1.DataSource = viewHotProessItems;
 | 
						|
                this.Grid1.DataBind();
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 查找管线焊口
 | 
						|
        /// <summary>
 | 
						|
        /// 查找
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnSearch_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (this.GetButtonPower(BLL.Const.BtnSave))
 | 
						|
            {
 | 
						|
                if (this.drpUnit.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpUnit.SelectedValue))
 | 
						|
                {
 | 
						|
                    Alert.ShowInTop("请选择单位!", MessageBoxIcon.Warning);
 | 
						|
                    return;
 | 
						|
                }
 | 
						|
                else if (this.drpInstallationId.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpInstallationId.SelectedValue))
 | 
						|
                {
 | 
						|
                    Alert.ShowInTop("请选择装置名称!", MessageBoxIcon.Warning);
 | 
						|
                    return;
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    string window = String.Format("ShowHotProessSearch.aspx?unitId={0}&&installationId={1}", this.drpUnit.SelectedValue, this.drpInstallationId.SelectedValue, "编辑 - ");
 | 
						|
                    PageContext.RegisterStartupScript(Window1.GetSaveStateReference(this.hdJOTID.ClientID)
 | 
						|
                      + Window1.GetShowReference(window));
 | 
						|
                }
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 关闭弹出窗体
 | 
						|
        /// <summary>
 | 
						|
        /// 关闭弹出窗体
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void Window1_Close(object sender, WindowCloseEventArgs e)
 | 
						|
        {
 | 
						|
            viewHotProessItems = new List<Model.View_HotProessItem>();
 | 
						|
            int pointCount = int.Parse(this.drpPointCount.SelectedValue);
 | 
						|
            List<string> infos = Funs.GetStrListByStr(hdJOTID.Text, ',');
 | 
						|
            foreach (var item in infos)
 | 
						|
            {
 | 
						|
                int count = (from x in viewHotProessItems where x.JOT_ID == item select x).Count();
 | 
						|
                int c = pointCount - count;
 | 
						|
                if (c > 0)
 | 
						|
                {
 | 
						|
                    for (int i = 0; i < c; i++)
 | 
						|
                    {
 | 
						|
                        Model.View_HotProessItem info = Funs.DB.View_HotProessItem.FirstOrDefault(x => x.JOT_ID == item);
 | 
						|
                        info.PointCount = count + i + 1;
 | 
						|
                        viewHotProessItems.Add(info);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (viewHotProessItems.Count > 0)
 | 
						|
            {
 | 
						|
                this.Grid1.DataSource = viewHotProessItems;
 | 
						|
                this.Grid1.DataBind();
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 删除热处理
 | 
						|
        /// <summary>
 | 
						|
        /// 删除
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnDelete_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (this.GetButtonPower(BLL.Const.BtnDelete))
 | 
						|
            {
 | 
						|
                if (!string.IsNullOrEmpty(HotProessId))
 | 
						|
                {
 | 
						|
                    BLL.HotProessManageEditService.DeleteHotProessItemByHotProessId(HotProessId);
 | 
						|
                    BLL.HotProessManageEditService.DeleteHotProessByHotProessID(HotProessId);
 | 
						|
                    ShowNotify("删除成功!", MessageBoxIcon.Success);
 | 
						|
                    viewHotProessItems.Clear();
 | 
						|
                    this.HotProessId = null;
 | 
						|
                    this.Grid1.DataSource = null;
 | 
						|
                    this.Grid1.DataBind();
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    Alert.ShowInTop("请选择要删除的热处理记录!", MessageBoxIcon.Warning);
 | 
						|
                }
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion     
 | 
						|
 | 
						|
        #region 右键删除
 | 
						|
        /// <summary>
 | 
						|
        /// 右键删除
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnMenuDelete_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (this.GetButtonPower(BLL.Const.BtnDelete))
 | 
						|
            {
 | 
						|
                if (Grid1.SelectedRowIndexArray.Length == 0)
 | 
						|
                {
 | 
						|
                    Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
 | 
						|
                    return;
 | 
						|
                }
 | 
						|
                foreach (int rowIndex in Grid1.SelectedRowIndexArray)
 | 
						|
                {
 | 
						|
                    string rowID = Grid1.DataKeys[rowIndex][0].ToString();
 | 
						|
                    var item = viewHotProessItems.FirstOrDefault(x => x.JOT_ID == rowID);
 | 
						|
                    if (item != null)
 | 
						|
                    {
 | 
						|
                        viewHotProessItems.RemoveAt(rowIndex);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                Grid1.DataSource = viewHotProessItems;
 | 
						|
                Grid1.DataBind();
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 保存热处理
 | 
						|
        /// <summary>
 | 
						|
        /// 保存
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnSave_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (this.GetButtonPower(BLL.Const.BtnSave))
 | 
						|
            {
 | 
						|
                if (viewHotProessItems.Count > 0)
 | 
						|
                {
 | 
						|
                    foreach (var item in viewHotProessItems)
 | 
						|
                    {
 | 
						|
                        if (item.JOT_ID == null)
 | 
						|
                        {
 | 
						|
                            Alert.ShowInTop("焊口不能为空!", MessageBoxIcon.Warning);
 | 
						|
                            return;
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                }
 | 
						|
 | 
						|
                if (this.drpUnit.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpUnit.SelectedValue))
 | 
						|
                {
 | 
						|
                    Alert.ShowInTop("请选择单位!", MessageBoxIcon.Warning);
 | 
						|
                    return;
 | 
						|
                }
 | 
						|
                if (this.drpInstallationId.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpInstallationId.SelectedValue))
 | 
						|
                {
 | 
						|
                    Alert.ShowInTop("请选择装置名称!", MessageBoxIcon.Warning);
 | 
						|
                    return;
 | 
						|
                }
 | 
						|
                Model.HotProess newHotProess = new Model.HotProess();
 | 
						|
                newHotProess.ProjectId = this.CurrUser.LoginProjectId;
 | 
						|
                newHotProess.UnitId = this.drpUnit.SelectedValue;
 | 
						|
                newHotProess.InstallationId = this.drpInstallationId.SelectedValue;
 | 
						|
                newHotProess.HotProessNo = this.txtHotProessNo.Text.Trim();
 | 
						|
                newHotProess.ProessDate = Funs.GetNewDateTime(this.txtProessDate.Text.Trim());
 | 
						|
                newHotProess.ProessMethod = this.txtProessMethod.Text.Trim();
 | 
						|
                newHotProess.ProessEquipment = this.txtProessEquipment.Text.Trim();
 | 
						|
                if (this.drpTabler.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpTabler.SelectedValue))
 | 
						|
                {
 | 
						|
                    newHotProess.Tabler = this.drpTabler.SelectedValue;
 | 
						|
                }
 | 
						|
                newHotProess.Remark = this.txtRemark.Text.Trim();
 | 
						|
                if (!string.IsNullOrEmpty(this.HotProessId))
 | 
						|
                {
 | 
						|
                    newHotProess.HotProessId = this.HotProessId;
 | 
						|
                    BLL.HotProessManageEditService.UpdateHotProess(newHotProess);
 | 
						|
                    BLL.HotProessManageEditService.DeleteHotProessItemByHotProessId(HotProessId);
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    newHotProess.HotType = "0";
 | 
						|
                    this.HotProessId = SQLHelper.GetNewID(typeof(Model.HotProess));
 | 
						|
                    newHotProess.HotProessId = this.HotProessId;
 | 
						|
                    BLL.HotProessManageEditService.AddHotProess(newHotProess);
 | 
						|
                }
 | 
						|
 | 
						|
                JArray mergedData = Grid1.GetMergedData();
 | 
						|
                foreach (JObject mergedRow in mergedData)
 | 
						|
                {
 | 
						|
                    string status = mergedRow.Value<string>("status");
 | 
						|
                    JObject values = mergedRow.Value<JObject>("values");
 | 
						|
 | 
						|
                    string rowID = values.Value<string>("JOT_ID").ToString();
 | 
						|
                    var item = viewHotProessItems.FirstOrDefault(x => x.JOT_ID == rowID);
 | 
						|
                    if (item != null)
 | 
						|
                    {
 | 
						|
                        item.HotProessId = this.HotProessId;
 | 
						|
                        item.JOT_ID = rowID;
 | 
						|
                        item.PointCount = Funs.GetNewInt(values.Value<string>("PointCount"));
 | 
						|
                        item.RequiredT = values.Value<string>("RequiredT");
 | 
						|
                        item.ActualT = values.Value<string>("ActualT");
 | 
						|
                        item.RequestTime = values.Value<string>("RequestTime");
 | 
						|
                        item.ActualTime = values.Value<string>("ActualTime");
 | 
						|
                        item.RecordChartNo = values.Value<string>("RecordChartNo");
 | 
						|
                        item.HardnessReportNo = values.Value<string>("HardnessReportNo");
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                foreach (var item in viewHotProessItems)
 | 
						|
                {
 | 
						|
                    Model.HotProessItem newHotProessItem = new Model.HotProessItem();
 | 
						|
                    newHotProessItem.HotProessId = this.HotProessId;
 | 
						|
                    newHotProessItem.JOT_ID = item.JOT_ID;
 | 
						|
                    newHotProessItem.PointCount = item.PointCount;
 | 
						|
                    newHotProessItem.RequiredT = item.RequiredT;
 | 
						|
                    newHotProessItem.ActualT = item.ActualT;
 | 
						|
                    newHotProessItem.RequestTime = item.RequestTime;
 | 
						|
                    newHotProessItem.ActualTime = item.ActualTime;
 | 
						|
                    newHotProessItem.RecordChartNo = item.RecordChartNo;
 | 
						|
                    newHotProessItem.HardnessReportNo = item.HardnessReportNo;
 | 
						|
                    BLL.HotProessManageEditService.AddHotProessItem(newHotProessItem, this.txtHotProessNo.Text, this.txtProessDate.Text.Trim());
 | 
						|
                }
 | 
						|
                ShowNotify("保存成功!", MessageBoxIcon.Success);
 | 
						|
                InitTreeMenu();
 | 
						|
                viewHotProessItems.Clear();
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion  
 | 
						|
 | 
						|
        #region DropDownList下拉选择事件
 | 
						|
        /// <summary>
 | 
						|
        /// 单位下拉选择事件
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            this.drpInstallationId.Items.Clear();
 | 
						|
            if (!string.IsNullOrEmpty(this.drpUnit.SelectedValue) && this.drpUnit.SelectedValue != BLL.Const._Null)
 | 
						|
            {
 | 
						|
                //if (BLL.WorkAreaService.IsSupervisor(this.CurrUser.UnitId, this.CurrUser.LoginProjectId))
 | 
						|
                //{
 | 
						|
                //    BLL.Project_InstallationService.InitInstallationBySupervisorUnitIdListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpUnit.SelectedValue, this.CurrUser.UnitId, true);
 | 
						|
                //    this.drpInstallationId.SelectedIndex = 0;
 | 
						|
                //}
 | 
						|
                //else
 | 
						|
                //{
 | 
						|
                //    BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpUnit.SelectedValue, true);
 | 
						|
                //    this.drpInstallationId.SelectedIndex = 0;
 | 
						|
                //}
 | 
						|
                BLL.Project_InstallationService.InitInstallationListDownList(this.drpInstallationId, this.CurrUser.LoginProjectId, this.drpUnit.SelectedValue, true);
 | 
						|
                this.drpInstallationId.SelectedIndex = 0;
 | 
						|
 | 
						|
                //加载编号            
 | 
						|
                string prefixCode = string.Empty;
 | 
						|
                var tccCode = BLL.UnitService.GetUnitCodeByUnitId(BLL.Const.UnitId_CD);
 | 
						|
                var unitCode = BLL.UnitService.GetUnitCodeByUnitId(this.drpUnit.SelectedValue);
 | 
						|
                if (!string.IsNullOrEmpty(tccCode))
 | 
						|
                {
 | 
						|
                    prefixCode = tccCode + "-" + unitCode + "-PWHT-";
 | 
						|
                }
 | 
						|
                this.txtHotProessNo.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.HotProess", "HotProessNo", this.CurrUser.LoginProjectId, prefixCode);
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                Funs.FineUIPleaseSelect(this.drpInstallationId);
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 装置下拉选择事件
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void drpInstallationId_SelectedIndexChanged(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (this.drpUnit.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpUnit.SelectedValue) && this.drpInstallationId.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpInstallationId.SelectedValue))
 | 
						|
            {
 | 
						|
                //加载编号            
 | 
						|
                string prefixCode = string.Empty;
 | 
						|
                var tccCode = BLL.UnitService.GetUnitCodeByUnitId(BLL.Const.UnitId_CD);
 | 
						|
                var unitCode = BLL.UnitService.GetUnitCodeByUnitId(this.drpUnit.SelectedValue);
 | 
						|
                var area = BLL.WorkAreaService.GetWorkAreaByProjectIdAndInstalltionIdAndUnitId(this.CurrUser.LoginProjectId, this.drpInstallationId.SelectedValue, this.drpUnit.SelectedValue);
 | 
						|
                if (!string.IsNullOrEmpty(tccCode))
 | 
						|
                {
 | 
						|
                    prefixCode = tccCode + "-" + unitCode + "-" + area.WorkAreaCode + "-PWHT-";
 | 
						|
                }
 | 
						|
                this.txtHotProessNo.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.HotProess", "HotProessNo", this.CurrUser.LoginProjectId, prefixCode);
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 获取按钮权限
 | 
						|
        /// <summary>
 | 
						|
        /// 获取按钮权限
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="button"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        private bool GetButtonPower(string button)
 | 
						|
        {
 | 
						|
            return BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_HotProessManageMenuId, button);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
} |