169 lines
5.9 KiB
C#
169 lines
5.9 KiB
C#
using BLL;
|
|
using FineUIPro.Web.HSSE.InApproveManager;
|
|
using System;
|
|
|
|
namespace FineUIPro.Web.HSSE.QualityAudit
|
|
{
|
|
public partial class VehicleEdit : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
private string VehicleId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["VehicleId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["VehicleId"] = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 加载页面
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
|
|
UnitService.InitUnitDropDownList(this.drpUnitId, this.CurrUser.LoginProjectId, true);
|
|
this.VehicleId = Request.Params["VehicleId"];
|
|
if (!string.IsNullOrEmpty(this.VehicleId))
|
|
{
|
|
Model.HSSE_Vehicle vehicle = BLL.VehicleService.GetVehicleById(this.VehicleId);
|
|
if (vehicle != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(vehicle.UnitId))
|
|
{
|
|
this.drpUnitId.SelectedValue = vehicle.UnitId;
|
|
}
|
|
this.txtCarNo.Text = vehicle.CarNo;
|
|
this.txtPhone.Text = vehicle.Phone;
|
|
this.txtVehType.Text = vehicle.VehType;
|
|
this.txtOperatorName.Text = vehicle.OperatorName;
|
|
this.txtRemark.Text = vehicle.Remark;
|
|
if (vehicle.BeginTime.HasValue)
|
|
{
|
|
this.txtBeginTime.Text = string.Format("{0:yyyy-MM-dd}", vehicle.BeginTime);
|
|
}
|
|
if (vehicle.EndTime.HasValue)
|
|
{
|
|
this.txtEndTime.Text = string.Format("{0:yyyy-MM-dd}", vehicle.EndTime);
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.txtBeginTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
|
}
|
|
|
|
if (Request.Params["value"] == "0")
|
|
{
|
|
this.btnSave.Hidden = true;
|
|
}
|
|
}
|
|
}
|
|
#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;
|
|
}
|
|
|
|
SaveData(true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存数据
|
|
/// </summary>
|
|
/// <param name="isClose"></param>
|
|
private void SaveData(bool isClose)
|
|
{
|
|
Model.HSSE_Vehicle vehicle = new Model.HSSE_Vehicle
|
|
{
|
|
ProjectId = this.CurrUser.LoginProjectId,
|
|
CarNo = this.txtCarNo.Text.Trim(),
|
|
Phone = this.txtPhone.Text.Trim(),
|
|
VehType=this.txtVehType.Text.Trim(),
|
|
OperatorName=this.txtOperatorName.Text.Trim()
|
|
};
|
|
if (this.drpUnitId.SelectedValue!=BLL.Const._Null)
|
|
{
|
|
vehicle.UnitId = this.drpUnitId.SelectedValue;
|
|
}
|
|
vehicle.BeginTime = Convert.ToDateTime(this.txtBeginTime.Text.Trim());
|
|
vehicle.EndTime = Convert.ToDateTime(this.txtEndTime.Text.Trim());
|
|
|
|
|
|
if (!string.IsNullOrEmpty(VehicleId))
|
|
{
|
|
vehicle.VehicleId = this.VehicleId;
|
|
BLL.VehicleService.UpdateVehicle(vehicle);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, vehicle.CarNo, vehicle.VehicleId, BLL.Const.VehicleMenuId,BLL.Const.BtnModify);
|
|
}
|
|
else
|
|
{
|
|
this.VehicleId = SQLHelper.GetNewID(typeof(Model.QualityAudit_EquipmentQuality));
|
|
vehicle.VehicleId = this.VehicleId;
|
|
BLL.VehicleService.AddVehicle(vehicle);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, vehicle.CarNo, vehicle.VehicleId, BLL.Const.VehicleMenuId, BLL.Const.BtnAdd);
|
|
}
|
|
if (isClose)
|
|
{
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 附件上传
|
|
/// <summary>
|
|
/// 上传附件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAttachUrl_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.btnSave.Hidden)
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/EquipmentQualityAttachUrl&menuId={1}type=-1", VehicleId, BLL.Const.VehicleMenuId)));
|
|
}
|
|
else
|
|
{
|
|
if (this.drpUnitId.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择单位名称", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(this.VehicleId))
|
|
{
|
|
SaveData(false);
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/EquipmentQualityAttachUrl&menuId={1}", VehicleId, BLL.Const.VehicleMenuId)));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
}
|
|
} |