144 lines
6.1 KiB
C#
144 lines
6.1 KiB
C#
using System;
|
|
using BLL;
|
|
using Model;
|
|
|
|
namespace FineUIPro.Web.common.BaseInfo
|
|
{
|
|
public partial class ProjectEdit : PageBase
|
|
{
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
LoadData();
|
|
BLL.Base_ProjectTypeService.InitProjectTypeDropDownList(drpProjectType, true, Resources.Lan.PleaseSelect);
|
|
string projectId = Request.QueryString["ProjectId"];
|
|
|
|
if (!String.IsNullOrEmpty(projectId))
|
|
{
|
|
var q = BLL.Base_ProjectService.GetProjectByProjectId(projectId);
|
|
if (q != null)
|
|
{
|
|
txtProjectCode.Text = q.ProjectCode;
|
|
txtProjectName.Text = q.ProjectName;
|
|
txtShortName.Text = q.ShortName;
|
|
txtProjectAddress.Text = q.ProjectAddress;
|
|
|
|
if (q.StartDate.HasValue)
|
|
{
|
|
txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", q.StartDate);
|
|
}
|
|
if (q.EndDate.HasValue)
|
|
{
|
|
txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", q.EndDate);
|
|
}
|
|
if (q.ProjectTypeId != null)
|
|
{
|
|
drpProjectType.SelectedValue = q.ProjectTypeId;
|
|
}
|
|
|
|
this.txtProjectPrincipal.Text = q.ProjectPrincipal;
|
|
this.txtConstructionPrincipal.Text = q.ConstructionPrincipal;
|
|
txtRemark.Text = q.Remark;
|
|
|
|
if (q.IsClosed.HasValue)
|
|
{
|
|
this.ckbIsClosed.Checked = q.IsClosed.Value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void LoadData()
|
|
{
|
|
btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.ProjectMenuId, Const.BtnSave))
|
|
{
|
|
Model.Base_Project project = new Base_Project();
|
|
string projectId = Request.QueryString["ProjectId"];
|
|
|
|
project.ProjectCode = txtProjectCode.Text.Trim();
|
|
project.ProjectName = txtProjectName.Text.Trim();
|
|
project.ShortName = txtShortName.Text.Trim();
|
|
project.ProjectAddress = txtProjectAddress.Text.Trim();
|
|
if (!string.IsNullOrEmpty(txtStartDate.Text.Trim()))
|
|
{
|
|
project.StartDate = Convert.ToDateTime(txtStartDate.Text.Trim());
|
|
}
|
|
if (!string.IsNullOrEmpty(txtEndDate.Text.Trim()))
|
|
{
|
|
project.EndDate = Convert.ToDateTime(txtEndDate.Text.Trim());
|
|
}
|
|
if (drpProjectType.SelectedValue != "null")
|
|
{
|
|
project.ProjectTypeId = drpProjectType.SelectedValue;
|
|
}
|
|
|
|
project.ProjectPrincipal = this.txtProjectPrincipal.Text.Trim();
|
|
project.ConstructionPrincipal = this.txtConstructionPrincipal.Text.Trim();
|
|
project.IsClosed = ckbIsClosed.Checked;
|
|
project.Remark = txtRemark.Text.Trim();
|
|
|
|
if (String.IsNullOrEmpty(projectId))
|
|
{
|
|
string newProjectId = SQLHelper.GetNewID(typeof(Model.Base_Project));
|
|
project.ProjectId = newProjectId;
|
|
if (!BLL.Base_ProjectService.IsExistProjectCode(newProjectId, txtProjectCode.Text.Trim()))
|
|
{
|
|
BLL.Base_ProjectService.AddProject(project);
|
|
|
|
// 给新项目拷贝一份系统环境设置
|
|
string setSql = "insert into dbo.Sys_Set (SetId,SetName,IsAuto,SetValue,ProjectId) select SetId,SetName,IsAuto,SetValue,'" + newProjectId + "' from dbo.Sys_Set where ProjectId='0'";
|
|
BLL.SQLHelper.ExecutSql(setSql);
|
|
BLL.Sys_LogService.AddLog(Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.ProjectMenuId, Const.BtnAdd, newProjectId);
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInParent(Resources.Lan.ProjectCodeExists, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!BLL.Base_ProjectService.IsExistProjectCode(projectId, txtProjectCode.Text.Trim()))
|
|
{
|
|
Model.Base_Project oldProject = BLL.Base_ProjectService.GetProjectByProjectId(projectId);
|
|
project.ProjectId = projectId;
|
|
BLL.Base_ProjectService.UpdateProject(project);
|
|
BLL.Sys_LogService.AddLog(Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.ProjectMenuId, Const.BtnModify, projectId);
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInParent(Resources.Lan.ProjectCodeExists, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
// 关闭本窗体,然后回发父窗体
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
else
|
|
{
|
|
ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |