using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using BLL; using Model; namespace FineUIPro.Web.Personal { public partial class TestRunPerformanceEdit : PageBase { /// /// 定义项 /// public string TestRunPerformanceId { get { return (string)ViewState["TestRunPerformanceId"]; } set { ViewState["TestRunPerformanceId"] = value; } } /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); ProjectService.InitAllProjectDropDownList2(this.drpProject, true); this.TestRunPerformanceId = Request.QueryString["TestRunPerformanceId"]; TestRunPerformanceStandardService.InitTypeDropDownList(drpType, true); Funs.FineUIPleaseSelect(this.drpItem); Funs.FineUIPleaseSelect(this.drpUnit); if (!String.IsNullOrEmpty(this.TestRunPerformanceId)) { var performance = BLL.Person_TestRunPerformanceService.GetPersonTestRunPerformanceById(this.TestRunPerformanceId); if (performance != null) { if (performance.Months != null) { this.txtMonths.Text = string.Format("{0:yyyy-MM-dd}", performance.Months); } this.lbUserName.Text = BLL.UserService.GetUserNameByUserId(performance.UserId); if (!string.IsNullOrEmpty(performance.ProjectId)) { this.drpProject.SelectedValue = performance.ProjectId; } this.txtJobContent.Text = performance.JobContent; Model.Base_TestRunPerformanceStandard standard = BLL.TestRunPerformanceStandardService.GetPerformanceStandardById(performance.TestRunPerformanceStandardId); if (standard != null) { this.drpType.SelectedValue = standard.Type; TestRunPerformanceStandardService.InitItemDropDownList(drpItem, this.drpType.SelectedValue, true); this.drpItem.SelectedValue = standard.Item; TestRunPerformanceStandardService.InitUnitDropDownList(drpUnit, this.drpType.SelectedValue, this.drpItem.SelectedValue, true); this.drpUnit.SelectedValue = standard.TestRunPerformanceStandardId; } if (performance.Days != null) { this.txtDays.Text = performance.Days.ToString(); } } } else { this.lbUserName.Text = this.CurrUser.UserName; } } } /// /// 保存数据 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtMonths.Text.Trim())) { Alert.ShowInParent("请选择月份!", MessageBoxIcon.Warning); return; } if (this.drpProject.SelectedValue == BLL.Const._Null) { Alert.ShowInParent("请选择工作地点!", MessageBoxIcon.Warning); return; } if (this.drpType.SelectedValue == BLL.Const._Null) { Alert.ShowInParent("请选择工作类别!", MessageBoxIcon.Warning); return; } if (this.drpItem.SelectedValue == BLL.Const._Null) { Alert.ShowInParent("请选择工作项!", MessageBoxIcon.Warning); return; } if (this.drpUnit.SelectedValue == BLL.Const._Null) { Alert.ShowInParent("请选择计量单位!", MessageBoxIcon.Warning); return; } if (this.txtDays.Text.Trim() == "0" || string.IsNullOrEmpty(this.txtDays.Text.Trim())) { Alert.ShowInParent("请输入标准工作日!", MessageBoxIcon.Warning); return; } Model.Person_TestRunPerformance newperformance = new Model.Person_TestRunPerformance() { Months = Funs.GetNewDateTimeOrNow(this.txtMonths.Text.Trim()), UserId = this.CurrUser.UserId, ProjectId = this.drpProject.SelectedValue, JobContent = this.txtJobContent.Text.Trim(), TestRunPerformanceStandardId = this.drpUnit.SelectedValue, Days = Funs.GetNewInt(this.txtDays.Text.Trim()), }; if (!string.IsNullOrEmpty(this.TestRunPerformanceId)) { newperformance.TestRunPerformanceId = this.TestRunPerformanceId; BLL.Person_TestRunPerformanceService.UpdatePersonTestRunPerformance(newperformance); BLL.LogService.AddSys_Log(this.CurrUser, null, newperformance.TestRunPerformanceId, BLL.Const.TestRunPerformanceMenuId, BLL.Const.BtnAdd); } else { newperformance.TestRunPerformanceId = SQLHelper.GetNewID(); BLL.Person_TestRunPerformanceService.AddPersonTestRunPerformance(newperformance); BLL.LogService.AddSys_Log(this.CurrUser, null, newperformance.TestRunPerformanceId, BLL.Const.TestRunPerformanceMenuId, BLL.Const.BtnModify); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } protected void drpType_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpType.SelectedValue != BLL.Const._Null) { TestRunPerformanceStandardService.InitItemDropDownList(drpItem, this.drpType.SelectedValue, true); this.drpItem.SelectedIndex = 0; this.drpUnit.Items.Clear(); Funs.FineUIPleaseSelect(this.drpUnit); this.drpUnit.SelectedIndex = 0; } else { this.drpItem.Items.Clear(); Funs.FineUIPleaseSelect(this.drpItem); this.drpItem.SelectedIndex = 0; this.drpUnit.Items.Clear(); Funs.FineUIPleaseSelect(this.drpUnit); this.drpUnit.SelectedIndex = 0; } } protected void drpItem_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpItem.SelectedValue != BLL.Const._Null) { TestRunPerformanceStandardService.InitUnitDropDownList(drpUnit, this.drpType.SelectedValue,this.drpItem.SelectedValue, true); this.drpUnit.SelectedIndex = 0; } else { this.drpUnit.Items.Clear(); Funs.FineUIPleaseSelect(this.drpUnit); this.drpUnit.SelectedIndex = 0; } } protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpUnit.SelectedValue != BLL.Const._Null) { Model.Base_TestRunPerformanceStandard standard = BLL.TestRunPerformanceStandardService.GetPerformanceStandardById(this.drpUnit.SelectedValue); if (standard != null) { if (standard.Days != null) { this.txtDays.Text = standard.Days.ToString(); if (standard.Days > 0) { this.txtDays.Readonly = true; } else { this.txtDays.Readonly = false; } } } } else { this.txtDays.Text = string.Empty; this.txtDays.Readonly = true; } } } }