165 lines
6.0 KiB
C#
165 lines
6.0 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.ThreeYearAction.FireGasSafety
|
|
{
|
|
public partial class SafetyResponsibilityAgreementEdit : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string Id
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["Id"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["Id"] = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 项目主键
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
this.InitDropDownList();
|
|
this.Id = Request.Params["FileId"];
|
|
if (!string.IsNullOrEmpty(this.Id))
|
|
{
|
|
Model.FireGasSafety_SafetyResponsibilityAgreement model = BLL.SafetyresponsibilityagreementService.GetById(this.Id);
|
|
if (model != null)
|
|
{
|
|
this.ProjectId = model.ProjectId;
|
|
if (this.ProjectId != this.CurrUser.LoginProjectId)
|
|
{
|
|
this.InitDropDownList();
|
|
}
|
|
///读取编号
|
|
this.txtCode.Text = model.Code;
|
|
this.txtName.Text = model.Name;
|
|
this.txtResponsibleMan.Text = model.ResponsibleMan;
|
|
if (!string.IsNullOrEmpty(model.CompileMan))
|
|
{
|
|
this.drpCompileMan.SelectedValue = model.CompileMan;
|
|
}
|
|
this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", model.CompileDate);
|
|
this.txtFileContent.Text = HttpUtility.HtmlDecode(model.Content);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.drpCompileMan.SelectedValue = this.CurrUser.UserId;
|
|
this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
|
|
|
////自动生成编码
|
|
this.txtCode.Text = SQLHelper.RunProcNewId2("SpGetNewCode3ByProjectId", "dbo.FireGasSafety_SafetyResponsibilityAgreement", "Code", CurrUser.LoginProjectId);
|
|
this.txtName.Text = this.SimpleForm1.Title;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化下拉框
|
|
/// </summary>
|
|
private void InitDropDownList()
|
|
{
|
|
BLL.UserService.InitUserDropDownList(this.drpCompileMan, this.ProjectId, false);
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
this.SaveData(BLL.Const.BtnSave);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存数据
|
|
/// </summary>
|
|
/// <param name="type"></param>
|
|
private void SaveData(string type)
|
|
{
|
|
Model.FireGasSafety_SafetyResponsibilityAgreement model = new Model.FireGasSafety_SafetyResponsibilityAgreement
|
|
{
|
|
ProjectId = this.ProjectId,
|
|
Code = this.txtCode.Text.Trim(),
|
|
Name = this.txtName.Text.Trim(),
|
|
ResponsibleMan = this.txtResponsibleMan.Text.Trim()
|
|
};
|
|
if (this.drpCompileMan.SelectedValue != BLL.Const._Null)
|
|
{
|
|
model.CompileMan = this.drpCompileMan.SelectedValue;
|
|
}
|
|
model.CompileDate = Funs.GetNewDateTime(this.txtCompileDate.Text.Trim());
|
|
model.Content = HttpUtility.HtmlEncode(this.txtFileContent.Text);
|
|
////单据状态
|
|
if (!string.IsNullOrEmpty(this.Id))
|
|
{
|
|
model.Id = this.Id;
|
|
BLL.SafetyresponsibilityagreementService.Update(model);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, model.Code, model.Id, BLL.Const.SafetyResponsibilityAgreementMenuId, BLL.Const.BtnModify);
|
|
}
|
|
else
|
|
{
|
|
this.Id = SQLHelper.GetNewID(typeof(Model.FireGasSafety_SafetyResponsibilityAgreement));
|
|
model.Id = this.Id;
|
|
BLL.SafetyresponsibilityagreementService.Add(model);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, model.Code, model.Id, BLL.Const.SafetyResponsibilityAgreementMenuId, BLL.Const.BtnAdd);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 附件上传
|
|
/// <summary>
|
|
/// 上传附件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAttachUrl_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.Id))
|
|
{
|
|
SaveData(BLL.Const.BtnSave);
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/SafetyResponsibilityAgreementAttachUrl&menuId={1}", Id, BLL.Const.SafetyResponsibilityAgreementMenuId)));
|
|
}
|
|
#endregion
|
|
}
|
|
} |