190 lines
7.4 KiB
C#
190 lines
7.4 KiB
C#
using BLL;
|
||
using Model;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.Linq;
|
||
|
||
namespace FineUIPro.Web.DataShow
|
||
{
|
||
public partial class ConstructionEquipment : PageBase
|
||
{
|
||
#region 加载页面
|
||
/// <summary>
|
||
/// 加载页面
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
Funs.DropDownPageSize(this.ddlPageSize);
|
||
// btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
||
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
||
BLL.ProjectService.InitProjectDropDownList(this.drpProject, true);
|
||
// 绑定表格t
|
||
BindGrid();
|
||
this.Panel1.Title = "施工机具设备(" + BLL.UnitService.GetUnitNameByUnitId(BLL.Const.UnitId_CWCEC) + ")";
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 绑定数据
|
||
/// </summary>
|
||
private void BindGrid()
|
||
{
|
||
string strSql = string.Empty;
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
|
||
strSql = @"SELECT ID,ProjectId,ProjectCode,ProjectName,UnitId,UnitName,SpecialEquipmentId,SpecialEquipmentName,SizeModel,OwnerCheck,CertificateNum,IsUsed,CompileDate,EQType
|
||
FROM (SELECT Item.EquipmentInItemId AS ID,EQ.ProjectId,P.ProjectCode,P.ProjectName,EQ.UnitId,Unit.UnitName,Item.SpecialEquipmentId
|
||
,SPE.SpecialEquipmentName,Item.SizeModel,Item.OwnerCheck,Item.CertificateNum,Item.IsUsed,EQ.CompileDate,'特种设备' AS EQType
|
||
FROM InApproveManager_EquipmentInItem AS Item
|
||
LEFT JOIN InApproveManager_EquipmentIn AS EQ ON EQ.EquipmentInId = Item.EquipmentInId
|
||
LEFT JOIN Base_SpecialEquipment AS SPE ON Item.SpecialEquipmentId = SPE.SpecialEquipmentId
|
||
LEFT JOIN Base_Project AS P ON EQ.ProjectId = P.ProjectId
|
||
LEFT JOIN Base_Unit AS Unit ON Unit.UnitId = EQ.UnitId
|
||
UNION ALL SELECT Item.GeneralEquipmentInItemId AS ID,EQ.ProjectId,P.ProjectCode,P.ProjectName,EQ.UnitId,Unit.UnitName,Item.SpecialEquipmentId
|
||
,SPE.SpecialEquipmentName,Item.SizeModel,Item.OwnerCheck,Item.CertificateNum,Item.IsUsed,EQ.CompileDate,'一般设备' AS EQType
|
||
FROM InApproveManager_GeneralEquipmentInItem AS Item
|
||
LEFT JOIN InApproveManager_GeneralEquipmentIn AS EQ ON EQ.GeneralEquipmentInId = Item.GeneralEquipmentInId
|
||
LEFT JOIN Base_SpecialEquipment AS SPE ON Item.SpecialEquipmentId = SPE.SpecialEquipmentId
|
||
LEFT JOIN Base_Project AS P ON EQ.ProjectId = P.ProjectId
|
||
LEFT JOIN Base_Unit AS Unit ON Unit.UnitId = EQ.UnitId ) V
|
||
WHERE 1=1 ";
|
||
|
||
strSql += " AND V.IsUsed = @IsUsed";
|
||
listStr.Add(new SqlParameter("@IsUsed", "1"));
|
||
if (this.rbType.SelectedValue == "2")
|
||
{
|
||
strSql += " AND V.EQType = @EQType";
|
||
listStr.Add(new SqlParameter("@EQType", "特种设备"));
|
||
}
|
||
if (this.drpProject.SelectedValue != Const._Null)
|
||
{
|
||
strSql += " AND V.ProjectId = @ProjectId";
|
||
listStr.Add(new SqlParameter("@ProjectId", this.drpProject.SelectedValue));
|
||
}
|
||
if (!string.IsNullOrEmpty(this.txtStartTime.Text))
|
||
{
|
||
strSql += " AND V.CompileDate >=@StartTime";
|
||
listStr.Add(new SqlParameter("@StartTime", this.txtStartTime.Text));
|
||
}
|
||
if (!string.IsNullOrEmpty(this.txtEndTime.Text))
|
||
{
|
||
strSql += " AND V.CompileDate <=@EndTime";
|
||
listStr.Add(new SqlParameter("@EndTime", this.txtEndTime.Text));
|
||
}
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
|
||
Grid1.RecordCount = tb.Rows.Count;
|
||
var table = this.GetPagedDataTable(Grid1, tb);
|
||
Grid1.DataSource = table;
|
||
Grid1.DataBind();
|
||
}
|
||
#endregion
|
||
|
||
#region 查询
|
||
/// <summary>
|
||
/// 查询
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||
{
|
||
this.BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 表排序、分页、关闭窗口
|
||
/// <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 Grid1_Sort(object sender, GridSortEventArgs 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 Window1_Close(object sender, WindowCloseEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region Grid双击事件 编辑
|
||
/// <summary>
|
||
/// Grid行双击事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
||
{
|
||
EditData();
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
private void EditData()
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
var getEQ = Funs.DB.InApproveManager_EquipmentInItem.FirstOrDefault(x => x.EquipmentInItemId == Grid1.SelectedRowID);
|
||
if (getEQ != null)
|
||
{
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../HSSE/InApproveManager/EquipmentInView.aspx?EquipmentInId={0}", getEQ.EquipmentInId, "查看 - ")));
|
||
}
|
||
else
|
||
{
|
||
var getGEQ = Funs.DB.InApproveManager_GeneralEquipmentInItem.FirstOrDefault(x => x.GeneralEquipmentInItemId == Grid1.SelectedRowID);
|
||
if (getGEQ != null)
|
||
{
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../HSSE/InApproveManager/GeneralEquipmentInView.aspx?EquipmentInId={0}", getGEQ.GeneralEquipmentInId, "查看 - ")));
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
#endregion
|
||
|
||
protected void btnView_Click(object sender, EventArgs e)
|
||
{
|
||
EditData();
|
||
}
|
||
}
|
||
} |