169 lines
6.1 KiB
C#
169 lines
6.1 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 FireFightingEquipmentEdit : 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_FireFightingEquipment model = BLL.FirefightingequipmentService.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.txtPosition.Text = model.Position;
|
|||
|
if (!string.IsNullOrEmpty(model.CompileMan))
|
|||
|
{
|
|||
|
this.drpCompileMan.SelectedValue = model.CompileMan;
|
|||
|
}
|
|||
|
this.txtFindHiddenDanger.Text = model.FindHiddenDanger;
|
|||
|
this.txtHandlingMeasures.Text = model.HandlingMeasures;
|
|||
|
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_FireFightingEquipment", "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_FireFightingEquipment model = new Model.FireGasSafety_FireFightingEquipment
|
|||
|
{
|
|||
|
ProjectId = this.ProjectId,
|
|||
|
Code = this.txtCode.Text.Trim(),
|
|||
|
Name = this.txtName.Text.Trim(),
|
|||
|
Position = this.txtPosition.Text.Trim(),
|
|||
|
FindHiddenDanger = this.txtFindHiddenDanger.Text.Trim(),
|
|||
|
HandlingMeasures = this.txtHandlingMeasures.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.FirefightingequipmentService.Update(model);
|
|||
|
BLL.LogService.AddSys_Log(this.CurrUser, model.Code, model.Id, BLL.Const.FireFightingEquipmentMenuId, BLL.Const.BtnModify);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.Id = SQLHelper.GetNewID(typeof(Model.FireGasSafety_FireFightingEquipment));
|
|||
|
model.Id = this.Id;
|
|||
|
BLL.FirefightingequipmentService.Add(model);
|
|||
|
BLL.LogService.AddSys_Log(this.CurrUser, model.Code, model.Id, BLL.Const.FireFightingEquipmentMenuId, 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/FireFightingEquipmentAttachUrl&menuId={1}", Id, BLL.Const.FireFightingEquipmentMenuId)));
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|