SGGL_SHJ/SGGL/FineUIPro.Web/CQMS/Technical/TechnicalDisclose.aspx.cs

385 lines
14 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Threading.Tasks;
namespace FineUIPro.Web.CQMS.Technical
{
public partial class TechnicalDisclose : PageBase
{
/// <summary>
/// 项目id
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.ProjectId = this.CurrUser.LoginProjectId;
GetButtonPower();
//权限按钮方法
UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true);
UnitWorkService.InitUnitWorkDownList(drpUnitWork, this.CurrUser.LoginProjectId, true);
Funs.FineUIPleaseSelect(this.drpState);
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
var projectUnit = BLL.ProjectUnitService.GetProjectUnitByUnitIdProjectId(this.CurrUser.LoginProjectId, this.CurrUser.UnitId);
if (projectUnit != null && projectUnit.UnitType == Const.ProjectUnitType_2) //分包单位只看自己单位的数据
{
this.drpUnit.SelectedValue = this.CurrUser.UnitId;
this.drpUnit.Enabled = false;
}
// 绑定表格
BindGrid();
}
}
#endregion
public Task<DataTable> data()
{
Task<DataTable> task = new Task<DataTable>(() =>
{
return ChecklistData();
});
task.Start();
return task;
}
protected DataTable ChecklistData()
{
string strSql = @"SELECT chec.*,unit.UnitName,unitWork.UnitWorkName+(case unitWork.ProjectType when '1' then '(建筑)' else '(安装)' end) as UnitWorkName,"
+ @" u.PersonName as DiscloseManName "
+ @" FROM Technical_TechnicalDisclose chec"
+ @" left join Base_Unit unit on unit.unitId=chec.unitId"
+ @" left join WBS_UnitWork unitWork on unitWork.UnitWorkId = chec.UnitWorkId"
+ @" left join Person_Persons u on u.PersonId = chec.DiscloseMan"
+ @" where chec.ProjectId=@ProjectId";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
if (drpUnit.SelectedValue != BLL.Const._Null)
{
strSql += " AND chec.unitId=@unitId";
listStr.Add(new SqlParameter("@unitId", drpUnit.SelectedValue));
}
if (drpUnitWork.SelectedValue != Const._Null)
{
strSql += " AND chec.unitworkId=@unitworkId";
listStr.Add(new SqlParameter("@unitworkId", drpUnitWork.SelectedValue));
}
if (drpState.SelectedValue != Const._Null)
{
if (drpState.SelectedValue.Equals("1"))
{
strSql += " AND chec.state='1'";
}
else if (drpState.SelectedValue.Equals("0"))
{
strSql += " AND chec.state='0'";
}
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
return tb;
}
/// <summary>
/// 绑定数据
/// </summary>
public void BindGrid()
{
DataTable tb = ChecklistData();
// 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();
for (int i = 0; i < Grid1.Rows.Count; i++)
{
string rowID = Grid1.Rows[i].DataKeys[0].ToString();
if (rowID.Count() > 0)
{
Model.Technical_TechnicalDisclose TechnicalDisclose = BLL.CQMS_TechnicalDiscloseService.GetTechnicalDiscloseById(rowID);
if (TechnicalDisclose.State == "1") //已交底
{
Grid1.Rows[i].RowCssClass = "Green";
}
else //未交底
{
Grid1.Rows[i].RowCssClass = " Yellow ";
}
}
}
}
#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_FilterChange(object sender, EventArgs e)
{
BindGrid();
}
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
Grid1.PageIndex = e.NewPageIndex;
BindGrid();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
//Grid1.SortDirection = e.SortDirection;
//Grid1.SortField = e.SortField;
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)
{
btnMenuModify_Click(null, null);
}
#endregion
#region
/// <summary>
/// 编辑按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuModify_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string id = Grid1.SelectedRowID;
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("TechnicalDiscloseEdit.aspx?TechnicalDiscloseId={0}", id, "编辑 - ")));
}
#endregion
#region
/// <summary>
/// 批量删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDel_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string id = Grid1.SelectedRowID;
var checks = BLL.CQMS_TechnicalDiscloseService.GetTechnicalDiscloseById(id);
BLL.CQMS_TechnicalDiscloseService.DeleteTechnicalDiscloseById(id);
BLL.LogService.AddSys_Log(this.CurrUser, checks.DiscloseName, id, BLL.Const.CQMSTechnicalDiscloseMenuId, "删除施工技术交底");
Grid1.DataBind();
BindGrid();
Alert.ShowInTop("删除数据成功!", MessageBoxIcon.Success);
}
#endregion
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
if (Request.Params["value"] == "0")
{
return;
}
var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.PersonId, BLL.Const.CQMSTechnicalDiscloseMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnModify))
{
this.btnMenuModify.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnDelete))
{
this.btnMenuDel.Hidden = false;
}
}
}
#endregion
//<summary>
//获取总包参与人姓名
//</summary>
//<param name="state"></param>
//<returns></returns>
protected string ConvertMainPartys(object MainPartys)
{
return BLL.Person_PersonsService.getPersonsNamesPersonIds(MainPartys);
}
/// <summary>
/// 把状态转换代号为文字形式
/// </summary>
/// <param name="state"></param>
/// <returns></returns>
protected string ConvertState(object state)
{
if (state != null)
{
if (state.ToString() == "0")
{
return "未交底";
}
else if (state.ToString() == "1")
{
return "已交底";
}
else
{
return "";
}
}
return "";
}
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
{
//if (TechnicalDisclose.State.Equals("5") || TechnicalDisclose.State.Equals("6"))
//{
// Grid1.Rows[i].RowCssClass = "lightgreen";//未确认
//}
//else if (TechnicalDisclose.State == Const.TechnicalDisclose_Complete)
//{ //闭环
// Grid1.Rows[i].RowCssClass = "green";
//}
////else if( TechnicalDisclose.LimitDate> )
//else if (Convert.ToDateTime(TechnicalDisclose.LimitDate).AddDays(1).Date < DateTime.Now && TechnicalDisclose.State != BLL.Const.TechnicalDisclose_Complete) //延期未整改
//{
// Grid1.Rows[i].RowCssClass = "orange";
//}
//else //期内未整改
//{
// Grid1.Rows[i].RowCssClass = "red";
//}
}
protected void btnMenuView_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string id = Grid1.SelectedRowID;
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("TechnicalDiscloseView.aspx?TechnicalDiscloseId={0}", id, "查看 - ")));
}
protected void btnQR_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string TechnicalDiscloseId = Grid1.SelectedRowID;
var TechnicalDisclose = BLL.CQMS_TechnicalDiscloseService.GetTechnicalDiscloseById(TechnicalDiscloseId);
if (TechnicalDisclose.State == "1") //已交底
{
string strCode = "technical$" + TechnicalDiscloseId;
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("~/Controls/SeeQRImage.aspx?TechnicalDiscloseId={0}&strCode={1}", TechnicalDiscloseId, strCode), "二维码查看", 400, 400));
}
else //未交底
{
Alert.ShowInTop("该记录未完成交底,无法生成二维码!", MessageBoxIcon.Warning);
return;
}
}
protected void btnQuery_Click(object sender, EventArgs e)
{
BindGrid();
}
protected void btnRset_Click(object sender, EventArgs e)
{
drpUnit.SelectedIndex = 0;
drpState.SelectedIndex = 0;
drpUnitWork.SelectedIndex = 0;
BindGrid();
}
}
}