183 lines
		
	
	
		
			7.1 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			183 lines
		
	
	
		
			7.1 KiB
		
	
	
	
		
			C#
		
	
	
	
using BLL;
 | 
						|
using System;
 | 
						|
using System.Web;
 | 
						|
using System.Linq;
 | 
						|
using System.Data;
 | 
						|
using System.Text;
 | 
						|
 | 
						|
namespace FineUIPro.Web.HSSE.Solution
 | 
						|
{
 | 
						|
    public partial class ExpertArgumentListView : PageBase
 | 
						|
    {
 | 
						|
        #region 定义变量
 | 
						|
        /// <summary>
 | 
						|
        /// 主键
 | 
						|
        /// </summary>
 | 
						|
        public string LargerHazardListId
 | 
						|
        {
 | 
						|
            get
 | 
						|
            {
 | 
						|
                return (string)ViewState["LargerHazardListId"];
 | 
						|
            }
 | 
						|
            set
 | 
						|
            {
 | 
						|
                ViewState["LargerHazardListId"] = value;
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 加载页面
 | 
						|
        /// <summary>
 | 
						|
        /// 加载页面
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void Page_Load(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (!IsPostBack)
 | 
						|
            {              
 | 
						|
                this.btnClose.OnClientClick = ActiveWindow.GetHideReference();          
 | 
						|
                this.LargerHazardListId = Request.Params["LargerHazardListId"];
 | 
						|
               var getRecord = BLL.ExpertArgumentService.GetLargerHazardListById(LargerHazardListId);
 | 
						|
                if (getRecord != null)
 | 
						|
                {
 | 
						|
                    this.txtHazardCode.Text = getRecord.HazardCode;
 | 
						|
                    this.txtRecordTime.Text = string.Format("{0:yyyy-MM-dd}", getRecord.RecordTime);
 | 
						|
                    this.txtVersionNo.Text = getRecord.VersionNo;
 | 
						|
                    if (getRecord.States == Const.State_1 && this.CurrUser.UserId == Const.sysglyId)
 | 
						|
                    {
 | 
						|
                        var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectExpertArgumentMenuId);
 | 
						|
                        if (buttonList.Count() > 0)
 | 
						|
                        {
 | 
						|
                            if (buttonList.Contains(BLL.Const.BtnDelete))
 | 
						|
                            {
 | 
						|
                                this.btnCancel.Hidden = false;
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                // 绑定表格
 | 
						|
                BindGrid();
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 
 | 
						|
        /// </summary>
 | 
						|
        private void BindGrid()
 | 
						|
        {
 | 
						|
            var getView = from x in Funs.DB.View_Solution_LargerHazardListItem
 | 
						|
                          where x.LargerHazardListId == this.LargerHazardListId
 | 
						|
                          select x;
 | 
						|
            if (getView.Count() > 0)
 | 
						|
            {
 | 
						|
                Grid1.RecordCount = getView.Count();
 | 
						|
                DataTable tb = this.GetPagedDataTable(Grid1, getView.ToList());
 | 
						|
                Grid1.DataSource = tb;
 | 
						|
                Grid1.DataBind();
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                Grid1.DataSource = null;
 | 
						|
                Grid1.DataBind();
 | 
						|
            }
 | 
						|
        }
 | 
						|
               
 | 
						|
 | 
						|
        #region 作废按钮
 | 
						|
        /// <summary>
 | 
						|
        /// 保存按钮
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnCancel_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            var getData = BLL.ExpertArgumentService.GetLargerHazardListById(this.LargerHazardListId);
 | 
						|
            if (getData != null)
 | 
						|
            {
 | 
						|
                getData.States = "-1";
 | 
						|
                BLL.ExpertArgumentService.UpdateLargerHazardList(getData);
 | 
						|
            }
 | 
						|
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 保存数据
 | 
						|
        /// <summary>
 | 
						|
        /// 保存数据
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="type"></param>
 | 
						|
        private void SaveData(string type)
 | 
						|
        {
 | 
						|
            Model.Solution_LargerHazardList newRecord = new Model.Solution_LargerHazardList
 | 
						|
            {
 | 
						|
                LargerHazardListId = this.LargerHazardListId,
 | 
						|
                HazardCode = this.txtHazardCode.Text,
 | 
						|
                ProjectId = this.CurrUser.LoginProjectId,
 | 
						|
                RecordTime = Funs.GetNewDateTime(this.txtRecordTime.Text),
 | 
						|
                VersionNo = this.txtVersionNo.Text.Trim(),
 | 
						|
                RecardManId = this.CurrUser.UserId,
 | 
						|
                ////单据状态
 | 
						|
                States = BLL.Const.State_0,
 | 
						|
            };
 | 
						|
 | 
						|
            if (type == BLL.Const.BtnSubmit)
 | 
						|
            {
 | 
						|
                newRecord.States = BLL.Const.State_1;
 | 
						|
            }
 | 
						|
            if (!string.IsNullOrEmpty(this.LargerHazardListId))
 | 
						|
            {
 | 
						|
                BLL.ExpertArgumentService.UpdateLargerHazardList(newRecord);
 | 
						|
                BLL.LogService.AddSys_Log(this.CurrUser, newRecord.HazardCode, newRecord.LargerHazardListId, BLL.Const.ProjectExpertArgumentMenuId, BLL.Const.BtnModify);
 | 
						|
 | 
						|
                BLL.ExpertArgumentService.DeleteLargerHazardListItemByLargerHazardListId(this.LargerHazardListId);
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {                
 | 
						|
                this.LargerHazardListId = newRecord.LargerHazardListId = SQLHelper.GetNewID();
 | 
						|
                BLL.ExpertArgumentService.AddLargerHazardList(newRecord);
 | 
						|
                BLL.LogService.AddSys_Log(this.CurrUser, newRecord.HazardCode, newRecord.LargerHazardListId, BLL.Const.ProjectExpertArgumentMenuId, BLL.Const.BtnAdd);
 | 
						|
            }
 | 
						|
            var newListItems = from x in Funs.DB.Solution_LargerHazardListItem
 | 
						|
                               select new Model.Solution_LargerHazardListItem
 | 
						|
                               {
 | 
						|
                                   LargerHazardListItemId = x.LargerHazardListItemId,
 | 
						|
                                   SortIndex = x.SortIndex,
 | 
						|
                                   LargerHazardListId = this.LargerHazardListId,
 | 
						|
                                   UnitWorkId = x.UnitWorkId,
 | 
						|
                                   WorkPackageId = x.WorkPackageId,
 | 
						|
                                   WorkPackageSize = x.WorkPackageSize,
 | 
						|
                                   ExpectedStartTime = x.ExpectedStartTime,
 | 
						|
                                   ExpectedEndTime = x.ExpectedEndTime,
 | 
						|
                                   IsArgument = x.IsArgument,
 | 
						|
                                   UnitId = x.UnitId,
 | 
						|
                               };
 | 
						|
            if (newListItems != null && newListItems.Count() > 0)
 | 
						|
            {
 | 
						|
                Funs.DB.Solution_LargerHazardListItem.InsertAllOnSubmit(newListItems);
 | 
						|
                Funs.DB.SubmitChanges();
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion        
 | 
						|
 | 
						|
        #region 导出按钮
 | 
						|
        /// 导出按钮
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnOut_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            Response.ClearContent();
 | 
						|
            string filename = Funs.GetNewFileName();
 | 
						|
            Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("危大工程清单" + filename, System.Text.Encoding.UTF8) + ".xls");
 | 
						|
            Response.ContentType = "application/excel";
 | 
						|
            Response.ContentEncoding = Encoding.UTF8;
 | 
						|
            this.Grid1.PageSize = this.Grid1.RecordCount;
 | 
						|
            this.BindGrid();
 | 
						|
            Response.Write(GetGridTableHtml(Grid1));
 | 
						|
            Response.End();
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
} |