1
This commit is contained in:
+414
@@ -0,0 +1,414 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Services.Description;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using BLL;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace FineUIPro.Web.Customization.ZJ.HSSE.HiddenInspection
|
||||
{
|
||||
public partial class SuperviseCheckEdit : PageBase
|
||||
{
|
||||
#region 定义变量
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
public string SuperviseCheckId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["SuperviseCheckId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["SuperviseCheckId"] = value;
|
||||
}
|
||||
}
|
||||
public bool IsDel
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool)ViewState["IsDel"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["IsDel"] = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 定义集合
|
||||
/// </summary>
|
||||
private static List<Model.ZJ_SuperviseCheck_Detail> superviseCheckDetails = new List<Model.ZJ_SuperviseCheck_Detail>();
|
||||
#endregion
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.SuperviseCheckId = Request.Params["SuperviseCheckId"];
|
||||
btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
||||
|
||||
BLL.ProjectService.InitProjectDropDownList(this.ddlProjectId, true);
|
||||
//风险等级
|
||||
ListItem[] item1 = new ListItem[2];
|
||||
item1[0] = new ListItem("重大", "重大");
|
||||
item1[1] = new ListItem("一般", "一般");
|
||||
this.drpRiskLevel.DataValueField = "Text";
|
||||
this.drpRiskLevel.DataTextField = "Text";
|
||||
this.drpRiskLevel.DataSource = item1;
|
||||
this.drpRiskLevel.DataBind();
|
||||
|
||||
GetMenuPower();
|
||||
|
||||
var superviseCheckReport = BLL.SupervisecheckService.GetZJ_SuperviseCheckById(this.SuperviseCheckId);
|
||||
if (superviseCheckReport != null)
|
||||
{
|
||||
this.txtSuperviseCheckReportCode.Text = superviseCheckReport.SuperviseCheckReportCode;
|
||||
if (superviseCheckReport.CheckDate != null)
|
||||
{
|
||||
this.dpkCheckDate.Text = string.Format("{0:yyyy-MM-dd}", superviseCheckReport.CheckDate);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(superviseCheckReport.ProjectId))
|
||||
{
|
||||
this.ddlProjectId.SelectedValue = superviseCheckReport.ProjectId;
|
||||
BLL.UserService.InitUserDropDownList(drpRcMan, this.ddlProjectId.SelectedValue, false, "");
|
||||
|
||||
drpRcMan.SelectedValue= superviseCheckReport.RecUserId;
|
||||
}
|
||||
this.txtCheckTeam.Text = superviseCheckReport.CheckTeam;
|
||||
superviseCheckDetails = SupervisecheckDetailService.GetBySuperviseCheckId(SuperviseCheckId);
|
||||
Grid1.DataSource = superviseCheckDetails;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.txtCheckTeam.Text = BLL.UnitService.GetUnitNameByUnitId(this.CurrUser.UnitId) + this.CurrUser.UserName;
|
||||
this.dpkCheckDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void GetMenuPower()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(this.SuperviseCheckId))
|
||||
{
|
||||
var superviseCheckReport = BLL.SupervisecheckService.GetZJ_SuperviseCheckById(this.SuperviseCheckId);
|
||||
if ((this.CurrUser.UserId== superviseCheckReport.CreateMan || this.CurrUser.UserId== superviseCheckReport.RecUserId)&& superviseCheckReport.State != 3)
|
||||
{
|
||||
this.btnSave.Hidden=false;
|
||||
this.btnSubmit.Hidden=false;
|
||||
IsDel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsDel=false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.btnSave.Hidden = false;
|
||||
this.btnSubmit.Hidden = false;
|
||||
IsDel = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region 验证检查编号是否存在
|
||||
/// <summary>
|
||||
/// 验证检查编号是否存在
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
var standard = Funs.DB.ZJ_SuperviseCheck.FirstOrDefault(x => x.SuperviseCheckReportCode == this.txtSuperviseCheckReportCode.Text.Trim() && (x.SuperviseCheckId != this.SuperviseCheckId || (this.SuperviseCheckId == null && x.SuperviseCheckId != null)));
|
||||
if (standard != null)
|
||||
{
|
||||
ShowNotify("输入的检查编号已存在!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected void ddlProjectId_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
BLL.UserService.InitUserDropDownList(drpRcMan, this.ddlProjectId.SelectedValue, false,"");
|
||||
}
|
||||
|
||||
#region 保存
|
||||
/// <summary>
|
||||
/// 保存
|
||||
/// </summary>
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ddlProjectId.SelectedValue) || this.ddlProjectId.SelectedValue == BLL.Const._Null)
|
||||
{
|
||||
ShowNotify("请选择项目!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
this.SaveData(Const.BtnSave);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提交
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ddlProjectId.SelectedValue) || this.ddlProjectId.SelectedValue == BLL.Const._Null)
|
||||
{
|
||||
ShowNotify("请选择项目!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
this.SaveData(Const.BtnSubmit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存提交方法
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
private void SaveData(string type)
|
||||
{
|
||||
Model.ZJ_SuperviseCheck model = new Model.ZJ_SuperviseCheck
|
||||
{
|
||||
SuperviseCheckReportCode = txtSuperviseCheckReportCode.Text.Trim(),
|
||||
CheckTeam = txtCheckTeam.Text.Trim(),
|
||||
CheckDate = Funs.GetNewDateTime(this.dpkCheckDate.Text.Trim()),
|
||||
RecUserId = drpRcMan.SelectedValue,
|
||||
State = 0,
|
||||
ProjectId = ddlProjectId.SelectedValue,
|
||||
|
||||
};
|
||||
if (type == Const.BtnSubmit)
|
||||
{
|
||||
model.State = 1;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.SuperviseCheckId))
|
||||
{
|
||||
|
||||
model.SuperviseCheckId = this.SuperviseCheckId;
|
||||
BLL.SupervisecheckService.UpdateZJ_SuperviseCheck(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
model.SuperviseCheckId = Guid.NewGuid().ToString();
|
||||
model.CreateMan = CurrUser.UserId;
|
||||
model.CreateDate = DateTime.Now;
|
||||
this.SuperviseCheckId = model.SuperviseCheckId;
|
||||
BLL.SupervisecheckService.AddZJ_SuperviseCheck(model);
|
||||
}
|
||||
this.SaveDetail(model.SuperviseCheckId);
|
||||
PageContext.RegisterStartupScript(String.Format("showImg();"));
|
||||
|
||||
if (type == Const.BtnSubmit)
|
||||
{
|
||||
SupervisecheckService.VerifyStateBySuperviseCheckId(model.SuperviseCheckId);
|
||||
var superviseCheckReport = BLL.SupervisecheckService.GetZJ_SuperviseCheckById(this.SuperviseCheckId);
|
||||
if (superviseCheckReport != null&&superviseCheckReport.State==3)
|
||||
{
|
||||
WorkflowTodoitemsService.DoneWorkflow_TodoItems(model.SuperviseCheckId, this.CurrUser.UserId);//完成当前人待办
|
||||
}
|
||||
//推送下一步办理人待办事项
|
||||
string pcurl = Funs.SGGLUrl + "Customization/ZJ/HSSE/HiddenInspection/SuperviseCheckEdit.aspx?SuperviseCheckId=" + model.SuperviseCheckId;
|
||||
WorkflowTodoitemsService.Add(model.SuperviseCheckId, "安全监督检查", "整改", "", pcurl, "", model.CreateMan, model.RecUserId);
|
||||
|
||||
ShowNotify("提交成功.", MessageBoxIcon.Success);
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("保存成功。", MessageBoxIcon.Success);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存明细项
|
||||
/// </summary>
|
||||
private void SaveDetail(string objId)
|
||||
{
|
||||
//1.先删除明细项
|
||||
SupervisecheckDetailService.DeleteBySuperviseCheckId(objId);
|
||||
//2.根据列表中的明细项添加
|
||||
List<Model.ZJ_SuperviseCheck_Detail> detailLists = new List<Model.ZJ_SuperviseCheck_Detail>();
|
||||
JArray teamGroupData = Grid1.GetMergedData();
|
||||
foreach (JObject teamGroupRow in teamGroupData)
|
||||
{
|
||||
JObject values = teamGroupRow.Value<JObject>("values");
|
||||
int rowIndex = teamGroupRow.Value<int>("index");
|
||||
Model.ZJ_SuperviseCheck_Detail newDetail = new Model.ZJ_SuperviseCheck_Detail
|
||||
{
|
||||
SuperviseCheckId = objId,
|
||||
//ProNoticeCId= values.Value<string>("ProNoticeCId"),
|
||||
QueDescribe = values.Value<string>("QueDescribe"),
|
||||
QueSuggest = values.Value<string>("QueSuggest"),
|
||||
SituationDescription = values.Value<string>("SituationDescription"),
|
||||
RiskLevel = values.Value<string>("RiskLevel"),
|
||||
};
|
||||
if (Grid1.Rows[rowIndex].DataKeys.Length > 0)
|
||||
{
|
||||
newDetail.DetailId = Grid1.Rows[rowIndex].DataKeys[0].ToString();
|
||||
}
|
||||
detailLists.Add(newDetail);
|
||||
}
|
||||
if (detailLists.Count > 0)
|
||||
{
|
||||
Funs.DB.ZJ_SuperviseCheck_Detail.InsertAllOnSubmit(detailLists);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 检查项
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_PreDataBound(object sender, EventArgs e)
|
||||
{
|
||||
// 设置LinkButtonField的点击客户端事件
|
||||
LinkButtonField deleteField = Grid1.FindColumn("Delete") as LinkButtonField;
|
||||
deleteField.OnClientClick = GetDeleteScript();
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除提示
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string GetDeleteScript()
|
||||
{
|
||||
if (IsDel)
|
||||
{
|
||||
return Confirm.GetShowReference("删除选中行?", String.Empty, MessageBoxIcon.Question, Grid1.GetDeleteSelectedRowsReference(), String.Empty);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return Confirm.GetShowReference("不允许操作删除项。", MessageBoxIcon.Warning);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
||||
{
|
||||
string itemId = Grid1.DataKeys[e.RowIndex][0].ToString();
|
||||
|
||||
if (e.CommandName == "attchUrl")
|
||||
{
|
||||
if (!IsDel)
|
||||
{
|
||||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/ZJ/SuperviseCheck&menuId={1}&type=-1", itemId, BLL.Const.SuperviseCheckMenuId)));
|
||||
}
|
||||
else
|
||||
{
|
||||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/ZJ/SuperviseCheck&menuId={1}&type=0", itemId, BLL.Const.SuperviseCheckMenuId)));
|
||||
}
|
||||
|
||||
}
|
||||
if (e.CommandName == "RectificationUrl")
|
||||
{
|
||||
if (!IsDel)
|
||||
{
|
||||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/ZJ/SuperviseCheck&menuId={1}&type=-1", itemId + "Ref", BLL.Const.SuperviseCheckMenuId)));
|
||||
}
|
||||
else
|
||||
{
|
||||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/ZJ/SuperviseCheck&menuId={1}&type=0", itemId + "Ref", BLL.Const.SuperviseCheckMenuId)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 新增检查项
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
JArray teamGroupData = Grid1.GetMergedData();
|
||||
List<JObject> list = new List<JObject>();
|
||||
foreach (JObject teamGroupRow in teamGroupData)
|
||||
{
|
||||
JObject values = teamGroupRow.Value<JObject>("values");
|
||||
values.Add("DetailId", teamGroupRow.Value<string>("id"));
|
||||
list.Add(values);
|
||||
}
|
||||
|
||||
JObject defaultObj = new JObject
|
||||
{ { "DetailId",Guid.NewGuid() },
|
||||
{ "QueDescribe", "" },
|
||||
{ "QueSuggest", "" },
|
||||
{ "RiskLevelName", "" },
|
||||
{"SituationDescription","" },
|
||||
{ "Delete", String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>", GetDeleteScript(), IconHelper.GetResolvedIconUrl(Icon.Delete)) }
|
||||
};
|
||||
list.Add(defaultObj);
|
||||
Grid1.DataSource = list;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取整改前图片(放于Img中)
|
||||
/// </summary>
|
||||
/// <param name="proNoticeCId"></param>
|
||||
/// <returns></returns>
|
||||
protected string ConvertImageUrlByImage(object proNoticeCId)
|
||||
{
|
||||
string url = string.Empty;
|
||||
string httpUrl = string.Empty;
|
||||
var sysSet6 = (from x in Funs.DB.Sys_Set where x.SetName == "程序访问地址" select x).ToList().FirstOrDefault();
|
||||
if (sysSet6 != null)
|
||||
{
|
||||
httpUrl = sysSet6.SetValue;
|
||||
}
|
||||
if (proNoticeCId != null)
|
||||
{
|
||||
Model.AttachFile file = Funs.DB.AttachFile.FirstOrDefault(e => e.ToKeyId == proNoticeCId.ToString());
|
||||
if (file != null && !string.IsNullOrEmpty(file.AttachUrl))
|
||||
{
|
||||
string modelurl = file.AttachUrl.Replace('\\', '/');
|
||||
url = BLL.UploadAttachmentService.ShowImage(httpUrl, modelurl);
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取整改后图片
|
||||
/// </summary>
|
||||
/// <param name="proNoticeCId"></param>
|
||||
/// <returns></returns>
|
||||
protected string ConvertImgUrlByImage(object proNoticeCId)
|
||||
{
|
||||
string url = string.Empty;
|
||||
string httpUrl = string.Empty;
|
||||
var sysSet6 = (from x in Funs.DB.Sys_Set where x.SetName == "程序访问地址" select x).ToList().FirstOrDefault();
|
||||
if (sysSet6 != null)
|
||||
{
|
||||
httpUrl = sysSet6.SetValue;
|
||||
}
|
||||
if (proNoticeCId != null)
|
||||
{
|
||||
Model.AttachFile file = Funs.DB.AttachFile.FirstOrDefault(e => e.ToKeyId == (proNoticeCId.ToString() + "Ref"));
|
||||
if (file != null && !string.IsNullOrEmpty(file.AttachUrl))
|
||||
{
|
||||
string modelurl = file.AttachUrl.Replace('\\', '/');
|
||||
url = BLL.UploadAttachmentService.ShowImage(httpUrl, modelurl);
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user