using System; using System.Collections.Generic; using BLL; using System.Data.SqlClient; using System.Data; namespace FineUIPro.Web.HJGLServer.BaseInfo { public partial class WeldControl : PageBase { #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); this.drpExecStandardId.DataTextField = "ExecStandardName"; this.drpExecStandardId.DataValueField = "ExecStandardId"; this.drpExecStandardId.DataSource = BLL.HJGL_ExecStandardService.GetExecStandardNameList(); this.drpExecStandardId.DataBind(); Funs.FineUIPleaseSelect(drpExecStandardId); this.drpISC_ID.DataTextField = "ISC_IsoName"; this.drpISC_ID.DataValueField = "ISC_ID"; this.drpISC_ID.DataSource = BLL.HJGL_PipingClassService.GetIsoClassNameList(); this.drpISC_ID.DataBind(); Funs.FineUIPleaseSelect(drpISC_ID); this.drpJoty_Rate.DataTextField = "NDTR_Rate"; this.drpJoty_Rate.DataValueField = "NDTR_ID"; this.drpJoty_Rate.DataSource = BLL.HJGL_DetectionService.GetNDTRateNameList(); this.drpJoty_Rate.DataBind(); Funs.FineUIPleaseSelect(this.drpJoty_Rate); this.drpJoty_C_Rate.DataTextField = "NDTR_Rate"; this.drpJoty_C_Rate.DataValueField = "NDTR_ID"; this.drpJoty_C_Rate.DataSource = BLL.HJGL_DetectionService.GetNDTRateNameList(); this.drpJoty_C_Rate.DataBind(); Funs.FineUIPleaseSelect(this.drpJoty_C_Rate); this.drpJoty_D_Rate.DataTextField = "NDTR_Rate"; this.drpJoty_D_Rate.DataValueField = "NDTR_ID"; this.drpJoty_D_Rate.DataSource = BLL.HJGL_DetectionService.GetNDTRateNameList(); this.drpJoty_D_Rate.DataBind(); Funs.FineUIPleaseSelect(this.drpJoty_D_Rate); this.drpJoty_Level.DataTextField = "Text"; this.drpJoty_Level.DataValueField = "Value"; this.drpJoty_Level.DataSource = BLL.DropListService.HJGL_Joty_LevelItem(); this.drpJoty_Level.DataBind(); Funs.FineUIPleaseSelect(this.drpJoty_Level); this.drpJoty_C_Level.DataTextField = "Text"; this.drpJoty_C_Level.DataValueField = "Value"; this.drpJoty_C_Level.DataSource = BLL.DropListService.HJGL_Joty_LevelItem(); this.drpJoty_C_Level.DataBind(); Funs.FineUIPleaseSelect(this.drpJoty_C_Level); this.drpJoty_D_Level.DataTextField = "Text"; this.drpJoty_D_Level.DataValueField = "Value"; this.drpJoty_D_Level.DataSource = BLL.DropListService.HJGL_Joty_LevelItem(); this.drpJoty_D_Level.DataBind(); Funs.FineUIPleaseSelect(this.drpJoty_D_Level); // 绑定表格 BindGrid(); } } #endregion #region 绑定数据 /// /// 绑定数据 /// private void BindGrid() { string strSql = @"SELECT WeldControl.WeldControlId" + @", WeldControl.ExecStandardId" + @", WeldControl.ISC_ID" + @", WeldControl.JotyId" + @", WeldControl.Joty_Rate" + @", Rate1.NDTR_Name AS Joty_RateName" + @", WeldControl.Joty_Level" + @", WeldControl.JotyId_C" + @", WeldControl.Joty_C_Rate" + @", Rate2.NDTR_Name AS Joty_C_RateName" + @", WeldControl.Joty_C_Level" + @", WeldControl.JotyId_D" + @", WeldControl.Joty_D_Rate" + @", Rate3.NDTR_Name AS Joty_D_RateName" + @", WeldControl.Joty_D_Level" + @", ExecStandard.ExecStandardName" + @", IsoClass.ISC_IsoName" + @" FROM HJGL_BS_WeldControl AS WeldControl" + @" LEFT JOIN HJGL_BS_ExecStandard AS ExecStandard ON ExecStandard.ExecStandardId = WeldControl.ExecStandardId " + @" LEFT JOIN HJGL_BS_IsoClass AS IsoClass ON IsoClass.ISC_ID = WeldControl.ISC_ID " + @" LEFT JOIN HJGL_BS_NDTRate AS Rate1 ON Rate1.NDTR_ID = WeldControl.Joty_Rate " + @" LEFT JOIN HJGL_BS_NDTRate AS Rate2 ON Rate2.NDTR_ID = WeldControl.Joty_C_Rate " + @" LEFT JOIN HJGL_BS_NDTRate AS Rate3 ON Rate3.NDTR_ID = WeldControl.Joty_D_Rate " + @" WHERE 1=1"; List listStr = new List(); if (!string.IsNullOrEmpty(this.txtExecStandardNameS.Text.Trim())) { strSql += " AND ExecStandard.ExecStandardName LIKE @ExecStandardName"; listStr.Add(new SqlParameter("@ExecStandardName", "%" + this.txtExecStandardNameS.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.txtISC_IsoNameS.Text.Trim())) { strSql += " AND IsoClass.ISC_IsoName LIKE @ISC_IsoName"; listStr.Add(new SqlParameter("@ISC_IsoName", "%" + this.txtISC_IsoNameS.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(); } #endregion #region 分页排序 /// /// /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } /// /// 分页下拉选择 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } /// /// /// /// /// protected void Grid1_FilterChange(object sender, EventArgs e) { BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; BindGrid(); } #endregion #region 删除事件 /// /// 删除 /// /// /// protected void btnDelete_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldControlMenuId, Const.BtnDelete)) { if (judgementDelete(hfFormID.Text, true)) { BLL.HJGL_WeldControlService.DeleteWeldControlById(hfFormID.Text); BLL.Sys_LogService.AddLog(BLL.Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除焊缝检测比例对照表"); // 重新绑定表格,并模拟点击[新增按钮] BindGrid(); PageContext.RegisterStartupScript("onNewButtonClick();"); } } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } /// /// 右键删除事件 /// /// /// protected void btnMenuDelete_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldControlMenuId, Const.BtnDelete)) { this.DeleteData(); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } /// /// 删除方法 /// private void DeleteData() { if (Grid1.SelectedRowIndexArray.Length > 0) { bool isShow = true; if (Grid1.SelectedRowIndexArray.Length > 1) { isShow = false; } foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); if (judgementDelete(rowID, isShow)) { BLL.HJGL_WeldControlService.DeleteWeldControlById(rowID); BLL.Sys_LogService.AddLog(BLL.Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除焊缝检测比例对照表"); Alert.ShowInTop("删除完成!", MessageBoxIcon.Success); } } BindGrid(); PageContext.RegisterStartupScript("onNewButtonClick();"); } } #endregion #region 编辑 /// /// 右键编辑事件 /// /// /// protected void btnMenuEdit_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldControlMenuId, Const.BtnModify)) { this.EditData(); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } /// /// 编辑数据方法 /// private void EditData() { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string Id = Grid1.SelectedRowID; var weldControl = BLL.HJGL_WeldControlService.GetWeldControlById(Id); if (weldControl != null) { if (!string.IsNullOrEmpty(weldControl.ExecStandardId)) { this.drpExecStandardId.SelectedValue = weldControl.ExecStandardId; } if (!string.IsNullOrEmpty(weldControl.ISC_ID)) { this.drpISC_ID.SelectedValue = weldControl.ISC_ID; } if (!string.IsNullOrEmpty(weldControl.Joty_Rate)) { this.drpJoty_Rate.SelectedValue = weldControl.Joty_Rate; } if (!string.IsNullOrEmpty(weldControl.Joty_Level)) { this.drpJoty_Level.SelectedValue = weldControl.Joty_Level; } if (!string.IsNullOrEmpty(weldControl.Joty_C_Rate)) { this.drpJoty_C_Rate.SelectedValue = weldControl.Joty_C_Rate; } if (!string.IsNullOrEmpty(weldControl.Joty_C_Level)) { this.drpJoty_C_Level.SelectedValue = weldControl.Joty_C_Level; } if (!string.IsNullOrEmpty(weldControl.Joty_D_Rate)) { this.drpJoty_D_Rate.SelectedValue = weldControl.Joty_D_Rate; } if (!string.IsNullOrEmpty(weldControl.Joty_D_Level)) { this.drpJoty_D_Level.SelectedValue = weldControl.Joty_D_Level; } hfFormID.Text = Id; this.btnDelete.Enabled = true; } } #endregion #region 提交按钮 /// /// 提交按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldControlMenuId, Const.BtnSave)) { string strRowID = hfFormID.Text; Model.HJGL_BS_WeldControl newWeldControl = new Model.HJGL_BS_WeldControl(); if (this.drpExecStandardId.SelectedValue != BLL.Const._Null) { newWeldControl.ExecStandardId = this.drpExecStandardId.SelectedValue; } else { Alert.ShowInTop("请选择执行标准", MessageBoxIcon.Warning); return; } if (this.drpISC_ID.SelectedValue != BLL.Const._Null) { newWeldControl.ISC_ID = this.drpISC_ID.SelectedValue; } if (this.drpJoty_Rate.SelectedValue != BLL.Const._Null) { newWeldControl.Joty_Rate = this.drpJoty_Rate.SelectedValue; } if (this.drpJoty_Level.SelectedValue != BLL.Const._Null) { newWeldControl.Joty_Level = this.drpJoty_Level.SelectedValue; } if (this.drpJoty_C_Rate.SelectedValue != BLL.Const._Null) { newWeldControl.Joty_C_Rate = this.drpJoty_C_Rate.SelectedValue; } if (this.drpJoty_C_Level.SelectedValue != BLL.Const._Null) { newWeldControl.Joty_C_Level = this.drpJoty_C_Level.SelectedValue; } if (this.drpJoty_D_Rate.SelectedValue != BLL.Const._Null) { newWeldControl.Joty_D_Rate = this.drpJoty_D_Rate.SelectedValue; } if (this.drpJoty_D_Level.SelectedValue != BLL.Const._Null) { newWeldControl.Joty_D_Level = this.drpJoty_D_Level.SelectedValue; } if (!string.IsNullOrEmpty(strRowID)) { newWeldControl.WeldControlId = strRowID; BLL.HJGL_WeldControlService.UpdateWeldControl(newWeldControl); BLL.Sys_LogService.AddLog(BLL.Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "修改焊缝检测比例对照表"); } else { newWeldControl.WeldControlId = SQLHelper.GetNewID(typeof(Model.HJGL_BS_WeldControl)); BLL.HJGL_WeldControlService.AddWeldControl(newWeldControl); BLL.Sys_LogService.AddLog(BLL.Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "添加焊缝检测比例对照表"); } // 重新绑定表格,并点击当前编辑或者新增的行 BindGrid(); Alert.ShowInTop("提交成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript("onNewButtonClick();"); //PageContext.RegisterStartupScript(String.Format("F('{0}').selectRow('{1}');", Grid1.ClientID, UnitQualitySort.UnitQualitySortId)); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } #endregion #region 判断是否可删除 /// /// 判断是否可以删除 /// /// private bool judgementDelete(string id, bool isShow) { string content = string.Empty; //if (BLL.HJGL_PW_IsoInfoService.GetIsoInfoByNDTID(id) > 0) //{ // content = "管线中已经使用了该探伤类型,不能删除!"; //} //if (BLL.HJGL_PW_JointInfoService.GetJointInfoByRepairID1(id) > 0) //{ // content = "焊口中已经使用该探伤类型,不能删除!"; //} if (string.IsNullOrEmpty(content)) { return true; } else { if (isShow) { Alert.ShowInTop(content, MessageBoxIcon.Error); } return false; } } #endregion #region 查询 /// /// 查询 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } #endregion } }