143 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			143 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using BLL; | |||
|  | using System; | |||
|  | using System.Collections.Generic; | |||
|  | using System.Linq; | |||
|  | using System.Web; | |||
|  | using System.Web.UI; | |||
|  | using System.Web.UI.WebControls; | |||
|  | 
 | |||
|  | namespace FineUIPro.Web.CQMS.Check | |||
|  | { | |||
|  |     public partial class RewardAndPunishEdit : PageBase | |||
|  |     { | |||
|  |         /// <summary> | |||
|  |         /// 项目id | |||
|  |         /// </summary> | |||
|  |         public string RewardAndPunishID | |||
|  |         { | |||
|  |             get | |||
|  |             { | |||
|  |                 return (string)ViewState["RewardAndPunishID"]; | |||
|  |             } | |||
|  |             set | |||
|  |             { | |||
|  |                 ViewState["RewardAndPunishID"] = value; | |||
|  |             } | |||
|  |         }   /// <summary> | |||
|  |             /// 图片是否可以编辑 -1查看 0编辑 | |||
|  |             /// </summary> | |||
|  |         public int QuestionImg | |||
|  |         { | |||
|  |             get | |||
|  |             { | |||
|  |                 return Convert.ToInt32(ViewState["QuestionImg"]); | |||
|  |             } | |||
|  |             set | |||
|  |             { | |||
|  |                 ViewState["QuestionImg"] = value; | |||
|  |             } | |||
|  |         } | |||
|  |         protected void Page_Load(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (!IsPostBack) | |||
|  |             { | |||
|  |                 BLL.RewardAndPunishService.InitTypeDropDownList(drpType); | |||
|  |                 //UnitService.InitUnitDownList(drpResponseUnit, this.CurrUser.LoginProjectId, false); | |||
|  |                 UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpResponseUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, false); | |||
|  | 
 | |||
|  |                 this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); | |||
|  |                 RewardAndPunishID = Request.Params["RewardAndPunishID"]; | |||
|  |                 if (!string.IsNullOrEmpty(RewardAndPunishID)) | |||
|  |                 { | |||
|  |                     this.hdId.Text = RewardAndPunishID; | |||
|  | 
 | |||
|  | 
 | |||
|  |                     Model.Check_RewardAndPunish RewardAndPunish = BLL.RewardAndPunishService.GetRewardAndPunishById(RewardAndPunishID); | |||
|  |                     if (RewardAndPunish != null) | |||
|  |                     { | |||
|  |                         this.CurrUser.LoginProjectId = RewardAndPunish.ProjectId; | |||
|  |                         if (RewardAndPunish.Type.HasValue) | |||
|  |                             this.drpType.SelectedValue = RewardAndPunish.Type.Value.ToString(); | |||
|  |                         if (!string.IsNullOrEmpty(RewardAndPunish.ResponseUnit)) | |||
|  | 
 | |||
|  |                             this.drpResponseUnit.SelectedValue = RewardAndPunish.ResponseUnit; | |||
|  |                         if (RewardAndPunish.Money.HasValue) | |||
|  |                             this.txtMoney.Text = RewardAndPunish.Money.Value.ToString(); | |||
|  |                         if (RewardAndPunish.Date.HasValue) | |||
|  |                             this.dpDate.Text = string.Format("{0:yyyy-MM-dd}", RewardAndPunish.Date.Value); | |||
|  |                         this.txtDescription.Text = RewardAndPunish.Description; | |||
|  |                         if (this.CurrUser.UserId == RewardAndPunish.CreateMan) | |||
|  |                         { | |||
|  |                             QuestionImg = 1; | |||
|  |                         } | |||
|  |                         else | |||
|  |                         { | |||
|  |                             QuestionImg = 0; | |||
|  |                             this.btnSave.Hidden = true; | |||
|  |                         } | |||
|  |                     } | |||
|  |                 } | |||
|  |             } | |||
|  |         } | |||
|  |         protected void WindowAtt_Close(object sender, WindowCloseEventArgs e) | |||
|  |         { | |||
|  | 
 | |||
|  |         } | |||
|  |         protected void imgBtnFile_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (string.IsNullOrEmpty(this.hdId.Text))   //新增记录 | |||
|  |             { | |||
|  |                 this.hdId.Text = SQLHelper.GetNewID(typeof(Model.Check_CheckControl)); | |||
|  |             } | |||
|  |             PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/CheckControl&menuId={2}", QuestionImg, this.hdId.Text, BLL.Const.RewardAndPunishMenuId))); | |||
|  |         } | |||
|  |         protected void btnSave_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (BLL.CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.RewardAndPunishMenuId, BLL.Const.BtnSave)) | |||
|  |             { | |||
|  |                 SaveData(); | |||
|  | 
 | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         private void SaveData() | |||
|  |         { | |||
|  |             Model.Check_RewardAndPunish RewardAndPunish = new Model.Check_RewardAndPunish(); | |||
|  |             if (!string.IsNullOrEmpty(this.hdId.Text)) | |||
|  |             { | |||
|  |                 RewardAndPunish.RewardAndPunishID = this.hdId.Text; | |||
|  |             } | |||
|  |             RewardAndPunish.ProjectId = this.CurrUser.LoginProjectId; | |||
|  |             RewardAndPunish.Type = int.Parse(this.drpType.SelectedValue); | |||
|  | 
 | |||
|  |             RewardAndPunish.ResponseUnit = this.drpResponseUnit.SelectedValue; | |||
|  | 
 | |||
|  |             RewardAndPunish.Money = Decimal.Parse(this.txtMoney.Text); | |||
|  | 
 | |||
|  |             RewardAndPunish.Date = Convert.ToDateTime(this.dpDate.Text.Trim()); | |||
|  |             RewardAndPunish.Description = this.txtDescription.Text; | |||
|  |             RewardAndPunish.CreateMan = this.CurrUser.UserId; | |||
|  |             if (string.IsNullOrEmpty(this.hdId.Text.Trim())) | |||
|  |             { | |||
|  |                 RewardAndPunish.RewardAndPunishID = Guid.NewGuid().ToString(); | |||
|  |             } | |||
|  |             if (string.IsNullOrEmpty(RewardAndPunishID)) | |||
|  |             { | |||
|  |                 BLL.RewardAndPunishService.AddRewardAndPunish(RewardAndPunish); | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 BLL.RewardAndPunishService.UpdateRewardAndPunish(RewardAndPunish); | |||
|  | 
 | |||
|  |             } | |||
|  |             ShowNotify("提交成功!", MessageBoxIcon.Success); | |||
|  |             PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); | |||
|  |         } | |||
|  | 
 | |||
|  | 
 | |||
|  |     } | |||
|  | } |