302 lines
14 KiB
C#
302 lines
14 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;
|
|
using Model;
|
|
|
|
namespace FineUIPro.Web.common.BaseInfo
|
|
{
|
|
public partial class ProjectSave : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
LoadData();
|
|
|
|
///创建人
|
|
this.drpCreateMan.DataTextField = "UserName";
|
|
this.drpCreateMan.DataValueField = "UserId";
|
|
this.drpCreateMan.DataSource = BLL.Sys_UserService.GetUserList();
|
|
this.drpCreateMan.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpCreateMan);
|
|
this.drpCreateMan.SelectedValue = this.CurrUser.UserId;
|
|
///检测单位
|
|
this.drpCheckUnit.DataTextField = "UnitName";
|
|
this.drpCheckUnit.DataValueField = "UnitId";
|
|
this.drpCheckUnit.DataSource = from x in Funs.DB.Base_Unit orderby x.UnitCode select x;
|
|
this.drpCheckUnit.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpCheckUnit);
|
|
///检测标准
|
|
this.drpTestStandardId.DataTextField = "TestStandardCode";
|
|
this.drpTestStandardId.DataValueField = "TestStandardId";
|
|
this.drpTestStandardId.DataSource = BLL.HJGL_TestStandardService.GetTestStandardNameList();
|
|
this.drpTestStandardId.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpTestStandardId);
|
|
this.drpTestStandardId.SelectedValue = "4194689e-6932-43cd-ab4f-77259e1e3418";
|
|
|
|
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;
|
|
//this.rblProjectSoft.SelectedValue = q.ProjectSoft;
|
|
|
|
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.ProjectSoft == "2")
|
|
//{
|
|
// txtStartDate.Hidden = true;
|
|
// txtEndDate.Hidden = true;
|
|
// UploadAttach.Hidden = false;
|
|
//}
|
|
//else
|
|
//{
|
|
// txtStartDate.Hidden = false;
|
|
// txtEndDate.Hidden = false;
|
|
// UploadAttach.Hidden = true;
|
|
//}
|
|
|
|
this.txtProjectPrincipal.Text = q.ProjectPrincipal;
|
|
this.txtProjectManager.Text = q.ProjectManager;
|
|
this.txtSecurePrincipal.Text = q.SecurePrincipal;
|
|
this.txtTechnicalPrincipal.Text = q.TechnicalPrincipal;
|
|
|
|
txtRemark.Text = q.Remark;
|
|
|
|
if (q.IsClosed.HasValue)
|
|
{
|
|
this.ckbIsClosed.Checked = q.IsClosed.Value;
|
|
}
|
|
if (!string.IsNullOrEmpty(q.CreateManId))
|
|
{
|
|
this.drpCreateMan.SelectedValue = q.CreateManId;
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(q.CheckUnitId))
|
|
{
|
|
this.drpCheckUnit.SelectedValue = q.CheckUnitId;
|
|
}
|
|
|
|
this.txtWatchUnit.Text = q.WatchUnit;
|
|
if (!string.IsNullOrEmpty(q.TestStandardId))
|
|
{
|
|
this.drpTestStandardId.SelectedValue = q.TestStandardId;
|
|
}
|
|
}
|
|
}
|
|
//else
|
|
//{
|
|
// string projectSoft = Request.QueryString["projectSoft"];
|
|
// if (projectSoft != null)
|
|
// {
|
|
// this.rblProjectSoft.SelectedValue = projectSoft;
|
|
// if (projectSoft == "2")
|
|
// {
|
|
// txtStartDate.Hidden = true;
|
|
// txtEndDate.Hidden = true;
|
|
// UploadAttach.Hidden = false;
|
|
// }
|
|
// else
|
|
// {
|
|
// txtStartDate.Hidden = false;
|
|
// txtEndDate.Hidden = false;
|
|
// UploadAttach.Hidden = true;
|
|
// }
|
|
// }
|
|
//}
|
|
}
|
|
}
|
|
|
|
private void LoadData()
|
|
{
|
|
btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
}
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.ProjectMenuId, Const.BtnSave))
|
|
{
|
|
if (this.drpCreateMan.SelectedValue == BLL.Const._Null)
|
|
{
|
|
ShowNotify("请选择创建人!");
|
|
return;
|
|
}
|
|
if (this.drpCheckUnit.SelectedValue == BLL.Const._Null)
|
|
{
|
|
ShowNotify("请选择检测单位!");
|
|
return;
|
|
}
|
|
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();
|
|
|
|
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());
|
|
}
|
|
|
|
project.ProjectPrincipal = this.txtProjectPrincipal.Text.Trim();
|
|
project.ProjectManager = this.txtProjectManager.Text.Trim();
|
|
project.SecurePrincipal = this.txtSecurePrincipal.Text.Trim();
|
|
project.TechnicalPrincipal = this.txtTechnicalPrincipal.Text.Trim();
|
|
project.CreateManId = this.drpCreateMan.SelectedValue;
|
|
project.IsClosed = ckbIsClosed.Checked;
|
|
project.Remark = txtRemark.Text.Trim();
|
|
project.ProjectSoft = "1"; // this.rblProjectSoft.SelectedValue;
|
|
if (this.drpTestStandardId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
project.TestStandardId = this.drpTestStandardId.SelectedValue;
|
|
}
|
|
if (this.drpCheckUnit.SelectedValue != BLL.Const._Null)
|
|
{
|
|
project.CheckUnitId = this.drpCheckUnit.SelectedValue;
|
|
}
|
|
project.WatchUnit = this.txtWatchUnit.Text.Trim();
|
|
|
|
if (String.IsNullOrEmpty(projectId))
|
|
{
|
|
string newProjectId = SQLHelper.GetNewID(typeof(Model.Base_Project));
|
|
projectId = newProjectId;
|
|
project.ProjectId = newProjectId;
|
|
if (!BLL.Base_ProjectService.IsExistProjectCode(newProjectId, txtProjectCode.Text.Trim(),"1"))
|
|
{
|
|
BLL.Base_ProjectService.AddProject(project);
|
|
|
|
// 给新项目拷贝一份报表
|
|
string reportSql = "insert into dbo.Common_ReportServer (ReportId,TabContent, ReportName,InitTabContent,projectId) select ReportId,TabContent, ReportName,InitTabContent,'" + newProjectId + "' from dbo.Common_ReportServer where projectId='0'";
|
|
BLL.SQLHelper.ExecutSql(reportSql);
|
|
|
|
// 给新项目拷贝一份系统环境设置
|
|
string setSql = "insert into dbo.Project_Sys_Set (SetId,SetName,IsAuto,SetValue,ProjectId) select SetId,SetName,IsAuto,SetValue,'" + newProjectId + "' from dbo.Project_Sys_Set where ProjectId='0'";
|
|
BLL.SQLHelper.ExecutSql(setSql);
|
|
|
|
if (this.CurrUser.UserId != BLL.Const.GlyId)
|
|
{
|
|
// 给新项目项目单位插入当前用户单位
|
|
Model.Project_Unit newUnit = new Model.Project_Unit();
|
|
newUnit.ProjectId = newProjectId;
|
|
newUnit.UnitId = this.CurrUser.UnitId;
|
|
newUnit.InTime = System.DateTime.Now;
|
|
BLL.Project_UnitService.AddProject_Unit(newUnit);
|
|
|
|
// 给新项目项目用户插入当前用户
|
|
Model.Project_User newUser = new Model.Project_User();
|
|
newUser.ProjectId = newProjectId;
|
|
newUser.UserId = this.CurrUser.UserId;
|
|
newUser.IsPost = true;
|
|
|
|
BLL.Project_UserService.AddProject_User(newUser);
|
|
}
|
|
|
|
//if (project.ProjectSoft == "2")//当选择压力容器时,在新项目中增加制造分公司
|
|
//{
|
|
// Model.Project_Unit projectUnit = new Project_Unit();
|
|
// projectUnit.UnitId = BLL.Const.zzfgsId;//制造分公司Id
|
|
// projectUnit.ProjectId = newProjectId;
|
|
// projectUnit.UnitType = BLL.Const.UnitType_4; // 施工
|
|
// BLL.Project_UnitService.AddProject_Unit(projectUnit);
|
|
//}
|
|
|
|
BLL.Sys_LogService.AddLog(BLL.Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "添加项目信息");
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInParent("此施工号已存在!");
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!BLL.Base_ProjectService.IsExistProjectCode(projectId, txtProjectCode.Text.Trim(),"1"))
|
|
{
|
|
Model.Base_Project oldProject = BLL.Base_ProjectService.GetProjectByProjectId(projectId);
|
|
project.ProjectId = projectId;
|
|
project.TestEngineeringCode = oldProject.TestEngineeringCode;
|
|
BLL.Base_ProjectService.UpdateProject(project);
|
|
BLL.Sys_LogService.AddLog(BLL.Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "修改项目信息");
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInParent("此施工号已存在!");
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (this.drpCheckUnit.SelectedValue == "26645a1f-3256-4962-9b27-d33d7dea087e") //如果检测单位是甬安公司,则按规则自动生成检测工程编号
|
|
{
|
|
string years = DateTime.Now.Year.ToString().Substring(2, 2);
|
|
string pfx = "YA" + years + "-GD";
|
|
if (string.IsNullOrEmpty(project.TestEngineeringCode))
|
|
{
|
|
project.TestEngineeringCode = BLL.SQLHelper.RunProcNewId("SpGetNewCode3", "dbo.Base_Project", "TestEngineeringCode", pfx);
|
|
BLL.Base_ProjectService.UpdateProject(project);
|
|
}
|
|
}
|
|
if (this.drpCheckUnit.SelectedValue != BLL.Const._Null)
|
|
{
|
|
Model.Project_Unit pUnit = BLL.Project_UnitService.GetProject_UnitByProjectIdUnitId(project.ProjectId, this.drpCheckUnit.SelectedValue);
|
|
if (pUnit == null)
|
|
{
|
|
Model.Project_Unit nUnit = new Model.Project_Unit();
|
|
nUnit.UnitId = this.drpCheckUnit.SelectedValue;
|
|
nUnit.ProjectId = project.ProjectId;
|
|
BLL.Project_UnitService.AddProject_Unit(nUnit);
|
|
}
|
|
}
|
|
// 关闭本窗体,然后回发父窗体
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!");
|
|
}
|
|
}
|
|
|
|
#region 附件上传
|
|
/// <summary>
|
|
/// 上传附件资源
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAttachUrl_Click(object sender, EventArgs e)
|
|
{
|
|
string edit = "0"; // 表示能打开附件上传窗口,但不能上传附件
|
|
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectMenuId, BLL.Const.BtnSave))
|
|
{
|
|
if (string.IsNullOrEmpty(Request.QueryString["ProjectId"]))
|
|
{
|
|
ShowNotify("保存数据后再上传!");
|
|
}
|
|
else
|
|
{
|
|
edit = "1";
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/BaseInfo/Project&menuId={1}&edit={2}", Request.QueryString["ProjectId"], Const.ProjectMenuId, edit)));
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |