using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Data; using BLL; namespace FineUIPro.Web.WeldMat.UsingSentMat { public partial class UsingtMatSelect : PageBase { #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); // 绑定表格 BindGrid(); } } /// /// 绑定数据 /// private void BindGrid() { string strSql = @"SELECT UsingMat.UsingMatId, UsingMat.ProjectId, UsingMat.UsePosition, UsingMat.WeldId,UsingMat.UsingPlanId,ISNULL(UsingMat.Amount,0) AS Amount, ISNULL(UsingMat.TwoAmount,0) AS TwoAmount,UsingMat.UsingMan, UsingMat.UsingDate, (CASE WHEN stockIn.Warrantybook IS NOT NULL THEN stockIn.Warrantybook ELSE UsingMat.Warrantybook END) AS Warrantybook, UsingMat.Number,Project.ProjectCode,Project.ProjectName,WeldInfo.WeldCode, WeldInfo.WeldName,WeldInfo.WeldSpec,Welder.WED_Code AS WelderCode, Welder.WED_Name AS UsingManName,team.TeamGroupName,UsingPlan.InPutDate, (CASE WHEN UsingPlan.InPutMan IS NOT NULL THEN (CASE WHEN userInput.UserName IS NOT NULL THEN userInput.UserName ELSE welderInput.WED_Name END) ELSE '' END) AS InPutMan, --man.UserName AS InPutMan, unit.UnitName AS UsingUnit,unitStore.UnitStoreName FROM dbo.Weld_UsingMat AS UsingMat LEFT JOIN dbo.Base_Project AS Project ON Project.ProjectId = UsingMat.ProjectId LEFT JOIN dbo.Weld_WeldInfo AS WeldInfo ON WeldInfo.WeldId = UsingMat.WeldId LEFT JOIN HJGL_BS_Welder AS Welder ON Welder.WED_ID = UsingMat.UsingMan LEFT JOIN dbo.Weld_UsingPlan AS UsingPlan ON UsingPlan.UsingPlanId = UsingMat.UsingPlanId LEFT JOIN dbo.Weld_StockIn AS stockIn ON stockIn.StockInId = UsingMat.StockInId LEFT JOIN dbo.Base_TeamGroup team ON team.TeamGroupId = UsingPlan.TeamGroupId LEFT JOIN dbo.Sys_User AS userInput ON userInput.UserId=UsingPlan.InPutMan LEFT JOIN dbo.HJGL_BS_Welder AS welderInput ON welderInput.WED_ID=UsingPlan.InPutMan LEFT JOIN dbo.Base_Unit unit ON unit.UnitId=UsingPlan.UsingUnit LEFT JOIN dbo.Weld_UnitStore unitStore ON unitStore.UnitStoreId = stockIn.UnitStoreId WHERE 1=1"; List listStr = new List(); if (!string.IsNullOrEmpty(this.txtWelderCode.Text.Trim())) { strSql += " AND Welder.WED_Code LIKE @WelderCode"; listStr.Add(new SqlParameter("@WelderCode", "%" + this.txtWelderCode.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.txtTeamGroup.Text.Trim())) { strSql += " AND team.TeamGroupName LIKE @TeamGroupName"; listStr.Add(new SqlParameter("@TeamGroupName", "%" + this.txtTeamGroup.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.txtProjectCode.Text.Trim())) { strSql += " AND Project.ProjectCode LIKE @ProjectCode"; listStr.Add(new SqlParameter("@ProjectCode", "%" + this.txtProjectCode.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.txtWeldName.Text.Trim())) { strSql += " AND WeldInfo.WeldName LIKE @WeldName"; listStr.Add(new SqlParameter("@WeldName", "%" + this.txtWeldName.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.txtJOT_ID.Text.Trim())) { strSql += " AND UsingMat.UsePosition LIKE @UsePosition"; listStr.Add(new SqlParameter("@UsePosition", "%" + this.txtJOT_ID.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.txtUsingMan.Text.Trim())) { strSql += " AND Welder.WED_Name LIKE @WED_Name"; listStr.Add(new SqlParameter("@WED_Name", "%" + this.txtUsingMan.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.txtUsingUnit.Text.Trim())) { strSql += " AND unit.UnitName LIKE @UnitName"; listStr.Add(new SqlParameter("@UnitName", "%" + this.txtUsingUnit.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 页索引改变事件 /// /// 页索引改变事件 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } #endregion #region 排序 /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; BindGrid(); } #endregion #region 分页选择下拉改变事件 /// /// 分页选择下拉改变事件 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } #endregion protected void btnModify_Click(object sender, EventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.CLGL_UsingMatMenuId, BLL.Const.BtnModify)) { if (!string.IsNullOrEmpty(Grid1.SelectedRowID)) { PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("ModityWeld.aspx?usingMatId={0}", Grid1.SelectedRowID, "编辑 - "))); } else { ShowNotify("请选择要修改的记录!", MessageBoxIcon.Warning); } } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } protected void Window2_Close(object sender, EventArgs e) { BindGrid(); } #region 查询 /// /// 查询 /// /// /// protected void btnSearch_Click(object sender, EventArgs e) { BindGrid(); } #endregion #region Grid行点击事件 /// /// Grid行点击事件 /// /// /// protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == "print")//打印材料标签 { string reportId = BLL.Const.CLGL_MaterialLabelReportId; PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../../Common/ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId=0", reportId, this.Grid1.SelectedRowID, string.Empty, "打印 - "))); } } #endregion } }