using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using BLL; namespace FineUIPro.Web.WeldingProcess.WeldingManage { public partial class WeldReportItemEdit : PageBase { #region 定义项 /// /// 单位主键 /// public string UnitId { get { return (string)ViewState["UnitId"]; } set { ViewState["UnitId"] = value; } } /// /// 装置主键 /// public string InstallationId { get { return (string)ViewState["InstallationId"]; } set { ViewState["InstallationId"] = value; } } /// /// 焊口主键 /// public string WeldJointId { get { return (string)ViewState["WeldJointId"]; } set { ViewState["WeldJointId"] = value; } } /// /// 日报主键 /// public string WeldingDailyId { get { return (string)ViewState["WeldingDailyId"]; } set { ViewState["WeldingDailyId"] = value; } } /// /// 被选择项列表 /// public List SelectedList { get { return (List)ViewState["SelectedList"]; } set { ViewState["SelectedList"] = value; } } #endregion #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.SelectedList = new List(); //this.NoSelectedList = new List(); string strList = Request.Params["strList"]; List list = Funs.GetStrListByStr(strList, '|'); if (list.Count() == 3) { this.InstallationId = list[0]; this.UnitId = list[1]; this.WeldingDailyId = list[2]; ///盖面焊工 BLL.WelderService.InitProjectWelderDropDownList(this.drpCoverWelderId, true, CurrUser.LoginProjectId, this.UnitId, Resources.Lan.PleaseSelect); ///打底焊工 BLL.WelderService.InitProjectWelderDropDownList(this.drpBackingWelderId, true, CurrUser.LoginProjectId, this.UnitId, Resources.Lan.PleaseSelect); } this.InitTreeMenu();//加载树 } } #endregion #region 加载树 /// /// 加载树 /// private void InitTreeMenu() { this.tvControlItem.Nodes.Clear(); TreeNode rootNode = new TreeNode(); rootNode.Text = Resources.Lan.PipelineCode; rootNode.NodeID = "0"; rootNode.Expanded = true; this.tvControlItem.Nodes.Add(rootNode); var iso = (from x in Funs.DB.Pipeline_Pipeline where x.InstallationId == this.InstallationId && x.UnitId == this.UnitId orderby x.PipelineCode select x).ToList(); if (!string.IsNullOrEmpty(this.txtPipelineCode.Text)) { iso = (from x in iso where x.PipelineCode.Contains(this.txtPipelineCode.Text.Trim()) orderby x.PipelineCode select x).ToList(); } foreach (var item in iso) { TreeNode newNode = new TreeNode(); newNode.Text = item.PipelineCode; newNode.NodeID = item.PipelineId; newNode.ToolTip = item.PipelineCode; newNode.EnableClickEvent = true; rootNode.Nodes.Add(newNode); } } #endregion #region 数据绑定 /// /// 数据绑定 /// private void BindGrid() { string pipelineId = this.tvControlItem.SelectedNodeID; string strSql = @"SELECT jot.WeldJointId,jot.WeldJointCode,jot.Dia,jot.Thickness, method.WeldingMethodCode FROM dbo.Pipeline_WeldJoint jot LEFT JOIN dbo.Pipeline_Pipeline iso ON iso.PipelineId = jot.PipelineId LEFT JOIN dbo.Pipeline_PreWeldingDaily preJot ON preJot.WeldJointId = jot.WeldJointId LEFT JOIN dbo.Base_WeldingMethod method ON method.WeldingMethodId = jot.WeldingMethodId WHERE iso.InstallationId IS NOT NULL AND jot.WeldTypeId IS NOT NULL AND iso.DetectionRateId IS NOT NULL AND preJot.PreWeldingDailyId IS NULL AND (jot.WeldingDailyId IS NULL OR jot.WeldingDailyId=@WeldingDailyId) AND jot.ProjectId=@ProjectId AND jot.PipelineId=@PipelineId"; List listStr = new List(); listStr.Add(new SqlParameter("@WeldingDailyId", this.WeldingDailyId)); listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId)); listStr.Add(new SqlParameter("@PipelineId", pipelineId)); strSql += " ORDER BY CONVERT(INT,dbo.Fun_GetParseInt(jot.WeldJointCode))"; SqlParameter[] parameter = listStr.ToArray(); DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter); string weldJointIds = Request.Params["weldJointIds"]; if (!string.IsNullOrEmpty(weldJointIds)) { string[] jots = weldJointIds.Split('|'); foreach (string jotId in jots) { DataRow r = dt.Select("WeldJointId='" + jotId + "'").FirstOrDefault(); if (r != null) { dt.Rows.Remove(r); } } } // 2.获取当前分页数据 Grid1.RecordCount = dt.Rows.Count; Grid1.DataSource = dt; Grid1.DataBind(); #region 暂不用这个方法 //List toDoMatterList = BLL.Pipeline_WeldingDailyService.GetWeldReportItemFind(this.CurrUser.LoginProjectId, this.WeldingDailyId, pipelineId); //if (!string.IsNullOrEmpty(weldJointIds)) //{ // string[] weldJoints = weldJointIds.Split('|'); // foreach (string weldJointId in weldJoints) // { // Model.SpWeldingDailyItem item = toDoMatterList.FirstOrDefault(e => e.WeldJointId == weldJointId); // if (item != null) // { // toDoMatterList.Remove(item); // } // } //} //DataTable tb = this.LINQToDataTable(toDoMatterList); //// 2.获取当前分页数据 //Grid1.RecordCount = tb.Rows.Count; //var table = this.GetPagedDataTable(Grid1, tb); //Grid1.DataSource = table; //Grid1.DataBind(); //string[] arr = new string[this.Grid1.Rows.Count]; //int a = 0; //for (int i = 0; i < this.Grid1.Rows.Count; i++) //{ // string rowId = this.Grid1.Rows[i].DataKeys[0].ToString(); // if (weldJointIds.Contains(rowId)) // { // arr[a] = rowId; // } // a++; //} //Grid1.SelectedRowIDArray = arr; #endregion } #endregion #region 管线查询 /// /// 查询 /// /// /// protected void btnQuery_Click(object sender, EventArgs e) { this.InitTreeMenu(); this.BindGrid(); } #endregion #region 点击TreeView /// /// 点击TreeView /// /// /// protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e) { string[] selectRowId = Grid1.SelectedRowIDArray; for (int i = 0; i < this.Grid1.Rows.Count; i++) { string rowId = this.Grid1.Rows[i].DataKeys[0].ToString(); if (selectRowId.Contains(rowId)) { SelectedList.Add(rowId); } //else //{ // NoSelectedList.Add(rowId); //} } this.BindGrid(); } #endregion #region DropDownList下拉事件 /// /// 盖面、打底焊工一致 /// /// /// protected void drpCoverWelderId_OnSelectedIndexChanged(object sender, EventArgs e) { this.drpBackingWelderId.SelectedValue = this.drpCoverWelderId.SelectedValue; } #endregion #region 排序 /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { this.BindGrid(); } #endregion #region 提交按钮 /// /// 提交按钮 /// /// /// protected void btnAccept_Click(object sender, EventArgs e) { if (this.drpCoverWelderId.SelectedValue != Const._Null && this.drpBackingWelderId.SelectedValue != Const._Null) { string itemsString = string.Empty; string[] selectRowId = Grid1.SelectedRowIDArray; for (int i = 0; i < this.Grid1.Rows.Count; i++) { string rowId = this.Grid1.Rows[i].DataKeys[0].ToString(); if (selectRowId.Contains(rowId)) { SelectedList.Add(rowId); } } string weldJointIds = Request.Params["weldJointIds"]; if (!string.IsNullOrEmpty(weldJointIds)) { string[] jots = weldJointIds.Split('|'); foreach (string jotId in jots) { SelectedList.Add(jotId); } } itemsString = this.drpCoverWelderId.SelectedValue + "|" + this.drpBackingWelderId.SelectedValue + "#"; foreach (var item in SelectedList) { if (!itemsString.Contains(item)) { itemsString += item + "|"; } } PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(itemsString) + ActiveWindow.GetHidePostBackReference()); } else { ShowNotify(Resources.Lan.PleaseSelectWelder, MessageBoxIcon.Warning); return; } } #endregion } }