ZHJA_HJGL/HJGL_ZH/FineUIPro.Web/common/Resource/EditLawRegulation.aspx.cs

220 lines
8.5 KiB
C#
Raw Normal View History

2024-05-08 17:17:11 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
namespace FineUIPro.Web.common.Resource
{
public partial class EditLawRegulation : PageBase
{
/// <summary>
///新建时生成新的法律法规编号
/// </summary>
public string NewLawRegulationId
{
get
{
return (string)ViewState["NewLawRegulationId"];
}
set
{
ViewState["NewLawRegulationId"] = value;
}
}
/// <summary>
/// 法律法规编号
/// </summary>
public string LawRegulationId
{
get
{
return (string)ViewState["LawRegulationId"];
}
set
{
ViewState["LawRegulationId"] = value;
}
}
/// <summary>
/// 类型1-施工安全2-施工质量
/// </summary>
public string Type
{
get
{
return (string)ViewState["Type"];
}
set
{
ViewState["Type"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.LawRegulationId = Request.Params["lawRegulationId"];
this.NewLawRegulationId = Request.Params["newLawRegulationId"];
this.Type = Request.Params["type"];
if (!string.IsNullOrEmpty(this.LawRegulationId))
{
var law = BLL.Common_LawRegulationService.GetLawRegulationByLawRegulationId(this.LawRegulationId);
if (law != null)
{
this.txtLawRegulationCode.Text = law.LawRegulationCode.ToString();
this.txtLawRegulationName.Text = law.LawRegulationName;
if (!string.IsNullOrEmpty(law.LawRegulationGrade))
{
this.drpLawRegulationGrade.SelectedValue = law.LawRegulationGrade;
}
if (law.AffectiveDate.HasValue)
{
this.txtAffectiveDate.Text = string.Format("{0:yyyy-MM-dd}", law.AffectiveDate);
}
if (law.ApproveDate.HasValue)
{
this.txtApproveDate.Text = string.Format("{0:yyyy-MM-dd}", law.ApproveDate);
}
if (law.ImplementationDate.HasValue)
{
this.txtImplementationDate.Text = string.Format("{0:yyyy-MM-dd}", law.ImplementationDate);
}
if (law.RevisionDate.HasValue)
{
this.txtRevisionDate.Text = string.Format("{0:yyyy-MM-dd}", law.RevisionDate);
}
this.txtAttentionItem.Text = law.AttentionItem;
}
}
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
if (GetButtonPower(BLL.Const.BtnSave))
{
Model.Common_LawRegulation newLaw = new Model.Common_LawRegulation();
newLaw.LawRegulationCode = Convert.ToInt32(this.txtLawRegulationCode.Text);
newLaw.LawRegulationName = this.txtLawRegulationName.Text;
if (this.drpLawRegulationGrade.SelectedValue != "0")
{
newLaw.LawRegulationGrade = this.drpLawRegulationGrade.SelectedValue;
}
if (!string.IsNullOrEmpty(this.txtAffectiveDate.Text))
{
newLaw.AffectiveDate = Convert.ToDateTime(this.txtAffectiveDate.Text);
}
if (!string.IsNullOrEmpty(this.txtApproveDate.Text))
{
newLaw.ApproveDate = Convert.ToDateTime(this.txtApproveDate.Text);
}
if (!string.IsNullOrEmpty(this.txtImplementationDate.Text))
{
newLaw.ImplementationDate = Convert.ToDateTime(this.txtImplementationDate.Text);
}
if (!string.IsNullOrEmpty(this.txtRevisionDate.Text))
{
newLaw.RevisionDate = Convert.ToDateTime(this.txtRevisionDate.Text);
}
newLaw.AttentionItem = this.txtAttentionItem.Text;
newLaw.Type = this.Type;
if (string.IsNullOrEmpty(this.LawRegulationId))
{
if (!BLL.Common_LawRegulationService.IsExistLawRegulationCode(NewLawRegulationId, newLaw.LawRegulationCode, this.Type))
{
newLaw.LawRegulationId = NewLawRegulationId;
newLaw.IsModel = "0";
BLL.Common_LawRegulationService.AddLawRegulation(newLaw);
BLL.Sys_LogService.AddLog(BLL.Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "添加法律法规信息");
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
ShowAlert("编号不能重复!", MessageBoxIcon.Warning);
}
}
else
{
if (!BLL.Common_LawRegulationService.IsExistLawRegulationCode(LawRegulationId, newLaw.LawRegulationCode, this.Type))
{
Model.Common_LawRegulation law = BLL.Common_LawRegulationService.GetLawRegulationByLawRegulationId(LawRegulationId);
newLaw.LawRegulationId = this.LawRegulationId;
newLaw.IsModel = law.IsModel;
BLL.Common_LawRegulationService.UpdateLawRegulation(newLaw);
BLL.Sys_LogService.AddLog(BLL.Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "修改法律法规信息");
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
ShowAlert("编号不能重复!", MessageBoxIcon.Warning);
}
}
}
else
{
Alert.ShowInParent("您没有这个权限,请与管理员联系!!");
}
}
protected void btnClose_Click(object sender, EventArgs e)
{
// 关闭窗体时未提交则删除已上传的附件
var q = BLL.Common_LawRegulationService.GetLawRegulationByLawRegulationId(NewLawRegulationId);
if (q == null)
{
BLL.AttachFileService.DeleteAttachFile(BLL.Funs.RootPath, NewLawRegulationId, Const.LawRegulationListMenuId);
}
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
/// <summary>
/// 附件上传处理
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void UploadAttach_Click(object sender, EventArgs e)
{
string edit = "0"; // 表示能打开附件上传窗口,但不能操作
string tokey = "";
if (GetButtonPower(BLL.Const.BtnSave))
{
if (string.IsNullOrEmpty(this.LawRegulationId))
{
tokey = this.NewLawRegulationId;
}
else
{
tokey = LawRegulationId;
}
edit = "1";
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Common/LawRegulation&menuId={1}&edit={2}", tokey, Const.LawRegulationListMenuId, edit)));
}
}
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private bool GetButtonPower(string button)
{
return BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.LawRegulationListMenuId, button);
}
}
}