using BLL; using BLL.CQMS.Comprehensive; using System; using System.Linq; namespace FineUIPro.Web.Customization.CNCCG.CQMS { public partial class ReportPreparationEdit : PageBase { public string Id { get { return (string)ViewState["Id"]; } set { ViewState["Id"] = value; } } public string type { get { return (string)ViewState["type"]; } set { ViewState["type"] = value; } } public Model.SUBQHSEDB db = Funs.DB; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); Id = Request.Params["Id"]; type = Request.Params["type"]; if (!string.IsNullOrEmpty(type)) { btnSave.Hidden = true; } if (!string.IsNullOrEmpty(Id)) { var result = db.Project_ReportPreparation.FirstOrDefault(x => x.Id == Id); if (result != null) { txtUnitName.Text = UnitService.GetUnitNameByUnitId(result.UnitId); txtProjectName.Text = ProjectService.GetProjectNameByProjectId(result.ProjectId); txtProjectScale.Text = result.ProjectScale; txtAwardsName.Text = result.AwardsName; if (result.StartTime.HasValue) { dpStartTime.Text = result.StartTime.ToString(); } if (result.EndTime.HasValue) { dpEndTime.Text = result.EndTime.ToString(); } if (result.CreateTime.HasValue) { dpCreateTime.Text = result.CreateTime.ToString(); } txtAwardsLevel.Text = result.AwardsLevel; txtNodePlan.Text = result.NodePlan; txtProgress.Text = result.Progress; txtAwardsPersonName.Text = result.AwardsPersonName; txtPersonPhone.Text = result.PersonPhone; txtUnitPersonName.Text = result.UnitPersonName; txtUnitPersonPhone.Text = result.UnitPersonPhone; txtAwardsUnit.Text = result.AwardsUnit; } } else { if (!string.IsNullOrEmpty(CurrUser.UnitId)) { txtUnitName.Text = UnitService.GetUnitNameByUnitId(CurrUser.UnitId); } else { txtUnitName.Text = UnitService.GetUnitNameByUnitId(CommonService.GetIsThisUnit().UnitId); } txtProjectName.Text = ProjectService.GetProjectNameByProjectId(CurrUser.LoginProjectId); dpCreateTime.Text = DateTime.Now.ToString(); } } } /// /// 保存 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { var uid = CurrUser.UnitId; if (string.IsNullOrEmpty(uid)) { uid = CommonService.GetIsThisUnit().UnitId; } var model = new Model.Project_ReportPreparation() { UnitId = uid, ProjectId = CurrUser.LoginProjectId, ProjectScale = txtProjectScale.Text.Trim(), AwardsName= txtAwardsName.Text.Trim(), StartTime= Convert.ToDateTime(dpStartTime.Text), EndTime=Convert.ToDateTime(dpEndTime.Text), CreateTime=Convert.ToDateTime(dpCreateTime.Text), AwardsLevel= txtAwardsLevel.Text.Trim(), NodePlan= txtNodePlan.Text, Progress= txtProgress.Text, AwardsPersonName= txtAwardsPersonName.Text, PersonPhone= txtPersonPhone.Text, UnitPersonName= txtUnitPersonName.Text, UnitPersonPhone= txtUnitPersonPhone.Text, AwardsUnit= txtAwardsUnit.Text }; if (!string.IsNullOrEmpty(Id)) { model.Id = Id; ReportPreparationService.Update(model); } else { model.Id = Guid.NewGuid().ToString(); ReportPreparationService.Insert(model); } ShowNotify("编辑完成!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } } }