CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/TestRun/BeforeTestRun/BeforeTestRun.aspx.cs

341 lines
12 KiB
C#
Raw Normal View History

2021-04-30 10:28:37 +08:00
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
namespace FineUIPro.Web.TestRun.BeforeTestRun
{
public partial class BeforeTestRun : PageBase
{
#region
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.hdType.Text = Request.Params["type"];
if (hdType.Text == "1")
{
this.Title = "单机试车";
this.Window1.Title = "单机试车";
this.Grid1.Columns[1].HeaderText = "单试时间";
this.Grid1.Columns[4].HeaderText = "设备总数";
}
else if (hdType.Text == "2")
{
this.Title = "冲洗吹扫";
this.Window1.Title = "冲洗吹扫";
this.Grid1.Columns[1].HeaderText = "吹扫时间";
this.Grid1.Columns[4].HeaderText = "吹扫包数";
}
else if (hdType.Text == "3")
{
this.Title = "化学清洗";
this.Window1.Title = "化学清洗";
this.Grid1.Columns[1].HeaderText = "化洗时间";
this.Grid1.Columns[4].HeaderText = "化洗系统数";
}
else if (hdType.Text == "4")
{
this.Title = "烘炉";
this.Window1.Title = "烘炉";
this.Grid1.Columns[1].HeaderText = "烘炉时间";
this.Grid1.Columns[4].HeaderText = "设备总数";
}
else if (hdType.Text == "5")
{
this.Title = "催化剂装填";
this.Window1.Title = "催化剂装填";
this.Grid1.Columns[1].HeaderText = "装填时间";
this.Grid1.Columns[4].HeaderText = "设备总数";
}
else if (hdType.Text == "6")
{
this.Title = "分子筛装填";
this.Window1.Title = "分子筛装填";
this.Grid1.Columns[1].HeaderText = "装填时间";
this.Grid1.Columns[4].HeaderText = "设备总数";
}
else if (hdType.Text == "7")
{
this.Title = "电气调试";
this.Window1.Title = "电气调试";
this.Grid1.Columns[1].HeaderText = "调试时间";
this.Grid1.Columns[4].HeaderText = "设备总数";
}
else if (hdType.Text == "8")
{
this.Title = "仪表调试";
this.Window1.Title = "仪表调试";
this.Grid1.Columns[1].HeaderText = "调试时间";
this.Grid1.Columns[4].HeaderText = "回路总数";
}
GetButtonPower();
BindGrid();
btnNew.OnClientClick = Window1.GetShowReference("BeforeTestRunEdit.aspx?type=" + this.hdType.Text.Trim()) + "return false;";
BLL.UnitService.InitUnitDownList(this.drpUnitId, this.CurrUser.LoginProjectId, true);
BLL.UnitWorkService.InitUnitWorkDropDownList(this.drpUnitWorkId, this.CurrUser.LoginProjectId, true);
}
}
#endregion
#region
//加载列表
public void BindGrid()
{
string strSql = @"SELECT run.BeforeTestRunId,
run.ProjectId,
run.Code,
run.Type,
run.Time,
run.UnitWorkId,
run.UnitId,
run.Count,
run.CompleteCount,
run.TotalCount,
run.CompleteRate,
run.Remark,
unitWork.UnitWorkName,
unit.UnitName "
+ @" FROM Driver_BeforeTestRun AS run "
+ @" LEFT JOIN WBS_UnitWork AS unitWork ON unitWork.UnitWorkId = run.UnitWorkId"
+ @" LEFT JOIN Base_Unit AS unit ON unit.UnitId = run.UnitId WHERE run.ProjectId=@projectId AND run.Type=@type";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId));
listStr.Add(new SqlParameter("@type", this.hdType.Text.Trim()));
if (!string.IsNullOrEmpty(this.drpUnitWorkId.SelectedValue) && this.drpUnitWorkId.SelectedValue != BLL.Const._Null)
{
strSql += " AND run.UnitWorkId=@unitWorkId";
listStr.Add(new SqlParameter("@unitWorkId", this.drpUnitWorkId.SelectedValue));
}
if (!string.IsNullOrEmpty(this.drpUnitId.SelectedValue) && this.drpUnitId.SelectedValue != BLL.Const._Null)
{
strSql += " AND run.UnitId=@unitId";
listStr.Add(new SqlParameter("@unitId", this.drpUnitId.SelectedValue));
}
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
/// <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)
{
Grid1.SortDirection = e.SortDirection;
Grid1.SortField = e.SortField;
BindGrid();
}
#endregion
#region
//搜索按钮事件
protected void btnSearch_Click(object sender, EventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#endregion
#region
protected void btnMenuModify_Click(object sender, EventArgs e)
{
EditData();
}
/// <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;
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("BeforeTestRunEdit.aspx?id={0}&&type={1}", Grid1.SelectedRowID, this.hdType.Text.Trim(), "编辑 - ")));
}
#endregion
#region
protected void btnMenuDel_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length > 0)
{
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
var info = BLL.BeforeTestRunService.GetBeforeTestRunById(rowID);
if (info != null)
{
BLL.BeforeTestRunService.DeleteBeforeTestRun(rowID);
}
}
BindGrid();
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
}
}
#endregion
#region Grid行点击事件
/// <summary>
/// Grid行点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
{
string menuid = "";
if (this.hdType.Text == "1")
{
menuid = BLL.Const.SingleTestRunMenuId;
}
else if (this.hdType.Text == "2")
{
menuid = BLL.Const.ClearMenuId;
}
else if (this.hdType.Text =="3")
{
menuid = BLL.Const.ChemClearMenuId;
}
else if (this.hdType.Text == "4")
{
menuid = BLL.Const.OvenMenuId;
}
else if (this.hdType.Text == "5")
{
menuid = BLL.Const.CatalystMenuId;
}
else if (this.hdType.Text == "6")
{
menuid = BLL.Const.ZeoliteMenuId;
}
else if (this.hdType.Text == "7")
{
menuid = BLL.Const.ELDebugMenuId;
}
else if (this.hdType.Text == "8")
{
menuid = BLL.Const.INDebugMenuId;
}
string id = Grid1.DataKeys[e.RowIndex][0].ToString();
if (e.CommandName == "AttachUrl")
{
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/TestRun/BeforeTestRun&menuId={1}", id, menuid)));
}
}
#endregion
#region
/// <summary>
/// 权限设置
/// </summary>
private void GetButtonPower()
{
string menuid = "";
if (this.hdType.Text == "1")
{
menuid = BLL.Const.SingleTestRunMenuId;
}
else if (this.hdType.Text == "2")
{
menuid = BLL.Const.ClearMenuId;
}
else if (this.hdType.Text == "3")
{
menuid = BLL.Const.ChemClearMenuId;
}
else if (this.hdType.Text == "4")
{
menuid = BLL.Const.OvenMenuId;
}
else if (this.hdType.Text == "5")
{
menuid = BLL.Const.CatalystMenuId;
}
else if (this.hdType.Text == "6")
{
menuid = BLL.Const.ZeoliteMenuId;
}
else if (this.hdType.Text == "7")
{
menuid = BLL.Const.ELDebugMenuId;
}
else if (this.hdType.Text == "8")
{
menuid = BLL.Const.INDebugMenuId;
}
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, menuid);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
this.btnNew.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnModify))
{
this.btnMenuModify.Hidden = false;
this.Grid1.EnableRowDoubleClickEvent = true;
}
if (buttonList.Contains(BLL.Const.BtnDelete))
{
this.btnMenuDel.Hidden = false;
}
}
}
#endregion
}
}