using BLL; using System; namespace FineUIPro.Web.TestRun.DriverRun { public partial class DriverRunContactEdit :PageBase { #region 加载 /// /// 页面加载 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BLL.UnitService.InitUnitDownList(this.drpUnitId, this.CurrUser.LoginProjectId, true); string id = Request.Params["id"]; if (!string.IsNullOrEmpty(id)) { Model.DriverRun_DriverRunContact data = BLL.DriverRunContactService.GetDriverRunContactById(id); if (data != null) { this.hdId.Text = id; this.txtCode.Text = data.Code; if (!string.IsNullOrEmpty(data.UnitId)) { this.drpUnitId.SelectedValue = data.UnitId; } this.txtContact.Text = data.Contact; this.txtHeadMan.Text = data.HeadMan; this.txtContents.Text = data.Contents; this.txtResultDef.Text = data.ResultDef; this.txtRemark.Text = data.Remark; } } } } #endregion #region 附件上传 /// /// 附件上传 /// /// /// protected void btnAttach_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录 { this.hdId.Text = SQLHelper.GetNewID(typeof(Model.DriverRun_DriverRunContact)); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/DriverRun/DriverRunContact&menuId={1}", this.hdId.Text, BLL.Const.DriverRunContactMenuId))); } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (this.drpUnitId.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择单位名称!", MessageBoxIcon.Warning); return; } string id = Request.Params["id"]; Model.DriverRun_DriverRunContact newData = new Model.DriverRun_DriverRunContact(); newData.Code = this.txtCode.Text.Trim(); if (this.drpUnitId.SelectedValue != BLL.Const._Null) { newData.UnitId = this.drpUnitId.SelectedValue; } newData.Contact = this.txtContact.Text.Trim(); newData.HeadMan = this.txtHeadMan.Text.Trim(); newData.Contents = this.txtContents.Text.Trim(); newData.ResultDef = this.txtResultDef.Text.Trim(); newData.Remark = this.txtRemark.Text.Trim(); newData.ProjectId = this.CurrUser.LoginProjectId; if (!string.IsNullOrEmpty(id)) { newData.DriverRunContactId = id; BLL.DriverRunContactService.UpdateDriverRunContact(newData); } else { if (!string.IsNullOrEmpty(this.hdId.Text)) { newData.DriverRunContactId = this.hdId.Text.Trim(); } else { newData.DriverRunContactId = SQLHelper.GetNewID(typeof(Model.DriverRun_DriverRunContact)); this.hdId.Text = newData.DriverRunContactId; } BLL.DriverRunContactService.AddDriverRunContact(newData); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion } }