using BLL; using System; namespace FineUIPro.Web.TestRun.DriverSub { public partial class DriverSubPlanEdit :PageBase { #region 加载 /// /// 页面加载 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //BLL.UnitService.InitUnitDownList(this.drpSubUnitId, this.CurrUser.LoginProjectId, true); //BLL.UnitWorkService.InitUnitWorkDropDownList(this.drpUnitWorkIds, this.CurrUser.LoginProjectId, true); string id = Request.Params["id"]; SubcontractingTypes.DataSource=DropListService.drpDriverSubNameList(); SubcontractingTypes.DataTextField = "Text"; SubcontractingTypes.DataValueField = "Value"; SubcontractingTypes.DataBind(); if (!string.IsNullOrEmpty(id)) { Model.DriverSub_DriverSubPlan data = BLL.DriverSubPlanService.GetDriverSubPlanById(id); if (data != null) { this.hdId.Text = id; this.txtCode.Text = data.Code; this.SubcontractingTypes.SelectedValueArray= data.SubcontractingTypes.Split(','); } } } } #endregion #region 附件上传 /// /// 附件上传 /// /// /// protected void btnAttach_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录 { this.hdId.Text = SQLHelper.GetNewID(typeof(Model.DriverSub_DriverSubPlan)); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/DriverSub/DriverSubPlan&menuId={1}", this.hdId.Text, BLL.Const.DriverSubPlanMenuId))); } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { string id = Request.Params["id"]; Model.DriverSub_DriverSubPlan newData = new Model.DriverSub_DriverSubPlan(); newData.Code = this.txtCode.Text.Trim(); newData.SubcontractingTypes = GetStringByArray(this.SubcontractingTypes.SelectedValueArray); newData.ProjectId = this.CurrUser.LoginProjectId; if (!string.IsNullOrEmpty(id)) { newData.DriverSubPlanId = id; BLL.DriverSubPlanService.UpdateDriverSubPlan(newData); } else { if (!string.IsNullOrEmpty(this.hdId.Text)) { newData.DriverSubPlanId = this.hdId.Text.Trim(); } else { newData.DriverSubPlanId = SQLHelper.GetNewID(typeof(Model.DriverSub_DriverSubPlan)); this.hdId.Text = newData.DriverSubPlanId; } BLL.DriverSubPlanService.AddDriverSubPlan(newData); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } /// /// 获取字符串 /// /// /// private string GetStringByArray(string[] array) { string str = string.Empty; foreach (var item in array) { if (item != BLL.Const._Null) { str += item + ","; } } if (!string.IsNullOrEmpty(str)) { str = str.Substring(0, str.LastIndexOf(",")); } return str; } #endregion } }