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 LeaderCheckEdit : 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;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 页面加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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_LeaderCheck.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);
|
|
|
|
txtCLeaders.Text = result.CLeaders.ToString();
|
|
txtBLeaders.Text = result.BLeaders;
|
|
txtCheckDate.Text = result.CheckDate.ToString();
|
|
txtHiddendangers.Text = result.Hiddendangers.ToString() ;
|
|
|
|
txtCloseDate.Text = result.CloseDate.ToString();
|
|
drpCloseType.SelectedValue = result.CloseType;
|
|
txtRemarks.Text = result.Remarks;
|
|
}
|
|
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_LeaderCheck model = new Model.Report_LeaderCheck();
|
|
model.ProjectId = this.CurrUser.LoginProjectId;
|
|
model.Unitid = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId).UnitId;
|
|
model.Months = Convert.ToDateTime(this.txtMonths.Text);
|
|
|
|
model.CheckDate = Convert.ToDateTime(txtCheckDate.Text.Trim());
|
|
model.CloseDate = Convert.ToDateTime(txtCloseDate.Text.Trim());
|
|
model.CLeaders = txtCLeaders.Text.Trim();
|
|
model.BLeaders = txtBLeaders.Text.Trim();
|
|
model.CloseType = drpCloseType.SelectedValue;
|
|
model.Hiddendangers = Convert.ToInt32(txtHiddendangers.Text);
|
|
model.Remarks = txtRemarks.Text;
|
|
|
|
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;
|
|
LeaderCheckService.Update(model);
|
|
}
|
|
else
|
|
{
|
|
model.Id = SQLHelper.GetNewID(typeof(Model.Report_LeaderCheck));
|
|
this.Id = model.Id;
|
|
LeaderCheckService.Insert(model);
|
|
}
|
|
}
|
|
}
|
|
} |