SGGL_JT/SUBQHSE/FineUIPro.Web/HSSE/Meeting/WeekMeetingEdit.aspx.cs

240 lines
10 KiB
C#
Raw Normal View History

2025-04-07 17:43:30 +08:00
using System;
using System.Web;
using BLL;
namespace FineUIPro.Web.HSSE.Meeting
{
public partial class WeekMeetingEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string WeekMeetingId
{
get
{
return (string)ViewState["WeekMeetingId"];
}
set
{
ViewState["WeekMeetingId"] = 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.WeekMeetingId = Request.Params["WeekMeetingId"];
if (!string.IsNullOrEmpty(this.WeekMeetingId))
{
Model.Meeting_WeekMeeting weekMeeting = BLL.WeekMeetingService.GetWeekMeetingById(this.WeekMeetingId);
if (weekMeeting != null)
{
this.ProjectId = weekMeeting.ProjectId;
if (this.ProjectId != this.CurrUser.LoginProjectId)
{
this.InitDropDownList();
}
///读取编号
this.txtWeekMeetingCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(this.WeekMeetingId);
this.txtWeekMeetingName.Text = weekMeeting.WeekMeetingName;
this.txtWeekMeetingDate.Text = string.Format("{0:yyyy-MM-dd}", weekMeeting.WeekMeetingDate);
if (weekMeeting.AttentPersonNum != null)
{
this.txtAttentPersonNum.Text = weekMeeting.AttentPersonNum.ToString();
}
if (!string.IsNullOrEmpty(weekMeeting.CompileMan))
{
this.drpCompileMan.SelectedValue = weekMeeting.CompileMan;
}
this.txtWeekMeetingContents.Text = HttpUtility.HtmlDecode(weekMeeting.WeekMeetingContents);
this.txtMeetingHours.Text = Convert.ToString(weekMeeting.MeetingHours);
var hostMan = BLL.UserService.GetUserByUserId(weekMeeting.MeetingHostMan);
if (hostMan != null)
{
this.txtMeetingHostMan.Text = hostMan.UserName;
}
else
{
this.txtMeetingHostMan.Text = weekMeeting.MeetingHostMan;
}
this.txtAttentPerson.Text = weekMeeting.AttentPerson;
this.drpUnit.SelectedValue = weekMeeting.UnitId;
}
}
else
{
this.drpCompileMan.SelectedValue = this.CurrUser.UserId;
this.drpUnit.SelectedValue = this.CurrUser.UnitId ?? CommonService.GetThisUnitId();
this.txtWeekMeetingDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
var codeTemplateRule = BLL.SysConstSetService.GetCodeTemplateRuleByMenuId(BLL.Const.ProjectWeekMeetingMenuId);
if (codeTemplateRule != null)
{
this.txtWeekMeetingContents.Text = HttpUtility.HtmlDecode(codeTemplateRule.Template);
}
////自动生成编码
this.txtWeekMeetingCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectWeekMeetingMenuId, this.ProjectId, this.CurrUser.UnitId);
this.txtWeekMeetingName.Text = this.SimpleForm1.Title;
this.txtMeetingHours.Text = "1";
this.txtMeetingHostMan.Text = this.CurrUser.UserName;
}
}
}
#endregion
/// <summary>
/// 初始化下拉框
/// </summary>
private void InitDropDownList()
{
BLL.UnitService.InitProjectUnitDropDownList(this.drpUnit, this.ProjectId, false);
BLL.UserService.InitUserDropDownList(this.drpCompileMan, this.ProjectId, true);
}
#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.Meeting_WeekMeeting weekMeeting = new Model.Meeting_WeekMeeting
{
ProjectId = this.ProjectId,
WeekMeetingCode = this.txtWeekMeetingCode.Text.Trim(),
WeekMeetingName = this.txtWeekMeetingName.Text.Trim(),
WeekMeetingDate = Funs.GetNewDateTime(this.txtWeekMeetingDate.Text.Trim()),
AttentPersonNum = Funs.GetNewIntOrZero(this.txtAttentPersonNum.Text.Trim()),
WeekMeetingContents = HttpUtility.HtmlEncode(this.txtWeekMeetingContents.Text),
CompileDate = DateTime.Now,
MeetingHours = Funs.GetNewIntOrZero(this.txtMeetingHours.Text.Trim()),
MeetingHostMan = this.txtMeetingHostMan.Text.Trim(),
AttentPerson = this.txtAttentPerson.Text.Trim(),
States = BLL.Const.State_2,
};
if (this.drpCompileMan.SelectedValue != BLL.Const._Null)
{
weekMeeting.CompileMan = this.drpCompileMan.SelectedValue;
}
if (this.drpUnit.SelectedValue != BLL.Const._Null)
{
weekMeeting.UnitId = this.drpUnit.SelectedValue;
}
if (!string.IsNullOrEmpty(this.WeekMeetingId))
{
weekMeeting.WeekMeetingId = this.WeekMeetingId;
BLL.WeekMeetingService.UpdateWeekMeeting(weekMeeting);
BLL.LogService.AddSys_Log(this.CurrUser, weekMeeting.WeekMeetingCode, weekMeeting.WeekMeetingId, BLL.Const.ProjectWeekMeetingMenuId, BLL.Const.BtnModify);
}
else
{
this.WeekMeetingId = SQLHelper.GetNewID();
weekMeeting.WeekMeetingId = this.WeekMeetingId;
BLL.WeekMeetingService.AddWeekMeeting(weekMeeting);
BLL.LogService.AddSys_Log(this.CurrUser, weekMeeting.WeekMeetingCode, weekMeeting.WeekMeetingId, BLL.Const.ProjectWeekMeetingMenuId, BLL.Const.BtnAdd);
}
//Project_HSSEData_HSSEService.StatisticalData(this.CurrUser.LoginProjectId, Project_HSSEData_HSSEService.HSSEDateType.SafetyMeeting);
}
#endregion
#region
/// <summary>
/// 上传附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.WeekMeetingId))
{
SaveData(BLL.Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/WeekMeetingAttachUrl&menuId={1}", WeekMeetingId,BLL.Const.ProjectWeekMeetingMenuId)));
}
#endregion
protected void btnAttachUrl1_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.WeekMeetingId))
{
SaveData(Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/ClassMeetingAttachUrl&menuId={1}&strParam=1", this.WeekMeetingId, Const.ProjectWeekMeetingMenuId)));
}
protected void btnAttachUrl2_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.WeekMeetingId))
{
SaveData(Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/ClassMeetingAttachUrl&menuId={1}&strParam=2", this.WeekMeetingId, Const.ProjectWeekMeetingMenuId)));
}
/// <summary>
/// 计算参会人数
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void txtAttentPerson_Blur(object sender, EventArgs e)
{
string str = this.txtAttentPerson.Text.Trim();
if (!string.IsNullOrEmpty(str))
{
if (str.Contains(","))
{
this.txtAttentPersonNum.Text = str.Split(',').Length.ToString();
}
else if (str.Contains(""))
{
this.txtAttentPersonNum.Text = str.Split('').Length.ToString();
}
else if (str.Contains(";"))
{
this.txtAttentPersonNum.Text = str.Split(';').Length.ToString();
}
else if (str.Contains(""))
{
this.txtAttentPersonNum.Text = str.Split('').Length.ToString();
}
}
}
}
}