236 lines
9.1 KiB
C#
236 lines
9.1 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Web;
|
|
|
|
namespace FineUIPro.Web.SHIYE.Work
|
|
{
|
|
public partial class FireWorkEdit : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string LicenseId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["LicenseId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["LicenseId"] = 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.ProjectId = this.CurrUser.LoginProjectId;
|
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
this.InitDropDownList();
|
|
this.LicenseId = Request.Params["LicenseId"];
|
|
if (!string.IsNullOrEmpty(this.LicenseId))
|
|
{
|
|
Model.SY_License_FireWork License = BLL.SYLicensePublicService.GetFireWorkByIds(this.LicenseId);
|
|
|
|
if (License != null)
|
|
{
|
|
this.ProjectId = License.ProjectId;
|
|
if (this.ProjectId != this.CurrUser.LoginProjectId)
|
|
{
|
|
this.InitDropDownList();
|
|
}
|
|
this.txtLicenseCode.Text = License.LicenseCode;
|
|
if (!string.IsNullOrEmpty(License.ApplyUnitId))
|
|
{
|
|
this.drpUnitId.SelectedValue = License.ApplyUnitId;
|
|
}
|
|
this.txtWorkType.Text = License.WorkType;
|
|
this.txtWorkPlace.Text = License.WorkPalce;
|
|
this.txtApplicantMan.Text =License.ApplyManId;
|
|
this.txtApplyDate.Text = string.Format("{0:yyyy-MM-dd}", License.ApplyDate);
|
|
this.txtWorkMeasures.Text = HttpUtility.HtmlDecode(License.WorkMeasures);
|
|
//if (!string.IsNullOrEmpty(License.WorkPalce))
|
|
//{
|
|
// this.drpWorkAreaId.SelectedValueArray = License.WorkPalce.Split(',');
|
|
//}
|
|
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", License.ValidityStartTime);
|
|
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", License.ValidityEndTime);
|
|
this.drpStates.SelectedValue = License.States;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.txtApplicantMan.Text = this.CurrUser.UserName;
|
|
this.drpUnitId.SelectedValue = this.CurrUser.UnitId;
|
|
this.txtApplyDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
|
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
|
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(1));
|
|
////自动生成编码
|
|
this.txtLicenseCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectLicenseManagerMenuId, this.ProjectId, this.CurrUser.UnitId);
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 初始化下拉框
|
|
/// </summary>
|
|
private void InitDropDownList()
|
|
{
|
|
UnitService.InitUnitDropDownList(this.drpUnitId, this.ProjectId, true);
|
|
//LicenseTypeService.InitLicenseTypeDropDownList(this.drpLicenseTypeId, true);
|
|
//UnitWorkService.InitUnitWorkDownList(this.drpWorkAreaId, this.ProjectId, false);
|
|
}
|
|
|
|
#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="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSubmit_Click(object sender, EventArgs e)
|
|
{
|
|
this.SaveData(BLL.Const.BtnSubmit);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存数据
|
|
/// </summary>
|
|
/// <param name="type"></param>
|
|
private void SaveData(string type)
|
|
{
|
|
if (this.drpUnitId.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择申请单位!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
Model.SY_License_FireWork License = new Model.SY_License_FireWork
|
|
{
|
|
ProjectId = this.ProjectId,
|
|
LicenseCode = this.txtLicenseCode.Text.Trim()
|
|
};
|
|
//if (this.drpLicenseTypeId.SelectedValue != BLL.Const._Null)
|
|
//{
|
|
// License.WorkType = this.drpLicenseTypeId.SelectedText;
|
|
//}
|
|
if (this.drpUnitId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
License.ApplyUnitId = this.drpUnitId.SelectedValue;
|
|
}
|
|
|
|
License.ApplyManId = this.CurrUser.UserId;
|
|
//if (!string.IsNullOrEmpty(this.drpWorkAreaId.SelectedValue))
|
|
//{
|
|
// string workAreaIds = string.Empty;
|
|
// var workAreas = this.drpWorkAreaId.SelectedValueArray;
|
|
// foreach (var item in workAreas)
|
|
// {
|
|
// workAreaIds += item + ",";
|
|
// }
|
|
// License.WorkPalce = workAreaIds;
|
|
//}
|
|
License.WorkPalce = this.txtWorkPlace.Text;
|
|
License.WorkType = this.txtWorkType.Text;
|
|
License.ValidityStartTime = Funs.GetNewDateTime(this.txtStartDate.Text);
|
|
License.ValidityEndTime = Funs.GetNewDateTime(this.txtEndDate.Text);
|
|
License.ApplyDate = Funs.GetNewDateTime(this.txtApplyDate.Text.Trim());
|
|
License.WorkMeasures = HttpUtility.HtmlEncode(this.txtWorkMeasures.Text);
|
|
License.States = BLL.Const.State_0;
|
|
if (!string.IsNullOrEmpty(this.drpStates.SelectedValue))
|
|
{
|
|
License.States = this.drpStates.SelectedValue;
|
|
}
|
|
else
|
|
{
|
|
License.States =null;
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(this.LicenseId))
|
|
{
|
|
License.FireWorkId = this.LicenseId;
|
|
BLL.SYLicensePublicService.UpdateFireWork(License);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, License.LicenseCode, License.FireWorkId, BLL.Const.ProjectLicenseManagerMenuId, BLL.Const.BtnModify);
|
|
}
|
|
else
|
|
{
|
|
License.ApplyManId = this.CurrUser.UserName;
|
|
this.LicenseId = SQLHelper.GetNewID(typeof(Model.SY_License_FireWork));
|
|
License.FireWorkId = this.LicenseId;
|
|
BLL.SYLicensePublicService.AddFireWork(License);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, License.LicenseCode, License.FireWorkId, BLL.Const.ProjectLicenseManagerMenuId, BLL.Const.BtnAdd);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 附件上传
|
|
/// <summary>
|
|
/// 上传附件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAttachUrl_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.LicenseId))
|
|
{
|
|
this.SaveData(BLL.Const.BtnSave);
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/LicenseAttachUrl&menuId={1}", LicenseId, BLL.Const.ProjectLicenseManagerMenuId)));
|
|
}
|
|
#endregion
|
|
|
|
#region 单位选择事件
|
|
/// <summary>
|
|
/// 单位选择事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpLicenseTypeId_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
//var type = BLL.LicenseTypeService.GetLicenseTypeById(this.drpLicenseTypeId.SelectedValue);
|
|
//if (type != null)
|
|
//{
|
|
// // this.txtWorkMeasures.Text = HttpUtility.HtmlDecode(type.LicenseContents);
|
|
//}
|
|
}
|
|
#endregion
|
|
}
|
|
} |