SGGL_HBAZ/SGGL/FineUIPro.Web/SYHSE/SYHSEData_PromiseEdit.aspx.cs

112 lines
3.8 KiB
C#

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
/// <summary>
/// 主键
/// </summary>
public string PromiseId
{
get
{
return (string)ViewState["PromiseId"];
}
set
{
ViewState["PromiseId"] = value;
}
}
#endregion
/// <summary>
/// 把状态转换代号为文字形式
/// </summary>
/// <param name="state"></param>
/// <returns></returns>
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);
}
}
}
}