using BLL; using System; using System.Linq; namespace FineUIPro.Web.SHIYE.Hazard { public partial class RoutingInspectionEdit : PageBase { #region 定义项 /// /// 主键 /// private string PatrolPlanId { get { return (string)ViewState["PatrolPlanId"]; } set { ViewState["PatrolPlanId"] = value; } } private string HazardSelectedItemId { get { return (string)ViewState["HazardSelectedItemId"]; } set { ViewState["HazardSelectedItemId"] = value; } } private string RoutingInspectionId { get { return (string)ViewState["RoutingInspectionId"]; } set { ViewState["RoutingInspectionId"] = value; } } /// /// 图片路径 /// public string ImageUrl { get { return (string)ViewState["ImageUrl"]; } set { ViewState["ImageUrl"] = value; } } /// /// 整改后附件路径 /// public string RectificationImageUrl { get { return (string)ViewState["RectificationImageUrl"]; } set { ViewState["RectificationImageUrl"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString)) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); UserService.InitUsersDropDownList(this.drpPatrolMan, this.CurrUser.LoginProjectId, true, string.Empty); this.PatrolPlanId = Request.Params["PatrolPlanId"]; this.hdCheckManId.Text = this.CurrUser.UserId; if (!string.IsNullOrEmpty(this.PatrolPlanId)) { Model.Hazard_RoutingInspection routingInspection = BLL.Hazard_RoutingInspectionService.GetRoutingInspectionByPatrolPlanId(this.PatrolPlanId); Model.Hazard_PatrolPlan plan = BLL.Hazard_PatrolPlanService.GetPatrolPlanByPatrolPlanId(this.PatrolPlanId); HazardSelectedItemId = plan.HazardSelectedItemId; Model.Hazard_HazardSelectedItem item = BLL.Hazard_HazardSelectedItemService.GetHazardSelectedItemByHazardSelectedItemId(plan.HazardSelectedItemId); if (routingInspection != null) { RoutingInspectionId = routingInspection.RoutingInspectionId; if (!string.IsNullOrEmpty(routingInspection.PatrolManId)) { this.drpPatrolMan.SelectedValue = routingInspection.PatrolManId; } if (routingInspection.PatrolTime != null) { this.txtPatrolTime.Text = string.Format("{0:yyyy-MM-dd}", routingInspection.PatrolTime); } if (routingInspection.PatrolResult != null) { this.rblPatrolResult.SelectedValue = routingInspection.PatrolResult.ToString(); } this.txtControlMeasures.Text = routingInspection.ControlMeasures; this.txtDealReason.Text = routingInspection.DealReason; if (!string.IsNullOrEmpty(routingInspection.RiskManId)) { // this.drpRiskMan.SelectedValue = routingInspection.RiskManId; } } else { this.drpPatrolMan.SelectedValue = this.CurrUser.UserId; this.txtPatrolTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); //this.drpRiskMan.SelectedValue = this.CurrUser.UserId; } } } } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectRiskControlMenuId, BLL.Const.BtnSave)) { SaveData(); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } } /// /// 保存数据 /// /// private void SaveData() { Model.SY_Hazard_RoutingInspection routingInspection = new Model.SY_Hazard_RoutingInspection(); routingInspection.HazardSelectedItemId = this.HazardSelectedItemId; routingInspection.PatrolManId = this.drpPatrolMan.SelectedValue; routingInspection.PatrolTime = Funs.GetNewDateTimeOrNow(this.txtPatrolTime.Text.Trim()); routingInspection.PatrolResult = Convert.ToInt32(this.rblPatrolResult.SelectedValue); //routingInspection.OldRiskLevel = p.HazardLevel; routingInspection.ControlMeasures = this.txtControlMeasures.Text.Trim(); routingInspection.DealReason = this.txtDealReason.Text.Trim(); //routingInspection.RiskManId = this.drpRiskMan.SelectedValue; routingInspection.PatrolPlanId = this.PatrolPlanId; if (!string.IsNullOrEmpty(RoutingInspectionId)) { routingInspection.RoutingInspectionId = RoutingInspectionId; //BLL.Hazard_RoutingInspectionService.UpdateRoutingInspection(routingInspection); //BLL.LogService.AddSys_Log(this.CurrUser, routingInspection.PatrolResult.ToString(), routingInspection.RoutingInspectionId, BLL.Const.ProjectRiskControlMenuId, BLL.Const.BtnModify); } else { routingInspection.RoutingInspectionId = SQLHelper.GetNewID(); this.RoutingInspectionId = routingInspection.RoutingInspectionId; //BLL.Hazard_RoutingInspectionService.AddRoutingInspection(routingInspection); BLL.LogService.AddSys_Log(this.CurrUser, routingInspection.PatrolResult.ToString(), routingInspection.RoutingInspectionId, BLL.Const.ProjectRiskControlMenuId, BLL.Const.BtnAdd); } // p.CheckDate = routingInspection.PatrolTime; } #endregion #region 附件上传 /// /// 上传附件资源 /// /// /// protected void btnAttachUrl_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.RoutingInspectionId)) { //SaveData(false); } string edit = "0"; if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectRiskControlMenuId, BLL.Const.BtnSave)) { edit = "1"; DateTime date = Funs.GetNewDateTimeOrNow(this.txtPatrolTime.Text.Trim()); string dateStr = date.Year.ToString() + date.Month.ToString(); PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/RoutingInspection/" + dateStr + "&menuId={1}&edit={2}", this.RoutingInspectionId, Const.ProjectRiskControlMenuId, edit))); } } #endregion } }