236 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			236 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			C#
		
	
	
	
using BLL;
 | 
						|
using System;
 | 
						|
using System.Linq;
 | 
						|
 | 
						|
namespace FineUIPro.Web.EditorManage
 | 
						|
{
 | 
						|
    public partial class FCRLogEditorEdit : PageBase
 | 
						|
    {
 | 
						|
        #region 加载
 | 
						|
        /// <summary>
 | 
						|
        /// 加载
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        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();
 | 
						|
                }
 | 
						|
 | 
						|
                BLL.ConstService.InitConstIdDropDownList(this.drpDiscipline, BLL.Const.FCRLog_Discipline, true);
 | 
						|
                BLL.ConstService.InitConstIdDropDownList(this.drpCategory, BLL.Const.FCRLog_Category, true);
 | 
						|
                BLL.ConstService.InitConstIdDropDownList(this.drpCDI, BLL.Const.PM_CDI, true);
 | 
						|
                BLL.Sys_UserService.InitUserDropDownList(this.drpInitiator, true);
 | 
						|
 | 
						|
                this.drpCostYorN.DataTextField = "ConstText";
 | 
						|
                this.drpCostYorN.DataValueField = "ConstValue";
 | 
						|
                this.drpCostYorN.DataSource = BLL.ConstValue.drpConstItemList(BLL.ConstValue.Group_YesOrNo);
 | 
						|
                this.drpCostYorN.DataBind();
 | 
						|
                Funs.FineUIPleaseSelect(this.drpCostYorN);
 | 
						|
 | 
						|
                this.drpSchYorN.DataTextField = "ConstText";
 | 
						|
                this.drpSchYorN.DataValueField = "ConstValue";
 | 
						|
                this.drpSchYorN.DataSource = BLL.ConstValue.drpConstItemList(BLL.ConstValue.Group_YesOrNo);
 | 
						|
                this.drpSchYorN.DataBind();
 | 
						|
                Funs.FineUIPleaseSelect(this.drpSchYorN);
 | 
						|
 | 
						|
 | 
						|
                string FCRLogId = Request.Params["FCRLogId"];
 | 
						|
                if (!string.IsNullOrEmpty(FCRLogId))
 | 
						|
                {
 | 
						|
                    Model.Editor_FCRLog fcrlog = BLL.FCRLogService.GetFCRLogById(FCRLogId);
 | 
						|
                    if (fcrlog != null)
 | 
						|
                    {
 | 
						|
                        this.txtFCRNo.Text = fcrlog.FCRNo;
 | 
						|
                        if (!string.IsNullOrEmpty(fcrlog.DisciplineId))
 | 
						|
                        {
 | 
						|
                            this.drpDiscipline.SelectedValue = fcrlog.DisciplineId;
 | 
						|
                        }
 | 
						|
                        if (!string.IsNullOrEmpty(fcrlog.CategoryId))
 | 
						|
                        {
 | 
						|
                            this.drpCategory.SelectedValue = fcrlog.CategoryId;
 | 
						|
                        }
 | 
						|
                        //this.txtInitiator.Text = fcrlog.Initiator;
 | 
						|
                        this.drpInitiator.SelectedValue = fcrlog.Initiator;
 | 
						|
                        drpDesignReason.SelectedValue = fcrlog.DesignReason;
 | 
						|
 | 
						|
                        if (!string.IsNullOrEmpty(fcrlog.CDIId))
 | 
						|
                        {
 | 
						|
                            this.drpCDI.SelectedValue = fcrlog.CDIId;
 | 
						|
                        }
 | 
						|
                        if (fcrlog.TDCRecDate.HasValue)
 | 
						|
                        {
 | 
						|
                            this.txtTDCRecDate.Text = string.Format("{0:yyyy-MM-dd}", fcrlog.TDCRecDate);
 | 
						|
                        }
 | 
						|
                        if (fcrlog.FCRIssueDate.HasValue)
 | 
						|
                        {
 | 
						|
                            this.txtFCRIssueDate.Text = string.Format("{0:yyyy-MM-dd}", fcrlog.FCRIssueDate);
 | 
						|
                        }
 | 
						|
                        if (fcrlog.ConReturnDate.HasValue)
 | 
						|
                        {
 | 
						|
                            this.txtConReturnDate.Text = string.Format("{0:yyyy-MM-dd}", fcrlog.ConReturnDate);
 | 
						|
                        }
 | 
						|
                        this.drpCostYorN.SelectedValue = fcrlog.CostYorN;
 | 
						|
                        if (fcrlog.CostCNY.HasValue)
 | 
						|
                        {
 | 
						|
                            this.txtCost.Text = fcrlog.CostCNY.ToString();
 | 
						|
                        }
 | 
						|
                        this.drpSchYorN.SelectedValue = fcrlog.SchYorN;
 | 
						|
                        if (fcrlog.SchDays.HasValue)
 | 
						|
                        {
 | 
						|
                            this.txtSchDay.Text = fcrlog.SchDays.ToString();
 | 
						|
                        }
 | 
						|
                        if (this.CurrUser.UserId == this.drpInitiator.SelectedValue || this.CurrUser.RoleId==Const.Role_TDC || this.CurrUser.UserId == BLL.Const.GlyId)
 | 
						|
                        {
 | 
						|
                            this.btnSave.Hidden = false;
 | 
						|
                        }
 | 
						|
                        else
 | 
						|
                        {
 | 
						|
                            this.btnSave.Hidden = true;
 | 
						|
                        }
 | 
						|
 | 
						|
                        txtRemark.Text = fcrlog.Remark;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    this.drpInitiator.SelectedValue = this.CurrUser.UserId;
 | 
						|
                    //string eprojectId = Request.Params["eProjectId"];
 | 
						|
                    //if (!string.IsNullOrEmpty(eprojectId))
 | 
						|
                    //{
 | 
						|
                    //    var eproject = BLL.EProjectService.GeteProjectById(eprojectId);
 | 
						|
                    //    if (eproject != null)
 | 
						|
                    //    {
 | 
						|
                    //        this.txtFCRNo.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode3", "dbo.Editor_FCRLog", "FCRNo", eproject.ProjectControl_JobNo + "-FCR-");
 | 
						|
                    //    }
 | 
						|
                    //}
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 保存
 | 
						|
        protected void btnSave_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (this.drpDiscipline.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpDiscipline.SelectedValue))
 | 
						|
            {
 | 
						|
                ShowAlert("Please select Discipline!", MessageBoxIcon.Warning);
 | 
						|
                return;
 | 
						|
            }
 | 
						|
            string FCRLogId = Request.Params["FCRLogId"];
 | 
						|
            Model.Editor_FCRLog newFCRLog = new Model.Editor_FCRLog();
 | 
						|
            newFCRLog.FCRNo = this.txtFCRNo.Text.Trim();
 | 
						|
            if (this.drpDiscipline.SelectedValue != BLL.Const._Null)
 | 
						|
            {
 | 
						|
                newFCRLog.DisciplineId = this.drpDiscipline.SelectedValue;
 | 
						|
                newFCRLog.DisciplineName = this.drpDiscipline.SelectedItem.Text.Trim();
 | 
						|
            }
 | 
						|
            if (this.drpCategory.SelectedValue != BLL.Const._Null)
 | 
						|
            {
 | 
						|
                newFCRLog.CategoryId = this.drpCategory.SelectedValue;
 | 
						|
                newFCRLog.CategoryName = this.drpCategory.SelectedItem.Text.Trim();
 | 
						|
            }
 | 
						|
            //newFCRLog.Initiator = this.txtInitiator.Text.Trim();
 | 
						|
            if (this.drpInitiator.SelectedValue != BLL.Const._Null)
 | 
						|
            {
 | 
						|
                newFCRLog.Initiator = this.drpInitiator.SelectedValue;
 | 
						|
                newFCRLog.InitiatorName = this.drpInitiator.SelectedItem.Text;
 | 
						|
            }
 | 
						|
 | 
						|
            newFCRLog.DesignReason = drpDesignReason.SelectedValue;
 | 
						|
            if (this.drpCDI.SelectedValue != BLL.Const._Null)
 | 
						|
            {
 | 
						|
                newFCRLog.CDIId = this.drpCDI.SelectedValue;
 | 
						|
                newFCRLog.CDIName = this.drpCDI.SelectedItem.Text.Trim();
 | 
						|
            }
 | 
						|
            newFCRLog.TDCRecDate = Funs.GetNewDateTime(this.txtTDCRecDate.Text.Trim());
 | 
						|
            newFCRLog.FCRIssueDate = Funs.GetNewDateTime(this.txtFCRIssueDate.Text.Trim());
 | 
						|
            newFCRLog.ConReturnDate = Funs.GetNewDateTime(this.txtConReturnDate.Text.Trim());
 | 
						|
            if (this.drpCostYorN.SelectedValue != BLL.Const._Null)
 | 
						|
            {
 | 
						|
                newFCRLog.CostYorN = this.drpCostYorN.SelectedValue;
 | 
						|
            }
 | 
						|
            newFCRLog.CostCNY = Funs.GetNewDecimal(this.txtCost.Text.Trim());
 | 
						|
            if (this.drpSchYorN.SelectedValue != BLL.Const._Null)
 | 
						|
            {
 | 
						|
                newFCRLog.SchYorN = this.drpSchYorN.SelectedValue;
 | 
						|
            }
 | 
						|
            newFCRLog.SchDays = Funs.GetNewDecimal(this.txtSchDay.Text.Trim());
 | 
						|
            newFCRLog.Remark = this.txtRemark.Text.Trim();
 | 
						|
            if (!string.IsNullOrEmpty(FCRLogId))
 | 
						|
            {
 | 
						|
                newFCRLog.FCRLogId = FCRLogId;
 | 
						|
                BLL.FCRLogService.UpdateFCRLog(newFCRLog);
 | 
						|
                BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Modify FCR Log Editor information!");
 | 
						|
                ShowNotify("Save Successfully!", MessageBoxIcon.Success);
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                newFCRLog.EProjectId = Request.Params["eProjectId"];
 | 
						|
                FCRLogId = SQLHelper.GetNewID(typeof(Model.Editor_FCRLog));
 | 
						|
                newFCRLog.FCRLogId = FCRLogId;
 | 
						|
                BLL.FCRLogService.AddFCRLog(newFCRLog);
 | 
						|
                BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Add FCR Log Editor information!");
 | 
						|
                ShowNotify("Save Successfully!", MessageBoxIcon.Success);
 | 
						|
            }
 | 
						|
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 下拉选择事件
 | 
						|
        /// <summary>
 | 
						|
        ///专业下拉选择事件
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void drpDiscipline_SelectedIndexChanged(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (this.drpDiscipline.SelectedValue != BLL.Const._Null)
 | 
						|
            {
 | 
						|
                string job_No = string.Empty;
 | 
						|
                string eprojectId = Request.Params["eProjectId"];
 | 
						|
                var eproject = BLL.EProjectService.GeteProjectById(eprojectId);
 | 
						|
                if (eproject != null)
 | 
						|
                {
 | 
						|
                    job_No = eproject.ProjectControl_JobNo;
 | 
						|
                }
 | 
						|
                string disciplineText = this.drpDiscipline.SelectedItem.Text;
 | 
						|
                string discipline = disciplineText.Substring(0, disciplineText.IndexOf('_'));
 | 
						|
                string prefixCode = job_No + "-FCR-" + discipline + "-";
 | 
						|
                this.txtFCRNo.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCodeByJobNo3", "dbo.Editor_FCRLog", "FCRNo", prefixCode);
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                this.txtFCRNo.Text = string.Empty;
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 权限设置
 | 
						|
        /// <summary>
 | 
						|
        /// 菜单按钮权限
 | 
						|
        /// </summary>
 | 
						|
        private void GetButtonPower()
 | 
						|
        {
 | 
						|
            var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.UserId, BLL.Const.FCRLogMenuId);
 | 
						|
            if (buttonList.Count() > 0)
 | 
						|
            {
 | 
						|
                if (buttonList.Contains(BLL.Const.BtnSave))
 | 
						|
                {
 | 
						|
                    this.btnSave.Hidden = false;
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion        
 | 
						|
    }
 | 
						|
} |