专项检查
This commit is contained in:
@@ -1,17 +1,349 @@
|
||||
using System;
|
||||
using BLL;
|
||||
using FineUIPro.Web.HSSE.Check;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Text;
|
||||
using AspNet = System.Web.UI.WebControls;
|
||||
|
||||
namespace FineUIPro.Web.OfficeCheck.Inspect
|
||||
{
|
||||
public partial class ProjectQualityInspection : System.Web.UI.Page
|
||||
public partial class ProjectQualityInspection : PageBase
|
||||
{
|
||||
#region 定义项
|
||||
public List<string> ItemSelectedList
|
||||
{
|
||||
get
|
||||
{
|
||||
return (List<string>)ViewState["ItemSelectedList"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["ItemSelectedList"] = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
||||
this.txtStartTime.Text = DateTime.Today.ToString("yyyy-MM-dd");
|
||||
this.txtEndTime.Text = DateTime.Today.ToString("yyyy-MM-dd");
|
||||
SetButtonPower();
|
||||
SetProblemTypes();
|
||||
SetResponsibleUnit();
|
||||
SetUnitProject();
|
||||
getList();
|
||||
}
|
||||
}
|
||||
#region 请求质量专检列表
|
||||
public void getList()
|
||||
{
|
||||
string strSql = "SELECT a.InspectionId,a.InspectionCode,a.ProjectId,(SELECT ProjectName FROM Base_Project as p WHERE p.ProjectId = a.ProjectId) as ProjectName, a.PersonResponsible,(SELECT UserName FROM Sys_User as u WHERE u.UserID = a.PersonResponsible) as PersonResponsibleName, (CASE WHEN a.States = '1' THEN '待检查' WHEN a.States = '2' THEN '待审核/整改' WHEN a.States = '3' THEN '已闭环' END ) as Status, a.CheckMan, a.CreateTime, a.ProblemTypeName,b.CompileTime as CheckTime, " +
|
||||
"b.InspectionItemId,b.BeforelUrl,b.AfterUrl, (CASE WHEN b.States = '1'and a.States = '1' THEN '待提交' WHEN a.States = '2' and b.States = '1' THEN '待审核' WHEN a.States = '2' and b.States = '2' THEN '待整改' WHEN a.States = '2' and b.States = '3' THEN '已闭环' WHEN a.States = '3' THEN '已闭环' END) as itemStates," +
|
||||
"a.Place FROM Inspect_InspectionItem as b LEFT JOIN Inspect_Inspection as a on b.InspectionId = a.InspectionId WHERE a.InspectType = '2'";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
||||
{
|
||||
strSql += "and a.ProjectId = @ProjectId";
|
||||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtCheckMan.Text.Trim()))
|
||||
{
|
||||
strSql += " AND a.CheckMan LIKE @CheckMan";
|
||||
listStr.Add(new SqlParameter("@CheckMan", "%" + this.txtCheckMan.Text.Trim() + "%"));
|
||||
}
|
||||
if (this.txtType.SelectedText.Trim() != "请选择" && !string.IsNullOrEmpty(this.txtType.SelectedText.Trim()))
|
||||
{
|
||||
strSql += " AND a.ProblemTypeName = @Type";
|
||||
listStr.Add(new SqlParameter("@Type", this.txtType.SelectedText.Trim()));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtWorkAreaName.SelectedText) && this.txtWorkAreaName.SelectedText.Trim() != "请选择")
|
||||
{
|
||||
strSql += " AND a.Place = @Place";
|
||||
listStr.Add(new SqlParameter("@Place", this.txtWorkAreaName.SelectedText.Trim()));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtWorkAreaName.Text.Trim()))
|
||||
{
|
||||
strSql += " AND a.Place LIKE @Place";
|
||||
listStr.Add(new SqlParameter("@Place", "%" + this.txtWorkAreaName.Text.Trim() + "%"));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(txtStartTime.Text.Trim()))
|
||||
{
|
||||
strSql += " AND b.CompileTime >= @StartTime";
|
||||
listStr.Add(new SqlParameter("@StartTime", string.Format("{0} {1}", this.txtStartTime.Text.Trim(), "00:00:00")));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtEndTime.Text.Trim()))
|
||||
{
|
||||
strSql += " AND b.CompileTime <= @EndTime";
|
||||
listStr.Add(new SqlParameter("@EndTime", string.Format("{0} {1}", this.txtEndTime.Text.Trim(), "23:59:59")));
|
||||
}
|
||||
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 问题类型下拉框赋值
|
||||
public void SetProblemTypes()
|
||||
{
|
||||
txtType.DataValueField = "QualityQuestionTypeId";
|
||||
txtType.DataTextField = "QualityQuestionType";
|
||||
List<Model.Base_QualityQuestionType> list = (from x in Funs.DB.Base_QualityQuestionType select x).ToList();
|
||||
list.Insert(0, new Model.Base_QualityQuestionType()
|
||||
{
|
||||
QualityQuestionTypeId = "-1",
|
||||
QualityQuestionType = "请选择"
|
||||
});
|
||||
txtType.DataSource = list;
|
||||
txtType.DataBind();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 单位工程下拉框赋值
|
||||
public void SetUnitProject()
|
||||
{
|
||||
List<Model.WBS_UnitWork> list = new List<Model.WBS_UnitWork>() {
|
||||
new Model.WBS_UnitWork()
|
||||
{
|
||||
UnitWorkId = "-1",
|
||||
UnitWorkName = "请选择"
|
||||
}
|
||||
};
|
||||
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
||||
{
|
||||
list.AddRange((from x in Funs.DB.WBS_UnitWork where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList());
|
||||
}
|
||||
txtWorkAreaName.DataValueField = "UnitWorkId";
|
||||
txtWorkAreaName.DataTextField = "UnitWorkName";
|
||||
txtWorkAreaName.DataSource = list;
|
||||
txtWorkAreaName.DataBind();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 责任单位下拉框赋值
|
||||
public void SetResponsibleUnit()
|
||||
{
|
||||
List<Model.UnitItem> list = new List<Model.UnitItem>() {
|
||||
new Model.UnitItem()
|
||||
{
|
||||
UnitId = "-1",
|
||||
UnitName = "请选择"
|
||||
}
|
||||
};
|
||||
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
||||
{
|
||||
list.AddRange((from x in Funs.DB.Project_ProjectUnit
|
||||
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
|
||||
where x.ProjectId == this.CurrUser.LoginProjectId
|
||||
select new Model.UnitItem()
|
||||
{
|
||||
UnitId = y.UnitId,
|
||||
UnitName = y.UnitName
|
||||
}).ToList());
|
||||
}
|
||||
txtResponsibilityUnitName.DataValueField = "UnitId";
|
||||
txtResponsibilityUnitName.DataTextField = "UnitName";
|
||||
txtResponsibilityUnitName.DataSource = list;
|
||||
txtResponsibilityUnitName.DataBind();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 整改后图片
|
||||
protected string ConvertImgUrl(object registrationId)
|
||||
{
|
||||
string url = string.Empty;
|
||||
if (registrationId != null)
|
||||
{
|
||||
var imgUrl = Funs.DB.Inspect_InspectionItem.FirstOrDefault(x => x.InspectionItemId == registrationId.ToString()).AfterUrl;
|
||||
if (imgUrl != null)
|
||||
{
|
||||
url = BLL.UploadAttachmentService.ShowImage(ConfigurationManager.AppSettings["CEMS_IMG_URL"], imgUrl);
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 整改前图片
|
||||
protected string ConvertImgUrlByImage(object registrationId)
|
||||
{
|
||||
string url = string.Empty;
|
||||
if (registrationId != null)
|
||||
{
|
||||
var imgUrl = Funs.DB.Inspect_InspectionItem.FirstOrDefault(x => x.InspectionItemId == registrationId.ToString()).BeforelUrl;
|
||||
if (imgUrl != null)
|
||||
{
|
||||
url = BLL.UploadAttachmentService.ShowImage(ConfigurationManager.AppSettings["CEMS_IMG_URL"], imgUrl);
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 关闭window弹窗
|
||||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||||
{
|
||||
getList();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 查看详细
|
||||
protected void btnMenuSee_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||||
{
|
||||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
string id = Grid1.SelectedRowID;
|
||||
|
||||
if (id != null)
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectQualityInspectionView.aspx?InspectionItemId={0}", id, "查看 - ")));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 查询
|
||||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
getList();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 排序
|
||||
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
||||
{
|
||||
getList();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 分页
|
||||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||||
{
|
||||
Grid1.PageIndex = e.NewPageIndex;
|
||||
getList();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 分页条数下拉框
|
||||
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
||||
getList();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Grid行点击事件
|
||||
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
||||
{
|
||||
string RegistrationId = Grid1.DataKeys[e.RowIndex][0].ToString();
|
||||
Model.HSSE_Hazard_HazardRegister hazardRegister = BLL.HSSE_Hazard_HazardRegisterService.GetHazardRegisterByCheckItemDetailId(RegistrationId);
|
||||
if (e.CommandName == "IsSelected")
|
||||
{
|
||||
CheckBoxField checkField = (CheckBoxField)Grid1.FindColumn("ckbIsSelected");
|
||||
if (checkField.GetCheckedState(e.RowIndex))
|
||||
{
|
||||
if (!ItemSelectedList.Contains(RegistrationId))
|
||||
{
|
||||
ItemSelectedList.Add(RegistrationId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ItemSelectedList.Contains(RegistrationId))
|
||||
{
|
||||
ItemSelectedList.Remove(RegistrationId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e.CommandName == "del")
|
||||
{
|
||||
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HSSE_HiddenRectificationListMenuId, BLL.Const.BtnDelete))
|
||||
{
|
||||
if (hazardRegister.States != Const.State_3 || this.CurrUser.UserId == BLL.Const.hfnbdId) //待整改
|
||||
{
|
||||
var getD = BLL.HSSE_Hazard_HazardRegisterService.GetHazardRegisterByHazardRegisterId(RegistrationId);
|
||||
if (getD != null)
|
||||
{
|
||||
BLL.LogService.AddSys_Log(this.CurrUser, getD.HazardCode, getD.HazardRegisterId, BLL.Const.HSSE_HiddenRectificationListMenuId, BLL.Const.BtnDelete);
|
||||
BLL.HSSE_Hazard_HazardRegisterService.DeleteHazardRegisterByHazardRegisterId(RegistrationId);
|
||||
getList();
|
||||
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop("已闭环,无法删除!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Grid双击事件
|
||||
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
||||
{
|
||||
btnMenuSee_Click(null, null);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取按钮权限
|
||||
public void SetButtonPower()
|
||||
{
|
||||
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, "66A8D852-A542-47C7-B474-C0EEA73AC58E");
|
||||
if (buttonList.Count() > 0)
|
||||
{
|
||||
if (buttonList.Contains(BLL.Const.BtnDelete))
|
||||
{
|
||||
this.btnMenuDel.Hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除
|
||||
protected void btnMenuDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length > 0)
|
||||
{
|
||||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
||||
Model.Inspect_InspectionItem item = db.Inspect_InspectionItem.FirstOrDefault(x => x.InspectionItemId == rowID);
|
||||
if (item != null)
|
||||
{
|
||||
|
||||
db.Inspect_InspectionItem.DeleteOnSubmit(item);
|
||||
db.SubmitChanges();
|
||||
int count = db.Inspect_Inspection.Count(x=> x.InspectionId == item.InspectionId);
|
||||
if(count == 0) {
|
||||
db.Inspect_Inspection.DeleteOnSubmit(db.Inspect_Inspection.FirstOrDefault(x => x.InspectionId == item.InspectionId));
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
getList();
|
||||
ShowNotify("删除数据成功!");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user