524 lines
20 KiB
C#
524 lines
20 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
using System.Data.SqlClient;
|
|
using BLL;
|
|
using System.Data;
|
|
using System.Text;
|
|
|
|
namespace FineUIPro.Web.HJGL.WeldingManage
|
|
{
|
|
public partial class WeldingProcessCard : PageBase
|
|
{
|
|
#region 加载页面
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
// 绑定表格
|
|
BindGrid();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = "SELECT Matcheds.MatchedProcedureMaterialId"
|
|
+ @",Matcheds.MaterialClass1"
|
|
+ @",Matcheds.MaterialGroup1"
|
|
+ @",Matcheds.STE_Name1"
|
|
+ @",Matcheds.MaterialClass2"
|
|
+ @",Matcheds.MaterialGroup2"
|
|
+ @",Matcheds.STE_Name2"
|
|
+ @",Matcheds.WME_Name"
|
|
+ @",Matcheds.Specifications"
|
|
+ @",Matcheds.Thickness"
|
|
+ @",Matcheds.Dia"
|
|
+ @",Matcheds.IsHotTreatmentName"
|
|
+ @",Matcheds.WeldingProcessCardCode"
|
|
+ @",Matcheds.WeldingProcessCardId"
|
|
+ @",Matcheds.State"
|
|
+ @" FROM HJGL_View_MatchedProcedureMaterial AS Matcheds WHERE 1=1 ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (this.rblState.SelectedValue == "1")
|
|
{
|
|
strSql += " AND (Matcheds.State IS NULL OR Matcheds.State = '1')";
|
|
}
|
|
else
|
|
{
|
|
string endStep = BLL.AudiFlowService.GetEndAuditFlowStep(BLL.Const.HJGL_WeldingProcessCardMenuId).AudiFlowStep.ToString();
|
|
if (!string.IsNullOrEmpty(endStep))
|
|
{
|
|
if (this.rblState.SelectedValue != endStep)
|
|
{
|
|
strSql += " AND ((Matcheds.WeldingProcessCardId IS NOT NULL) AND (Matcheds.State != @State))";
|
|
listStr.Add(new SqlParameter("@State", endStep));
|
|
}
|
|
else
|
|
{
|
|
strSql += " AND (Matcheds.State = @State)";
|
|
listStr.Add(new SqlParameter("@State", endStep));
|
|
}
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtMaterialClass1.Text.Trim()))
|
|
{
|
|
strSql += " AND Matcheds.MaterialClass1 LIKE @MaterialClass1";
|
|
listStr.Add(new SqlParameter("@MaterialClass1", "%" + this.txtMaterialClass1.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtMaterialGroup1.Text.Trim()))
|
|
{
|
|
strSql += " AND Matcheds.MaterialGroup1 LIKE @MaterialGroup1";
|
|
listStr.Add(new SqlParameter("@MaterialGroup1", "%" + this.txtMaterialGroup1.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtSTE_Name1.Text.Trim()))
|
|
{
|
|
strSql += " AND Matcheds.STE_Name1 LIKE @STE_Name1";
|
|
listStr.Add(new SqlParameter("@STE_Name1", "%" + this.txtSTE_Name1.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtMaterialClass2.Text.Trim()))
|
|
{
|
|
strSql += " AND Matcheds.MaterialClass2 LIKE @MaterialClass2";
|
|
listStr.Add(new SqlParameter("@MaterialClass2", "%" + this.txtMaterialClass2.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtMaterialGroup2.Text.Trim()))
|
|
{
|
|
strSql += " AND Matcheds.MaterialGroup2 LIKE @MaterialGroup2";
|
|
listStr.Add(new SqlParameter("@MaterialGroup2", "%" + this.txtMaterialGroup2.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtSTE_Name1.Text.Trim()))
|
|
{
|
|
strSql += " AND Matcheds.STE_Name2 LIKE @STE_Name2";
|
|
listStr.Add(new SqlParameter("@STE_Name2", "%" + this.txtSTE_Name2.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtWME_Code.Text.Trim()))
|
|
{
|
|
strSql += " AND Matcheds.WME_Name LIKE @WME_Name";
|
|
listStr.Add(new SqlParameter("@WME_Name", "%" + this.txtWME_Code.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtSpecifications.Text.Trim()))
|
|
{
|
|
strSql += " AND Matcheds.Specifications LIKE @Specifications";
|
|
listStr.Add(new SqlParameter("@Specifications", "%" + this.txtSpecifications.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtThickness.Text.Trim()))
|
|
{
|
|
strSql += " AND Matcheds.Thickness LIKE @Thickness";
|
|
listStr.Add(new SqlParameter("@Thickness", "%" + this.txtThickness.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtDia.Text.Trim()))
|
|
{
|
|
strSql += " AND Matcheds.Dia LIKE @Dia";
|
|
listStr.Add(new SqlParameter("@Dia", "%" + this.txtDia.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtIsHotTreatmentName.Text.Trim()))
|
|
{
|
|
strSql += " AND Matcheds.IsHotTreatmentName LIKE @IsHotTreatmentName";
|
|
listStr.Add(new SqlParameter("@IsHotTreatmentName", "%" + this.txtIsHotTreatmentName.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtWeldingProcedureCode.Text.Trim()))
|
|
{
|
|
strSql += " AND Matcheds.WeldingProcessCardCode LIKE @WeldingProcessCardCode";
|
|
listStr.Add(new SqlParameter("@WeldingProcessCardCode", "%" + this.txtWeldingProcedureCode.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();
|
|
}
|
|
#endregion
|
|
|
|
#region 表头过滤
|
|
protected void Grid1_FilterChange(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 页索引改变事件
|
|
/// <summary>
|
|
/// 页索引改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
Grid1.PageIndex = e.NewPageIndex;
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 排序
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
Grid1.SortDirection = e.SortDirection;
|
|
Grid1.SortField = e.SortField;
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 分页选择下拉改变事件
|
|
/// <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();
|
|
}
|
|
#endregion
|
|
|
|
#region 弹出编辑窗口关闭事件
|
|
/// <summary>
|
|
/// 弹出编辑窗体关闭事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 编辑
|
|
/// <summary>
|
|
/// 双击Grid事件
|
|
/// </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 (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_WeldingProcessCardMenuId, BLL.Const.BtnSave))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
if (!string.IsNullOrEmpty(id))
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldingProcessCardEdit.aspx?MatchedProcedureMaterialId={0}", id, "编辑 - ")));
|
|
}
|
|
}
|
|
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)
|
|
{
|
|
this.DeleteData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除方法
|
|
/// </summary>
|
|
private void DeleteData()
|
|
{
|
|
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_WeldingProcessCardMenuId, BLL.Const.BtnDelete))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
bool isShow = false;
|
|
if (Grid1.SelectedRowIndexArray.Length == 1)
|
|
{
|
|
isShow = true;
|
|
}
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
if (this.judgementDelete(rowID, isShow))
|
|
{
|
|
var match = BLL.HJGL_MatchedProcedureMaterialService.GetMatchedProcedureMaterialById(rowID);
|
|
if (match != null)
|
|
{
|
|
var weldingProcessCard = BLL.HJGL_WeldingProcessCardService.GetWeldingProcessCardById(match.WeldingProcessCardId);
|
|
if (weldingProcessCard != null)
|
|
{
|
|
BLL.AuditFlowApproveService.DeleteAuditFlowApprove(match.WeldingProcessCardId);
|
|
BLL.HJGL_WeldingProcessCardService.DeleteWeldingProcessCardById(match.WeldingProcessCardId);
|
|
}
|
|
BLL.AttachFileService.DeleteAttachFile(BLL.Funs.RootPath, rowID, BLL.Const.HJGL_WeldingProcessCardMenuId);//删除附件
|
|
BLL.HJGL_MatchedProcedureMaterialService.DeleteMatchedProcedureMaterialById(rowID);
|
|
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除焊接工艺卡");
|
|
}
|
|
}
|
|
}
|
|
this.BindGrid();
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 判断是否可删除
|
|
/// </summary>
|
|
/// <param name="rowID"></param>
|
|
/// <param name="isShow"></param>
|
|
/// <returns></returns>
|
|
private bool judgementDelete(string rowID, bool isShow)
|
|
{
|
|
string content = string.Empty;
|
|
if (string.IsNullOrEmpty(content))
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
if (isShow)
|
|
{
|
|
Alert.ShowInTop(content);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 导出按钮
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnExport_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 = System.Text.Encoding.UTF8;
|
|
this.Grid1.PageSize = 500;
|
|
this.BindGrid();
|
|
Response.Write(GetGridTableHtml(Grid1));
|
|
Response.End();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出方法
|
|
/// </summary>
|
|
/// <param name="grid"></param>
|
|
/// <returns></returns>
|
|
private string GetGridTableHtml(Grid grid)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
|
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
|
sb.Append("<tr>");
|
|
foreach (GridColumn column in grid.Columns)
|
|
{
|
|
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
|
}
|
|
sb.Append("</tr>");
|
|
foreach (GridRow row in grid.Rows)
|
|
{
|
|
sb.Append("<tr>");
|
|
foreach (GridColumn column in grid.Columns)
|
|
{
|
|
string html = row.Values[column.ColumnIndex].ToString();
|
|
if (column.ColumnID == "tfNumber")
|
|
{
|
|
html = (row.FindControl("lblNumber") as AspNet.Label).Text;
|
|
}
|
|
if (column.ColumnID == "tfStates")
|
|
{
|
|
html = (row.FindControl("lblState") as AspNet.Label).Text;
|
|
}
|
|
sb.AppendFormat("<td>{0}</td>", html);
|
|
}
|
|
|
|
sb.Append("</tr>");
|
|
}
|
|
|
|
sb.Append("</table>");
|
|
|
|
return sb.ToString();
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 状态筛选事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void rblState_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
this.Toolbar2.Hidden = false;
|
|
this.Toolbar3.Hidden = false;
|
|
this.Toolbar4.Hidden = false;
|
|
EmptyText();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 取消查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.Toolbar2.Hidden = true;
|
|
this.Toolbar3.Hidden = true;
|
|
this.Toolbar4.Hidden = true;
|
|
EmptyText();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 清空查询文本框中的值
|
|
/// </summary>
|
|
private void EmptyText()
|
|
{
|
|
this.txtMaterialClass1.Text = string.Empty;
|
|
this.txtMaterialGroup1.Text = string.Empty;
|
|
this.txtSTE_Name1.Text = string.Empty;
|
|
this.txtWME_Code.Text = string.Empty;
|
|
this.txtSpecifications.Text = string.Empty;
|
|
this.txtMaterialClass2.Text = string.Empty;
|
|
this.txtMaterialGroup2.Text = string.Empty;
|
|
this.txtSTE_Name2.Text = string.Empty;
|
|
this.txtThickness.Text = string.Empty;
|
|
this.txtDia.Text = string.Empty;
|
|
this.txtIsHotTreatmentName.Text = string.Empty;
|
|
this.txtWeldingProcedureCode.Text = string.Empty;
|
|
}
|
|
#endregion
|
|
|
|
#region 格式化字符串
|
|
/// <summary>
|
|
/// 把状态转换代号为文字形式
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertState(object st)
|
|
{
|
|
if (!string.IsNullOrEmpty(st.ToString()))
|
|
{
|
|
var s = BLL.AudiFlowService.GetAuditFlow(BLL.Const.HJGL_WeldingProcessCardMenuId, Convert.ToInt32(st));
|
|
if (s != null)
|
|
{
|
|
return s.AuditFlowName.ToString();
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
#endregion
|
|
|
|
#region 增加定稿文件
|
|
/// <summary>
|
|
/// 增加定稿文件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnFinalAdd_Click(object sender, EventArgs e)
|
|
{
|
|
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_WeldingProcessCardMenuId, BLL.Const.BtnAdd))
|
|
{
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("WeldingProcessCardFinalFile.aspx", "编辑 - ")));
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Grid行点击事件
|
|
/// <summary>
|
|
/// Grid行点击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
if (e.CommandName == "finalFile")
|
|
{
|
|
string id = Grid1.DataKeys[e.RowIndex][0].ToString();
|
|
Model.HJGL_WeldingProcedure_MatchedProcedureMaterial match = BLL.HJGL_MatchedProcedureMaterialService.GetMatchedProcedureMaterialById(id);
|
|
if (match.Flag == "1")
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/HJGL/WeldingProcessCard&menuId={1}&edit=0", id, BLL.Const.HJGL_WeldingProcessCardMenuId)));
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("不是定稿文件!");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
} |