using BLL; using Model.APIItem.SYHSE; using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Threading.Tasks; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.SYHSE { public partial class SYHSEData_PromiseEdit : PageBase { #region 公共字段 /// /// 主键 /// public string PromiseId { get { return (string)ViewState["PromiseId"]; } set { ViewState["PromiseId"] = value; } } #endregion /// /// 把状态转换代号为文字形式 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { PromiseId = Request.Params["PromiseId"]; if (!string.IsNullOrEmpty(PromiseId)) { var Promise = Funs.DB.SYHSEData_Promise.FirstOrDefault(x => x.PromiseId == PromiseId); if (Promise != null) { if (Promise.PromiseDate.HasValue) { this.txtPromiseDate.Text = Promise.PromiseDate.Value.ToString("yyyy-MM-dd"); } this.txtPromise.Text = Promise.Promise; } } } } protected void btnSave_Click(object sender, EventArgs e) { //string projectId, string userId, string menuId, string buttonName) if (BLL.CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SYHSE_PromiseMenuId, BLL.Const.BtnSave)) { Model.SYHSEData_Promise Promise = Funs.DB.SYHSEData_Promise.FirstOrDefault(x => x.PromiseId == PromiseId); if (Promise == null) { Promise = new Model.SYHSEData_Promise(); Promise.PromiseId = Guid.NewGuid().ToString(); Funs.DB.SYHSEData_Promise.InsertOnSubmit(Promise); } Promise.ProjectId = this.CurrUser.LoginProjectId; Promise.UnitId = this.CurrUser.UserId; Promise.CreateMan = this.CurrUser.UserId; Promise.CreateDate = DateTime.Now; Promise.Promise = this.txtPromise.Text; Promise.PromiseDate = this.txtPromiseDate.SelectedDate; Funs.DB.SubmitChanges(); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); DataPromiseItem newItem = new DataPromiseItem(); newItem.PromiseId = Promise.PromiseId; newItem.ProjectId = Promise.ProjectId; newItem.UnitId = Promise.UnitId; newItem.CreateMan = Promise.CreateMan; newItem.CreateDate = Promise.CreateDate; newItem.Promise = Promise.Promise; newItem.PromiseDate = Promise.PromiseDate; string contenttype = "application/json;charset=utf-8"; string url = ConfigurationManager.AppSettings["QHSE_URL"] + "api/SYHSEData/SavePromise"; string messages = APIGetHttpService.Http(url, "POST", contenttype, null, JsonConvert.SerializeObject(newItem)); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } } }