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.JDGL.Check { public partial class ProgressCompletionEdit : PageBase { /// /// id /// public string ProgressCompletionId { get { return (string)ViewState["ProgressCompletionId"]; } set { ViewState["ProgressCompletionId"] = value; } } /// /// 项目id /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); ProgressCompletionId = Request.Params["ProgressCompletionId"]; if (!string.IsNullOrEmpty(ProgressCompletionId)) { Model.JDGL_ProgressCompletion ProgressCompletion = BLL.ProgressCompletionService.GetProgressCompletionById(ProgressCompletionId); if (ProgressCompletion != null) { this.ProjectId = ProgressCompletion.ProjectId; if (ProgressCompletion.Months != null) { this.txtMonths.Text = string.Format("{0:yyyy-MM}", ProgressCompletion.Months); } if (ProgressCompletion.PlanNum != null) { this.txtPlanNum.Text = ProgressCompletion.PlanNum.ToString(); } if (ProgressCompletion.RealNum != null) { this.txtRealNum.Text = ProgressCompletion.RealNum.ToString(); } } } else { this.txtMonths.Text = string.Format("{0:yyyy-MM}",DateTime.Now); } } } protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(ProgressCompletionId)) { Model.JDGL_ProgressCompletion oldProgressCompletion = BLL.ProgressCompletionService.GetProgressCompletionByProjectIdAndMonths(this.CurrUser.LoginProjectId,this.txtMonths.Text.Trim()); if (oldProgressCompletion != null) { ShowNotify("该月份记录已存在!", MessageBoxIcon.Warning); return; } } SaveData(true); } private void SaveData(bool bl) { string ProgressCompletionId = Request.Params["ProgressCompletionId"]; Model.JDGL_ProgressCompletion ProgressCompletion = new Model.JDGL_ProgressCompletion(); ProgressCompletion.ProjectId = this.CurrUser.LoginProjectId; ProgressCompletion.Months = Funs.GetNewDateTime(this.txtMonths.Text.Trim()); if (!string.IsNullOrEmpty(this.txtPlanNum.Text.Trim())) { ProgressCompletion.PlanNum = Convert.ToDecimal(this.txtPlanNum.Text.Trim()); } if (!string.IsNullOrEmpty(this.txtRealNum.Text.Trim())) { ProgressCompletion.RealNum = Convert.ToDecimal(this.txtRealNum.Text.Trim()); } if (!string.IsNullOrEmpty(ProgressCompletionId)) { ProgressCompletion.ProgressCompletionId = ProgressCompletionId; BLL.ProgressCompletionService.UpdateProgressCompletion(ProgressCompletion); } else { ProgressCompletion.ProgressCompletionId = SQLHelper.GetNewID(typeof(Model.JDGL_ProgressCompletion)); BLL.ProgressCompletionService.AddProgressCompletion(ProgressCompletion); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } }