using BLL; using System; namespace FineUIPro.Web.CQMS.Check { public partial class AdminPenaltyEdit : PageBase { /// /// 项目主键 /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } /// /// 主键 /// public string PenaltyId { get { return (string)ViewState["PenaltyId"]; } set { ViewState["PenaltyId"] = value; } } /// /// 图片是否可以编辑 -1查看 0编辑 /// public int QuestionImg { get { return Convert.ToInt32(ViewState["QuestionImg"]); } set { ViewState["QuestionImg"] = value; } } /// /// 1:安全、2:质量 /// public string SysTemType { get { return (string)ViewState["SysTemType"]; } set { ViewState["SysTemType"] = value; } } /// /// 菜单Id /// public string MenuId { get { return (string)ViewState["MenuId"]; } set { ViewState["MenuId"] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ProjectId = this.CurrUser.LoginProjectId; this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.PenaltyId = Request.Params["PenaltyId"]; this.SysTemType = Request.Params["type"] ?? "1"; this.MenuId = BLL.Const.AdminPenaltyMenuId; UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpUnit, this.CurrUser.LoginProjectId, "", true); if (!string.IsNullOrEmpty(PenaltyId)) { //this.hdId.Text = PenaltyId; Model.Check_AdminPenalty model = BLL.AdminPenaltyService.GetAdminPenaltyById(PenaltyId); if (model != null) { this.ProjectId = model.ProjectId; this.txtCode.Text = model.PenaltyCode; this.txtPenaltyDate.Text = model.PenaltyDate.ToString("yyyy-MM-dd"); this.drpUnit.SelectedValue = model.UnitId; this.drpPenaltyType.SelectedValue = model.PenaltyType; this.drpPenaltyStatus.SelectedValue = model.PenaltyStatus; if (model.PenaltyAmount.HasValue) { this.txtMoney.Text = model.PenaltyAmount.Value.ToString(); } this.txtPenaltyAuthority.Text = model.PenaltyAuthority; this.txtDescription.Text = model.PenaltyContent; this.txtRemark.Text = model.Remark; } } else { ////自动生成编码 this.txtCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(this.MenuId, this.ProjectId, this.CurrUser.UnitId); this.txtPenaltyDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); } } } protected void WindowAtt_Close(object sender, WindowCloseEventArgs e) { } /// /// 保存 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { string unitId = this.drpUnit.SelectedValue; if (string.IsNullOrWhiteSpace(unitId) || unitId == Const._Null) { Alert.ShowInTop("请选择处罚单位!", MessageBoxIcon.Warning); return; } if (!string.IsNullOrWhiteSpace(this.txtMoney.Text)) { decimal moneyValue; if (decimal.TryParse(this.txtMoney.Text.Trim(), out moneyValue)) { } else { Alert.ShowInTop("金额必须为有效数字!", MessageBoxIcon.Warning); return; } } SaveData(true); PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } /// /// 保存 /// private void SaveData(bool isClose) { string unitId = this.drpUnit.SelectedValue; if (string.IsNullOrWhiteSpace(unitId) || unitId == Const._Null) { Alert.ShowInTop("请选择处罚单位!", MessageBoxIcon.Warning); return; } Model.Check_AdminPenalty model = new Model.Check_AdminPenalty(); model.ProjectId = this.CurrUser.LoginProjectId; model.PenaltyCode = this.txtCode.Text.Trim(); model.UnitId = unitId; model.UnitName = this.drpUnit.SelectedText; model.PenaltyType = this.drpPenaltyType.SelectedValue; model.PenaltyStatus = this.drpPenaltyStatus.SelectedValue; if (!string.IsNullOrWhiteSpace(this.txtMoney.Text)) { decimal moneyValue; if (decimal.TryParse(this.txtMoney.Text.Trim(), out moneyValue)) { model.PenaltyAmount = moneyValue; } else { Alert.ShowInTop("金额必须为有效数字!", MessageBoxIcon.Warning); return; } } model.PenaltyDate = Convert.ToDateTime(this.txtPenaltyDate.Text.Trim()); model.PenaltyContent = this.txtDescription.Text.Trim(); model.PenaltyAuthority = this.txtPenaltyAuthority.Text.Trim(); model.Remark = this.txtRemark.Text.Trim(); model.SysType = this.SysTemType; if (string.IsNullOrEmpty(this.PenaltyId)) { this.PenaltyId = SQLHelper.GetNewID(typeof(Model.Check_AdminPenalty)); model.PenaltyId = this.PenaltyId; model.CompileMan = this.CurrUser.UserId; model.CompileDate = DateTime.Now; BLL.AdminPenaltyService.AddAdminPenalty(model); } else { model.PenaltyId = this.PenaltyId; BLL.AdminPenaltyService.UpdateAdminPenalty(model); } if (isClose) { ShowNotify("保存成功!", MessageBoxIcon.Success); //更新三库事故事件 string message = string.Empty; SanKuDataSummaryReportService.UpdateAdminPenaltyRecord(model.PenaltyId, ref message); if (!string.IsNullOrWhiteSpace(message)) { ShowNotify(message, MessageBoxIcon.Warning); } } } #region 附件上传 /// /// 上传附件 /// /// /// protected void btnAttachUrl_Click2(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.PenaltyId)) { this.SaveData(false); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CheckAdminPenalty&menuId={1}", this.PenaltyId, this.MenuId))); } #endregion #region 附件上传 /// /// 上传附件 /// /// /// protected void btnAttachUrl_Click(object sender, EventArgs e) { if (this.btnSave.Hidden) { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CheckAdminPenalty&menuId={1}&type=-1", this.PenaltyId, this.MenuId))); } else { if (string.IsNullOrEmpty(this.PenaltyId)) { SaveData(false); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CheckAdminPenalty&menuId={1}", this.PenaltyId, this.MenuId))); } } #endregion } }