279 lines
9.9 KiB
C#
279 lines
9.9 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.YLRQ.ConstructionManagement
|
|
{
|
|
public partial class WeldingManagement : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
BridProjectGrid();
|
|
BindGrid();
|
|
}
|
|
}
|
|
|
|
#region 绑定数据
|
|
|
|
/// <summary>
|
|
/// 绑定项目
|
|
/// </summary>
|
|
public void BridProjectGrid()
|
|
{
|
|
GridProject.DataSource = BLL.Base_ProjectService.GetYlrqProjectListByUserId(this.CurrUser.UserId, "2");
|
|
GridProject.DataBind();
|
|
drpProject.Value = this.CurrUser.LoginProjectId;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
public void BindGrid()
|
|
{
|
|
if (string.IsNullOrEmpty(drpProject.Value))
|
|
{
|
|
Grid1.DataSource = null;
|
|
Grid1.DataBind();
|
|
return;
|
|
}
|
|
|
|
string strSql = @"select a.WeldingId,a.ProjectId,a.WeldingCode,d.STE_Code as STE_Code1,a.TextureMaterial1,e.STE_Code as STE_Code2,a.TextureMaterial2,a.WeldLength,f.JST_Name,a.GrooveType,a.Thickness,a.HeatTreatmentType,a.CreateId,a.CreateTime,a.SortField,c.UserName from PV_WeldInformation as a inner join Base_Project as b on a.ProjectId=b.ProjectId left join Sys_User as c on c.UserId=a.CreateId left join HJGL_BS_Steel as d on d.STE_ID=a.TextureMaterial1 left join HJGL_BS_Steel as e on e.STE_ID=a.TextureMaterial2 left join HJGL_BS_SlopeType as f on f.JST_ID=a.GrooveType where 1=1 and a.ProjectId=@ProjectId order by SortField asc ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", drpProject.Value));
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
// 2.获取当前分页数据
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 施工号下拉框
|
|
/// </summary>
|
|
protected void drpProject_TextChanged(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 热处理类型名称
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected string ConvertProessTypes(object ProessTypes)
|
|
{
|
|
string proessTypes = string.Empty;
|
|
if (ProessTypes != null)
|
|
{
|
|
proessTypes = BLL.HJGL_PW_JointInfoService.ConvertProessTypes(ProessTypes.ToString());
|
|
}
|
|
|
|
return proessTypes;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭弹出框执行
|
|
/// </summary>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 分页排序
|
|
/// <summary>
|
|
/// 页索引改变事件
|
|
/// </summary>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页选择下拉改变事件
|
|
/// </summary>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 按钮操作
|
|
|
|
/// <summary>
|
|
/// 添加
|
|
/// </summary>
|
|
protected void btnAdd_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.PV_WeldingManagement, Const.BtnAdd))
|
|
{
|
|
if (!string.IsNullOrEmpty(drpProject.Value))
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldingManagementEdit.aspx?WeldingId={0}&ProjectId={1}", "", drpProject.Value, "新增 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("请先选择施工号!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 批量增加
|
|
/// </summary>
|
|
protected void btnBatchAdd_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.PV_WeldingManagement, Const.BtnAdd))
|
|
{
|
|
if (!string.IsNullOrEmpty(drpProject.Value))
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldingManagementBatchEdit.aspx?WeldingId={0}&ProjectId={1}", "", drpProject.Value, "新增 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("请先选择施工号!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑
|
|
/// </summary>
|
|
protected void btnEdit_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.PV_WeldingManagement, Const.BtnModify))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
int row = Grid1.SelectedRowIndexArray[0];
|
|
if (!string.IsNullOrEmpty(drpProject.Value))
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldingManagementEdit.aspx?WeldingId={0}&ProjectId={1}", Grid1.DataKeys[row][0], drpProject.Value, "新增 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("请先选择施工号!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
protected void btnDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.PV_WeldingManagement, Const.BtnDelete))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
try
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
if (Funs.DB.PV_ManagementMethod.Count(p => p.WeldingId == rowID) > 0)
|
|
{
|
|
ShowNotify("当前焊缝已存在焊接方法,无法进行删除操作!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
var model = Funs.DB.PV_WeldInformation.FirstOrDefault(p => p.WeldingId == rowID);
|
|
Funs.DB.PV_WeldInformation.DeleteOnSubmit(model);
|
|
}
|
|
Funs.DB.SubmitChanges();
|
|
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
|
BindGrid();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ShowNotify(ex.Message, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出
|
|
/// </summary>
|
|
protected void btnExport_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.PV_WeldingManagement, Const.BtnIn))
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Grid双击事件
|
|
/// </summary>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
int row = Grid1.SelectedRowIndexArray[0];
|
|
if (!string.IsNullOrEmpty(drpProject.Value))
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldingManagementEdit.aspx?WeldingId={0}&ProjectId={1}", Grid1.DataKeys[row][0], drpProject.Value, "新增 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("请先选择施工号!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 变颜色
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
|
|
{
|
|
//e.CellCssClasses[joint.ColumnIndex] = "color";
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
} |