SGGL_JT/SUBQHSE/FineUIPro.Web/ThreeYearAction/ConstructionStandardization/BenchmarkWorkSiteEdit.aspx.cs

220 lines
8.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
namespace FineUIPro.Web.ThreeYearAction.ConstructionStandardization
{
public partial class BenchmarkWorkSiteEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
private string Id
{
get
{
return (string)ViewState["Id"];
}
set
{
ViewState["Id"] = value;
}
}
/// <summary>
/// 附件路径
/// </summary>
public string AttachUrl
{
get
{
return (string)ViewState["AttachUrl"];
}
set
{
ViewState["AttachUrl"] = 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.btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.InitDropDownList();
this.Id = Request.Params["Id"];
if (!string.IsNullOrEmpty(this.Id))
{
Model.ConstructionStandardization_BenchmarkWorkSite model = BLL.BenchmarkWorkSiteService.GetById(this.Id);
if (model != null)
{
UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpGeneralContractorUnit, model.ProjectId, BLL.Const.ProjectUnitType_1, false);
UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpSupervisor, model.ProjectId, BLL.Const.ProjectUnitType_3, false);
UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpOwner, model.ProjectId, BLL.Const.ProjectUnitType_4, false);
///读取编号
this.txtCode.Text = model.Code;
this.txtName.Text = model.Name;
this.drpProject.SelectedValue = model.ProjectId;
this.drpGeneralContractorUnit.SelectedValue = model.GeneralContractor;
this.drpSupervisor.SelectedValue = model.Supervisor;
this.drpOwner.SelectedValue = model.Owner;
this.txtAchieveResults.Text = model.AchieveResults;
this.txtGraphicProgress.Text = model.GraphicProgress;
this.txtUnitOpinion.Text = model.UnitOpinion;
}
}
//else
//{
// //自动生成编码
// this.txtCode.Text = SQLHelper.RunProcNewId2("SpGetNewCode3ByProjectId", "dbo.FireGasSafety_BenchmarkWorkSite", "Code", CurrUser.LoginProjectId);
// //自动生成编码
// this.txtCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.BenchmarkWorkSiteMenuId, this.CurrUser.LoginProjectId, this.CurrUser.UnitId);
//}
}
}
#endregion
/// <summary>
/// 初始化下拉框
/// </summary>
private void InitDropDownList()
{
BLL.ProjectService.InitAllProjectDropDownList(this.drpProject, 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)
{
if (this.drpProject.SelectedValue == BLL.Const._Null)
{
Alert.ShowInTop("请选择项目", MessageBoxIcon.Warning);
return;
}
if (this.drpGeneralContractorUnit.SelectedValue == BLL.Const._Null)
{
Alert.ShowInTop("请选择总包单位", MessageBoxIcon.Warning);
return;
}
if (this.drpSupervisor.SelectedValue == BLL.Const._Null)
{
Alert.ShowInTop("请选择监理单位", MessageBoxIcon.Warning);
return;
}
if (this.drpOwner.SelectedValue == BLL.Const._Null)
{
Alert.ShowInTop("请选择业主单位", MessageBoxIcon.Warning);
return;
}
Model.ConstructionStandardization_BenchmarkWorkSite model = new Model.ConstructionStandardization_BenchmarkWorkSite
{
Code = this.txtCode.Text.Trim(),
Name = this.txtName.Text.Trim(),
AchieveResults = this.txtAchieveResults.Text.Trim(),
GraphicProgress = this.txtGraphicProgress.Text.Trim(),
UnitOpinion = this.txtUnitOpinion.Text.Trim(),
CompileMan = this.CurrUser.UserId,
CompileDate = DateTime.Now
};
model.ProjectId = this.drpProject.SelectedValue;
model.GeneralContractor = this.drpGeneralContractorUnit.SelectedValue;
model.Owner = this.drpOwner.SelectedValue;
model.Supervisor = this.drpSupervisor.SelectedValue;
model.CompileMan = this.CurrUser.UserId;
model.CompileDate = DateTime.Now;
if (!string.IsNullOrEmpty(this.Id))
{
model.Id = this.Id;
BLL.BenchmarkWorkSiteService.Update(model);
BLL.LogService.AddSys_Log(this.CurrUser, model.Code, model.Id, BLL.Const.BenchmarkWorkSiteMenuId, BLL.Const.BtnModify);
}
else
{
this.Id = SQLHelper.GetNewID(typeof(Model.ConstructionStandardization_BenchmarkWorkSite));
model.Id = this.Id;
BLL.BenchmarkWorkSiteService.Add(model);
BLL.LogService.AddSys_Log(this.CurrUser, model.Code, model.Id, BLL.Const.BenchmarkWorkSiteMenuId, BLL.Const.BtnAdd);
}
}
#endregion
#region DropDownList下拉选择事件
/// <summary>
/// 项目下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpProject_SelectedIndexChanged(object sender, EventArgs e)
{
UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpGeneralContractorUnit, this.drpProject.SelectedValue, BLL.Const.ProjectUnitType_1, false);
UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpSupervisor, this.drpProject.SelectedValue, BLL.Const.ProjectUnitType_3, false);
UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpOwner, this.drpProject.SelectedValue, BLL.Const.ProjectUnitType_4, false);
}
#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/BenchmarkWorkSite&menuId={1}", Id, BLL.Const.BenchmarkWorkSiteMenuId)));
}
#endregion
}
}