SGGL_JT/SUBQHSE/FineUIPro.Web/SHIYE/Work/BreakGroundEdit.aspx.cs

193 lines
7.2 KiB
C#

using BLL;
using System;
using System.Web;
namespace FineUIPro.Web.SHIYE.Work
{
public partial class BreakGroundEdit : 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_BreakGround License = BLL.SYLicensePublicService.GetBreakGroundByIds(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.WorkDepth.Text = License.WorkDepth;
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);
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);
}
#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.drpUnitId.SelectedValue == BLL.Const._Null)
{
Alert.ShowInTop("请选择申请单位!", MessageBoxIcon.Warning);
return;
}
Model.SY_License_BreakGround License = new Model.SY_License_BreakGround
{
ProjectId = this.ProjectId,
LicenseCode = this.txtLicenseCode.Text.Trim()
};
if (this.drpUnitId.SelectedValue != BLL.Const._Null)
{
License.ApplyUnitId = this.drpUnitId.SelectedValue;
}
License.WorkDepth= this.WorkDepth.Text;
License.ApplyManId = this.CurrUser.UserId;
License.WorkPalce = this.txtWorkPlace.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.BreakGroundId = this.LicenseId;
BLL.SYLicensePublicService.UpdateBreakGround(License);
BLL.LogService.AddSys_Log(this.CurrUser, License.LicenseCode, License.BreakGroundId, BLL.Const.ProjectLicenseManagerMenuId, BLL.Const.BtnModify);
}
else
{
License.ApplyManId = this.CurrUser.UserName;
this.LicenseId = SQLHelper.GetNewID(typeof(Model.SY_License_BreakGround));
License.BreakGroundId = this.LicenseId;
BLL.SYLicensePublicService.AddBreakGround(License);
BLL.LogService.AddSys_Log(this.CurrUser, License.LicenseCode, License.BreakGroundId, 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
}
}