using BLL; using System; using System.Collections.Generic; namespace FineUIPro.Web.TestRun.DriverSummary { public partial class SpecialSummaryEdit : PageBase { #region 加载 /// /// 页面加载 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BLL.UserService.InitUserDropDownList(this.drpSummaryPerson, this.CurrUser.LoginProjectId, false); string id = Request.Params["id"]; if (!string.IsNullOrEmpty(id)) { Model.Driver_DriverSummary data = BLL.DriverSummaryService.GetDriverSummaryById(id); if (data != null) { this.hdId.Text = id; this.txtDriverSummaryCode.Text = data.DriverSummaryCode; if (!string.IsNullOrEmpty(data.SummaryPerson)) { this.drpSummaryPerson.SelectedValue = data.SummaryPerson; } WindowAtt_Close(null, null); WindowAtt2_Close(null, null); } } else { this.drpSummaryPerson.SelectedValue = this.CurrUser.UserId; } } } #endregion #region 附件上传 /// /// 附件上传 /// /// /// protected void btnAttach_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录 { this.hdId.Text = SQLHelper.GetNewID(typeof(Model.Driver_DriverSummary)); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/DriverSummary/SpecialSummary&menuId={1}&strParam=1", this.hdId.Text, BLL.Const.SpecialSummaryMenuId))); } protected void WindowAtt_Close(object sender, WindowCloseEventArgs e) { this.lbtnAttach.Text = string.Empty; string url = string.Empty; var attLists = BLL.AttachFileService.Getfiles(this.hdId.Text + "#1", BLL.Const.SpecialSummaryMenuId); if (attLists != null) { List lists = Funs.GetStrListByStr(attLists.AttachUrl, ','); if (lists.Count > 0) { foreach (var item in lists) { url += item.Substring(item.IndexOf('_') + 1) + "\r\n"; } } if (!string.IsNullOrEmpty(url)) { this.lbtnAttach.Text = url; } } } /// /// 签字版附件 /// /// /// protected void btnAttach2_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录 { this.hdId.Text = SQLHelper.GetNewID(typeof(Model.Driver_DriverSummary)); } PageContext.RegisterStartupScript(WindowAtt2.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/DriverSummary/SpecialSummary&menuId={1}&strParam=2", this.hdId.Text, BLL.Const.SpecialSummaryMenuId))); } protected void WindowAtt2_Close(object sender, WindowCloseEventArgs e) { this.lbtnAttach2.Text = string.Empty; string url = string.Empty; var attLists = BLL.AttachFileService.Getfiles(this.hdId.Text + "#2", BLL.Const.SpecialSummaryMenuId); if (attLists != null) { List lists = Funs.GetStrListByStr(attLists.AttachUrl, ','); if (lists.Count > 0) { foreach (var item in lists) { url += item.Substring(item.IndexOf('_') + 1) + "\r\n"; } } if (!string.IsNullOrEmpty(url)) { this.lbtnAttach2.Text = url; } } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.drpSummaryPerson.SelectedValue)) { Alert.ShowInTop("请选择总结人", MessageBoxIcon.Warning); return; } string id = Request.Params["id"]; Model.Driver_DriverSummary newData = new Model.Driver_DriverSummary(); newData.DriverSummaryCode = this.txtDriverSummaryCode.Text.Trim(); newData.SummaryPerson = this.drpSummaryPerson.SelectedValue; newData.SubmitDate = DateTime.Now; newData.ProjectId = this.CurrUser.LoginProjectId; if (!string.IsNullOrEmpty(id)) { newData.DriverSummaryId = id; BLL.DriverSummaryService.UpdateDriverSummary(newData); } else { newData.SummaryType = "1"; if (!string.IsNullOrEmpty(this.hdId.Text)) { newData.DriverSummaryId = this.hdId.Text.Trim(); } else { newData.DriverSummaryId = SQLHelper.GetNewID(typeof(Model.Driver_DriverSummary)); this.hdId.Text = newData.DriverSummaryId; } BLL.DriverSummaryService.AddDriverSummary(newData); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion } }