using System; using System.Collections.Generic; using System.Linq; using BLL; using System.Data.SqlClient; using System.Data; namespace FineUIPro.Web.HotProcessHard { public partial class HotProessTrust : PageBase { #region 定义项 /// /// 热处理委托主键 /// public string HotProessTrustId { get { return (string)ViewState["HotProessTrustId"]; } set { ViewState["HotProessTrustId"] = value; } } #endregion #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString(); this.HotProessTrustId = string.Empty; this.InitTreeMenu();//加载树 } } #endregion #region 加载树 /// /// 加载树 /// private void InitTreeMenu() { string projectName = string.Empty; var pro = BLL.Base_ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId); if (pro != null) { this.tvControlItem.Nodes.Clear(); TreeNode rootNode = new TreeNode(); rootNode.Text = "[" + pro.ProjectCode + "]" + pro.ProjectName; rootNode.NodeID = "0"; rootNode.Expanded = true; rootNode.EnableClickEvent = true; this.tvControlItem.Nodes.Add(rootNode); List trustLists = new List(); ///热处理委托单 if (!string.IsNullOrEmpty(this.txtSearchNo.Text.Trim())) { trustLists = (from x in Funs.DB.HotProess_Trust where x.ProjectId==CurrUser.LoginProjectId && x.HotProessTrustNo.Contains(this.txtSearchNo.Text.Trim()) orderby x.HotProessTrustNo select x).ToList(); } else { trustLists = (from x in Funs.DB.HotProess_Trust where x.ProjectId == CurrUser.LoginProjectId orderby x.HotProessTrustNo select x).ToList(); } this.BindNodes(rootNode, trustLists); } } #endregion #region 绑定树节点 /// /// 绑定树节点 /// /// private void BindNodes(TreeNode node, List trustList) { foreach (var item in trustList) { TreeNode newNode = new TreeNode(); newNode.Text = item.HotProessTrustNo; newNode.NodeID = item.HotProessTrustId; newNode.ToolTip = item.HotProessTrustNo; newNode.CommandName = Resources.Lan.RequestSheetNumber; newNode.EnableClickEvent = true; node.Nodes.Add(newNode); } } #endregion #region 点击TreeView /// /// 点击TreeView /// /// /// protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e) { if (this.tvControlItem.SelectedNodeID != "0") { this.HotProessTrustId = tvControlItem.SelectedNodeID; this.BindGrid(); } } #endregion #region DropDownList下拉选择事件 /// /// 项目下拉选择事件 /// /// /// protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e) { this.InitTreeMenu(); } #endregion #region 数据绑定 /// /// 数据绑定 /// private void BindGrid() { string strSql = string.Empty; List listStr = new List(); this.SetTextTemp(); this.PageInfoLoad(); ///页面输入提交信息 if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID)) { var hotProessTrust = BLL.HotProess_TrustService.GetHotProessTrustById(this.tvControlItem.SelectedNodeID); if (hotProessTrust != null) { this.HotProessTrustId = hotProessTrust.HotProessTrustId; strSql = @"SELECT * " + @" FROM dbo.View_HotProess_TrustItem AS Trust" + @" WHERE Trust.ProjectId= @ProjectId AND Trust.HotProessTrustId=@HotProessTrustId "; listStr.Add(new SqlParameter("@ProjectId", hotProessTrust != null ? hotProessTrust.ProjectId : this.CurrUser.LoginProjectId)); listStr.Add(new SqlParameter("@HotProessTrustId", this.HotProessTrustId)); if (!string.IsNullOrEmpty(this.txtIsoNo.Text.Trim())) { strSql += @" and Trust.PipelineCode like '%'+@PipelineCode+'%' "; listStr.Add(new SqlParameter("@PipelineCode", this.txtIsoNo.Text.Trim())); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); // 2.获取当前分页数据 //var table = this.GetPagedDataTable(Grid1, tb1); Grid1.RecordCount = tb.Rows.Count; //tb = GetFilteredTable(Grid1.FilteredData, tb); var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } } } /// /// 查询 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } #region 加载页面输入提交信息 /// /// 加载页面输入提交信息 /// private void PageInfoLoad() { var trust = BLL.HotProess_TrustService.GetHotProessTrustById(this.HotProessTrustId); if (trust != null) { this.txtHotProessTrustNo.Text = trust.HotProessTrustNo; if (trust.ProessDate.HasValue) { this.txtProessDate.Text = string.Format("{0:yyyy-MM-dd}", trust.ProessDate); } if (!string.IsNullOrEmpty(trust.InstallationId)) { this.txtInstallationName.Text = BLL.Project_InstallationService.GetProject_InstallationNameByInstallationId(trust.InstallationId); } if (!string.IsNullOrEmpty(trust.UnitId)) { this.txtUnitName.Text = BLL.Base_UnitService.GetUnitNameByUnitId(trust.UnitId); } this.txtProessMethod.Text = trust.ProessMethod; this.txtProessEquipment.Text = trust.ProessEquipment; if (!string.IsNullOrEmpty(trust.Tabler)) { this.txtTabler.Text = BLL.Sys_UserService.GetUserNameByUserId(trust.Tabler); } this.txtRemark.Text = trust.Remark; } } #endregion #region 清空文本 /// /// 清空文本 /// private void SetTextTemp() { this.txtHotProessTrustNo.Text = string.Empty; this.txtProessDate.Text = string.Empty; this.txtInstallationName.Text = string.Empty; this.txtUnitName.Text = string.Empty; this.txtProessMethod.Text = string.Empty; this.txtProessEquipment.Text = string.Empty; this.txtTabler.Text = string.Empty; this.txtRemark.Text = string.Empty; } #endregion #endregion #region 分页排序 #region 页索引改变事件 /// /// 页索引改变事件 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { BindGrid(); } #endregion #region 排序 /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { BindGrid(); } #endregion #region 分页选择下拉改变事件 /// /// 分页选择下拉改变事件 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } #endregion #endregion #region 热处理委托 维护事件 /// /// 增加热处理委托 /// /// /// protected void btnNew_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HotProessTrustMenuId, Const.BtnAdd)) { //if (this.tvControlItem.SelectedNode != null && this.tvControlItem.SelectedNodeID == this.CurrUser.LoginProjectId) //{ this.SetTextTemp(); string window = String.Format("HotProessTrustEdit.aspx?HotProessTrustId={0}", string.Empty, "新增 - "); PageContext.RegisterStartupScript(Window1.GetSaveStateReference(this.hdHotProessTrustId.ClientID) + Window1.GetShowReference(window)); //} //else //{ // ShowNotify(Resources.Lan.PleaseSelectProject, MessageBoxIcon.Warning); //} } else { ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); } } #region 编辑热处理委托 /// /// 编辑热处理委托 /// /// /// protected void btnEdit_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HotProessTrustMenuId, Const.BtnSave)) { var trustManage = BLL.HotProess_TrustService.GetHotProessTrustById(this.HotProessTrustId); if (trustManage != null) { string window = String.Format("HotProessTrustEdit.aspx?HotProessTrustId={0}", this.HotProessTrustId, "编辑 - "); PageContext.RegisterStartupScript(Window1.GetSaveStateReference(this.hdHotProessTrustId.ClientID) + Window1.GetShowReference(window)); } else { ShowNotify(Resources.Lan.PleaseSelectModifyHotProessTrust, MessageBoxIcon.Warning); } } else { ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); } } #endregion #region 删除热处理委托 /// /// 删除热处理委托 /// /// /// protected void btnDelete_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HotProessTrustMenuId, Const.BtnDelete)) { var trustManage = BLL.HotProess_TrustService.GetHotProessTrustById(this.HotProessTrustId); if (trustManage != null) { var hotProessItems = from x in Funs.DB.HotProess_TrustItem where x.HotProessTrustId == this.HotProessTrustId select x; foreach (var item in hotProessItems) { if (!string.IsNullOrEmpty(item.HotProessTrustItemId)) { var hotReort = (from x in Funs.DB.HotProess_Report where x.HotProessTrustItemId == item.HotProessTrustItemId select x).ToList(); if (hotReort.Count() > 0) { ShowNotify(Resources.Lan.HotReortExists, MessageBoxIcon.Warning); return; } } } BLL.HotProessTrustItemService.DeleteHotProessTrustItemById(this.HotProessTrustId); BLL.HotProess_TrustService.DeleteHotProessTrustById(this.HotProessTrustId); //BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Resources.Lan.DeleteHotProess); Alert.ShowInTop(Resources.Lan.DeletedSuccessfully, MessageBoxIcon.Success); this.InitTreeMenu(); SetTextTemp(); this.Grid1.DataSource = null; this.Grid1.DataBind(); } else { ShowNotify(Resources.Lan.PleaseSelectDeleteHotProessTrust, MessageBoxIcon.Warning); } } else { ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); return; } } #endregion #endregion #region 关闭弹出窗口及刷新页面 /// /// 关闭弹出窗口 /// /// /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { this.InitTreeMenu(); this.HotProessTrustId = this.hdHotProessTrustId.Text; this.tvControlItem.SelectedNodeID = this.HotProessTrustId; this.BindGrid(); this.hdHotProessTrustId.Text = string.Empty; } #region 查询 /// /// 查询 /// /// /// protected void Tree_TextChanged(object sender, EventArgs e) { this.InitTreeMenu(); } #endregion #endregion #region 右键编辑热处理报告 /// /// 热处理报告 /// /// /// protected void btnMenuHotProessReport_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HotProessTrustMenuId, Const.BtnSave)) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("HotProessReport.aspx?HotProessTrustItemId={0}", this.Grid1.SelectedRowID, "编辑热处理报告 - "))); } else { Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); } } #endregion } }