using BLL; using FineUIPro.Web.HSSE.InApproveManager; using System; namespace FineUIPro.Web.HSSE.QualityAudit { public partial class VehicleEdit : PageBase { #region 定义项 /// /// 主键 /// private string VehicleId { get { return (string)ViewState["VehicleId"]; } set { ViewState["VehicleId"] = value; } } #endregion #region 加载页面 /// /// 加载页面 /// /// /// 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 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (this.drpUnitId.SelectedValue==BLL.Const._Null) { Alert.ShowInTop("请选择单位名称", MessageBoxIcon.Warning); return; } SaveData(true); } /// /// 保存数据 /// /// 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 附件上传 /// /// 上传附件 /// /// /// 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 } }