156 lines
7.1 KiB
C#
156 lines
7.1 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Web;
|
|||
|
using System.Web.UI;
|
|||
|
using System.Web.UI.WebControls;
|
|||
|
using BLL;
|
|||
|
|
|||
|
namespace FineUIPro.Web.common.WelderManage
|
|||
|
{
|
|||
|
public partial class WelderViolationEdit : PageBase
|
|||
|
{
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
|
|||
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|||
|
BLL.Base_UnitService.InitUnitDropDownList(this.drpUnit, true, BLL.Const.UnitType_5, Resources.Lan.PleaseSelect);//单位
|
|||
|
this.drpRecordMan.DataTextField = "UserName";
|
|||
|
this.drpRecordMan.DataValueField = "UserId";
|
|||
|
this.drpRecordMan.DataSource = BLL.Sys_UserService.GetUserList();
|
|||
|
this.drpRecordMan.DataBind();
|
|||
|
Funs.FineUIPleaseSelect(this.drpRecordMan, Resources.Lan.PleaseSelect);
|
|||
|
|
|||
|
this.hdWelderId.Text = Request.Params["welderId"];
|
|||
|
string welderViolationId = Request.Params["WelderViolationId"];
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(welderViolationId))
|
|||
|
{
|
|||
|
Model.Welder_Violation welderViolation = BLL.WelderViolationService.GetViolationById(welderViolationId);
|
|||
|
if (welderViolation != null)
|
|||
|
{
|
|||
|
this.hdWelderId.Text = welderViolation.WelderId;
|
|||
|
if (!string.IsNullOrEmpty(welderViolation.UnitId))
|
|||
|
{
|
|||
|
drpUnit.SelectedValue = welderViolation.UnitId;
|
|||
|
}
|
|||
|
|
|||
|
if (welderViolation.ViolationDate.HasValue)
|
|||
|
{
|
|||
|
this.txtViolationDate.Text = string.Format("{0:yyyy-MM-dd}", welderViolation.ViolationDate);
|
|||
|
}
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(welderViolation.WelderViolationTypeId))
|
|||
|
{
|
|||
|
var type = BLL.WelderViolationTypeService.GetWelderViolationType(welderViolation.WelderViolationTypeId);
|
|||
|
if (!string.IsNullOrEmpty(type.Flag))
|
|||
|
{
|
|||
|
drpViolationFlag.SelectedValue = type.Flag;
|
|||
|
BLL.WelderViolationTypeService.InitWelderViolationTypeDropDownList(drpViolationType, type.Flag, true, Resources.Lan.PleaseSelect);
|
|||
|
drpViolationType.SelectedValue = welderViolation.WelderViolationTypeId;
|
|||
|
|
|||
|
var results = BLL.DropListService.GetResultsList(type.Flag);
|
|||
|
this.drpResults.DataValueField = "Value";
|
|||
|
this.drpResults.DataTextField = "Text";
|
|||
|
this.drpResults.DataSource = results;
|
|||
|
this.drpResults.DataBind();
|
|||
|
BLL.Funs.FineUIPleaseSelect(this.drpResults, Resources.Lan.PleaseSelect);
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(welderViolation.Results))
|
|||
|
{
|
|||
|
drpResults.SelectedValue = welderViolation.Results;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
txtSpecialNote.Text = welderViolation.SpecialNote;
|
|||
|
txtProject.Text = welderViolation.Project;
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(welderViolation.RecordMan))
|
|||
|
{
|
|||
|
drpRecordMan.SelectedValue = welderViolation.RecordMan;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var welder = BLL.WelderService.GetWelderById(this.hdWelderId.Text);
|
|||
|
if (welder != null)
|
|||
|
{
|
|||
|
drpUnit.SelectedValue = welder.UnitId;
|
|||
|
}
|
|||
|
drpRecordMan.SelectedValue = CurrUser.UserId;
|
|||
|
this.txtViolationDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
|||
|
}
|
|||
|
|
|||
|
var w = BLL.WelderService.GetWelderById(this.hdWelderId.Text);
|
|||
|
if (w != null)
|
|||
|
{
|
|||
|
this.txtWelderCode.Text = w.WelderCode;
|
|||
|
txtWelderName.Text = w.WelderName;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#region 保存
|
|||
|
/// <summary>
|
|||
|
/// 保存按钮
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnSave_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
string welderViolationId = Request.Params["WelderViolationId"];
|
|||
|
Model.Welder_Violation welderViolation = new Model.Welder_Violation();
|
|||
|
welderViolation.WelderId = this.hdWelderId.Text;
|
|||
|
if (drpUnit.SelectedValue != BLL.Const._Null)
|
|||
|
{
|
|||
|
welderViolation.UnitId = drpUnit.SelectedValue;
|
|||
|
}
|
|||
|
if (drpViolationType.SelectedValue == Const._Null || string.IsNullOrEmpty(drpViolationType.SelectedValue))
|
|||
|
{
|
|||
|
ShowNotify("违章类型不能为空!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
welderViolation.ViolationDate = Funs.GetNewDateTime(this.txtViolationDate.Text.Trim());
|
|||
|
welderViolation.WelderViolationTypeId = drpViolationType.SelectedValue;
|
|||
|
welderViolation.Results = drpResults.SelectedValue;
|
|||
|
welderViolation.SpecialNote = txtSpecialNote.Text.Trim();
|
|||
|
welderViolation.Project = txtProject.Text.Trim();
|
|||
|
if (drpRecordMan.SelectedValue != BLL.Const._Null)
|
|||
|
{
|
|||
|
welderViolation.RecordMan = drpRecordMan.SelectedValue;
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(welderViolationId))
|
|||
|
{
|
|||
|
welderViolation.WelderViolationId = welderViolationId;
|
|||
|
BLL.WelderViolationService.UpdateWelderViolation(welderViolation);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
welderViolation.WelderViolationId = SQLHelper.GetNewID(typeof(Model.Welder_Violation));
|
|||
|
BLL.WelderViolationService.AddWelderViolation(welderViolation);
|
|||
|
}
|
|||
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|||
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|||
|
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
protected void drpViolationFlag_OnSelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (drpViolationFlag.SelectedValue != "0")
|
|||
|
{
|
|||
|
BLL.WelderViolationTypeService.InitWelderViolationTypeDropDownList(drpViolationType, drpViolationFlag.SelectedValue, true, "-请选择-");
|
|||
|
var results = BLL.DropListService.GetResultsList(drpViolationFlag.SelectedValue);
|
|||
|
this.drpResults.DataValueField = "Value";
|
|||
|
this.drpResults.DataTextField = "Text";
|
|||
|
this.drpResults.DataSource = results;
|
|||
|
this.drpResults.DataBind();
|
|||
|
BLL.Funs.FineUIPleaseSelect(this.drpResults, Resources.Lan.PleaseSelect);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|