using BLL; using System; using System.Collections; using System.Collections.Generic; 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 Data_LicenceEdit : PageBase { #region 公共字段 /// /// 主键 /// public string Id { get { return (string)ViewState["Id"]; } set { ViewState["Id"] = value; } } #endregion /// /// 把状态转换代号为文字形式 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Id = Request.Params["Id"]; if (!string.IsNullOrEmpty(Id)) { var licence = Funs.DB.SYHSEData_Licence.FirstOrDefault(x => x.Id == Id); if (licence != null) { if (licence.ReportDate.HasValue) { this.txtReportDate.Text = licence.ReportDate.Value.ToString("yyyy-MM-dd"); } if (licence.Amount.HasValue) { this.txtAmount.Text = licence.Amount.Value.ToString(); } if (!string.IsNullOrEmpty(licence.Type)) { this.drpType.SelectedValue = licence.Type; } } } } } 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_LicenceMenuId, BLL.Const.BtnSave)) { Model.SYHSEData_Licence licence = Funs.DB.SYHSEData_Licence.FirstOrDefault(x => x.Id == Id); if (licence == null) { licence = new Model.SYHSEData_Licence(); licence.Id = Guid.NewGuid().ToString(); Funs.DB.SYHSEData_Licence.InsertOnSubmit(licence); } licence.ProjectId = this.CurrUser.LoginProjectId; licence.UnitId = this.CurrUser.UserId; licence.CreateMan = this.CurrUser.UserId; licence.CreateDate = DateTime.Now; if (!string.IsNullOrEmpty(this.txtAmount.Text)) { licence.Amount = int.Parse(this.txtAmount.Text); } licence.Type = this.drpType.SelectedText ; licence.ReportDate = this.txtReportDate.SelectedDate; Funs.DB.SubmitChanges(); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } else { Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } } }