xinjiang/SGGL/FineUIPro.Web/SYHSE/Data_EnvironmentProtectionS...

215 lines
7.1 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
namespace FineUIPro.Web.SYHSE
{
public partial class Data_EnvironmentProtectionShow : PageBase
{
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Funs.DropDownPageSize(this.ddlPageSize);
// 绑定表格
this.BindGrid();
}
}
#region
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
string strSql = @" SELECT newId() Id, [DetectionTimeA],[DetectionAddress]
,[DetectionProject]
,max([DetectionValue])[DetectionValue]
,max([StandValue])[StandValue]
,max([AvgFlow])[AvgFlow]
,max([SumFlow])[SumFlow]
FROM [dbo].[SYHSEData_EnvironmentProtection]
WHERE ProjectId = @ProjectId
";
List<SqlParameter> listStr = new List<SqlParameter>
{
new SqlParameter("@projectId", this.CurrUser.LoginProjectId),
};
if (!string.IsNullOrEmpty(this.txtStartTime.Text.Trim()))
{
strSql += " AND DetectionTimeA >= @DetectionTimeA ";
listStr.Add(new SqlParameter("@DetectionTimeA", "%" + this.txtStartTime.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.txtStartTime.Text.Trim()))
{
strSql += " AND DetectionTimeZ <= @DetectionTimeZ ";
listStr.Add(new SqlParameter("@DetectionTimeZ", "%" + this.txtStartTime.Text.Trim() + "%"));
}
strSql += @" group by [DetectionTimeA],[DetectionAddress]
,[DetectionProject],ShowIndex
order by [DetectionTimeA] desc,ShowIndex asc";
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
// 2.获取当前分页数据
//var table = this.GetPagedDataTable(Grid1, tb1);
Grid1.RecordCount = tb.Rows.Count;
//tb = GetFilteredTable(Grid1.FilteredData, tb);
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 btSearch_Click(object sender, EventArgs e)
{
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 导入焊接日报
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SYHSE_EnvironmentProtectionMenuId, BLL.Const.BtnSave))
{
PageContext.RegisterStartupScript(WindowImport.GetShowReference(String.Format("Data_EnvironmentProtectionDataIn.aspx", "导入 - ")));
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#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 (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.SYHSE_EnvironmentProtectionMenuId, Const.BtnDelete))
{
if (Grid1.SelectedRowIDArray.Length > 0)
{
foreach (var item in Grid1.SelectedRowIDArray)
{
SYHSEData_EnvironmentProtectionService.DeleteProjectById(item);
}
BindGrid();
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#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 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 Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
BindGrid();
}
#endregion
protected void btAdd_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.SYHSE_EnvironmentProtectionMenuId, Const.BtnAdd))
{
PageContext.RegisterStartupScript(WindowAdd.GetShowReference(String.Format("Data_EnvironmentProtectionEdit.aspx?Id={0}", string.Empty, "新增 - ")));
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
protected void WindowAdd_Close(object sender, WindowCloseEventArgs e)
{
this.BindGrid();
}
public string ConvertMan(Object userId)
{
Model.Sys_User user = Funs.DB.Sys_User.FirstOrDefault(e => e.UserId == userId.ToString());
if (user != null)
{
return user.UserName;
}
else
{
return userId.ToString();
}
}
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录", MessageBoxIcon.Warning);
return;
}
PageContext.RegisterStartupScript(WindowAdd.GetShowReference(String.Format("Data_EnvironmentProtectionEdit.aspx?Id={0}", Grid1.SelectedRowID, "编辑 - ")));
}
protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
{
BindGrid();
}
}
}