148 lines
4.9 KiB
C#
148 lines
4.9 KiB
C#
using BLL;
|
|
using Model.Enums;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.Customization.CNCEC4.HSSE.Report
|
|
{
|
|
public partial class EmergencyMonthEdit : PageBase
|
|
{
|
|
public string Id
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["Id"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["Id"] = value;
|
|
}
|
|
}
|
|
|
|
public string action
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["action"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["action"] = value;
|
|
}
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.Id = Request.Params[nameof(Id)];
|
|
this.action = Request.Params[nameof(action)];
|
|
showInfo();
|
|
if (this.action == ActionEnums.View.ToString())
|
|
{
|
|
btnSave.Hidden = true;
|
|
btnSubmit.Hidden = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载数据
|
|
/// </summary>
|
|
void showInfo()
|
|
{
|
|
var project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
|
|
if (project != null)
|
|
{
|
|
this.txtProjectName.Text = project.ProjectName;
|
|
this.txtUnitName.Text = BLL.UnitService.GetUnitNameByUnitId(project.UnitId);
|
|
}
|
|
|
|
var result = Funs.DB.Report_EmergencyMonth.FirstOrDefault(a => a.Id == this.Id);
|
|
if (result != null)
|
|
{
|
|
project = BLL.ProjectService.GetProjectByProjectId(result.ProjectId);
|
|
if (project != null)
|
|
{
|
|
this.txtProjectName.Text = project.ProjectName;
|
|
this.txtUnitName.Text = BLL.UnitService.GetUnitNameByUnitId(project.UnitId);
|
|
}
|
|
|
|
this.txtMonths.Text = string.Format("{0:yyyy-MM}", result.Months);
|
|
txtEmName.Text = result.EmName.ToString();
|
|
txtEmDate.Text = result.EmDate.ToString() ;
|
|
drpEmType.SelectedValue = result.EmType;
|
|
txtEmPerson.Text = result.EmPerson.ToString();
|
|
|
|
txtEmMoney.Text = result.EmMoney.ToString();
|
|
}
|
|
else
|
|
{
|
|
this.txtMonths.Text = string.Format("{0:yyyy-MM}", Request.Params["monts"].ToString());
|
|
}
|
|
}
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
SaveData(BLL.Const.BtnSave);
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 提交
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSubmit_Click(object sender, EventArgs e)
|
|
{
|
|
SaveData(BLL.Const.BtnSubmit);
|
|
ShowNotify("提交成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
|
|
void SaveData(string type)
|
|
{
|
|
Model.Report_EmergencyMonth model = new Model.Report_EmergencyMonth();
|
|
model.ProjectId = this.CurrUser.LoginProjectId;
|
|
model.Unitid = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId).UnitId;
|
|
model.Months = Convert.ToDateTime(this.txtMonths.Text);
|
|
|
|
model.EmDate = Convert.ToDateTime(txtEmDate.Text.Trim());
|
|
model.EmName = txtEmName.Text.Trim();
|
|
model.EmPerson = Convert.ToInt32(txtEmPerson.Text);
|
|
model.EmMoney = Convert.ToDecimal(txtEmMoney.Text);
|
|
model.EmType = drpEmType.SelectedValue ;
|
|
|
|
if (type == BLL.Const.BtnSave)
|
|
{
|
|
model.States = "0";
|
|
}
|
|
else
|
|
{
|
|
model.States = "1";
|
|
}
|
|
if (this.action == ActionEnums.Edit.ToString() || !string.IsNullOrEmpty(this.Id))
|
|
{
|
|
model.Id = this.Id;
|
|
EmergencyMonthService.Update(model);
|
|
}
|
|
else
|
|
{
|
|
//判断该月份是否存在
|
|
var report = BLL.EmergencyMonthService.GetReportByMonth(this.CurrUser.LoginProjectId, this.txtMonths.Text.Trim());
|
|
if (report != null)
|
|
{
|
|
Alert.ShowInTop("本月月报已存在!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
|
|
model.CreateDate = DateTime.Now;
|
|
model.Id = SQLHelper.GetNewID(typeof(Model.Report_HazardAdminister));
|
|
this.Id = model.Id;
|
|
EmergencyMonthService.Insert(model);
|
|
}
|
|
}
|
|
}
|
|
} |