259 lines
11 KiB
C#
259 lines
11 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.SES
|
|||
|
{
|
|||
|
public partial class CQualityPunishEdit : PageBase
|
|||
|
{
|
|||
|
#region 加载
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|||
|
string view = Request.Params["view"];
|
|||
|
if (view == "1")
|
|||
|
{
|
|||
|
this.btnSave.Hidden = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
GetButtonPower();//按钮权限
|
|||
|
}
|
|||
|
|
|||
|
var role = BLL.Sys_RoleService.GetRole(CurrUser.RoleId);
|
|||
|
if (role != null && role.RoleName == "Contract Administrator")
|
|||
|
{
|
|||
|
txtSESNo.Required = true;
|
|||
|
txtCompletionDate.Required = true;
|
|||
|
txtSESNo.Enabled = true;
|
|||
|
txtCompletionDate.Enabled = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
txtSESNo.Required = false;
|
|||
|
txtCompletionDate.Required = false;
|
|||
|
txtSESNo.Enabled = false;
|
|||
|
txtCompletionDate.Enabled = false;
|
|||
|
}
|
|||
|
|
|||
|
//BLL.SESRelatedDataService.InitFONoDropDownList(this.drpFO_No, true);//合同号
|
|||
|
BLL.ContractorService.InitDropDownList(drpContractor, true); //承包商;
|
|||
|
BLL.DepartService.InitDropDownList(this.drpBYC_RU, true);//BYC负责部门
|
|||
|
BLL.Sys_UserService.InitUserDropDownList(this.drpViolationInspector, true);//违章检查人
|
|||
|
|
|||
|
|
|||
|
string punishmentId = Request.Params["punishmentId"];
|
|||
|
if (!string.IsNullOrEmpty(punishmentId))
|
|||
|
{
|
|||
|
Model.View_EMC_Punishment punishment = BLL.PunishmentService.GetPunishmentViewById(punishmentId);
|
|||
|
Model.EMC_Punishment pun = BLL.PunishmentService.GetPunishmentById(punishmentId);
|
|||
|
if (punishment != null)
|
|||
|
{
|
|||
|
this.txtPunishDate.Text = punishment.PunishDate != null ? string.Format("{0:yyyy-MM-dd}", punishment.PunishDate) : "";
|
|||
|
this.txtPunishTime.Text = punishment.PunishDate != null ? punishment.PunishDate.Value.ToShortTimeString() : "";
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(punishment.ContractorId))
|
|||
|
{
|
|||
|
this.drpContractor.SelectedValue = punishment.ContractorId;
|
|||
|
BLL.SESRelatedDataService.InitFONoDropDownList(this.drpFO_No, drpContractor.SelectedValue, true);//合同号
|
|||
|
this.drpFO_No.SelectedValue = punishment.FO_NO;
|
|||
|
}
|
|||
|
|
|||
|
this.txtDiscispline.Text = punishment.Discipline;
|
|||
|
this.txtLocation.Text = punishment.Location;
|
|||
|
this.txtDescription.Text = punishment.Description;
|
|||
|
|
|||
|
this.txtCompany.Text = punishment.Company.HasValue ? punishment.Company.ToString() : "";
|
|||
|
this.txtIndividual.Text = punishment.Individual.HasValue ? punishment.Individual.ToString() : "";
|
|||
|
this.txtBackcharge.Text = punishment.Backcharge.HasValue ? punishment.Backcharge.Value.ToString("0.00") : "";
|
|||
|
|
|||
|
if (pun != null && !string.IsNullOrEmpty(pun.ViolationDegree))
|
|||
|
{
|
|||
|
drpViolationDegree.SelectedValue = pun.ViolationDegree;
|
|||
|
}
|
|||
|
txtContractAdmin.Text = punishment.Contract_Admin;
|
|||
|
txtMainCoordinator.Text = punishment.Main_Coordinator;
|
|||
|
txtMCDept.Text = punishment.MCDept;
|
|||
|
txtUserRepresentative.Text = punishment.User_Representative;
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(punishment.BYC_RU))
|
|||
|
{
|
|||
|
this.drpBYC_RU.SelectedValue = punishment.BYC_RU;
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(punishment.Violation_Inspector))
|
|||
|
{
|
|||
|
this.drpViolationInspector.SelectedValue = punishment.Violation_Inspector;
|
|||
|
var user = BLL.Sys_UserService.GetUsersByUserId(punishment.Violation_Inspector);
|
|||
|
string depName = BLL.DepartService.GetDepartNameById(user.DepartId);
|
|||
|
txtInspectionDep.Text = depName;
|
|||
|
}
|
|||
|
|
|||
|
this.txtCompletionDate.Text = punishment.CompletionDate != null ? string.Format("{0:yyyy-MM-dd}", punishment.CompletionDate) : "";
|
|||
|
this.txtSESNo.Text = punishment.SES_No;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 保存
|
|||
|
/// <summary>
|
|||
|
/// 保存
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnSave_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
string punishmentId = Request.Params["punishmentId"];
|
|||
|
Model.EMC_Punishment punishment = new Model.EMC_Punishment();
|
|||
|
|
|||
|
if (this.drpContractor.SelectedValue == BLL.Const._Null)
|
|||
|
{
|
|||
|
Alert.ShowInTop("Please select Contractor!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (this.drpFO_No.SelectedValue == BLL.Const._Null)
|
|||
|
{
|
|||
|
Alert.ShowInTop("Please select Contract No.!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
if (punishmentId == null)
|
|||
|
{
|
|||
|
punishmentId = string.Empty;
|
|||
|
}
|
|||
|
if (BLL.PunishmentService.IsExistSES_NO(punishmentId, this.txtSESNo.Text.Trim(), "2"))
|
|||
|
{
|
|||
|
Alert.ShowInTop("The Backcharge SES NO. already exists!");
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
punishment.PunishDate = Funs.GetNewDateTime(this.txtPunishDate.Text.Trim() + " " + txtPunishTime.Text.Trim());
|
|||
|
punishment.FO_NO = drpFO_No.SelectedValue;
|
|||
|
if (txtSESNo.Text.Trim() != string.Empty)
|
|||
|
{
|
|||
|
punishment.SES_No = txtSESNo.Text.Trim();
|
|||
|
}
|
|||
|
punishment.Location = txtLocation.Text.Trim();
|
|||
|
punishment.Description = txtDescription.Text.Trim();
|
|||
|
if (txtCompany.Text != string.Empty)
|
|||
|
{
|
|||
|
punishment.Company = Convert.ToDecimal(txtCompany.Text.Trim());
|
|||
|
}
|
|||
|
if (txtIndividual.Text != string.Empty)
|
|||
|
{
|
|||
|
punishment.Individual = Convert.ToDecimal(txtIndividual.Text.Trim());
|
|||
|
}
|
|||
|
punishment.ViolationDegree = drpViolationDegree.SelectedValue;
|
|||
|
if (drpBYC_RU.SelectedValue != Const._Null)
|
|||
|
{
|
|||
|
punishment.BYC_RU = drpBYC_RU.SelectedValue;
|
|||
|
}
|
|||
|
if (drpViolationInspector.SelectedValue != Const._Null)
|
|||
|
{
|
|||
|
punishment.Violation_Inspector = drpViolationInspector.SelectedValue;
|
|||
|
}
|
|||
|
punishment.CompletionDate = Funs.GetNewDateTime(this.txtCompletionDate.Text.Trim());
|
|||
|
punishment.Flag = "2";
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(punishmentId))
|
|||
|
{
|
|||
|
punishment.PunishmentId = punishmentId;
|
|||
|
BLL.PunishmentService.UpdatePunishment(punishment);
|
|||
|
BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Modify Contractor Quality Punishment!");
|
|||
|
ShowNotify("Save successfully!", MessageBoxIcon.Success);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
punishment.PunishmentId = SQLHelper.GetNewID(typeof(Model.EMC_Punishment));
|
|||
|
BLL.PunishmentService.AddPunishment(punishment);
|
|||
|
BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Add Contractor Quality Punishment!");
|
|||
|
ShowNotify("Save successfully!", MessageBoxIcon.Success);
|
|||
|
}
|
|||
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
protected void drpContractor_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (this.drpContractor.SelectedValue != BLL.Const._Null)
|
|||
|
{
|
|||
|
this.drpFO_No.Items.Clear();
|
|||
|
BLL.SESRelatedDataService.InitFONoDropDownList(this.drpFO_No, drpContractor.SelectedValue, true);//合同号
|
|||
|
drpFO_No.SelectedValue = BLL.Const._Null;
|
|||
|
txtDiscispline.Text = string.Empty;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected void drpFO_No_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (drpFO_No.SelectedValue != Const._Null)
|
|||
|
{
|
|||
|
string foNO = drpFO_No.SelectedValue;
|
|||
|
Model.View_FC_SESRelatedData fc = BLL.SESRelatedDataService.GetSESRelatedDataViewByFO(foNO);
|
|||
|
if (fc != null)
|
|||
|
{
|
|||
|
txtDiscispline.Text = fc.Discipline;
|
|||
|
txtContractAdmin.Text = fc.Contract_Admin;
|
|||
|
txtMainCoordinator.Text = fc.Main_Coordinator;
|
|||
|
txtUserRepresentative.Text = fc.User_Representative;
|
|||
|
txtMCDept.Text = fc.MCDept;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected void drpViolationInspector_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (drpViolationInspector.SelectedValue != Const._Null)
|
|||
|
{
|
|||
|
string manId = drpViolationInspector.SelectedValue;
|
|||
|
var user = BLL.Sys_UserService.GetUsersByUserId(manId);
|
|||
|
string depName = BLL.DepartService.GetDepartNameById(user.DepartId);
|
|||
|
txtInspectionDep.Text = depName;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected void txtPunish_OnTextChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
decimal? numCompany = 0;
|
|||
|
decimal? numIndividual = 0;
|
|||
|
if (txtCompany.Text != string.Empty)
|
|||
|
{
|
|||
|
numCompany = Funs.GetNewDecimal(txtCompany.Text);
|
|||
|
}
|
|||
|
if (txtIndividual.Text != string.Empty)
|
|||
|
{
|
|||
|
numIndividual = Funs.GetNewDecimal(txtIndividual.Text);
|
|||
|
}
|
|||
|
|
|||
|
txtBackcharge.Text = (numCompany + numIndividual).Value.ToString("0.00");
|
|||
|
}
|
|||
|
|
|||
|
#region 权限设置
|
|||
|
/// <summary>
|
|||
|
/// 菜单按钮权限
|
|||
|
/// </summary>
|
|||
|
private void GetButtonPower()
|
|||
|
{
|
|||
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.UserId, BLL.Const.CQualityPunishMenuId);
|
|||
|
if (buttonList.Count() > 0)
|
|||
|
{
|
|||
|
if (buttonList.Contains(BLL.Const.BtnSave))
|
|||
|
{
|
|||
|
this.btnSave.Hidden = false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|