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 绑定数据 /// /// 绑定项目 /// public void BridProjectGrid() { GridProject.DataSource = BLL.Base_ProjectService.GetYlrqProjectListByUserId(this.CurrUser.UserId, "2"); GridProject.DataBind(); drpProject.Value = this.CurrUser.LoginProjectId; } /// /// 绑定数据 /// 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 listStr = new List(); 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(); } /// /// 施工号下拉框 /// protected void drpProject_TextChanged(object sender, EventArgs e) { BindGrid(); } /// /// 热处理类型名称 /// /// protected string ConvertProessTypes(object ProessTypes) { string proessTypes = string.Empty; if (ProessTypes != null) { proessTypes = BLL.HJGL_PW_JointInfoService.ConvertProessTypes(ProessTypes.ToString()); } return proessTypes; } /// /// 关闭弹出框执行 /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { this.BindGrid(); } #endregion #region 分页排序 /// /// 页索引改变事件 /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { BindGrid(); } /// /// 排序 /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { BindGrid(); } /// /// 分页选择下拉改变事件 /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } #endregion #region 按钮操作 /// /// 添加 /// 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); } } /// /// 批量增加 /// 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); } } /// /// 编辑 /// 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); } } /// /// 删除 /// 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); } } /// /// 导出 /// 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); } } /// /// Grid双击事件 /// 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); } } /// /// 变颜色 /// /// /// protected void Grid1_RowDataBound(object sender, GridRowEventArgs e) { //e.CellCssClasses[joint.ColumnIndex] = "color"; } #endregion } }