327 lines
13 KiB
C#
327 lines
13 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace FineUIPro.Web.HJGL.WeldingManage
|
|
{
|
|
public partial class WeldingProcedureSearch : PageBase
|
|
{
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
BLL.Base_MaterialService.InitMaterialDropDownList(this.drpSte_NameS, true, this.CurrUser.LoginProjectId);
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
|
|
#region 绑定数据
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT weldingProcedure.WeldingProcedureId,
|
|
weldingProcedure.WeldingProcedureCode,
|
|
weldingProcedure.WType,
|
|
weldingProcedure.Material,
|
|
weldingProcedure.Specification,
|
|
weldingProcedure.Welding,
|
|
weldingProcedure.WRange,
|
|
weldingProcedure.Remark,
|
|
weldingProcedure.JointsForm,
|
|
weldingProcedure.TubeDiameter,
|
|
weldingProcedure.SpecimenThickness,
|
|
weldingProcedure.WeldMethod,
|
|
weldingProcedure.WeldPositionCode,
|
|
weldingProcedure.WeldPreheating,
|
|
weldingProcedure.PWHT,
|
|
material.MaterialType,
|
|
material.MaterialClass,
|
|
material.MaterialGroup"
|
|
+ @" FROM PW_WeldingProcedure AS weldingProcedure"
|
|
+ @" LEFT JOIN Base_Material material ON material.MaterialId = weldingProcedure.MaterialId WHERE ProjectId = '"+this.CurrUser.LoginProjectId+"' ";
|
|
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (!string.IsNullOrEmpty(this.txtWeldingProcedureIdS.Text.Trim()))
|
|
{
|
|
strSql += " AND weldingProcedure.WeldingProcedureCode LIKE @WeldingProcedureCode";
|
|
listStr.Add(new SqlParameter("@WeldingProcedureCode", "%" + this.txtWeldingProcedureIdS.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtSType.Text.Trim()))
|
|
{
|
|
strSql += " AND weldingProcedure.WType LIKE @WType";
|
|
listStr.Add(new SqlParameter("@WType", "%" + this.txtSType.Text.Trim() + "%"));
|
|
}
|
|
if (this.drpSte_NameS.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpSte_NameS.SelectedValue))
|
|
{
|
|
strSql += " AND weldingProcedure.MaterialId = @MaterialId";
|
|
listStr.Add(new SqlParameter("@MaterialId", this.drpSte_NameS.SelectedValue));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtSpecificationS.Text.Trim()))
|
|
{
|
|
strSql += " AND weldingProcedure.Specification LIKE @Specification";
|
|
listStr.Add(new SqlParameter("@Specification", "%" + this.txtSpecificationS.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtWeldingS.Text.Trim()))
|
|
{
|
|
strSql += " AND weldingProcedure.Welding LIKE @Welding";
|
|
listStr.Add(new SqlParameter("@Welding", "%" + this.txtWeldingS.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtWRangeS.Text.Trim()))
|
|
{
|
|
strSql += " AND weldingProcedure.WRange LIKE @WRange";
|
|
listStr.Add(new SqlParameter("@WRange", "%" + this.txtWRangeS.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtTubeDiameterS.Text.Trim()))
|
|
{
|
|
strSql += " AND weldingProcedure.TubeDiameter LIKE @TubeDiameter";
|
|
listStr.Add(new SqlParameter("@TubeDiameter", "%" + this.txtTubeDiameterS.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtJointsFormS.Text.Trim()))
|
|
{
|
|
strSql += " AND weldingProcedure.JointsForm LIKE @JointsForm";
|
|
listStr.Add(new SqlParameter("@JointsForm", "%" + this.txtJointsFormS.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtSpecimenThicknessS.Text.Trim()))
|
|
{
|
|
strSql += " AND weldingProcedure.SpecimenThickness LIKE @SpecimenThickness";
|
|
listStr.Add(new SqlParameter("@SpecimenThickness", "%" + this.txtSpecimenThicknessS.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtWeldMethodS.Text.Trim()))
|
|
{
|
|
strSql += " AND weldingProcedure.WeldMethod LIKE @WeldMethod";
|
|
listStr.Add(new SqlParameter("@WeldMethod", "%" + this.txtWeldMethodS.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtWeldPositionCodeS.Text.Trim()))
|
|
{
|
|
strSql += " AND weldingProcedure.WeldPositionCode LIKE @WeldPositionCode";
|
|
listStr.Add(new SqlParameter("@WeldPositionCode", "%" + this.txtWeldPositionCodeS.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtWeldPreheatingS.Text.Trim()))
|
|
{
|
|
strSql += " AND weldingProcedure.WeldPreheating LIKE @WeldPreheating";
|
|
listStr.Add(new SqlParameter("@WeldPreheating", "%" + this.txtWeldPreheatingS.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtPWHTS.Text.Trim()))
|
|
{
|
|
strSql += " AND weldingProcedure.PWHT LIKE @PWHT";
|
|
listStr.Add(new SqlParameter("@PWHT", "%" + this.txtPWHTS.Text.Trim() + "%"));
|
|
}
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
//tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 改变索引事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页下拉选择事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 增加按钮事件
|
|
/// <summary>
|
|
/// 增加按钮事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
if (GetButtonPower(Const.BtnAdd))
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldingProcedureSearchEdit.aspx", "新增 - ")));
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 编辑
|
|
/// <summary>
|
|
/// 双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
this.EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 右键编辑事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
|
{
|
|
this.EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑数据方法
|
|
/// </summary>
|
|
private void EditData()
|
|
{
|
|
if (GetButtonPower(Const.BtnModify))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldingProcedureSearchEdit.aspx?weldingProcedureId={0}", Grid1.SelectedRowID, "编辑 - ")));
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 右键删除事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (GetButtonPower(Const.BtnDelete))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
string strShowNotify = string.Empty;
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var weldingProcedure = BLL.WeldingProcedureService.GetWeldingProcedureByWeldingProcedureId(rowID);
|
|
if (weldingProcedure != null)
|
|
{
|
|
string cont = judgementDelete(rowID);
|
|
if (string.IsNullOrEmpty(cont))
|
|
{
|
|
BLL.WeldingProcedureService.DeleteWeldingProcedure(rowID);
|
|
}
|
|
else
|
|
{
|
|
strShowNotify += "焊接工艺评定" + ":" + weldingProcedure.WeldingProcedureCode + cont;
|
|
}
|
|
}
|
|
}
|
|
BindGrid();
|
|
if (!string.IsNullOrEmpty(strShowNotify))
|
|
{
|
|
Alert.ShowInTop(strShowNotify, MessageBoxIcon.Warning);
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
|
|
#region 判断是否可删除
|
|
/// <summary>
|
|
/// 判断是否可以删除
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private string judgementDelete(string id)
|
|
{
|
|
string content = string.Empty;
|
|
//if (Funs.DB.Pipeline_WeldJoint.FirstOrDefault(x => x.PipeAssembly1Id == id) != null)
|
|
//{
|
|
// content += "已在【焊口信息】中使用,不能删除!";
|
|
//}
|
|
|
|
return content;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#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_WeldingProcedureMenuId, button);
|
|
}
|
|
#endregion
|
|
}
|
|
} |