110 lines
4.5 KiB
C#
110 lines
4.5 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.HJGL.BaseInfo
|
|
{
|
|
public partial class TemperatureSetEdit : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string TemperatureSetId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["TemperatureSetId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["TemperatureSetId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
//温度类型
|
|
this.drpTemperatureType.DataTextField = "Text";
|
|
this.drpTemperatureType.DataValueField = "Value";
|
|
this.drpTemperatureType.DataSource = BLL.Base_TemperatureSetService.getTemperatureType();
|
|
this.drpTemperatureType.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpTemperatureType);
|
|
|
|
this.TemperatureSetId = Request.Params["TemperatureSetId"];
|
|
if (!string.IsNullOrEmpty(this.TemperatureSetId))
|
|
{
|
|
Model.Base_TemperatureSet temperatureSet = BLL.Base_TemperatureSetService.GetTemperatureSetById(this.TemperatureSetId);
|
|
if (temperatureSet != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(temperatureSet.TemperatureType))
|
|
{
|
|
this.drpTemperatureType.SelectedValue = temperatureSet.TemperatureType;
|
|
}
|
|
this.txtTemperature.Text = temperatureSet.Temperature.HasValue ? temperatureSet.Temperature.ToString() : "";
|
|
this.txtRemark.Text = temperatureSet.Remark;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.drpTemperatureType.SelectedValue==BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择温度类型!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
var q = Funs.DB.Base_TemperatureSet.FirstOrDefault(x => x.TemperatureType == this.drpTemperatureType.SelectedValue.Trim() && x.Temperature==Funs.GetNewInt(this.txtTemperature.Text.Trim())&&(x.TemperatureSetId != this.TemperatureSetId || (this.TemperatureSetId == null && x.TemperatureSetId != null)));
|
|
if (q != null)
|
|
{
|
|
Alert.ShowInTop("此类型温度已经存在!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
Model.Base_TemperatureSet newTemperatureSet = new Model.Base_TemperatureSet
|
|
{
|
|
Temperature = Funs.GetNewInt(this.txtTemperature.Text.Trim()),
|
|
Remark = this.txtRemark.Text.Trim()
|
|
};
|
|
if (this.drpTemperatureType.SelectedValue!=BLL.Const._Null)
|
|
{
|
|
newTemperatureSet.TemperatureType = this.drpTemperatureType.SelectedValue;
|
|
}
|
|
if (!string.IsNullOrEmpty(this.TemperatureSetId))
|
|
{
|
|
newTemperatureSet.TemperatureSetId = this.TemperatureSetId;
|
|
BLL.Base_TemperatureSetService.UpdateTemperatureSet(newTemperatureSet);
|
|
//BLL.Sys_LogService.AddLog(Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_GrooveTypeMenuId, Const.BtnModify, this.GrooveTypeId);
|
|
}
|
|
else
|
|
{
|
|
this.TemperatureSetId = SQLHelper.GetNewID(typeof(Model.Base_TemperatureSet));
|
|
newTemperatureSet.TemperatureSetId = this.TemperatureSetId;
|
|
BLL.Base_TemperatureSetService.AddTemperatureSet(newTemperatureSet);
|
|
//BLL.Sys_LogService.AddLog(Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_GrooveTypeMenuId, Const.BtnAdd, this.GrooveTypeId);
|
|
}
|
|
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
#endregion
|
|
}
|
|
} |