271 lines
12 KiB
C#
271 lines
12 KiB
C#
using BLL;
|
|
using FineUIPro.Web.HSSE.InApproveManager;
|
|
using System;
|
|
|
|
namespace FineUIPro.Web.Customization.CNCCG.HSSE.InApproveManager
|
|
{
|
|
public partial class GeneralEquipmentInItemEdit : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string GeneralEquipmentInItemId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["GeneralEquipmentInItemId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["GeneralEquipmentInItemId"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 主表主键
|
|
/// </summary>
|
|
public string GeneralEquipmentInId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["GeneralEquipmentInId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["GeneralEquipmentInId"] = 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();
|
|
///机具设备下拉框
|
|
BLL.SpecialEquipmentService.InitSpecialEquipmentDropDownList(this.drpSpecialEquipmentId, false, true);
|
|
UnitService.InitUnitDropDownList(this.droUseUnitId, this.ProjectId, true);
|
|
this.cbIsUsed.Checked = true;
|
|
this.GeneralEquipmentInId = Request.Params["GeneralEquipmentInId"];
|
|
this.GeneralEquipmentInItemId = Request.Params["GeneralEquipmentInItemId"];
|
|
if (!string.IsNullOrEmpty(this.GeneralEquipmentInItemId))
|
|
{
|
|
Model.InApproveManager_GeneralEquipmentInItem generalEquipmentInItem = BLL.GeneralEquipmentInItemService.GetGeneralEquipmentInItemById(this.GeneralEquipmentInItemId);
|
|
if (generalEquipmentInItem != null)
|
|
{
|
|
this.GeneralEquipmentInId = generalEquipmentInItem.GeneralEquipmentInId;
|
|
if (!string.IsNullOrEmpty(generalEquipmentInItem.SpecialEquipmentId))
|
|
{
|
|
this.drpSpecialEquipmentId.SelectedValue = generalEquipmentInItem.SpecialEquipmentId;
|
|
}
|
|
this.txtSizeModel.Text = generalEquipmentInItem.SizeModel;
|
|
this.txtOwnerCheck.Text = generalEquipmentInItem.OwnerCheck;
|
|
this.txtCertificateNum.Text = generalEquipmentInItem.CertificateNum;
|
|
if (generalEquipmentInItem.IsUsed != true)
|
|
{
|
|
this.cbIsUsed.Checked = false;
|
|
}
|
|
droUseUnitId.SelectedValue = generalEquipmentInItem.UseUnitId;
|
|
//txtUnit.Text= generalEquipmentInItem.Unit;
|
|
txtQuantity.Text = generalEquipmentInItem.Quantity?.ToString();
|
|
txtManufacturer.Text = generalEquipmentInItem.Manufacturer;
|
|
txtUseDate.SelectedDate = generalEquipmentInItem.UseDate;
|
|
txtRemark.Text = generalEquipmentInItem.Remark;
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(this.GeneralEquipmentInId))
|
|
{
|
|
Model.InApproveManager_GeneralEquipmentIn generalEquipmentIn = BLL.GeneralEquipmentInService.GetGeneralEquipmentInById(this.GeneralEquipmentInId);
|
|
if (generalEquipmentIn != null)
|
|
{
|
|
this.ProjectId = generalEquipmentIn.ProjectId;
|
|
if (this.ProjectId != this.CurrUser.LoginProjectId)
|
|
{
|
|
this.InitDropDownList();
|
|
}
|
|
this.txtGeneralEquipmentInCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(this.GeneralEquipmentInId);
|
|
if (!string.IsNullOrEmpty(generalEquipmentIn.UnitId))
|
|
{
|
|
this.drpUnitId.SelectedValue = generalEquipmentIn.UnitId;
|
|
}
|
|
//this.txtCarNumber.Text = generalEquipmentIn.CarNumber;
|
|
//this.txtSubProjectName.Text = generalEquipmentIn.SubProjectName;
|
|
//this.txtContentDef.Text = generalEquipmentIn.ContentDef;
|
|
//this.txtOtherDef.Text = generalEquipmentIn.OtherDef;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
////自动生成编码
|
|
this.txtGeneralEquipmentInCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.GeneralEquipmentInMenuId, this.ProjectId, this.CurrUser.UnitId);
|
|
if (!string.IsNullOrEmpty(CurrUser.UnitId))
|
|
{
|
|
drpUnitId.SelectedValue = CurrUser.UnitId;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化下拉框
|
|
/// </summary>
|
|
private void InitDropDownList()
|
|
{
|
|
UnitService.InitUnitDropDownList(this.drpUnitId, this.ProjectId, true);
|
|
UnitService.InitUnitDropDownList(this.droUseUnitId, this.ProjectId, true);
|
|
// UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpUnitId, this.ProjectId, Const.ProjectUnitType_2, true);
|
|
// this.drpUnitId.Enabled = false;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (this.drpUnitId.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择单位名称!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (this.drpSpecialEquipmentId.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择设备!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (this.droUseUnitId.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择使用单位!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
SaveGeneralEquipmentInData();
|
|
SaveData();
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
|
|
}
|
|
|
|
private void SaveGeneralEquipmentInData()
|
|
{
|
|
|
|
Model.InApproveManager_GeneralEquipmentIn generalEquipmentIn = new Model.InApproveManager_GeneralEquipmentIn
|
|
{
|
|
ProjectId = this.ProjectId,
|
|
GeneralEquipmentInCode = this.txtGeneralEquipmentInCode.Text.Trim()
|
|
};
|
|
if (this.drpUnitId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
generalEquipmentIn.UnitId = this.drpUnitId.SelectedValue;
|
|
}
|
|
//generalEquipmentIn.CarNumber = this.txtCarNumber.Text.Trim();
|
|
//generalEquipmentIn.SubProjectName = this.txtSubProjectName.Text.Trim();
|
|
//generalEquipmentIn.ContentDef = this.txtContentDef.Text.Trim();
|
|
//generalEquipmentIn.OtherDef = this.txtOtherDef.Text.Trim();
|
|
generalEquipmentIn.State = BLL.Const.State_2;
|
|
generalEquipmentIn.CompileMan = this.CurrUser.UserId;
|
|
generalEquipmentIn.CompileDate = DateTime.Now;
|
|
if (!string.IsNullOrEmpty(this.GeneralEquipmentInId))
|
|
{
|
|
generalEquipmentIn.GeneralEquipmentInId = this.GeneralEquipmentInId;
|
|
BLL.GeneralEquipmentInService.UpdateGeneralEquipmentIn(generalEquipmentIn);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, generalEquipmentIn.GeneralEquipmentInCode, generalEquipmentIn.GeneralEquipmentInId, BLL.Const.GeneralEquipmentInMenuId, BLL.Const.BtnModify);
|
|
}
|
|
else
|
|
{
|
|
this.GeneralEquipmentInId = SQLHelper.GetNewID(typeof(Model.InApproveManager_GeneralEquipmentIn));
|
|
generalEquipmentIn.GeneralEquipmentInId = this.GeneralEquipmentInId;
|
|
BLL.GeneralEquipmentInService.AddGeneralEquipmentIn(generalEquipmentIn);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, generalEquipmentIn.GeneralEquipmentInCode, generalEquipmentIn.GeneralEquipmentInId, BLL.Const.GeneralEquipmentInMenuId, BLL.Const.BtnAdd);
|
|
}
|
|
}
|
|
void SaveData()
|
|
{
|
|
Model.InApproveManager_GeneralEquipmentInItem generalEquipmentInItem = new Model.InApproveManager_GeneralEquipmentInItem
|
|
{
|
|
GeneralEquipmentInId = this.GeneralEquipmentInId
|
|
};
|
|
if (this.drpSpecialEquipmentId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
generalEquipmentInItem.SpecialEquipmentId = this.drpSpecialEquipmentId.SelectedValue;
|
|
}
|
|
if (this.droUseUnitId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
generalEquipmentInItem.UseUnitId = this.droUseUnitId.SelectedValue;
|
|
}
|
|
generalEquipmentInItem.SizeModel = this.txtSizeModel.Text.Trim();
|
|
generalEquipmentInItem.OwnerCheck = this.txtOwnerCheck.Text.Trim();
|
|
generalEquipmentInItem.CertificateNum = this.txtCertificateNum.Text.Trim();
|
|
generalEquipmentInItem.IsUsed = Convert.ToBoolean(this.cbIsUsed.Checked);
|
|
generalEquipmentInItem.UseUnitId = droUseUnitId.SelectedValue;
|
|
//generalEquipmentInItem.Unit = txtUnit.Text.Trim();
|
|
generalEquipmentInItem.Quantity = Convert.ToInt32(txtQuantity.Text.Trim());
|
|
generalEquipmentInItem.Manufacturer = this.txtManufacturer.Text.Trim();
|
|
generalEquipmentInItem.UseDate = this.txtUseDate.SelectedDate;
|
|
generalEquipmentInItem.Remark = this.txtRemark.Text.Trim();
|
|
|
|
if (!string.IsNullOrEmpty(this.GeneralEquipmentInItemId))
|
|
{
|
|
generalEquipmentInItem.GeneralEquipmentInItemId = this.GeneralEquipmentInItemId;
|
|
BLL.GeneralEquipmentInItemService.UpdateGeneralEquipmentInItem(generalEquipmentInItem);
|
|
}
|
|
else
|
|
{
|
|
this.GeneralEquipmentInItemId = SQLHelper.GetNewID(typeof(Model.InApproveManager_GeneralEquipmentInItem));
|
|
generalEquipmentInItem.GeneralEquipmentInItemId = this.GeneralEquipmentInItemId;
|
|
BLL.GeneralEquipmentInItemService.AddGeneralEquipmentInItem(generalEquipmentInItem);
|
|
}
|
|
// Project_HSSEData_HSSEService.StatisticalData(this.CurrUser.LoginProjectId, Project_HSSEData_HSSEService.HSSEDateType.ConstructionEquipment);
|
|
//PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 附件上传
|
|
/// <summary>
|
|
/// 上传附件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAttachUrl_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.GeneralEquipmentInId))
|
|
{
|
|
SaveData();
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/GeneralEquipmentInAttachUrl&menuId={1}", this.GeneralEquipmentInId, BLL.Const.GeneralEquipmentInMenuId)));
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
} |