135 lines
		
	
	
		
			6.5 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			135 lines
		
	
	
		
			6.5 KiB
		
	
	
	
		
			C#
		
	
	
	
using BLL;
 | 
						|
using System;
 | 
						|
 | 
						|
namespace FineUIPro.Web.EditorManage
 | 
						|
{
 | 
						|
    public partial class CostReportEdit : PageBase
 | 
						|
    {
 | 
						|
        protected void Page_Load(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (!IsPostBack)
 | 
						|
            {
 | 
						|
                this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
 | 
						|
 | 
						|
                this.drpEProjectId.DataTextField = "ProjectControl_JobNo";
 | 
						|
                this.drpEProjectId.DataValueField = "EProjectId";
 | 
						|
                this.drpEProjectId.DataSource = BLL.EProjectService.GetEProjectList();
 | 
						|
                this.drpEProjectId.DataBind();
 | 
						|
                Funs.FineUIPleaseSelect(this.drpEProjectId);
 | 
						|
 | 
						|
                string costReportId = Request.Params["costReportId"];
 | 
						|
                if (!string.IsNullOrEmpty(costReportId))
 | 
						|
                {
 | 
						|
                    Model.Editor_CostReport costReport = BLL.CostReportService.GetCostReportById(costReportId);
 | 
						|
                    if (costReport != null)
 | 
						|
                    {
 | 
						|
                        if (!string.IsNullOrEmpty(costReport.EProjectId))
 | 
						|
                        {
 | 
						|
                            var eproject = BLL.EProjectService.GeteProjectById(costReport.EProjectId);
 | 
						|
                            if (eproject != null)
 | 
						|
                            {
 | 
						|
                                this.drpEProjectId.SelectedValue = eproject.EProjectId;
 | 
						|
                                this.txtJobType.Text = eproject.ProjectControl_JobType;
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                        this.txtMonth.Text = string.Format("{0:yyyy-MM}", costReport.Monthly);
 | 
						|
                        this.txtOrginalBudget.Text = costReport.OrginalBudget == null ? "" : costReport.OrginalBudget.ToString();
 | 
						|
                        this.txtChangedBudget.Text = costReport.ChangedBudget == null ? "" : costReport.ChangedBudget.ToString();
 | 
						|
                        this.txtActualCost.Text = costReport.ActualCost == null ? "" : costReport.ActualCost.ToString();
 | 
						|
                        this.txtCommittedPRPO.Text = costReport.CommittedPRPO == null ? "" : costReport.CommittedPRPO.ToString();
 | 
						|
                        this.txtCommittedSSRs.Text = costReport.CommittedSSRs == null ? "" : costReport.CommittedSSRs.ToString();
 | 
						|
                        this.txtCostToComplete.Text = costReport.CostToComplete == null ? "" : costReport.CostToComplete.ToString();
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 提交按钮
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnSave_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            try
 | 
						|
            {
 | 
						|
                if (this.drpEProjectId.SelectedValue == BLL.Const._Null)
 | 
						|
                {
 | 
						|
                    ShowAlert("Please select Job No.!", MessageBoxIcon.Warning);
 | 
						|
                    return;
 | 
						|
                }
 | 
						|
                if (string.IsNullOrEmpty(this.txtMonth.Text.Trim()))
 | 
						|
                {
 | 
						|
                    ShowAlert("Please select Month!", MessageBoxIcon.Warning);
 | 
						|
                    return;
 | 
						|
                }
 | 
						|
                string costReportId = Request.Params["costReportId"];
 | 
						|
                Model.Editor_CostReport newCostReport = new Model.Editor_CostReport();
 | 
						|
                newCostReport.EProjectId = this.drpEProjectId.SelectedValue;
 | 
						|
                newCostReport.Monthly = this.txtMonth.Text.Trim();
 | 
						|
                newCostReport.OrginalBudget = Funs.GetNewDecimalOrZero(this.txtOrginalBudget.Text.Trim());
 | 
						|
                newCostReport.ChangedBudget = Funs.GetNewDecimalOrZero(this.txtChangedBudget.Text.Trim());
 | 
						|
                newCostReport.ActualCost = Funs.GetNewDecimalOrZero(this.txtActualCost.Text.Trim());
 | 
						|
                newCostReport.CommittedPRPO = Funs.GetNewDecimalOrZero(this.txtCommittedPRPO.Text.Trim());
 | 
						|
                newCostReport.CommittedSSRs = Funs.GetNewDecimalOrZero(this.txtCommittedSSRs.Text.Trim());
 | 
						|
                newCostReport.CostToComplete = Funs.GetNewDecimalOrZero(this.txtCostToComplete.Text.Trim());
 | 
						|
 | 
						|
                if (!string.IsNullOrEmpty(costReportId))
 | 
						|
                {
 | 
						|
                    newCostReport.CostReportId = costReportId;
 | 
						|
                    BLL.CostReportService.UpdateCostReport(newCostReport);
 | 
						|
                    BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Modify Cost report!");
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    costReportId = SQLHelper.GetNewID(typeof(Model.Editor_CostReport));
 | 
						|
                    newCostReport.CostReportId = costReportId;
 | 
						|
                    BLL.CostReportService.AddCostReport(newCostReport);
 | 
						|
                    BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Add Cost report!");
 | 
						|
                }
 | 
						|
                //更新Control中OrginalBudget和CM中Cost to complete
 | 
						|
                var eproject = BLL.EProjectService.GeteProjectById(newCostReport.EProjectId);
 | 
						|
                eproject.ProjectControl_OrginalBudget = newCostReport.OrginalBudget;
 | 
						|
                eproject.ProjectControl_ChangedBudget = newCostReport.ChangedBudget;
 | 
						|
                eproject.ProjectControl_Actual = newCostReport.ActualCost;
 | 
						|
                eproject.ProjectControl_CommittedPRPO = newCostReport.CommittedPRPO;
 | 
						|
                eproject.ProjectControl_CommittedSSRs = newCostReport.CommittedSSRs;
 | 
						|
                eproject.PM_General_CostToComplete = newCostReport.CostToComplete;
 | 
						|
                eproject.ModifyDate = DateTime.Now;
 | 
						|
                eproject.ModifyPerson = CurrUser.UserId;
 | 
						|
                BLL.EProjectService.UpdateOrginalBudget(eproject);
 | 
						|
 | 
						|
                ShowNotify("Save Successfully!", MessageBoxIcon.Success);
 | 
						|
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
 | 
						|
            }
 | 
						|
            catch (Exception ex)
 | 
						|
            {
 | 
						|
                Alert.ShowInParent(ex.ToString());
 | 
						|
                return;
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #region DropDownList下拉选择事件
 | 
						|
        /// <summary>
 | 
						|
        /// 项目号下拉选择事件
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void drpEProjectId_SelectedIndexChanged(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (this.drpEProjectId.SelectedValue != BLL.Const._Null)
 | 
						|
            {
 | 
						|
                var eProject = BLL.EProjectService.GeteProjectById(this.drpEProjectId.SelectedValue);
 | 
						|
                if (eProject != null)
 | 
						|
                {
 | 
						|
                    this.txtJobType.Text = eProject.ProjectControl_JobType;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                this.txtJobType.Text = string.Empty;
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
} |