/// <summary> /// 检查职位名是否存在 /// </summary> protected void CheckDutyName() { string str = String.Empty; string id = Utils.GetQueryStringValue("id"); string name = Utils.GetQueryStringValue("name"); if (!string.IsNullOrEmpty(name)) { BPosition BLL = new BPosition(); if (String.IsNullOrEmpty(id)) {//新增 if (BLL.ExistsNum(name, 0, this.SiteUserInfo.CompanyId)) { str = "1"; } } else { //更新 MGovPosition Model = BLL.GetGovPositionModel(Utils.GetInt(id), this.SiteUserInfo.CompanyId); if (null != Model && !string.Equals(name, Model.Title)) { if (BLL.ExistsNum(name, 0, this.SiteUserInfo.CompanyId)) { str = "1"; } } } } Response.Clear(); Response.Write(str); Response.End(); }
/// <summary> /// 新增与编辑共用Model部分 /// </summary> protected void commonModel(MGovPosition Model, string dutyName, string content) { Model.CompanyId = this.SiteUserInfo.CompanyId; Model.Description = content; Model.IssueTime = DateTime.Now; Model.OperatorId = this.SiteUserInfo.UserId; Model.Title = dutyName; }
/// <summary> /// 保存 /// </summary> protected void PageSave(string doType) { #region 表单取值 string msg = ""; bool result = false; Response.Clear(); //职位名称 string dutyName = Utils.GetFormValue(txtDutyName.UniqueID); //职位说明书 string content = Utils.GetFormValue(txtContent.UniqueID); //职位编号 string dutyId = Utils.GetFormValue(hidDutyId.UniqueID); #endregion #region 表单验证 if (string.IsNullOrEmpty(dutyName)) { msg += "-请输入职务名称!"; } if (string.IsNullOrEmpty(content)) { msg += "-请输入职务描述!"; } if (!string.IsNullOrEmpty(msg)) { result = false; Response.Write(UtilsCommons.AjaxReturnJson(result ? "1" : "0", msg)); Response.End(); return; } #endregion #region 提交回应 BPosition BLL = new BPosition(); MGovPosition Model; if (doType == "add") { Model = new MGovPosition(); this.commonModel(Model, dutyName, content); result = BLL.AddGovPosition(Model); msg = result ? "添加成功!" : "添加失败!"; } if (doType == "update") { Model = BLL.GetGovPositionModel(Utils.GetInt(dutyId), this.SiteUserInfo.CompanyId); if (null != Model) { this.commonModel(Model, dutyName, content); Model.PositionId = Int32.Parse(dutyId); result = BLL.UpdateGovPosition(Model); msg = result ? "修改成功!" : "修改失败!"; } } Response.Clear(); Response.Write(UtilsCommons.AjaxReturnJson(result ? "1" : "0", msg)); Response.End(); #endregion }
/// <summary> /// 页面初始化 /// </summary> /// <param name="id">操作ID</param> protected void PageInit(string id) { BPosition BLL = new BPosition(); MGovPosition Model = BLL.GetGovPositionModel(Utils.GetInt(id), this.SiteUserInfo.CompanyId); if (null != Model) { this.txtDutyName.Text = Model.Title; //职位名 this.txtContent.Text = Model.Description; //职位说明 this.hidDutyId.Value = Model.PositionId.ToString(); if (!this.SiteUserInfo.IsHandleElse && this.SiteUserInfo.UserId != Model.OperatorId) { this.ph_Save.Visible = false; } } }