ChengDa_English/SGGL/FineUIPro.Web/ZHGL/Meeting/CompanySafetyMeetingEdit.as...

201 lines
9.3 KiB
C#
Raw Normal View History

2023-06-09 10:20:38 +08:00
using BLL;
using System;
using System.Web;
namespace FineUIPro.Web.ZHGL.Meeting
{
public partial class CompanySafetyMeetingEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string CompanySafetyMeetingId
{
get
{
return (string)ViewState["CompanySafetyMeetingId"];
}
set
{
ViewState["CompanySafetyMeetingId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.InitDropDownList();
this.CompanySafetyMeetingId = Request.Params["CompanySafetyMeetingId"];
if (!string.IsNullOrEmpty(this.CompanySafetyMeetingId))
{
Model.Meeting_CompanySafetyMeeting CompanySafetyMeeting = BLL.CompanySafetyMeetingService.GetCompanySafetyMeetingById(this.CompanySafetyMeetingId);
if (CompanySafetyMeeting != null)
{
this.txtCompanySafetyMeetingCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(this.CompanySafetyMeetingId);
this.txtCompanySafetyMeetingName.Text = CompanySafetyMeeting.CompanySafetyMeetingName;
this.txtCompanySafetyMeetingDate.Text = string.Format("{0:yyyy-MM-dd}", CompanySafetyMeeting.CompanySafetyMeetingDate);
if (!string.IsNullOrEmpty(CompanySafetyMeeting.CompileMan))
{
this.drpCompileMan.SelectedValue = CompanySafetyMeeting.CompileMan;
}
if (CompanySafetyMeeting.AttentPersonNum != null)
{
this.txtAttentPersonNum.Text = CompanySafetyMeeting.AttentPersonNum.ToString();
}
this.txtCompanySafetyMeetingContents.Text = HttpUtility.HtmlDecode(CompanySafetyMeeting.CompanySafetyMeetingContents);
this.txtMeetingHours.Text = Convert.ToString(CompanySafetyMeeting.MeetingHours);
this.txtMeetingHostMan.Text = CompanySafetyMeeting.MeetingHostMan;
this.txtAttentPerson.Text = CompanySafetyMeeting.AttentPerson;
}
}
else
{
this.drpCompileMan.SelectedValue = this.CurrUser.UserId;
this.txtCompanySafetyMeetingDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
var codeTemplateRule = BLL.SysConstSetService.GetCodeTemplateRuleByMenuId(BLL.Const.ProjectWeekMeetingMenuId);
if (codeTemplateRule != null)
{
this.txtCompanySafetyMeetingContents.Text = HttpUtility.HtmlDecode(codeTemplateRule.Template);
}
////自动生成编码
this.txtCompanySafetyMeetingCode.Text = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.CompanySafetyMeetingMenuId, null, this.CurrUser.UnitId);
this.txtCompanySafetyMeetingName.Text = this.SimpleForm1.Title;
this.txtMeetingHours.Text = "1";
this.txtMeetingHostMan.Text = this.CurrUser.UserName;
}
}
}
#endregion
/// <summary>
/// 初始化下拉框
/// </summary>
private void InitDropDownList()
{
UserService.InitUserDropDownList(this.drpCompileMan, null, 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_CompanySafetyMeeting CompanySafetyMeeting = new Model.Meeting_CompanySafetyMeeting
{
CompanySafetyMeetingCode = this.txtCompanySafetyMeetingCode.Text.Trim(),
CompanySafetyMeetingName = this.txtCompanySafetyMeetingName.Text.Trim(),
CompanySafetyMeetingDate = Funs.GetNewDateTime(this.txtCompanySafetyMeetingDate.Text.Trim())
};
if (this.drpCompileMan.SelectedValue != BLL.Const._Null)
{
CompanySafetyMeeting.CompileMan = this.drpCompileMan.SelectedValue;
}
CompanySafetyMeeting.AttentPersonNum = Funs.GetNewIntOrZero(this.txtAttentPersonNum.Text.Trim());
CompanySafetyMeeting.CompanySafetyMeetingContents = HttpUtility.HtmlEncode(this.txtCompanySafetyMeetingContents.Text);
CompanySafetyMeeting.CompileDate = DateTime.Now;
CompanySafetyMeeting.MeetingHours = Funs.GetNewInt(this.txtMeetingHours.Text.Trim());
CompanySafetyMeeting.MeetingHostMan = this.txtMeetingHostMan.Text.Trim();
CompanySafetyMeeting.AttentPerson = this.txtAttentPerson.Text.Trim();
if (!string.IsNullOrEmpty(this.CompanySafetyMeetingId))
{
CompanySafetyMeeting.CompanySafetyMeetingId = this.CompanySafetyMeetingId;
BLL.CompanySafetyMeetingService.UpdateCompanySafetyMeeting(CompanySafetyMeeting);
BLL.LogService.AddSys_Log(this.CurrUser, CompanySafetyMeeting.CompanySafetyMeetingCode, CompanySafetyMeeting.CompanySafetyMeetingId, BLL.Const.CompanySafetyMeetingMenuId, BLL.Const.BtnModify);
}
else
{
this.CompanySafetyMeetingId = SQLHelper.GetNewID(typeof(Model.Meeting_CompanySafetyMeeting));
CompanySafetyMeeting.CompanySafetyMeetingId = this.CompanySafetyMeetingId;
BLL.CompanySafetyMeetingService.AddCompanySafetyMeeting(CompanySafetyMeeting);
BLL.LogService.AddSys_Log(this.CurrUser, CompanySafetyMeeting.CompanySafetyMeetingCode, CompanySafetyMeeting.CompanySafetyMeetingId, BLL.Const.CompanySafetyMeetingMenuId, 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.CompanySafetyMeetingId))
{
SaveData(BLL.Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CompanySafetyMeetingAttachUrl&menuId={1}", this.CompanySafetyMeetingId, BLL.Const.CompanySafetyMeetingMenuId)));
}
#endregion
protected void btnAttachUrl1_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.CompanySafetyMeetingId))
{
SaveData(Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CompanySafetyMeetingAttachUrl&menuId={1}&strParam=1", this.CompanySafetyMeetingId, Const.CompanySafetyMeetingMenuId)));
}
protected void btnAttachUrl2_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.CompanySafetyMeetingId))
{
SaveData(Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CompanySafetyMeetingAttachUrl&menuId={1}&strParam=2", this.CompanySafetyMeetingId, Const.CompanySafetyMeetingMenuId)));
}
/// <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();
}
}
}
}
}